Commit 455e8051 by Torkel Ödegaard

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

parent 65af872e
......@@ -16,9 +16,8 @@ function (angular, _, moment, config, store) {
$scope.init = function() {
$scope.db = datasourceSrv.getGrafanaDB();
$scope.onAppEvent('save-dashboard', function() {
$scope.saveDashboard();
});
$scope.onAppEvent('save-dashboard', $scope.saveDashboard);
$scope.onAppEvent('delete-dashboard', $scope.deleteDashboard);
$scope.onAppEvent('zoom-out', function() {
$scope.zoom(2);
......@@ -57,10 +56,10 @@ function (angular, _, moment, config, store) {
$scope.isAdmin = function() {
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", "");
this.passwordCache(password);
$scope.passwordCache(password);
if (password === config.admin.password) { return true; }
......@@ -74,7 +73,7 @@ function (angular, _, moment, config, store) {
};
$scope.saveDashboard = function() {
if (!this.isAdmin()) { return false; }
if (!$scope.isAdmin()) { return false; }
var clone = angular.copy($scope.dashboard);
$scope.db.saveDashboard(clone)
......@@ -93,15 +92,14 @@ function (angular, _, moment, config, store) {
});
};
$scope.deleteDashboard = function(id, $event) {
$event.stopPropagation();
$scope.deleteDashboard = function(evt, options) {
if (!confirm('Are you sure you want to delete dashboard?')) {
return;
}
if (!this.isAdmin()) { return false; }
if (!$scope.isAdmin()) { return false; }
var id = options.id;
$scope.db.deleteDashboard(id).then(function(id) {
alertSrv.set('Dashboard Deleted', id + ' has been deleted', 'success', 5000);
}, function() {
......
......@@ -94,8 +94,7 @@ function (angular, _, config, $) {
}
};
$scope.showTags = function(evt) {
evt.stopPropagation();
$scope.showTags = function() {
$scope.tagsOnly = !$scope.tagsOnly;
$scope.query.query = $scope.tagsOnly ? "tags!:" : "";
$scope.giveSearchFocus = $scope.giveSearchFocus + 1;
......@@ -106,10 +105,14 @@ function (angular, _, config, $) {
$scope.search = function() {
$scope.showImport = false;
$scope.selectedIndex = 0;
$scope.searchDashboards($scope.query.query);
};
$scope.deleteDashboard = function(id, evt) {
evt.stopPropagation();
$scope.emitAppEvent('delete-dashboard', { id: id });
};
$scope.addMetricToCurrentDashboard = function (metricId) {
$scope.dashboard.rows.push({
title: '',
......@@ -126,8 +129,7 @@ function (angular, _, config, $) {
});
};
$scope.toggleImport = function ($event) {
$event.stopPropagation();
$scope.toggleImport = function () {
$scope.showImport = !$scope.showImport;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment