Files
grafana/public/app/features/apps/edit_ctrl.ts

44 lines
1.0 KiB
TypeScript
Raw Normal View History

2015-12-22 11:37:44 +01:00
///<reference path="../../headers/common.d.ts" />
2015-12-22 11:37:44 +01:00
import angular from 'angular';
import _ from 'lodash';
2015-12-22 11:37:44 +01:00
export class AppEditCtrl {
2015-12-22 13:42:48 +01:00
appModel: any;
2015-12-22 11:37:44 +01:00
/** @ngInject */
constructor(private backendSrv: any, private $routeParams: any) {}
2015-12-22 13:42:48 +01:00
init() {
this.appModel = {};
this.backendSrv.get(`/api/org/apps/${this.$routeParams.appId}/settings`).then(result => {
this.appModel = result;
2015-12-22 13:42:48 +01:00
});
2015-12-22 11:37:44 +01:00
}
update(options) {
var updateCmd = _.extend({
appId: this.appModel.appId,
orgId: this.appModel.orgId,
enabled: this.appModel.enabled,
pinned: this.appModel.pinned,
jsonData: this.appModel.jsonData,
}, options);
this.backendSrv.post(`/api/org/apps/${this.$routeParams.appId}/settings`, updateCmd).then(function() {
window.location.href = window.location.href;
2015-12-22 13:42:48 +01:00
});
}
toggleEnabled() {
this.update({enabled: this.appModel.enabled});
}
togglePinned() {
this.update({pinned: this.appModel.pinned});
}
2015-12-22 11:37:44 +01:00
}
angular.module('grafana.controllers').controller('AppEditCtrl', AppEditCtrl);