Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
metricFindQuery(query: string): Promise {
return getBackendSrv()
.fetch({
url: '/api/tsdb/query',
method: 'POST',
data: {
queries: [
{
target: query,
format: 'timeseries',
type: 'keys',
refId: 'keys',
datasourceId: this.id,
},
],
},
})
.toPromise()
return async (dispatch, getStore) => {
dispatch(pluginDashboardsLoad());
const dataSourceType = getStore().dataSources.dataSource.type;
const response = await getBackendSrv().get(`api/plugins/${dataSourceType}/dashboards`);
dispatch(pluginDashboardsLoaded(response));
};
}
async revokeAllUserSessions() {
const { userId } = this.props;
await getBackendSrv().post('/api/admin/users/' + userId + '/logout', {});
this.setState({ sessions: [] });
}
return async dispatch => {
const response = await getBackendSrv().get(`/api/teams/${id}`);
dispatch(teamLoaded(response));
dispatch(updateNavIndex(buildNavModel(response)));
};
}
return async dispatch => {
await getBackendSrv().put('/api/admin/users/' + id + '/permissions', permissions);
};
}
constructor(props: Props) {
super(props);
this.backendSrv = getBackendSrv();
}
async onCreateUser() {
const { name, email, login, password } = this.state;
await getBackendSrv().post('/api/admin/users', {
name,
email,
login,
password,
});
}
return async (dispatch, getStore) => {
const team = getStore().team.team;
await getBackendSrv().post(`/api/teams/${team.id}/groups`, { groupId: groupId });
dispatch(loadTeamGroups());
};
}
componentDidMount(): void {
const { dashboard, panelId } = this.props;
getBackendSrv()
.get(`/api/annotations?dashboardId=${dashboard.id}&panelId=${panelId}&limit=50&type=alert`)
.then((res: any[]) => {
const items = res.map((item: any) => {
return {
stateModel: alertDef.getStateDisplayModel(item.newState),
time: dashboard.formatDate(item.time, 'MMM D, YYYY HH:mm:ss'),
info: alertDef.getAlertAnnotationInfo(item),
};
});
this.setState({
stateHistoryItems: items,
});
});
}
export const getServerStats = async (): Promise => {
try {
const res = await getBackendSrv().get('api/admin/stats');
return [
{ name: 'Total users', value: res.users },
{ name: 'Total admins', value: res.admins },
{ name: 'Total editors', value: res.editors },
{ name: 'Total viewers', value: res.viewers },
{ name: 'Active users (seen last 30 days)', value: res.activeUsers },
{ name: 'Active admins (seen last 30 days)', value: res.activeAdmins },
{ name: 'Active editors (seen last 30 days)', value: res.activeEditors },
{ name: 'Active viewers (seen last 30 days)', value: res.activeViewers },
{ name: 'Active sessions', value: res.activeSessions },
{ name: 'Total dashboards', value: res.dashboards },
{ name: 'Total orgs', value: res.orgs },
{ name: 'Total playlists', value: res.playlists },
{ name: 'Total snapshots', value: res.snapshots },
{ name: 'Total dashboard tags', value: res.tags },
{ name: 'Total starred dashboards', value: res.stars },