mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
refactor: moved stuff into new features dir manage-dashboards
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
export class DashboardListCtrl {
|
||||
navModel: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(navModelSrv) {
|
||||
this.navModel = navModelSrv.getNav('dashboards', 'manage-dashboards', 0);
|
||||
}
|
||||
}
|
||||
36
public/app/features/manage-dashboards/SnapshotListCtrl.ts
Normal file
36
public/app/features/manage-dashboards/SnapshotListCtrl.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import _ from 'lodash';
|
||||
|
||||
export class SnapshotListCtrl {
|
||||
navModel: any;
|
||||
snapshots: any;
|
||||
|
||||
/** @ngInject */
|
||||
constructor(private $rootScope, private backendSrv, navModelSrv) {
|
||||
this.navModel = navModelSrv.getNav('dashboards', 'snapshots', 0);
|
||||
this.backendSrv.get('/api/dashboard/snapshots').then(result => {
|
||||
this.snapshots = result;
|
||||
});
|
||||
}
|
||||
|
||||
removeSnapshotConfirmed(snapshot) {
|
||||
_.remove(this.snapshots, { key: snapshot.key });
|
||||
this.backendSrv.delete('/api/snapshots/' + snapshot.key).then(
|
||||
() => {},
|
||||
() => {
|
||||
this.snapshots.push(snapshot);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
removeSnapshot(snapshot) {
|
||||
this.$rootScope.appEvent('confirm-modal', {
|
||||
title: 'Delete',
|
||||
text: 'Are you sure you want to delete snapshot ' + snapshot.name + '?',
|
||||
yesText: 'Delete',
|
||||
icon: 'fa-trash',
|
||||
onConfirm: () => {
|
||||
this.removeSnapshotConfirmed(snapshot);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
7
public/app/features/manage-dashboards/index.ts
Normal file
7
public/app/features/manage-dashboards/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import coreModule from 'app/core/core_module';
|
||||
|
||||
import { DashboardListCtrl } from './DashboardListCtrl';
|
||||
import { SnapshotListCtrl } from './SnapshotListCtrl';
|
||||
|
||||
coreModule.controller('DashboardListCtrl', DashboardListCtrl);
|
||||
coreModule.controller('SnapshotListCtrl', SnapshotListCtrl);
|
||||
@@ -0,0 +1,5 @@
|
||||
<page-header model="ctrl.navModel"></page-header>
|
||||
|
||||
<div class="page-container page-body">
|
||||
<manage-dashboards />
|
||||
</div>
|
||||
@@ -0,0 +1,32 @@
|
||||
<page-header model="ctrl.navModel"></page-header>
|
||||
|
||||
<div class="page-container page-body">
|
||||
<table class="filter-table">
|
||||
<thead>
|
||||
<th><strong>Name</strong></th>
|
||||
<th><strong>Snapshot url</strong></th>
|
||||
<th style="width: 70px"></th>
|
||||
<th style="width: 25px"></th>
|
||||
</thead>
|
||||
<tr ng-repeat="snapshot in ctrl.snapshots">
|
||||
<td>
|
||||
<a href="dashboard/snapshot/{{snapshot.key}}">{{snapshot.name}}</a>
|
||||
</td>
|
||||
<td >
|
||||
<a href="dashboard/snapshot/{{snapshot.key}}">dashboard/snapshot/{{snapshot.key}}</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="dashboard/snapshot/{{snapshot.key}}" class="btn btn-inverse btn-mini">
|
||||
<i class="fa fa-eye"></i>
|
||||
View
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<a ng-click="ctrl.removeSnapshot(snapshot)" class="btn btn-danger btn-mini">
|
||||
<i class="fa fa-remove"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user