Chore: remove unused files
This commit is contained in:
@@ -1,57 +0,0 @@
|
|||||||
import angular from 'angular';
|
|
||||||
import _ from 'lodash';
|
|
||||||
|
|
||||||
const template = `
|
|
||||||
<value-select-dropdown
|
|
||||||
variable="ctrl.dsOptions"
|
|
||||||
on-updated="ctrl.onChange(ctrl.dsOptions)"
|
|
||||||
dashboard="ctrl.dashboard">
|
|
||||||
</value-select-dropdown>
|
|
||||||
`;
|
|
||||||
|
|
||||||
angular
|
|
||||||
.module('grafana.directives')
|
|
||||||
.directive('datasourceSelector', () => {
|
|
||||||
return {
|
|
||||||
scope: {
|
|
||||||
datasources: "=",
|
|
||||||
options: "=",
|
|
||||||
onChange: "&"
|
|
||||||
},
|
|
||||||
controller: DatasourceSelectorCtrl,
|
|
||||||
controllerAs: 'ctrl',
|
|
||||||
template: template
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
class DatasourceSelectorCtrl {
|
|
||||||
|
|
||||||
/** @ngInject */
|
|
||||||
constructor($scope) {
|
|
||||||
this.scope = $scope;
|
|
||||||
let datasources = $scope.datasources;
|
|
||||||
let options = $scope.options;
|
|
||||||
this.dsOptions = {
|
|
||||||
multi: true,
|
|
||||||
current: {value: datasources, text: datasources.join(" + ")},
|
|
||||||
options: _.map(options, (ds) => {
|
|
||||||
return {text: ds, value: ds, selected: _.includes(datasources, ds)};
|
|
||||||
})
|
|
||||||
};
|
|
||||||
// Fix for Grafana 6.0
|
|
||||||
// https://github.com/grafana/grafana/blob/v6.0.0/public/app/core/directives/value_select_dropdown.ts#L291
|
|
||||||
this.dashboard = {
|
|
||||||
on: () => {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
onChange(updatedOptions) {
|
|
||||||
let newDataSources = updatedOptions.current.value;
|
|
||||||
this.scope.datasources = newDataSources;
|
|
||||||
|
|
||||||
// Run after model was changed
|
|
||||||
this.scope.$$postDigest(() => {
|
|
||||||
this.scope.onChange();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,9 +11,8 @@
|
|||||||
* Licensed under the Apache License, Version 2.0
|
* Licensed under the Apache License, Version 2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {TriggerPanelCtrl} from './triggers_panel_ctrl';
|
import { TriggerPanelCtrl } from './triggers_panel_ctrl';
|
||||||
import {loadPluginCss} from 'grafana/app/plugins/sdk';
|
import { loadPluginCss } from 'grafana/app/plugins/sdk';
|
||||||
import './datasource-selector.directive';
|
|
||||||
|
|
||||||
loadPluginCss({
|
loadPluginCss({
|
||||||
dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',
|
dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
<div class="editor-row">
|
|
||||||
<div class="section gf-form-group">
|
|
||||||
<div class="gf-form-inline">
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label width-9">Data sources</label>
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<datasource-selector
|
|
||||||
datasources="editor.selectedDatasources"
|
|
||||||
options="editor.panelCtrl.available_datasources"
|
|
||||||
on-change="editor.datasourcesChanged()">
|
|
||||||
</datasource-selector>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="editor-row" ng-repeat="target in ctrl.panel.targets">
|
|
||||||
<div class="section gf-form-group">
|
|
||||||
<h5 class="section-heading">{{ target.datasource }}</h5>
|
|
||||||
<div class="gf-form-inline">
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label query-keyword width-7">Group</label>
|
|
||||||
<input type="text"
|
|
||||||
ng-model="target.group.filter"
|
|
||||||
bs-typeahead="editor.getGroupNames[target.datasource]"
|
|
||||||
ng-blur="editor.parseTarget()"
|
|
||||||
data-min-length=0
|
|
||||||
data-items=100
|
|
||||||
class="gf-form-input width-14"
|
|
||||||
ng-class="{
|
|
||||||
'zbx-variable': editor.isVariable(target.group.filter),
|
|
||||||
'zbx-regex': editor.isRegex(target.group.filter)
|
|
||||||
}">
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label query-keyword width-7">Host</label>
|
|
||||||
<input type="text"
|
|
||||||
ng-model="target.host.filter"
|
|
||||||
bs-typeahead="editor.getHostNames[target.datasource]"
|
|
||||||
ng-blur="editor.parseTarget()"
|
|
||||||
data-min-length=0
|
|
||||||
data-items=100
|
|
||||||
class="gf-form-input width-14"
|
|
||||||
ng-class="{
|
|
||||||
'zbx-variable': editor.isVariable(target.host.filter),
|
|
||||||
'zbx-regex': editor.isRegex(target.host.filter)
|
|
||||||
}">
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label query-keyword width-7">Proxy</label>
|
|
||||||
<input type="text"
|
|
||||||
ng-model="target.proxy.filter"
|
|
||||||
bs-typeahead="editor.getProxyNames[target.datasource]"
|
|
||||||
ng-blur="editor.parseTarget()"
|
|
||||||
data-min-length=0
|
|
||||||
data-items=100
|
|
||||||
class="gf-form-input width-14"
|
|
||||||
ng-class="{
|
|
||||||
'zbx-variable': editor.isVariable(target.proxy.filter),
|
|
||||||
'zbx-regex': editor.isRegex(target.proxy.filter)
|
|
||||||
}">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gf-form-inline">
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label query-keyword width-7">Application</label>
|
|
||||||
<input type="text"
|
|
||||||
ng-model="target.application.filter"
|
|
||||||
bs-typeahead="editor.getApplicationNames[target.datasource]"
|
|
||||||
ng-blur="editor.parseTarget()"
|
|
||||||
data-min-length=0
|
|
||||||
data-items=100
|
|
||||||
class="gf-form-input width-14"
|
|
||||||
ng-class="{
|
|
||||||
'zbx-variable': editor.isVariable(target.application.filter),
|
|
||||||
'zbx-regex': editor.isRegex(target.application.filter)
|
|
||||||
}">
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label query-keyword width-7">Trigger</label>
|
|
||||||
<input type="text"
|
|
||||||
ng-model="target.trigger.filter"
|
|
||||||
ng-blur="editor.parseTarget()"
|
|
||||||
placeholder="trigger name"
|
|
||||||
class="gf-form-input width-14"
|
|
||||||
ng-style="target.trigger.style"
|
|
||||||
ng-class="{
|
|
||||||
'zbx-variable': editor.isVariable(target.trigger.filter),
|
|
||||||
'zbx-regex': editor.isRegex(target.trigger.filter)
|
|
||||||
}"
|
|
||||||
empty-to-null>
|
|
||||||
</div>
|
|
||||||
<div class="gf-form">
|
|
||||||
<label class="gf-form-label query-keyword width-7">Tags</label>
|
|
||||||
<input type="text" class="gf-form-input width-14"
|
|
||||||
ng-model="target.tags.filter"
|
|
||||||
ng-blur="editor.parseTarget()"
|
|
||||||
placeholder="tag1:value1, tag2:value2">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import * as utils from '../datasource-zabbix/utils';
|
|
||||||
import { getDefaultTarget } from './triggers_panel_ctrl';
|
|
||||||
|
|
||||||
class TriggersTabCtrl {
|
|
||||||
|
|
||||||
/** @ngInject */
|
|
||||||
constructor($scope, $rootScope, uiSegmentSrv, templateSrv) {
|
|
||||||
$scope.editor = this;
|
|
||||||
this.panelCtrl = $scope.ctrl;
|
|
||||||
this.panel = this.panelCtrl.panel;
|
|
||||||
this.templateSrv = templateSrv;
|
|
||||||
this.datasources = {};
|
|
||||||
|
|
||||||
// Load scope defaults
|
|
||||||
var scopeDefaults = {
|
|
||||||
getGroupNames: {},
|
|
||||||
getHostNames: {},
|
|
||||||
getApplicationNames: {},
|
|
||||||
getProxyNames: {},
|
|
||||||
oldTarget: _.cloneDeep(this.panel.targets)
|
|
||||||
};
|
|
||||||
_.defaultsDeep(this, scopeDefaults);
|
|
||||||
this.selectedDatasources = this.getSelectedDatasources();
|
|
||||||
|
|
||||||
this.initDatasources();
|
|
||||||
this.panelCtrl.refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
initDatasources() {
|
|
||||||
return this.panelCtrl.initDatasources()
|
|
||||||
.then((datasources) => {
|
|
||||||
_.each(datasources, (datasource) => {
|
|
||||||
this.datasources[datasource.name] = datasource;
|
|
||||||
this.bindSuggestionFunctions(datasource);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
bindSuggestionFunctions(datasource) {
|
|
||||||
// Map functions for bs-typeahead
|
|
||||||
let ds = datasource.name;
|
|
||||||
this.getGroupNames[ds] = _.bind(this.suggestGroups, this, datasource);
|
|
||||||
this.getHostNames[ds] = _.bind(this.suggestHosts, this, datasource);
|
|
||||||
this.getApplicationNames[ds] = _.bind(this.suggestApps, this, datasource);
|
|
||||||
this.getProxyNames[ds] = _.bind(this.suggestProxies, this, datasource);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSelectedDatasources() {
|
|
||||||
return _.compact(this.panel.targets.map(target => target.datasource));
|
|
||||||
}
|
|
||||||
|
|
||||||
suggestGroups(datasource, query, callback) {
|
|
||||||
return datasource.zabbix.getAllGroups()
|
|
||||||
.then(groups => {
|
|
||||||
return _.map(groups, 'name');
|
|
||||||
})
|
|
||||||
.then(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
suggestHosts(datasource, query, callback) {
|
|
||||||
const target = this.panel.targets.find(t => t.datasource === datasource.name);
|
|
||||||
let groupFilter = datasource.replaceTemplateVars(target.group.filter);
|
|
||||||
return datasource.zabbix.getAllHosts(groupFilter)
|
|
||||||
.then(hosts => {
|
|
||||||
return _.map(hosts, 'name');
|
|
||||||
})
|
|
||||||
.then(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
suggestApps(datasource, query, callback) {
|
|
||||||
const target = this.panel.targets.find(t => t.datasource === datasource.name);
|
|
||||||
let groupFilter = datasource.replaceTemplateVars(target.group.filter);
|
|
||||||
let hostFilter = datasource.replaceTemplateVars(target.host.filter);
|
|
||||||
return datasource.zabbix.getAllApps(groupFilter, hostFilter)
|
|
||||||
.then(apps => {
|
|
||||||
return _.map(apps, 'name');
|
|
||||||
})
|
|
||||||
.then(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
suggestProxies(datasource, query, callback) {
|
|
||||||
return datasource.zabbix.getProxies()
|
|
||||||
.then(proxies => _.map(proxies, 'host'))
|
|
||||||
.then(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
datasourcesChanged() {
|
|
||||||
const newTargets = [];
|
|
||||||
_.each(this.selectedDatasources, (ds) => {
|
|
||||||
const dsTarget = this.panel.targets.find((target => target.datasource === ds));
|
|
||||||
if (dsTarget) {
|
|
||||||
newTargets.push(dsTarget);
|
|
||||||
} else {
|
|
||||||
const newTarget = getDefaultTarget(this.panel.targets);
|
|
||||||
newTarget.datasource = ds;
|
|
||||||
newTargets.push(newTarget);
|
|
||||||
}
|
|
||||||
this.panel.targets = newTargets;
|
|
||||||
});
|
|
||||||
this.parseTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
parseTarget() {
|
|
||||||
this.initDatasources()
|
|
||||||
.then(() => {
|
|
||||||
var newTarget = _.cloneDeep(this.panel.targets);
|
|
||||||
if (!_.isEqual(this.oldTarget, newTarget)) {
|
|
||||||
this.oldTarget = newTarget;
|
|
||||||
this.panelCtrl.refresh();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
isRegex(str) {
|
|
||||||
return utils.isRegex(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
isVariable(str) {
|
|
||||||
return utils.isTemplateVariable(str, this.templateSrv.variables);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function triggerPanelTriggersTab() {
|
|
||||||
return {
|
|
||||||
restrict: 'E',
|
|
||||||
scope: true,
|
|
||||||
templateUrl: 'public/plugins/alexanderzobnin-zabbix-app/panel-triggers/partials/triggers_tab.html',
|
|
||||||
controller: TriggersTabCtrl,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user