Files
grafana/public/app/features/plugins/plugin_list_ctrl.ts
Torkel Ödegaard 0bc226d760 ux: more nav work
2017-08-15 20:24:16 +02:00

37 lines
854 B
TypeScript

///<reference path="../../headers/common.d.ts" />
import angular from 'angular';
export class PluginListCtrl {
plugins: any[];
tabIndex: number;
navModel: any;
/** @ngInject */
constructor(private backendSrv: any, $location, navModelSrv) {
this.tabIndex = 0;
this.navModel = navModelSrv.getNav('cfg', 'plugins');
var pluginType = $location.search().type || 'panel';
switch (pluginType) {
case "datasource": {
this.tabIndex = 1;
break;
}
case "app": {
this.tabIndex = 2;
break;
}
case "panel":
default:
this.tabIndex = 0;
}
this.backendSrv.get('api/plugins', {embedded: 0, type: pluginType}).then(plugins => {
this.plugins = plugins;
});
}
}
angular.module('grafana.controllers').controller('PluginListCtrl', PluginListCtrl);