|
|
@@ -65,27 +65,11 @@ function (angular, _, moment, config, store) {
|
|
|
window.sessionStorage["grafanaAdminPassword"] = pwd;
|
|
|
};
|
|
|
|
|
|
- $scope.isAdmin = function() {
|
|
|
- if (!config.admin || !config.admin.password) { return true; }
|
|
|
- if ($scope.passwordCache() === config.admin.password) { return true; }
|
|
|
-
|
|
|
- var password = window.prompt("Admin password", "");
|
|
|
- $scope.passwordCache(password);
|
|
|
-
|
|
|
- if (password === config.admin.password) { return true; }
|
|
|
-
|
|
|
- alertSrv.set('Save failed', 'Password incorrect', 'error');
|
|
|
-
|
|
|
- return false;
|
|
|
- };
|
|
|
-
|
|
|
$scope.openSearch = function() {
|
|
|
$scope.appEvent('show-dash-search');
|
|
|
};
|
|
|
|
|
|
$scope.saveDashboard = function() {
|
|
|
- if (!$scope.isAdmin()) { return false; }
|
|
|
-
|
|
|
var clone = angular.copy($scope.dashboard);
|
|
|
$scope.db.saveDashboard(clone)
|
|
|
.then(function(result) {
|
|
|
@@ -96,7 +80,7 @@ function (angular, _, moment, config, store) {
|
|
|
$location.path(result.url);
|
|
|
}
|
|
|
|
|
|
- $rootScope.$emit('dashboard-saved', $scope.dashboard);
|
|
|
+ $scope.appEvent('dashboard-saved', $scope.dashboard);
|
|
|
|
|
|
}, function(err) {
|
|
|
$scope.appEvent('alert-error', ['Save failed', err]);
|
|
|
@@ -104,8 +88,6 @@ function (angular, _, moment, config, store) {
|
|
|
};
|
|
|
|
|
|
$scope.deleteDashboard = function() {
|
|
|
- if (!$scope.isAdmin()) { return false; }
|
|
|
-
|
|
|
$scope.appEvent('confirm-modal', {
|
|
|
title: 'Delete dashboard',
|
|
|
text: 'Do you want to delete dashboard ' + $scope.dashboard.title + '?',
|
|
|
@@ -123,6 +105,16 @@ function (angular, _, moment, config, store) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ $scope.cloneDashboard = function() {
|
|
|
+ var newScope = $rootScope.$new();
|
|
|
+ newScope.clone = angular.copy($scope.dashboard);
|
|
|
+
|
|
|
+ $scope.appEvent('show-modal', {
|
|
|
+ src: './app/features/dashboard/partials/cloneDashboard.html',
|
|
|
+ scope: newScope,
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
$scope.exportDashboard = function() {
|
|
|
var blob = new Blob([angular.toJson($scope.dashboard, true)], { type: "application/json;charset=utf-8" });
|
|
|
window.saveAs(blob, $scope.dashboard.title + '-' + new Date().getTime());
|