Commit cd4fc78a by Torkel Ödegaard

trying to get dashboard settings, annotations and templating views be opened via url parameters

parent 4e6a0492
define([
'angular',
'lodash',
'jquery',
],
function (angular, _) {
function (angular, _, $) {
'use strict';
var module = angular.module('grafana.controllers');
......@@ -13,11 +14,12 @@ function (angular, _) {
{
text: "Dashbord",
href: "/",
startsWith: '/dashboard/',
icon: "fa fa-th-large",
links: [
{ text: 'Settings', href:"asd", icon: "fa fa-cogs" },
{ text: 'Templating', href:"asd", icon: "fa fa-cogs" },
{ text: 'Annotations', href:"asd", icon: "fa fa-bolt" },
{ text: 'Settings', editview: 'settings', icon: "fa fa-cogs" },
{ text: 'Templating', editview: 'templating', icon: "fa fa-cogs" },
{ text: 'Annotations', editview: 'annotations', icon: "fa fa-bolt" },
{ text: 'More', href:"asd", icon: "fa fa-bolt" },
]
},
......@@ -26,8 +28,8 @@ function (angular, _) {
icon: "fa fa-shield",
links: [
{ text: 'Data sources', href:"/account/datasources", icon: "fa fa-sitemap" },
{ text: 'Users', href:"/account/datasources", icon: "fa fa-users" },
{ text: 'API Keys', href:"/account/datasources", icon: "fa fa-key" },
{ text: 'Users', href:"/account/users", icon: "fa fa-users" },
{ text: 'API Keys', href:"/account/apikeys", icon: "fa fa-key" },
]
},
{
......@@ -39,12 +41,18 @@ function (angular, _) {
}
];
$scope.onAppEvent('$routeUpdate', function() {
$scope.updateState();
});
$scope.onAppEvent('$routeChangeSuccess', function() {
$scope.updateState();
});
$scope.updateState = function() {
var currentPath = $location.path();
var search = $location.search();
_.each($scope.menu, function(item) {
item.active = false;
......@@ -52,9 +60,25 @@ function (angular, _) {
item.active = true;
}
if (item.startsWith) {
if (currentPath.indexOf(item.startsWith) === 0) {
item.active = true;
}
}
_.each(item.links, function(link) {
link.active = false;
if (link.editview) {
var params = {};
_.each(search, function(value, key) {
if (value !== null) { params[key] = value; }
});
params.editview = link.editview;
link.href = currentPath + '?' + $.param(params);
}
if (link.href === currentPath) {
item.active = true;
link.active = true;
......
......@@ -5,6 +5,12 @@ define([
function (angular, $) {
'use strict';
var editViewMap = {
'settings': 'app/partials/dasheditor.html',
'annotations': 'app/features/annotations/partials/editor.html',
'templating': 'app/partials/templating_editor.html',
};
angular
.module('grafana.directives')
.directive('dashEditorLink', function($timeout) {
......@@ -25,7 +31,7 @@ function (angular, $) {
angular
.module('grafana.directives')
.directive('dashEditorView', function($compile) {
.directive('dashEditorView', function($compile, $location) {
return {
restrict: 'A',
link: function(scope, elem) {
......@@ -48,10 +54,13 @@ function (angular, $) {
if (editorScope) { editorScope.dismiss(); }
}
scope.onAppEvent("dashboard-loaded", hideEditorPane);
scope.onAppEvent('hide-dash-editor', hideEditorPane);
scope.onAppEvent('show-dash-editor', function(evt, payload) {
if (payload.editview) {
payload.src = editViewMap[payload.editview];
}
if (lastEditor === payload.src) {
hideEditorPane();
return;
......@@ -70,6 +79,14 @@ function (angular, $) {
lastEditor = null;
editorScope = null;
hideScrollbars(false);
if (payload.editview) {
var urlParams = $location.search();
if (payload.editview === urlParams.editview) {
delete urlParams.editview;
$location.search(urlParams);
}
}
};
// hide page scrollbars while edit pane is visible
......
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account > API Keys'"></div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account'"></div>
<div class="dashboard-edit-view" style="min-height: 500px">
......
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Admin'"></div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account'"></div>
<div class="dashboard-edit-view" style="min-height: 500px">
<div class="editor-row">
......
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account > Users'"></div>
<div ng-include="'app/partials/navbar.html'" ng-init="pageTitle='Account'"></div>
<div class="dashboard-edit-view" style="min-height: 500px">
......
......@@ -81,6 +81,11 @@ function (angular, _, $) {
};
DashboardViewState.prototype.syncState = function() {
if (this.state.editview) {
this.$scope.appEvent('show-dash-editor', { scope: this.$scope, editview: this.state.editview });
return;
}
if (this.panelScopes.length === 0) { return; }
if (this.fullscreen) {
......
......@@ -8,7 +8,7 @@
</div>
<ul class="sidemenu">
<li ng-repeat-start="item in menu">
<li ng-repeat-start="item in menu" ng-class="{'active': item.active}">
<a href="{{item.href}}" class="sidemenu-item"><i class="{{item.icon}}"></i>{{item.text}}</a>
</li>
<li ng-repeat-end ng-if="item.active">
......@@ -21,31 +21,7 @@
</ul>
</div>
<section class="pro-sidemenu-items">
<!-- <a class="pro&#45;sidemenu&#45;link" ng&#45;href="{{appSubUrl}}/"> -->
<!-- <i class="fa fa&#45;th&#45;large"></i> -->
<!-- Dashboards -->
<!-- </a> -->
<!-- <a class="pro&#45;sidemenu&#45;link" href="account/datasources"> -->
<!-- <i class="fa fa&#45;sitemap"></i> -->
<!-- Data -->
<!-- </a> -->
<!-- <a class="pro&#45;sidemenu&#45;link" href="account/users"> -->
<!-- <i class="fa fa&#45;users"></i>Users -->
<!-- </a> -->
<!-- <a class="pro&#45;sidemenu&#45;link" href="account/apikeys"> -->
<!-- <i class="fa fa&#45;key"></i>API Keys -->
<!-- </a> -->
<!-- <a class="pro&#45;sidemenu&#45;link" href="account/import"> -->
<!-- <i class="fa fa&#45;download"></i> -->
<!-- Import -->
<!-- </a> -->
<!-- -->
<!-- <a class="pro&#45;sidemenu&#45;link" href="profile"> -->
<!-- <i class="fa fa&#45;user"></i> -->
<!-- Profile -->
<!-- </a> -->
<!-- -->
<section class="pro-sidemenu-items" style="position: fixed; bottom: 0; width 200px; left: 0;">
<a class="pro-sidemenu-link" href="admin/users" ng-if="grafana.user.isGrafanaAdmin">
<i class="fa fa-institution"></i>Admin
</a>
......@@ -62,7 +38,6 @@
<a class="pro-sidemenu-link" href="login?logout">
<i class="fa fa-sign-out"></i>Sign out
</a>
</section>
</div>
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