瀏覽代碼

feat(apps): changed edit apps view to use plugin-component for apps config view

Torkel Ödegaard 10 年之前
父節點
當前提交
0fab210ad2

+ 11 - 0
public/app/core/directives/plugin_component.ts

@@ -141,6 +141,17 @@ function pluginDirectiveLoader($compile, datasourceSrv, $rootScope, $q, $http, $
           };
         });
       }
+      // AppConfigCtrl
+      case 'app-config-ctrl': {
+        return System.import(scope.ctrl.appModel.module).then(function(appModule) {
+          return {
+            name: 'app-config-' + scope.ctrl.appModel.appId,
+            bindings: {appModel: "=", appEditCtrl: "="},
+            attrs: {"app-model": "ctrl.appModel", "app-edit-ctrl": "ctrl"},
+            Component: appModule.ConfigCtrl,
+          };
+        });
+      }
       // Panel
       case 'panel': {
         return loadPanelComponentInfo(scope, attrs);

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

@@ -1,3 +1,2 @@
 import './edit_ctrl';
 import './list_ctrl';
-import './config_view';

+ 0 - 23
public/app/features/apps/config_view.ts

@@ -1,23 +0,0 @@
-///<reference path="../../headers/common.d.ts" />
-
-import angular from 'angular';
-
-/** @ngInject */
-function appConfigView(dynamicDirectiveSrv) {
-  return dynamicDirectiveSrv.create({
-    scope: {
-      appModel: "="
-    },
-    directive: scope => {
-      return System.import(scope.appModel.module).then(function(appModule) {
-        return {
-          name: 'app-config-' + scope.appModel.appId,
-          fn: appModule.configView,
-        };
-      });
-    },
-  });
-}
-
-
-angular.module('grafana.directives').directive('appConfigView', appConfigView);

+ 1 - 1
public/app/features/apps/partials/edit.html

@@ -97,7 +97,7 @@
 		<h3 class="simple-box-header">Configuration:</h3>
 		<div class="simple-box-body">
 			<div ng-if="ctrl.appModel.appId">
-				<app-config-view app-model="ctrl.appModel"></app-config-view>
+				<plugin-component type="app-config-ctrl"></plugin-component>
 				<div class="clearfix"></div>
 				<button type="submit" class="btn btn-success" ng-click="ctrl.update()">Save</button>
 			</div>

+ 2 - 2
public/app/features/panel/metrics_panel_ctrl.ts

@@ -6,8 +6,8 @@ import _ from 'lodash';
 import kbn from 'app/core/utils/kbn';
 import {PanelCtrl} from './panel_ctrl';
 
-import * as rangeUtil from '../../core/utils/rangeutil';
-import * as dateMath from '../../core/utils/datemath';
+import * as rangeUtil from 'app/core/utils/rangeutil';
+import * as dateMath from 'app/core/utils/datemath';
 
 class MetricsPanelCtrl extends PanelCtrl {
   error: boolean;