From f67563e9ee4f1a32d0be6c2f63bfa79c3ff1a402 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 8 Jan 2016 12:45:12 +0100 Subject: [PATCH] feat(apps): moving things around --- pkg/api/index.go | 14 ++++++++ public/app/core/controllers/sidemenu_ctrl.js | 10 +----- public/app/core/routes/all.js | 13 ++++---- public/app/features/apps/all.ts | 3 ++ public/app/features/{org => apps}/app_srv.ts | 0 .../app_edit_ctrl.ts => apps/edit_ctrl.ts} | 0 .../app_list_ctrl.ts => apps/list_ctrl.ts} | 0 .../app_edit.html => apps/partials/edit.html} | 0 .../app_list.html => apps/partials/list.html} | 2 +- public/app/features/org/app_directive.js | 32 ------------------- 10 files changed, 26 insertions(+), 48 deletions(-) create mode 100644 public/app/features/apps/all.ts rename public/app/features/{org => apps}/app_srv.ts (100%) rename public/app/features/{org/app_edit_ctrl.ts => apps/edit_ctrl.ts} (100%) rename public/app/features/{org/app_list_ctrl.ts => apps/list_ctrl.ts} (100%) rename public/app/features/{org/partials/app_edit.html => apps/partials/edit.html} (100%) rename public/app/features/{org/partials/app_list.html => apps/partials/list.html} (95%) delete mode 100644 public/app/features/org/app_directive.js diff --git a/pkg/api/index.go b/pkg/api/index.go index af8dfcb99f1..3a56a7f1205 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -55,6 +55,20 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { Url: "/", }) + if c.OrgRole == m.ROLE_ADMIN { + data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ + Text: "Data Sources", + Icon: "fa fa-fw fa-database", + Url: "/datasources", + }) + + data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ + Text: "Apps", + Icon: "fa fa-fw fa-cubes", + Url: "/apps", + }) + } + orgApps := m.GetAppPluginsQuery{OrgId: c.OrgId} err = bus.Dispatch(&orgApps) if err != nil { diff --git a/public/app/core/controllers/sidemenu_ctrl.js b/public/app/core/controllers/sidemenu_ctrl.js index bd58edccebc..e53b555466e 100644 --- a/public/app/core/controllers/sidemenu_ctrl.js +++ b/public/app/core/controllers/sidemenu_ctrl.js @@ -19,7 +19,7 @@ function (angular, _, $, coreModule, config) { $scope.mainLinks.push({ text: item.text, icon: item.icon, - href: $scope.getUrl(item.href) + url: $scope.getUrl(item.url) }); }); }; @@ -40,14 +40,6 @@ function (angular, _, $, coreModule, config) { text: "API Keys", 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) { diff --git a/public/app/core/routes/all.js b/public/app/core/routes/all.js index 82b9c409f9d..1f18210f8a9 100644 --- a/public/app/core/routes/all.js +++ b/public/app/core/routes/all.js @@ -10,6 +10,7 @@ define([ $locationProvider.html5Mode(true); var loadOrgBundle = new BundleLoader.BundleLoader('app/features/org/all'); + var loadAppsBundle = new BundleLoader.BundleLoader('app/features/apps/all'); $routeProvider .when('/', { @@ -131,17 +132,17 @@ define([ templateUrl: 'app/partials/reset_password.html', controller : 'ResetPasswordCtrl', }) - .when('/org/apps', { - templateUrl: 'app/features/org/partials/app_list.html', + .when('/apps', { + templateUrl: 'app/features/apps/partials/list.html', controller: 'AppListCtrl', controllerAs: 'ctrl', - resolve: loadOrgBundle, + resolve: loadAppsBundle, }) - .when('/org/apps/edit/:type', { - templateUrl: 'app/features/org/partials/app_edit.html', + .when('/apps/edit/:type', { + templateUrl: 'app/features/apps/partials/edit.html', controller: 'AppEditCtrl', controllerAs: 'ctrl', - resolve: loadOrgBundle, + resolve: loadAppsBundle, }) .when('/global-alerts', { templateUrl: 'app/features/dashboard/partials/globalAlerts.html', diff --git a/public/app/features/apps/all.ts b/public/app/features/apps/all.ts new file mode 100644 index 00000000000..005c0796493 --- /dev/null +++ b/public/app/features/apps/all.ts @@ -0,0 +1,3 @@ +import './edit_ctrl'; +import './list_ctrl'; +import './app_srv'; diff --git a/public/app/features/org/app_srv.ts b/public/app/features/apps/app_srv.ts similarity index 100% rename from public/app/features/org/app_srv.ts rename to public/app/features/apps/app_srv.ts diff --git a/public/app/features/org/app_edit_ctrl.ts b/public/app/features/apps/edit_ctrl.ts similarity index 100% rename from public/app/features/org/app_edit_ctrl.ts rename to public/app/features/apps/edit_ctrl.ts diff --git a/public/app/features/org/app_list_ctrl.ts b/public/app/features/apps/list_ctrl.ts similarity index 100% rename from public/app/features/org/app_list_ctrl.ts rename to public/app/features/apps/list_ctrl.ts diff --git a/public/app/features/org/partials/app_edit.html b/public/app/features/apps/partials/edit.html similarity index 100% rename from public/app/features/org/partials/app_edit.html rename to public/app/features/apps/partials/edit.html diff --git a/public/app/features/org/partials/app_list.html b/public/app/features/apps/partials/list.html similarity index 95% rename from public/app/features/org/partials/app_list.html rename to public/app/features/apps/partials/list.html index ea992a46a92..37897546eed 100644 --- a/public/app/features/org/partials/app_list.html +++ b/public/app/features/apps/partials/list.html @@ -18,7 +18,7 @@
  • diff --git a/public/app/features/org/app_directive.js b/public/app/features/org/app_directive.js deleted file mode 100644 index c58464f8075..00000000000 --- a/public/app/features/org/app_directive.js +++ /dev/null @@ -1,32 +0,0 @@ -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); - }); - } - } - }); - } - }; - }); -}); \ No newline at end of file