Преглед на файлове

Merge branch 'master' of github.com:grafana/grafana

Torkel Ödegaard преди 9 години
родител
ревизия
7e12460303
променени са 3 файла, в които са добавени 60 реда и са изтрити 18 реда
  1. 4 1
      docs/mkdocs.yml
  2. 9 7
      docs/sources/plugins/installation.md
  3. 47 10
      public/app/features/plugins/edit_ctrl.ts

+ 4 - 1
docs/mkdocs.yml

@@ -86,7 +86,10 @@ pages:
 - ['http_api/snapshot.md', 'API', 'Snapshot API']
 - ['http_api/other.md', 'API', 'Other API']
 
-- ['plugins/plugins.md', 'Plugins', 'Plugins']
+- ['plugins/overview.md', 'Plugins', 'Overview']
+- ['plugins/installation.md', 'Plugins', 'Installation']
+- ['plugins/datasources.md', 'Plugins', 'Datasource plugins']
+- ['plugins/panels.md', 'Plugins', 'Panel plugins']
 
 - ['tutorials/index.md', 'Tutorials', 'Tutorials']
 - ['tutorials/hubot_howto.md', 'Tutorials', 'How To integrate Hubot and Grafana']

+ 9 - 7
docs/sources/plugins/installation.md

@@ -8,37 +8,39 @@ page_keywords: grafana, plugins, documentation
 
 ## Installing plugins
 
-The easiest way to install plugins is by using the CLI tool grafana-cli which is bundled with grafana.
+The easiest way to install plugins is by using the CLI tool grafana-cli which is bundled with grafana. Before any modification take place after modifieng plugins, grafana-server need to be restarted.
 
 ### Grafana plugin directory
 On Linux systems the grafana-cli will assume that the grafana plugin directory is "/var/lib/grafana/plugins". Its possible to override the directory which grafana-cli will operate on by specifing the --path flag. On Windows systems this parameter have to be specified for every call.
 
-### List available plugins
+### Grafana-cli commands
+
+List available plugins
 ```
 grafana-cli list-remove
 ```
 
-### Install a plugin type
+Install a plugin type
 ```
 grafana-cli install <plugin-id>
 ```
 
-### List installed plugins
+List installed plugins
 ```
 grafana-cli ls
 ```
 
-### Upgrade all installed plugins
+Upgrade all installed plugins
 ```
 grafana-cli upgrade-all
 ```
 
-### Upgrade one plugin
+Upgrade one plugin
 ```
 grafana-cli upgrade <plugin-id>
 ```
 
-### Remove one plugin
+Remove one plugin
 ```
 grafana-cli remove <plugin-id>
 ```

+ 47 - 10
public/app/features/plugins/edit_ctrl.ts

@@ -9,6 +9,8 @@ export class PluginEditCtrl {
   includedPanels: any;
   includedDatasources: any;
   tabIndex: number;
+  preUpdateHook: () => any;
+  postUpdateHook: () => any;
 
   /** @ngInject */
   constructor(private backendSrv: any, private $routeParams: any) {
@@ -24,20 +26,55 @@ export class PluginEditCtrl {
   }
 
   update() {
-    var updateCmd = _.extend({
-      pluginId: this.model.pluginId,
-      orgId: this.model.orgId,
-      enabled: this.model.enabled,
-      pinned: this.model.pinned,
-      jsonData: this.model.jsonData,
-      secureJsonData: this.model.secureJsonData,
-    }, {});
-
-    this.backendSrv.post(`/api/org/plugins/${this.pluginId}/settings`, updateCmd).then(function() {
+    var chain = Promise.resolve();
+    var self = this;
+    // if set, handle the preUpdateHook. If this returns a promise,
+    // the next step of execution will block until the promise resolves.
+    // if the promise is rejected, this update will be aborted.
+    if (this.preUpdateHook != null) {
+      chain = chain.then(function() {
+        return Promise.resolve(self.preUpdateHook());
+      });
+    }
+
+    // Perform the core update procedure
+    chain = chain.then(function() {
+      var updateCmd = _.extend({
+        pluginId: self.model.pluginId,
+        orgId: self.model.orgId,
+        enabled: self.model.enabled,
+        pinned: self.model.pinned,
+        jsonData: self.model.jsonData,
+        secureJsonData: self.model.secureJsonData,
+      }, {});
+
+      return self.backendSrv.post(`/api/org/plugins/${self.pluginId}/settings`, updateCmd);
+    });
+
+    // if set, performt he postUpdate hook. If a promise is returned it will block
+    // the final step of the update procedure (reloading the page) until the promise
+    // resolves.  If the promise is rejected the page will not be reloaded. 
+    if (this.postUpdateHook != null) {
+      chain = chain.then(function() {
+        return Promise.resolve(this.postUpdateHook());
+      });
+    }
+
+    // all stesp in the update procedure are complete, so reload the page to make changes
+    // take effect.
+    chain.then(function() {
       window.location.href = window.location.href;
     });
   }
 
+  setPreUpdateHook(callback: () => any) {
+    this.preUpdateHook = callback;
+  }
+
+  setPOstUpdateHook(callback: () => any) {
+    this.postUpdateHook = callback;
+  }
+
   toggleEnabled() {
     this.update();
   }