mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
more renaming. also moved apps and datasource menus
This commit is contained in:
@@ -41,8 +41,8 @@ func Register(r *macaron.Macaron) {
|
|||||||
r.Get("/admin/orgs", reqGrafanaAdmin, Index)
|
r.Get("/admin/orgs", reqGrafanaAdmin, Index)
|
||||||
r.Get("/admin/orgs/edit/:id", reqGrafanaAdmin, Index)
|
r.Get("/admin/orgs/edit/:id", reqGrafanaAdmin, Index)
|
||||||
|
|
||||||
r.Get("/plugins", reqSignedIn, Index)
|
r.Get("/org/apps", reqSignedIn, Index)
|
||||||
r.Get("/plugins/edit/*", reqSignedIn, Index)
|
r.Get("/org/apps/edit/*", reqSignedIn, Index)
|
||||||
|
|
||||||
r.Get("/dashboard/*", reqSignedIn, Index)
|
r.Get("/dashboard/*", reqSignedIn, Index)
|
||||||
r.Get("/dashboard-solo/*", reqSignedIn, Index)
|
r.Get("/dashboard-solo/*", reqSignedIn, Index)
|
||||||
@@ -116,6 +116,10 @@ func Register(r *macaron.Macaron) {
|
|||||||
r.Get("/invites", wrap(GetPendingOrgInvites))
|
r.Get("/invites", wrap(GetPendingOrgInvites))
|
||||||
r.Post("/invites", quota("user"), bind(dtos.AddInviteForm{}), wrap(AddOrgInvite))
|
r.Post("/invites", quota("user"), bind(dtos.AddInviteForm{}), wrap(AddOrgInvite))
|
||||||
r.Patch("/invites/:code/revoke", wrap(RevokeInvite))
|
r.Patch("/invites/:code/revoke", wrap(RevokeInvite))
|
||||||
|
|
||||||
|
// apps
|
||||||
|
r.Get("/apps", wrap(GetAppPlugins))
|
||||||
|
r.Post("/apps", bind(m.UpdateAppPluginCmd{}), wrap(UpdateAppPlugin))
|
||||||
}, reqOrgAdmin)
|
}, reqOrgAdmin)
|
||||||
|
|
||||||
// create new org
|
// create new org
|
||||||
@@ -155,12 +159,6 @@ func Register(r *macaron.Macaron) {
|
|||||||
r.Get("/plugins", GetDataSourcePlugins)
|
r.Get("/plugins", GetDataSourcePlugins)
|
||||||
}, reqOrgAdmin)
|
}, reqOrgAdmin)
|
||||||
|
|
||||||
// PluginBundles
|
|
||||||
r.Group("/plugins", func() {
|
|
||||||
r.Get("/", wrap(GetAppPlugins))
|
|
||||||
r.Post("/", bind(m.UpdateAppPluginCmd{}), wrap(UpdateAppPlugin))
|
|
||||||
}, reqOrgAdmin)
|
|
||||||
|
|
||||||
r.Get("/frontend/settings/", GetFrontendSettings)
|
r.Get("/frontend/settings/", GetFrontendSettings)
|
||||||
r.Any("/datasources/proxy/:id/*", reqSignedIn, ProxyDataSourceRequest)
|
r.Any("/datasources/proxy/:id/*", reqSignedIn, ProxyDataSourceRequest)
|
||||||
r.Any("/datasources/proxy/:id", reqSignedIn, ProxyDataSourceRequest)
|
r.Any("/datasources/proxy/:id", reqSignedIn, ProxyDataSourceRequest)
|
||||||
|
|||||||
@@ -55,18 +55,6 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
|
|||||||
Href: "/",
|
Href: "/",
|
||||||
})
|
})
|
||||||
|
|
||||||
if c.OrgRole == m.ROLE_ADMIN {
|
|
||||||
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
|
|
||||||
Text: "Data Sources",
|
|
||||||
Icon: "fa fa-fw fa-database",
|
|
||||||
Href: "/datasources",
|
|
||||||
}, &dtos.NavLink{
|
|
||||||
Text: "Plugins",
|
|
||||||
Icon: "fa fa-fw fa-cubes",
|
|
||||||
Href: "/plugins",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
orgApps := m.GetAppPluginsQuery{OrgId: c.OrgId}
|
orgApps := m.GetAppPluginsQuery{OrgId: c.OrgId}
|
||||||
err = bus.Dispatch(&orgApps)
|
err = bus.Dispatch(&orgApps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ function (angular, _, $, coreModule, config) {
|
|||||||
text: "API Keys",
|
text: "API Keys",
|
||||||
href: $scope.getUrl("/org/apikeys"),
|
href: $scope.getUrl("/org/apikeys"),
|
||||||
});
|
});
|
||||||
|
$scope.orgMenu.push({
|
||||||
|
text: "Datasources",
|
||||||
|
href: $scope.getUrl("/datasources"),
|
||||||
|
});
|
||||||
|
$scope.orgMenu.push({
|
||||||
|
text: "Apps",
|
||||||
|
href: $scope.getUrl("/org/apps"),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.orgMenu.length > 0) {
|
if ($scope.orgMenu.length > 0) {
|
||||||
|
|||||||
@@ -131,14 +131,14 @@ define([
|
|||||||
templateUrl: 'app/partials/reset_password.html',
|
templateUrl: 'app/partials/reset_password.html',
|
||||||
controller : 'ResetPasswordCtrl',
|
controller : 'ResetPasswordCtrl',
|
||||||
})
|
})
|
||||||
.when('/plugins', {
|
.when('/org/apps', {
|
||||||
templateUrl: 'app/features/org/partials/plugins.html',
|
templateUrl: 'app/features/org/partials/apps.html',
|
||||||
controller: 'PluginsCtrl',
|
controller: 'AppsCtrl',
|
||||||
resolve: loadOrgBundle,
|
resolve: loadOrgBundle,
|
||||||
})
|
})
|
||||||
.when('/plugins/edit/:type', {
|
.when('/org/apps/edit/:type', {
|
||||||
templateUrl: 'app/features/org/partials/pluginEdit.html',
|
templateUrl: 'app/features/org/partials/appEdit.html',
|
||||||
controller: 'PluginEditCtrl',
|
controller: 'AppEditCtrl',
|
||||||
resolve: loadOrgBundle,
|
resolve: loadOrgBundle,
|
||||||
})
|
})
|
||||||
.otherwise({
|
.otherwise({
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ define([
|
|||||||
'./userInviteCtrl',
|
'./userInviteCtrl',
|
||||||
'./orgApiKeysCtrl',
|
'./orgApiKeysCtrl',
|
||||||
'./orgDetailsCtrl',
|
'./orgDetailsCtrl',
|
||||||
'./pluginsCtrl',
|
'./appsCtrl',
|
||||||
'./pluginEditCtrl',
|
'./appEditCtrl',
|
||||||
'./plugin_srv',
|
'./app_srv',
|
||||||
'./plugin_directive',
|
'./app_directive',
|
||||||
], function () {});
|
], function () {});
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ function (angular, _, config) {
|
|||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
var module = angular.module('grafana.controllers');
|
||||||
|
|
||||||
module.controller('PluginEditCtrl', function($scope, pluginSrv, $routeParams) {
|
module.controller('AppEditCtrl', function($scope, appSrv, $routeParams) {
|
||||||
$scope.init = function() {
|
$scope.init = function() {
|
||||||
$scope.current = {};
|
$scope.current = {};
|
||||||
$scope.getPlugins();
|
$scope.getApps();
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getPlugins = function() {
|
$scope.getApps = function() {
|
||||||
pluginSrv.get($routeParams.type).then(function(result) {
|
appSrv.get($routeParams.type).then(function(result) {
|
||||||
$scope.current = _.clone(result);
|
$scope.current = _.clone(result);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -25,7 +25,7 @@ function (angular, _, config) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope._update = function() {
|
$scope._update = function() {
|
||||||
pluginSrv.update($scope.current).then(function() {
|
appSrv.update($scope.current).then(function() {
|
||||||
window.location.href = config.appSubUrl + "plugins";
|
window.location.href = config.appSubUrl + "plugins";
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
32
public/app/features/org/app_directive.js
Normal file
32
public/app/features/org/app_directive.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
define([
|
||||||
|
'angular',
|
||||||
|
],
|
||||||
|
function (angular) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var module = angular.module('grafana.directives');
|
||||||
|
|
||||||
|
module.directive('appConfigLoader', function($compile) {
|
||||||
|
return {
|
||||||
|
restrict: 'E',
|
||||||
|
link: function(scope, elem) {
|
||||||
|
var directive = 'grafana-app-default';
|
||||||
|
//wait for the parent scope to be applied.
|
||||||
|
scope.panelAdded = false;
|
||||||
|
scope.$watch("current", function(newVal) {
|
||||||
|
if (newVal && !scope.panelAdded) {
|
||||||
|
if (newVal.module) {
|
||||||
|
scope.panelAdded = true;
|
||||||
|
directive = 'grafana-app-'+newVal.type;
|
||||||
|
scope.require([newVal.module], function () {
|
||||||
|
var panelEl = angular.element(document.createElement(directive));
|
||||||
|
elem.append(panelEl);
|
||||||
|
$compile(panelEl)(scope);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
58
public/app/features/org/app_srv.js
Normal file
58
public/app/features/org/app_srv.js
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
define([
|
||||||
|
'angular',
|
||||||
|
'lodash',
|
||||||
|
],
|
||||||
|
function (angular, _) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
|
module.service('appSrv', function($rootScope, $timeout, $q, backendSrv) {
|
||||||
|
var self = this;
|
||||||
|
this.init = function() {
|
||||||
|
console.log("appSrv init");
|
||||||
|
this.apps = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
this.get = function(type) {
|
||||||
|
return $q(function(resolve) {
|
||||||
|
if (type in self.apps) {
|
||||||
|
return resolve(self.apps[type]);
|
||||||
|
}
|
||||||
|
backendSrv.get('api/org/apps').then(function(results) {
|
||||||
|
_.forEach(results, function(p) {
|
||||||
|
self.apps[p.type] = p;
|
||||||
|
});
|
||||||
|
return resolve(self.apps[type]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.getAll = function() {
|
||||||
|
return $q(function(resolve) {
|
||||||
|
if (!_.isEmpty(self.apps)) {
|
||||||
|
return resolve(self.apps);
|
||||||
|
}
|
||||||
|
backendSrv.get('api/org/apps').then(function(results) {
|
||||||
|
_.forEach(results, function(p) {
|
||||||
|
self.apps[p.type] = p;
|
||||||
|
});
|
||||||
|
return resolve(self.apps);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.update = function(app) {
|
||||||
|
return $q(function(resolve, reject) {
|
||||||
|
backendSrv.post('api/org/apps', app).then(function(resp) {
|
||||||
|
self.apps[app.type] = app;
|
||||||
|
resolve(resp);
|
||||||
|
}, function(resp) {
|
||||||
|
reject(resp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.init();
|
||||||
|
});
|
||||||
|
});
|
||||||
32
public/app/features/org/appsCtrl.js
Normal file
32
public/app/features/org/appsCtrl.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
define([
|
||||||
|
'angular',
|
||||||
|
'app/core/config',
|
||||||
|
],
|
||||||
|
function (angular, config) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var module = angular.module('grafana.controllers');
|
||||||
|
|
||||||
|
module.controller('AppsCtrl', function($scope, $location, appSrv) {
|
||||||
|
|
||||||
|
$scope.init = function() {
|
||||||
|
$scope.apps = {};
|
||||||
|
$scope.getApps();
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.getApps = function() {
|
||||||
|
appSrv.getAll().then(function(result) {
|
||||||
|
$scope.apps = result;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.update = function(app) {
|
||||||
|
appSrv.update(app).then(function() {
|
||||||
|
window.location.href = config.appSubUrl + $location.path();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.init();
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<div>
|
|
||||||
{{current.type}} app does not have any additional config.
|
|
||||||
</div>
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
<topnav title="Plugins" icon="fa fa-fw fa-cubes" subnav="true">
|
<topnav title="Plugins" icon="fa fa-fw fa-cubes" subnav="true">
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li ><a href="plugins">Overview</a></li>
|
<li ><a href="org/apps">Overview</a></li>
|
||||||
<li class="active" ><a href="plugins/edit/{{current.type}}">Edit</a></li>
|
<li class="active" ><a href="org/apps/edit/{{current.type}}">Edit</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</topnav>
|
</topnav>
|
||||||
|
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<h2>Edit Plugin</h2>
|
<h2>Edit App</h2>
|
||||||
|
|
||||||
|
|
||||||
<form name="editForm">
|
<form name="editForm">
|
||||||
@@ -30,10 +30,10 @@
|
|||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<plugin-config-loader plugin="current"></plugin-config-loader>
|
<app-config-loader></app-config-loader>
|
||||||
<div class="pull-right" style="margin-top: 35px">
|
<div class="pull-right" style="margin-top: 35px">
|
||||||
<button type="submit" class="btn btn-success" ng-click="update()">Save</button>
|
<button type="submit" class="btn btn-success" ng-click="update()">Save</button>
|
||||||
<a class="btn btn-inverse" href="plugins">Cancel</a>
|
<a class="btn btn-inverse" href="org/apps">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
</form>
|
</form>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<topnav title="Plugins" icon="fa fa-fw fa-cubes" subnav="true">
|
<topnav title="Plugins" icon="fa fa-fw fa-cubes" subnav="true">
|
||||||
<ul class="nav">
|
<ul class="nav">
|
||||||
<li class="active" ><a href="plugins">Overview</a></li>
|
<li class="active" ><a href="org/apps">Overview</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</topnav>
|
</topnav>
|
||||||
|
|
||||||
@@ -8,23 +8,23 @@
|
|||||||
<div class="page">
|
<div class="page">
|
||||||
<h2>Plugins</h2>
|
<h2>Plugins</h2>
|
||||||
|
|
||||||
<div ng-if="!plugins">
|
<div ng-if="!apps">
|
||||||
<em>No plugins defined</em>
|
<em>No apps defined</em>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="grafana-options-table" ng-if="plugins">
|
<table class="grafana-options-table" ng-if="apps">
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>Type</strong></td>
|
<td><strong>Type</strong></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-repeat="(type, p) in plugins">
|
<tr ng-repeat="(type, p) in apps">
|
||||||
<td style="width:1%">
|
<td style="width:1%">
|
||||||
<i class="fa fa-cubes"></i>
|
<i class="fa fa-cubes"></i>
|
||||||
{{p.type}}
|
{{p.type}}
|
||||||
</td>
|
</td>
|
||||||
<td style="width: 1%">
|
<td style="width: 1%">
|
||||||
<a href="plugins/edit/{{p.type}}" class="btn btn-inverse btn-mini">
|
<a href="org/apps/edit/{{p.type}}" class="btn btn-inverse btn-mini">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
Edit
|
Edit
|
||||||
</a>
|
</a>
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
define([
|
|
||||||
'angular',
|
|
||||||
],
|
|
||||||
function (angular) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var module = angular.module('grafana.directives');
|
|
||||||
|
|
||||||
module.directive('pluginConfigLoader', function($compile) {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
link: function(scope, elem) {
|
|
||||||
var directive = 'grafana-app-core';
|
|
||||||
//wait for the parent scope to be applied.
|
|
||||||
scope.$watch("current", function(newVal) {
|
|
||||||
if (newVal) {
|
|
||||||
if (newVal.module) {
|
|
||||||
directive = 'grafana-app-'+newVal.type;
|
|
||||||
}
|
|
||||||
scope.require([newVal.module], function () {
|
|
||||||
var panelEl = angular.element(document.createElement(directive));
|
|
||||||
elem.append(panelEl);
|
|
||||||
$compile(panelEl)(scope);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
module.directive('grafanaAppCore', function() {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
templateUrl: 'app/features/org/partials/appConfigCore.html',
|
|
||||||
transclude: true,
|
|
||||||
link: function(scope) {
|
|
||||||
scope.update = function() {
|
|
||||||
//Perform custom save events to the plugins own backend if needed.
|
|
||||||
|
|
||||||
// call parent update to commit the change to the plugin object.
|
|
||||||
// this will cause the page to reload.
|
|
||||||
scope._update();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
define([
|
|
||||||
'angular',
|
|
||||||
'lodash',
|
|
||||||
],
|
|
||||||
function (angular, _) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var module = angular.module('grafana.services');
|
|
||||||
|
|
||||||
module.service('pluginSrv', function($rootScope, $timeout, $q, backendSrv) {
|
|
||||||
var self = this;
|
|
||||||
this.init = function() {
|
|
||||||
console.log("pluginSrv init");
|
|
||||||
this.plugins = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
this.get = function(type) {
|
|
||||||
return $q(function(resolve) {
|
|
||||||
if (type in self.plugins) {
|
|
||||||
return resolve(self.plugins[type]);
|
|
||||||
}
|
|
||||||
backendSrv.get('/api/plugins').then(function(results) {
|
|
||||||
_.forEach(results, function(p) {
|
|
||||||
self.plugins[p.type] = p;
|
|
||||||
});
|
|
||||||
return resolve(self.plugins[type]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.getAll = function() {
|
|
||||||
return $q(function(resolve) {
|
|
||||||
if (!_.isEmpty(self.plugins)) {
|
|
||||||
return resolve(self.plugins);
|
|
||||||
}
|
|
||||||
backendSrv.get('api/plugins').then(function(results) {
|
|
||||||
_.forEach(results, function(p) {
|
|
||||||
self.plugins[p.type] = p;
|
|
||||||
});
|
|
||||||
return resolve(self.plugins);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.update = function(plugin) {
|
|
||||||
return $q(function(resolve, reject) {
|
|
||||||
backendSrv.post('/api/plugins', plugin).then(function(resp) {
|
|
||||||
self.plugins[plugin.type] = plugin;
|
|
||||||
resolve(resp);
|
|
||||||
}, function(resp) {
|
|
||||||
reject(resp);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
this.init();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
define([
|
|
||||||
'angular',
|
|
||||||
'app/core/config',
|
|
||||||
],
|
|
||||||
function (angular, config) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var module = angular.module('grafana.controllers');
|
|
||||||
|
|
||||||
module.controller('PluginsCtrl', function($scope, $location, pluginSrv) {
|
|
||||||
|
|
||||||
$scope.init = function() {
|
|
||||||
$scope.plugins = {};
|
|
||||||
$scope.getPlugins();
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.getPlugins = function() {
|
|
||||||
pluginSrv.getAll().then(function(result) {
|
|
||||||
console.log(result);
|
|
||||||
$scope.plugins = result;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.update = function(plugin) {
|
|
||||||
pluginSrv.update(plugin).then(function() {
|
|
||||||
window.location.href = config.appSubUrl + $location.path();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.init();
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -98,7 +98,6 @@ function (angular, app, _, require, PanelMeta) {
|
|||||||
console.log('Text panel error: ', e);
|
console.log('Text panel error: ', e);
|
||||||
$scope.content = $sce.trustAsHtml(html);
|
$scope.content = $sce.trustAsHtml(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$scope.$$phase) {
|
if(!$scope.$$phase) {
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user