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