Files
grafana/public/app/stores/ServerStatsStore/ServerStatsStore.ts
Johannes Schill 8abef88b94 mobx: poc in using each store as individual prop on the react containers (#10414)
* mobx: poc in using each store as individual prop on the react containers

* prettier test

* fix: end the war between prettier vs tslint.

* mobx: Move stores into their own folders

* mobx: Refactor the AlertRule into its own file and add a helper-file

* mobx: Move NavItem out of NavStore and remove lodash dependancy

* mobx: Move ResultItem and SearchResultSection models out of the SearchStore

* mobx: ServerStatsStore rename .tsx => .ts. And move ServerStat-model to its own file.

* mobx: Remove lodash and jquery dependancy from ViewStore

* mobx: Remove issue with double question mark
2018-01-03 20:11:07 +01:00

25 lines
1.3 KiB
TypeScript

import { types, getEnv, flow } from 'mobx-state-tree';
import { ServerStat } from './ServerStat';
export const ServerStatsStore = types
.model('ServerStatsStore', {
stats: types.array(ServerStat),
error: types.optional(types.string, ''),
})
.actions(self => ({
load: flow(function* load() {
const backendSrv = getEnv(self).backendSrv;
const res = yield backendSrv.get('/api/admin/stats');
self.stats.clear();
self.stats.push(ServerStat.create({ name: 'Total dashboards', value: res.dashboards }));
self.stats.push(ServerStat.create({ name: 'Total users', value: res.users }));
self.stats.push(ServerStat.create({ name: 'Active users (seen last 30 days)', value: res.activeUsers }));
self.stats.push(ServerStat.create({ name: 'Total orgs', value: res.orgs }));
self.stats.push(ServerStat.create({ name: 'Total playlists', value: res.playlists }));
self.stats.push(ServerStat.create({ name: 'Total snapshots', value: res.snapshots }));
self.stats.push(ServerStat.create({ name: 'Total dashboard tags', value: res.tags }));
self.stats.push(ServerStat.create({ name: 'Total starred dashboards', value: res.stars }));
self.stats.push(ServerStat.create({ name: 'Total alerts', value: res.alerts }));
}),
}));