Przeglądaj źródła

feat(apps): moving things around

Torkel Ödegaard 10 lat temu
rodzic
commit
f67563e9ee

+ 14 - 0
pkg/api/index.go

@@ -55,6 +55,20 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
 		Url:  "/",
 		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}
 	orgApps := m.GetAppPluginsQuery{OrgId: c.OrgId}
 	err = bus.Dispatch(&orgApps)
 	err = bus.Dispatch(&orgApps)
 	if err != nil {
 	if err != nil {

+ 1 - 9
public/app/core/controllers/sidemenu_ctrl.js

@@ -19,7 +19,7 @@ function (angular, _, $, coreModule, config) {
         $scope.mainLinks.push({
         $scope.mainLinks.push({
           text: item.text,
           text: item.text,
           icon: item.icon,
           icon: item.icon,
-          href: $scope.getUrl(item.href)
+          url: $scope.getUrl(item.url)
         });
         });
       });
       });
     };
     };
@@ -40,14 +40,6 @@ 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) {

+ 7 - 6
public/app/core/routes/all.js

@@ -10,6 +10,7 @@ define([
     $locationProvider.html5Mode(true);
     $locationProvider.html5Mode(true);
 
 
     var loadOrgBundle = new BundleLoader.BundleLoader('app/features/org/all');
     var loadOrgBundle = new BundleLoader.BundleLoader('app/features/org/all');
+    var loadAppsBundle = new BundleLoader.BundleLoader('app/features/apps/all');
 
 
     $routeProvider
     $routeProvider
       .when('/', {
       .when('/', {
@@ -131,17 +132,17 @@ define([
         templateUrl: 'app/partials/reset_password.html',
         templateUrl: 'app/partials/reset_password.html',
         controller : 'ResetPasswordCtrl',
         controller : 'ResetPasswordCtrl',
       })
       })
-      .when('/org/apps', {
-        templateUrl: 'app/features/org/partials/app_list.html',
+      .when('/apps', {
+        templateUrl: 'app/features/apps/partials/list.html',
         controller: 'AppListCtrl',
         controller: 'AppListCtrl',
         controllerAs: 'ctrl',
         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',
         controller: 'AppEditCtrl',
         controllerAs: 'ctrl',
         controllerAs: 'ctrl',
-        resolve: loadOrgBundle,
+        resolve: loadAppsBundle,
       })
       })
       .when('/global-alerts', {
       .when('/global-alerts', {
         templateUrl: 'app/features/dashboard/partials/globalAlerts.html',
         templateUrl: 'app/features/dashboard/partials/globalAlerts.html',

+ 3 - 0
public/app/features/apps/all.ts

@@ -0,0 +1,3 @@
+import './edit_ctrl';
+import './list_ctrl';
+import './app_srv';

+ 0 - 0
public/app/features/org/app_srv.ts → public/app/features/apps/app_srv.ts


+ 0 - 0
public/app/features/org/app_edit_ctrl.ts → public/app/features/apps/edit_ctrl.ts


+ 0 - 0
public/app/features/org/app_list_ctrl.ts → public/app/features/apps/list_ctrl.ts


+ 0 - 0
public/app/features/org/partials/app_edit.html → public/app/features/apps/partials/edit.html


+ 1 - 1
public/app/features/org/partials/app_list.html → public/app/features/apps/partials/list.html

@@ -18,7 +18,7 @@
           <li>
           <li>
             <div class="filter-list-card-controls">
             <div class="filter-list-card-controls">
               <div class="filter-list-card-config">
               <div class="filter-list-card-config">
-								<a href="org/apps/edit/{{app.type}}">
+								<a href="apps/edit/{{app.type}}">
 									<i class="fa fa-cog"></i>
 									<i class="fa fa-cog"></i>
 								</a>
 								</a>
               </div>
               </div>

+ 0 - 32
public/app/features/org/app_directive.js

@@ -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);
-              });
-            }
-          }
-        });
-      }
-    };
-  });
-});