Commit d8ea970f by Torkel Ödegaard

Added support for delete dashboard

parent 4b382e0f
...@@ -14,7 +14,7 @@ function (angular, config, _, $, store) { ...@@ -14,7 +14,7 @@ function (angular, config, _, $, store) {
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion; $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
$scope.consoleEnabled = store.getBool('grafanaConsole'); $scope.consoleEnabled = store.getBool('grafanaConsole');
//$scope.showProSideMenu = store.getBool('grafanaProSideMenu'); $scope.showProSideMenu = store.getBool('grafanaProSideMenu');
$rootScope.profilingEnabled = store.getBool('profilingEnabled'); $rootScope.profilingEnabled = store.getBool('profilingEnabled');
$rootScope.performance = { loadStart: new Date().getTime() }; $rootScope.performance = { loadStart: new Date().getTime() };
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<div class="container-fluid"> <div class="container-fluid">
<span class="brand"> <span class="brand">
<a ng-click="toggleProSideMenu()"> <a ng-click="toggleProSideMenu()">
<img src="img/small.png"> <img class="logo-icon" src="img/fav32.png" bs-tooltip="'Grafana'" data-placement="bottom"></img>
</a> </a>
{{dashboard.title}} <span class="page-title">{{dashboard.title}}</span>
</span> </span>
<ul class="nav pull-right" ng-controller='DashboardNavCtrl' ng-init="init()"> <ul class="nav pull-right" ng-controller='DashboardNavCtrl' ng-init="init()">
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
</li> </li>
<li class="dropdown grafana-menu-save"> <li class="dropdown grafana-menu-save">
<a href="#" bs-tooltip="'Save'" data-placement="bottom" class="dropdown-toggle" data-toggle="dropdown" ng-click="openSaveDropdown()"> <a bs-tooltip="'Save'" data-placement="bottom" class="dropdown-toggle" data-toggle="dropdown" ng-click="openSaveDropdown()">
<i class='icon-save'></i> <i class='icon-save'></i>
</a> </a>
...@@ -52,6 +52,9 @@ ...@@ -52,6 +52,9 @@
<a class="link" ng-click="removeAsFavorite()">Remove as favorite</a> <a class="link" ng-click="removeAsFavorite()">Remove as favorite</a>
</li> </li>
<li> <li>
<a class="link" ng-click="editJson()">Dashboard JSON</a>
</li>
<li>
<a class="link" ng-click="exportDashboard()">Export dashboard</a> <a class="link" ng-click="exportDashboard()">Export dashboard</a>
</li> </li>
<li ng-show="db.saveTemp"> <li ng-show="db.saveTemp">
...@@ -62,12 +65,15 @@ ...@@ -62,12 +65,15 @@
</ul> </ul>
</li> </li>
<li class="dropdown grafana-menu-load" ng-controller="SearchCtrl" ng-init="init()" ng-include="'app/partials/search.html'"> <li class="dropdown grafana-menu-load">
<a bs-tooltip="'Search'" ng-click="openSearch()">
<i class='icon-folder-open'></i>
</a>
</li> </li>
<li class="grafana-menu-home"><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/'><i class='icon-home'></i></a></li> <li class="grafana-menu-home"><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/'><i class='icon-home'></i></a></li>
<li class="grafana-menu-edit" ng-show="dashboard.editable" bs-tooltip="'Configure dashboard'" data-placement="bottom"><a class="link" config-modal="app/partials/dasheditor.html"><i class='icon-cog pointer'></i></a></li> <li class="grafana-menu-edit" ng-show="dashboard.editable" bs-tooltip="'Configure dashboard'" data-placement="bottom"><a class="link" dash-editor-link="app/partials/dasheditor.html"><i class='icon-cog pointer'></i></a></li>
<li class="grafana-menu-stop-playlist hide"> <li class="grafana-menu-stop-playlist hide">
<a class='small' ng-click='stopPlaylist(2)'> <a class='small' ng-click='stopPlaylist(2)'>
......
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container-fluid">
<span class="brand">
<i class="icon-gears" style=""></i>
<span style="color: white; padding-left: 4px;">Grafana</span>
<ul class="nav" ng-controller='DashboardNavCtrl' ng-init="init()">
</span>
</ul>
</div>
</div>
</div>
<section class="pro-sidemenu-items"> <section class="pro-sidemenu-items">
<a class="pro-sidemenu-link pro-side-menu-user" href="/login?logout"> <a class="pro-sidemenu-link" href="/login?logout">
<img src="https://secure.gravatar.com/avatar/c8656e8972626f01e1703681d5e55f92?s=90&default=blank"> <i class="icon-lock"></i>
logout logout
</a> </a>
<a class="pro-sidemenu-link" href="/dashboard/db/home"> <a class="pro-sidemenu-link" href="/dashboard/db/home">
......
define([ define([
'angular', 'angular',
'../controllers/p_loginCtrl',
], ],
function (angular) { function (angular) {
"use strict"; "use strict";
...@@ -47,47 +48,4 @@ function (angular) { ...@@ -47,47 +48,4 @@ function (angular) {
}); });
module.controller('LoginCtrl', function($scope, $http, $location, $routeParams, alertSrv) {
$scope.loginModel = {};
$scope.init = function() {
if ($routeParams.logout) {
$scope.logout();
}
};
$scope.logout = function() {
$http.post('/logout').then(function() {
alertSrv.set('Logged out!', '', 'success', 3000);
$scope.emitAppEvent('logged-out');
}, function() {
alertSrv.set('Logout failed:', 'Unexpected error', 'error', 3000);
});
};
$scope.login = function() {
delete $scope.loginError;
if (!$scope.loginForm.$valid) {
return;
}
$http.post('/login', $scope.loginModel).then(function() {
$scope.emitAppEvent('logged-in');
$location.path('/');
}, function(err) {
if (err.status === 401) {
$scope.loginError = "Username or password is incorrect";
}
else {
$scope.loginError = "Unexpected error";
}
});
};
$scope.init();
});
}); });
...@@ -55,6 +55,15 @@ function (angular) { ...@@ -55,6 +55,15 @@ function (angular) {
}); });
}; };
GrafanaDatasource.prototype.deleteDashboard = function(id) {
return $http({ method: 'DELETE', url: '/api/dashboard/' + id })
.then(function(result) {
return result.data.title;
}, function(err) {
throw err.data;
});
};
GrafanaDatasource.prototype.searchDashboards = function(query) { GrafanaDatasource.prototype.searchDashboards = function(query) {
return $http.get('/api/search/', { params: { q: query } }) return $http.get('/api/search/', { params: { q: query } })
.then(function(results) { .then(function(results) {
......
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