Fixes delete link in search result, broken after recent changes to search results, Closes #749

pull/782/head
Torkel Ödegaard 11 years ago
parent 65af872ec6
commit 455e80513b
  1. 18
      src/app/controllers/dashboardNavCtrl.js
  2. 12
      src/app/controllers/search.js

@ -16,9 +16,8 @@ function (angular, _, moment, config, store) {
$scope.init = function() { $scope.init = function() {
$scope.db = datasourceSrv.getGrafanaDB(); $scope.db = datasourceSrv.getGrafanaDB();
$scope.onAppEvent('save-dashboard', function() { $scope.onAppEvent('save-dashboard', $scope.saveDashboard);
$scope.saveDashboard(); $scope.onAppEvent('delete-dashboard', $scope.deleteDashboard);
});
$scope.onAppEvent('zoom-out', function() { $scope.onAppEvent('zoom-out', function() {
$scope.zoom(2); $scope.zoom(2);
@ -57,10 +56,10 @@ function (angular, _, moment, config, store) {
$scope.isAdmin = function() { $scope.isAdmin = function() {
if (!config.admin || !config.admin.password) { return true; } if (!config.admin || !config.admin.password) { return true; }
if (this.passwordCache() === config.admin.password) { return true; } if ($scope.passwordCache() === config.admin.password) { return true; }
var password = window.prompt("Admin password", ""); var password = window.prompt("Admin password", "");
this.passwordCache(password); $scope.passwordCache(password);
if (password === config.admin.password) { return true; } if (password === config.admin.password) { return true; }
@ -74,7 +73,7 @@ function (angular, _, moment, config, store) {
}; };
$scope.saveDashboard = function() { $scope.saveDashboard = function() {
if (!this.isAdmin()) { return false; } if (!$scope.isAdmin()) { return false; }
var clone = angular.copy($scope.dashboard); var clone = angular.copy($scope.dashboard);
$scope.db.saveDashboard(clone) $scope.db.saveDashboard(clone)
@ -93,15 +92,14 @@ function (angular, _, moment, config, store) {
}); });
}; };
$scope.deleteDashboard = function(id, $event) { $scope.deleteDashboard = function(evt, options) {
$event.stopPropagation();
if (!confirm('Are you sure you want to delete dashboard?')) { if (!confirm('Are you sure you want to delete dashboard?')) {
return; return;
} }
if (!this.isAdmin()) { return false; } if (!$scope.isAdmin()) { return false; }
var id = options.id;
$scope.db.deleteDashboard(id).then(function(id) { $scope.db.deleteDashboard(id).then(function(id) {
alertSrv.set('Dashboard Deleted', id + ' has been deleted', 'success', 5000); alertSrv.set('Dashboard Deleted', id + ' has been deleted', 'success', 5000);
}, function() { }, function() {

@ -94,8 +94,7 @@ function (angular, _, config, $) {
} }
}; };
$scope.showTags = function(evt) { $scope.showTags = function() {
evt.stopPropagation();
$scope.tagsOnly = !$scope.tagsOnly; $scope.tagsOnly = !$scope.tagsOnly;
$scope.query.query = $scope.tagsOnly ? "tags!:" : ""; $scope.query.query = $scope.tagsOnly ? "tags!:" : "";
$scope.giveSearchFocus = $scope.giveSearchFocus + 1; $scope.giveSearchFocus = $scope.giveSearchFocus + 1;
@ -106,10 +105,14 @@ function (angular, _, config, $) {
$scope.search = function() { $scope.search = function() {
$scope.showImport = false; $scope.showImport = false;
$scope.selectedIndex = 0; $scope.selectedIndex = 0;
$scope.searchDashboards($scope.query.query); $scope.searchDashboards($scope.query.query);
}; };
$scope.deleteDashboard = function(id, evt) {
evt.stopPropagation();
$scope.emitAppEvent('delete-dashboard', { id: id });
};
$scope.addMetricToCurrentDashboard = function (metricId) { $scope.addMetricToCurrentDashboard = function (metricId) {
$scope.dashboard.rows.push({ $scope.dashboard.rows.push({
title: '', title: '',
@ -126,8 +129,7 @@ function (angular, _, config, $) {
}); });
}; };
$scope.toggleImport = function ($event) { $scope.toggleImport = function () {
$event.stopPropagation();
$scope.showImport = !$scope.showImport; $scope.showImport = !$scope.showImport;
}; };

Loading…
Cancel
Save