diff options
author | bobzel <zzzman@gmail.com> | 2023-04-26 13:11:58 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2023-04-26 13:11:58 -0400 |
commit | f885965824f76be69e6bd26109a5df85dc43eb80 (patch) | |
tree | 1444d9fdf1944496932e042d71fa9a47b1a52178 /src/client/util/ServerStats.tsx | |
parent | 4846ff09a02cce1da4f0b8984e387d7d204837f1 (diff) |
added stats button to mainview
Diffstat (limited to 'src/client/util/ServerStats.tsx')
-rw-r--r-- | src/client/util/ServerStats.tsx | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/client/util/ServerStats.tsx b/src/client/util/ServerStats.tsx new file mode 100644 index 000000000..0ab411bff --- /dev/null +++ b/src/client/util/ServerStats.tsx @@ -0,0 +1,55 @@ +import { action, computed, observable, runInAction } from 'mobx'; +import { observer } from 'mobx-react'; +import * as React from 'react'; +import { MainViewModal } from '../views/MainViewModal'; +import { DocumentView } from '../views/nodes/DocumentView'; +import './SharingManager.scss'; + +@observer +export class ServerStats extends React.Component<{}> { + public static Instance: ServerStats; + @observable private isOpen = false; // whether the SharingManager modal is open or not + + // private get linkVisible() { + // return this.targetDoc ? this.targetDoc["acl-" + PublicKey] !== SharingPermissions.None : false; + // } + + @action + public open = async () => { + /** + * Populates the list of users. + */ + fetch('/stats').then((res: Response) => res.text().then(action(stats => (this._stats = JSON.parse(stats))))); + + this.isOpen = true; + }; + + public close = action(() => { + this.isOpen = false; + }); + + constructor(props: {}) { + super(props); + ServerStats.Instance = this; + } + + @observable _stats: { [key: string]: any } | undefined; + + /** + * @returns the main interface of the SharingManager. + */ + @computed get sharingInterface() { + return ( + <div> + <span>Active users:{this._stats?.socketMap.length}</span> + {this._stats?.socketMap.map((user: any) => ( + <p>{user.username}</p> + ))} + </div> + ); + } + + render() { + return <MainViewModal contents={this.sharingInterface} isDisplayed={this.isOpen} interactive={true} closeOnExternalClick={this.close} />; + } +} |