Просмотр исходного кода

feat: panels v2, metrics-tab loading

Torkel Ödegaard 7 лет назад
Родитель
Сommit
cec70c1ed8

+ 1 - 2
public/app/features/dashboard/dashgrid/PanelEditor.tsx

@@ -22,7 +22,7 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
     }
 
     let loader = getAngularLoader();
-    var template = '<plugin-component type="query-ctrl" />';
+    var template = '<metrics-tab />';
     let scopeProps = {
       ctrl: {
         panel: this.props.panel,
@@ -32,7 +32,6 @@ export class PanelEditor extends React.Component<PanelEditorProps, any> {
           dashboard: this.props.dashboard,
         },
       },
-      target: {},
     };
 
     this.queryComp = loader.load(this.queryElement, scopeProps, template);

+ 5 - 7
public/app/features/dashboard/panel_model.ts

@@ -32,6 +32,7 @@ export class PanelModel {
   panels?: any;
   soloMode?: boolean;
   targets: any[];
+  datasource: string;
 
   // non persisted
   fullscreen: boolean;
@@ -46,13 +47,10 @@ export class PanelModel {
       this[property] = model[property];
     }
 
-    if (!this.gridPos) {
-      this.gridPos = { x: 0, y: 0, h: 3, w: 6 };
-    }
-
-    if (!this.targets) {
-      this.targets = [{}];
-    }
+    // defaults
+    this.gridPos = this.gridPos || { x: 0, y: 0, h: 3, w: 6 };
+    this.datasource = this.datasource || null;
+    this.targets = this.targets || [{}];
   }
 
   getSaveModel() {

+ 3 - 0
public/app/features/panel/metrics_tab.ts

@@ -1,5 +1,6 @@
 import { DashboardModel } from '../dashboard/dashboard_model';
 import Remarkable from 'remarkable';
+import coreModule from 'app/core/core_module';
 
 export class MetricsTabCtrl {
   dsName: string;
@@ -120,3 +121,5 @@ export function metricsTabDirective() {
     controller: MetricsTabCtrl,
   };
 }
+
+coreModule.directive('metricsTab', metricsTabDirective);

+ 6 - 6
yarn.lock

@@ -1114,7 +1114,7 @@ babel-plugin-istanbul@^4.1.5, babel-plugin-istanbul@^4.1.6:
     istanbul-lib-instrument "^1.10.1"
     test-exclude "^4.2.1"
 
-babel-plugin-jest-hoist@^22.4.4:
+babel-plugin-jest-hoist@^22.4.3, babel-plugin-jest-hoist@^22.4.4:
   version "22.4.4"
   resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.4.tgz#b9851906eab34c7bf6f8c895a2b08bea1a844c0b"
 
@@ -6498,7 +6498,7 @@ jest-docblock@^22.4.0, jest-docblock@^22.4.3:
   dependencies:
     detect-newline "^2.1.0"
 
-jest-environment-jsdom@^22.4.1:
+jest-environment-jsdom@^22.4.1, jest-environment-jsdom@^22.4.3:
   version "22.4.3"
   resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-22.4.3.tgz#d67daa4155e33516aecdd35afd82d4abf0fa8a1e"
   dependencies:
@@ -6506,7 +6506,7 @@ jest-environment-jsdom@^22.4.1:
     jest-util "^22.4.3"
     jsdom "^11.5.1"
 
-jest-environment-node@^22.4.1:
+jest-environment-node@^22.4.1, jest-environment-node@^22.4.3:
   version "22.4.3"
   resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-22.4.3.tgz#54c4eaa374c83dd52a9da8759be14ebe1d0b9129"
   dependencies:
@@ -6533,7 +6533,7 @@ jest-haste-map@^22.4.2:
     micromatch "^2.3.11"
     sane "^2.0.0"
 
-jest-jasmine2@^22.4.4:
+jest-jasmine2@^22.4.3, jest-jasmine2@^22.4.4:
   version "22.4.4"
   resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-22.4.4.tgz#c55f92c961a141f693f869f5f081a79a10d24e23"
   dependencies:
@@ -6587,7 +6587,7 @@ jest-resolve-dependencies@^22.1.0:
   dependencies:
     jest-regex-util "^22.4.3"
 
-jest-resolve@^22.4.2:
+jest-resolve@^22.4.2, jest-resolve@^22.4.3:
   version "22.4.3"
   resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-22.4.3.tgz#0ce9d438c8438229aa9b916968ec6b05c1abb4ea"
   dependencies:
@@ -6671,7 +6671,7 @@ jest-validate@^21.1.0:
     leven "^2.1.0"
     pretty-format "^21.2.1"
 
-jest-validate@^22.4.4:
+jest-validate@^22.4.3, jest-validate@^22.4.4:
   version "22.4.4"
   resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-22.4.4.tgz#1dd0b616ef46c995de61810d85f57119dbbcec4d"
   dependencies: