Merge branch 'master' into backend

This commit is contained in:
Alexander Zobnin
2020-05-29 10:33:11 +03:00
4 changed files with 1335 additions and 237 deletions

View File

@@ -26,68 +26,68 @@
"url": "https://github.com/alexanderzobnin/grafana-zabbix/issues"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/preset-env": "^7.7.7",
"@babel/preset-react": "^7.6.3",
"@emotion/core": "^10.0.27",
"@grafana/data": "^6.7.3",
"@grafana/runtime": "^6.7.3",
"@grafana/ui": "^6.7.3",
"@popperjs/core": "^2.4.0",
"@types/classnames": "^2.2.6",
"@babel/core": "7.7.7",
"@babel/preset-env": "7.7.7",
"@babel/preset-react": "7.6.3",
"@emotion/core": "10.0.27",
"@grafana/data": "6.7.3",
"@grafana/runtime": "6.7.3",
"@grafana/ui": "6.7.3",
"@popperjs/core": "2.4.0",
"@types/classnames": "2.2.9",
"@types/grafana": "github:CorpGlory/types-grafana",
"@types/jest": "^23.1.1",
"@types/jquery": "^3.3.0",
"@types/lodash": "^4.14.104",
"@types/moment": "^2.13.0",
"@types/react": "^16.4.6",
"@types/react-dom": "^16.0.11",
"@types/react-transition-group": "^2.0.15",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"@types/jest": "24.0.13",
"@types/jquery": "3.3.32",
"@types/lodash": "4.14.149",
"@types/react": "16.8.16",
"@types/react-dom": "16.8.4",
"@types/react-transition-group": "4.2.4",
"babel-jest": "24.8.0",
"babel-loader": "8.0.6",
"babel-plugin-transform-class-properties": "6.24.1",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-plugin-angularjs-annotate": "0.10.0",
"benchmark": "^2.1.4",
"classnames": "^2.2.6",
"classnames": "2.2.6",
"clean-webpack-plugin": "^0.1.19",
"codecov": "^3.1.0",
"copy-webpack-plugin": "^5.1.1",
"css-loader": "2.1.1",
"css-loader": "3.4.2",
"extract-text-webpack-plugin": "^4.0.0-beta.0",
"grunt": "^1.0.3",
"grunt": "1.0.4",
"grunt-benchmark": "^1.0.0",
"grunt-cli": "^1.3.1",
"grunt-cli": "1.3.2",
"grunt-execute": "^0.2.2",
"html-loader": "^0.5.5",
"jest": "^24.9.0",
"html-loader": "0.5.5",
"jest": "24.8.0",
"jscs": "^3.0.7",
"jsdom": "~11.3.0",
"jshint": "^2.9.6",
"jshint-stylish": "^2.1.0",
"load-grunt-tasks": "~3.2.0",
"lodash": "~4.17.13",
"memoize-one": "^5.1.1",
"moment": "~2.21.0",
"ng-annotate-webpack-plugin": "^0.3.0",
"node-sass": "^4.13.0",
"prop-types": "^15.6.2",
"lodash": "4.17.15",
"memoize-one": "5.1.1",
"moment": "2.24.0",
"ng-annotate-webpack-plugin": "0.3.0",
"node-sass": "4.13.1",
"prop-types": "15.7.2",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-popper": "^2.2.3",
"react-table-6": "^6.8.6",
"react-test-renderer": "^16.7.0",
"react-transition-group": "^2.5.2",
"react-transition-group": "4.3.0",
"rst2html": "github:thoward/rst2html#990cb89",
"sass-loader": "7.1.0",
"sass-loader": "8.0.2",
"semver": "^7.3.2",
"style-loader": "^0.23.1",
"style-loader": "1.1.3",
"tether-drop": "^1.4.2",
"ts-jest": "^24.2.0",
"ts-loader": "^4.4.1",
"ts-jest": "24.1.0",
"ts-loader": "4.4.1",
"tslint": "5.20.1",
"typescript": "^3.9.2",
"webpack": "4.29.6",
"webpack-cli": "3.2.3"
"typescript": "3.9.2",
"webpack": "4.41.5",
"webpack-cli": "3.3.10"
},
"resolutions": {
"js-yaml": "^3.13.1",

View File

@@ -306,6 +306,7 @@ class FuncInstance {
def: any;
params: any;
text: string;
added: boolean;
constructor(funcDef, params) {
this.def = funcDef;
@@ -408,7 +409,7 @@ class FuncInstance {
}
}
export function createFuncInstance(funcDef, params) {
export function createFuncInstance(funcDef, params?) {
if (_.isString(funcDef)) {
if (!index[funcDef]) {
throw { message: 'Method not found ' + name };

View File

@@ -58,6 +58,32 @@ function getSeverityOptions() {
}
export class ZabbixQueryController extends QueryCtrl {
static templateUrl: string;
zabbix: any;
replaceTemplateVars: any;
templateSrv: any;
editorModes: Array<{ value: string; text: string; queryType: number; }>;
slaPropertyList: Array<{ name: string; property: string; }>;
slaIntervals: Array<{ text: string; value: string; }>;
ackFilters: Array<{ text: string; value: number; }>;
problemAckFilters: string[];
sortByFields: Array<{ text: string; value: string; }>;
showEventsFields: Array<{ text: string; value: number[]; } | { text: string; value: number; }>;
showProblemsOptions: Array<{ text: string; value: string; }>;
resultFormats: Array<{ text: string; value: string; }>;
severityOptions: Array<{ val: number; text: string; }>;
getGroupNames: (...args: any[]) => any;
getHostNames: (...args: any[]) => any;
getApplicationNames: (...args: any[]) => any;
getItemNames: (...args: any[]) => any;
getITServices: (...args: any[]) => any;
getProxyNames: (...args: any[]) => any;
getVariables: (...args: any[]) => any;
init: () => void;
queryOptionsText: string;
metric: any;
showQueryOptions: boolean;
/** @ngInject */
constructor($scope, $injector, $rootScope, $sce, templateSrv) {
@@ -156,12 +182,12 @@ export class ZabbixQueryController extends QueryCtrl {
});
this.init = function() {
var target = this.target;
let target = this.target;
// Migrate old targets
target = migrations.migrate(target);
var scopeDefaults = {
const scopeDefaults = {
metric: {},
oldTarget: _.cloneDeep(this.target),
queryOptionsText: this.renderQueryOptionsText()
@@ -177,7 +203,7 @@ export class ZabbixQueryController extends QueryCtrl {
}
// Create function instances from saved JSON
target.functions = _.map(target.functions, function(func) {
target.functions = _.map(target.functions, func => {
return metricFunctions.createFuncInstance(func.def, func.params);
});
@@ -204,8 +230,8 @@ export class ZabbixQueryController extends QueryCtrl {
}
initFilters() {
let itemtype = _.find(this.editorModes, {'queryType': this.target.queryType});
itemtype = itemtype ? itemtype.value : null;
const mode = _.find(this.editorModes, {'queryType': this.target.queryType});
const itemtype = mode ? mode.value : null;
const promises = [
this.suggestGroups(),
this.suggestHosts(),
@@ -222,7 +248,7 @@ export class ZabbixQueryController extends QueryCtrl {
// Get list of metric names for bs-typeahead directive
getMetricNames(metricList, addAllValue) {
let metrics = _.uniq(_.map(this.metric[metricList], 'name'));
const metrics = _.uniq(_.map(this.metric[metricList], 'name'));
// Add template variables
_.forEach(this.templateSrv.variables, variable => {
@@ -251,7 +277,7 @@ export class ZabbixQueryController extends QueryCtrl {
}
suggestHosts() {
let groupFilter = this.replaceTemplateVars(this.target.group.filter);
const groupFilter = this.replaceTemplateVars(this.target.group.filter);
return this.zabbix.getAllHosts(groupFilter)
.then(hosts => {
this.metric.hostList = hosts;
@@ -260,8 +286,8 @@ export class ZabbixQueryController extends QueryCtrl {
}
suggestApps() {
let groupFilter = this.replaceTemplateVars(this.target.group.filter);
let hostFilter = this.replaceTemplateVars(this.target.host.filter);
const groupFilter = this.replaceTemplateVars(this.target.group.filter);
const hostFilter = this.replaceTemplateVars(this.target.host.filter);
return this.zabbix.getAllApps(groupFilter, hostFilter)
.then(apps => {
this.metric.appList = apps;
@@ -270,10 +296,10 @@ export class ZabbixQueryController extends QueryCtrl {
}
suggestItems(itemtype = 'num') {
let groupFilter = this.replaceTemplateVars(this.target.group.filter);
let hostFilter = this.replaceTemplateVars(this.target.host.filter);
let appFilter = this.replaceTemplateVars(this.target.application.filter);
let options = {
const groupFilter = this.replaceTemplateVars(this.target.group.filter);
const hostFilter = this.replaceTemplateVars(this.target.host.filter);
const appFilter = this.replaceTemplateVars(this.target.application.filter);
const options = {
itemtype: itemtype,
showDisabledItems: this.target.options.showDisabledItems
};
@@ -312,12 +338,15 @@ export class ZabbixQueryController extends QueryCtrl {
}
onTargetBlur() {
var newTarget = _.cloneDeep(this.target);
const newTarget = _.cloneDeep(this.target);
if (!_.isEqual(this.oldTarget, this.target)) {
this.oldTarget = newTarget;
this.targetChanged();
}
}
oldTarget(oldTarget: any, target: any) {
throw new Error("Method not implemented.");
}
onVariableChange() {
if (this.isContainsVariables()) {
@@ -354,7 +383,7 @@ export class ZabbixQueryController extends QueryCtrl {
}
addFunction(funcDef) {
var newFunc = metricFunctions.createFuncInstance(funcDef);
const newFunc = metricFunctions.createFuncInstance(funcDef);
newFunc.added = true;
this.target.functions.push(newFunc);
@@ -373,12 +402,12 @@ export class ZabbixQueryController extends QueryCtrl {
moveFunction(func, offset) {
const index = this.target.functions.indexOf(func);
_.move(this.target.functions, index, index + offset);
(_ as any).move(this.target.functions, index, index + offset);
this.targetChanged();
}
moveAliasFuncLast() {
var aliasFunc = _.find(this.target.functions, func => {
const aliasFunc = _.find(this.target.functions, func => {
return func.def.category === 'Alias';
});

1426
yarn.lock

File diff suppressed because it is too large Load Diff