diff --git a/server/src/api/site.rs b/server/src/api/site.rs index b517568e6..912378ab3 100644 --- a/server/src/api/site.rs +++ b/server/src/api/site.rs @@ -81,6 +81,7 @@ pub struct GetSiteResponse { site: Option, admins: Vec, banned: Vec, + pub online: usize, } #[derive(Serialize, Deserialize)] @@ -296,6 +297,7 @@ impl Perform for Oper { site: site_view, admins: admins, banned: banned, + online: 0 }) } } @@ -486,6 +488,7 @@ impl Perform for Oper { site: Some(site_view), admins: admins, banned: banned, + online: 0 }) } } diff --git a/server/src/websocket/server.rs b/server/src/websocket/server.rs index 08714c30b..41bb10581 100644 --- a/server/src/websocket/server.rs +++ b/server/src/websocket/server.rs @@ -492,8 +492,10 @@ fn parse_json_message(chat: &mut ChatServer, msg: StandardMessage) -> Result { + let online: usize = chat.sessions.len(); let get_site: GetSite = serde_json::from_str(data)?; - let res = Oper::new(user_operation, get_site).perform()?; + let mut res = Oper::new(user_operation, get_site).perform()?; + res.online = online; Ok(serde_json::to_string(&res)?) } UserOperation::Search => { diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9ee4afdd4..b6c901be1 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -43,6 +43,7 @@ export class Main extends Component { }, admins: [], banned: [], + online: null, }, showEditSite: false, loading: true, @@ -215,6 +216,9 @@ export class Main extends Component { }
    +
  • + # +
  • #
  • @@ -420,6 +424,7 @@ export class Main extends Component { this.state.site.admins = res.admins; this.state.site.site = res.site; this.state.site.banned = res.banned; + this.state.site.online = res.online; this.setState(this.state); document.title = `${WebSocketService.Instance.site.name}`; diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index 8c78d7d89..3221415b3 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -546,6 +546,7 @@ export interface GetSiteResponse { site: Site; admins: Array; banned: Array; + online: number; } diff --git a/ui/src/translations/en.ts b/ui/src/translations/en.ts index 459e3b79c..591221c63 100644 --- a/ui/src/translations/en.ts +++ b/ui/src/translations/en.ts @@ -70,6 +70,7 @@ export const en = { number_of_users:'{{count}} Users', number_of_subscribers:'{{count}} Subscribers', number_of_points:'{{count}} Points', + number_online:'{{count}} Users Online', name: 'Name', title: 'Title', category: 'Category',