| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- ///<reference path="../../headers/common.d.ts" />
- import angular from 'angular';
- import _ from 'lodash';
- export class SnapshotsCtrl {
- snapshots: any;
- /** @ngInject */
- constructor(private $rootScope, private backendSrv) {
- this.backendSrv.get('/api/dashboard/snapshots').then(result => {
- this.snapshots = result;
- });
- }
- removeSnapshotConfirmed(snapshot) {
- _.remove(this.snapshots, {key: snapshot.key});
- this.backendSrv.get('/api/snapshots-delete/' + snapshot.deleteKey)
- .then(() => {
- this.$rootScope.appEvent('alert-success', ['Snapshot deleted', '']);
- }, () => {
- this.$rootScope.appEvent('alert-error', ['Unable to delete snapshot', '']);
- this.snapshots.push(snapshot);
- });
- }
- removeSnapshot(snapshot) {
- this.$rootScope.appEvent('confirm-modal', {
- title: 'Confirm delete snapshot',
- text: 'Are you sure you want to delete snapshot ' + snapshot.name + '?',
- yesText: "Delete",
- icon: "fa-warning",
- onConfirm: () => {
- this.removeSnapshotConfirmed(snapshot);
- }
- });
- }
- }
- angular.module('grafana.controllers').controller('SnapshotsCtrl', SnapshotsCtrl);
|