mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(plugins): added dashboards tab to plugin edit page, #4275
This commit is contained in:
parent
2527289e3e
commit
c504abb84d
@ -1,7 +1,4 @@
|
||||
<navbar title="Plugins" title-url="plugins" icon="icon-gf icon-gf-apps">
|
||||
<a href="plugins/{{ctrl.model.pluginId}}/edit" class="navbar-page-btn">
|
||||
{{ctrl.model.name}}
|
||||
</a>
|
||||
</navbar>
|
||||
|
||||
<div class="page-container" ng-init="ctrl.init()">
|
||||
@ -23,7 +20,7 @@
|
||||
</div>
|
||||
|
||||
<ul class="gf-tabs">
|
||||
<li class="gf-tabs-item" ng-repeat="tab in ::['Overview', 'Config']">
|
||||
<li class="gf-tabs-item" ng-repeat="tab in ctrl.tabs">
|
||||
<a class="gf-tabs-link" ng-click="ctrl.tabIndex = $index" ng-class="{active: ctrl.tabIndex === $index}">
|
||||
{{::tab}}
|
||||
</a>
|
||||
@ -39,21 +36,18 @@
|
||||
</div>
|
||||
|
||||
<div class="tab-content page-content-with-sidebar" ng-if="ctrl.tabIndex === 1">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<editor-checkbox text="Enabled" model="ctrl.model.enabled" change="ctrl.toggleEnabled()"></editor-checkbox>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<editor-checkbox text="Pinned" model="ctrl.model.pinned" change="ctrl.togglePinned()"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div ng-if="ctrl.model.id">
|
||||
<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>
|
||||
|
||||
<div class="gf-form-button-row">
|
||||
<button type="submit" class="btn btn-success" ng-click="ctrl.enable()" ng-show="!ctrl.model.enabled">Enable</button>
|
||||
<button type="submit" class="btn btn-success" ng-click="ctrl.update()" ng-show="ctrl.model.enabled">Update</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tab-content page-content-with-sidebar" ng-if="ctrl.tabIndex === 2">
|
||||
<dashboard-import-list plugin="ctrl.model"></dashboard-import-list>
|
||||
</div>
|
||||
|
||||
<aside class="page-sidebar">
|
||||
|
@ -11,6 +11,8 @@ export class PluginEditCtrl {
|
||||
readmeHtml: any;
|
||||
includedDatasources: any;
|
||||
tabIndex: number;
|
||||
tabs: any;
|
||||
hasDashboards: any;
|
||||
preUpdateHook: () => any;
|
||||
postUpdateHook: () => any;
|
||||
|
||||
@ -19,6 +21,7 @@ export class PluginEditCtrl {
|
||||
this.model = {};
|
||||
this.pluginId = $routeParams.pluginId;
|
||||
this.tabIndex = 0;
|
||||
this.tabs = ['Overview'];
|
||||
}
|
||||
|
||||
init() {
|
||||
@ -35,6 +38,15 @@ export class PluginEditCtrl {
|
||||
return plug;
|
||||
});
|
||||
|
||||
if (this.model.type === 'app') {
|
||||
this.tabs.push('Config');
|
||||
|
||||
this.hasDashboards = _.findWhere(result.includes, {type: 'dashboard'});
|
||||
if (this.hasDashboards) {
|
||||
this.tabs.push('Dashboards');
|
||||
}
|
||||
}
|
||||
|
||||
return this.initReadme();
|
||||
});
|
||||
}
|
||||
@ -54,6 +66,7 @@ export class PluginEditCtrl {
|
||||
case 'panel': return 'icon-gf icon-gf-panel';
|
||||
case 'app': return 'icon-gf icon-gf-apps';
|
||||
case 'page': return 'icon-gf icon-gf-share';
|
||||
case 'dashboard': return 'icon-gf icon-gf-dashboard';
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,9 +77,7 @@ export class PluginEditCtrl {
|
||||
// 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());
|
||||
});
|
||||
chain = self.preUpdateHook();
|
||||
}
|
||||
|
||||
// Perform the core update procedure
|
||||
@ -86,7 +97,7 @@ export class PluginEditCtrl {
|
||||
// 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());
|
||||
return this.postUpdateHook();
|
||||
});
|
||||
}
|
||||
|
||||
@ -101,17 +112,16 @@ export class PluginEditCtrl {
|
||||
this.preUpdateHook = callback;
|
||||
}
|
||||
|
||||
setPOstUpdateHook(callback: () => any) {
|
||||
setPostUpdateHook(callback: () => any) {
|
||||
this.postUpdateHook = callback;
|
||||
}
|
||||
|
||||
toggleEnabled() {
|
||||
enable() {
|
||||
this.model.enabled = true;
|
||||
this.model.pinned = true;
|
||||
this.update();
|
||||
}
|
||||
|
||||
togglePinned() {
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
|
||||
angular.module('grafana.controllers').controller('PluginEditCtrl', PluginEditCtrl);
|
||||
|
Loading…
Reference in New Issue
Block a user