refactor: moved stuff into new features dir manage-dashboards

This commit is contained in:
Torkel Ödegaard
2018-09-10 13:59:31 +02:00
parent e4d9620fc0
commit 6c90a53654
9 changed files with 12 additions and 11 deletions

View File

@@ -0,0 +1,8 @@
export class DashboardListCtrl {
navModel: any;
/** @ngInject */
constructor(navModelSrv) {
this.navModel = navModelSrv.getNav('dashboards', 'manage-dashboards', 0);
}
}

View 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);
},
});
}
}

View 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);

View File

@@ -0,0 +1,5 @@
<page-header model="ctrl.navModel"></page-header>
<div class="page-container page-body">
<manage-dashboards />
</div>

View File

@@ -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>