From b7dab30a74a01dfbca4eb914f6fdcd8490c61e0c Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sat, 16 Dec 2017 14:39:53 +0300 Subject: [PATCH] Add tag filter by click at trigger tag icon, #487 --- dist/panel-triggers/partials/module.html | 3 ++- dist/panel-triggers/triggers_panel_ctrl.js | 16 ++++++++++++++++ dist/panel-triggers/triggers_panel_ctrl.js.map | 2 +- src/panel-triggers/partials/module.html | 3 ++- src/panel-triggers/triggers_panel_ctrl.js | 15 +++++++++++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/dist/panel-triggers/partials/module.html b/dist/panel-triggers/partials/module.html index 6ec3ad344..29e517141 100644 --- a/dist/panel-triggers/partials/module.html +++ b/dist/panel-triggers/partials/module.html @@ -18,7 +18,8 @@ - + {{tag.tag}}: {{tag.value}} diff --git a/dist/panel-triggers/triggers_panel_ctrl.js b/dist/panel-triggers/triggers_panel_ctrl.js index 006f4a726..01e539da6 100644 --- a/dist/panel-triggers/triggers_panel_ctrl.js +++ b/dist/panel-triggers/triggers_panel_ctrl.js @@ -548,6 +548,10 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap }, { key: 'parseTags', value: function parseTags(tagStr) { + if (!tagStr) { + return []; + } + var tags = _.map(tagStr.split(','), function (tag) { return tag.trim(); }); @@ -564,6 +568,18 @@ System.register(['lodash', 'jquery', 'moment', '../datasource-zabbix/utils', 'ap return tag.tag + ':' + tag.value; }).join(', '); } + }, { + key: 'addTagFilter', + value: function addTagFilter(tag, ds) { + var tagFilter = this.panel.targets[ds].tags.filter; + var targetTags = this.parseTags(tagFilter); + var newTag = { tag: tag.tag, value: tag.value }; + targetTags.push(newTag); + targetTags = _.uniqWith(targetTags, _.isEqual); + var newFilter = this.tagsToString(targetTags); + this.panel.targets[ds].tags.filter = newFilter; + this.refresh(); + } }, { key: 'switchComment', value: function switchComment(trigger) { diff --git a/dist/panel-triggers/triggers_panel_ctrl.js.map b/dist/panel-triggers/triggers_panel_ctrl.js.map index 584179b53..bd0fa37c1 100644 --- a/dist/panel-triggers/triggers_panel_ctrl.js.map +++ b/dist/panel-triggers/triggers_panel_ctrl.js.map @@ -1 +1 @@ -{"version":3,"sources":["../../src/panel-triggers/triggers_panel_ctrl.js"],"names":["filterTriggers","triggers","triggerFilter","utils","isRegex","_","filter","trigger","buildRegex","test","description","$","moment","PanelCtrl","triggerPanelOptionsTab","triggerPanelTriggersTab","migratePanelSchema","CURRENT_SCHEMA_VERSION","ZABBIX_DS_ID","DEFAULT_TARGET","group","host","application","tags","DEFAULT_SEVERITY","priority","severity","color","show","DEFAULT_TIME_FORMAT","PANEL_DEFAULTS","schemaVersion","datasources","targets","hostField","hostTechNameField","showTags","statusField","severityField","descriptionField","descriptionAtNewLine","hostsInMaintenance","showTriggers","sortTriggersBy","text","value","showEvents","limit","fontSize","pageSize","highlightNewEvents","highlightNewerThan","customLastChangeFormat","lastChangeFormat","triggerSeverity","okEventColor","ackEventColor","triggerStatusMap","TriggerPanelCtrl","$scope","$injector","$timeout","datasourceSrv","templateSrv","contextSrv","dashboardSrv","scope","editorTabIndex","defaultTimeFormat","pageIndex","triggerList","currentTriggersPage","panel","defaultsDeep","cloneDeep","available_datasources","map","getZabbixDataSources","length","push","isEmpty","initDatasources","events","on","onInitEditMode","bind","onRefresh","promises","ds","get","then","datasource","Promise","all","getMetricSources","meta","id","addEditorTab","timing","queryStart","Date","getTime","queryEnd","otherPanelInFullscreenMode","error","loading","setTimeQueryStart","getTriggers","setTimeQueryEnd","render","zabbixTriggers","catch","err","cancelled","console","log","message","data","emit","triggerListUnfiltered","formatTrigger","filterTriggersPost","sortTriggers","slice","getCurrentTriggersPage","zabbix","groupFilter","replaceTemplateVars","hostFilter","appFilter","triggersOptions","getAcknowledges","setMaintenanceStatus","filterTriggersPre","addTriggerDataSource","flatten","results","eventids","lastEvent","eventid","each","event","find","acknowledges","timestamp","unix","ack","clock","time","format","user","alias","name","surname","target","tagsFilter","replace","parseTags","every","tag","maintenance","maintenance_status","some","hosts","orderBy","zabbixTrigger","triggerObj","hostTechName","comments","lastchangeUnix","Number","lastchange","setTriggerLastChange","setTriggerSeverity","markAckEvents","age","fromNow","tagStr","split","trim","tagParts","join","showComment","grafana_user","ack_message","zabbixAPI","acknowledgeEvent","reject","startPos","endPos","Math","min","triggerValue","iconClass","isNewTrigger","statusClass","highlightIntervalMs","parseInterval","durationSec","now","e","elem","attrs","ctrl","pageCount","$watchGroup","renderPanel","switchPage","renderData","getContentHeight","panelHeight","height","el","currentTarget","parseInt","$apply","appendPaginationControls","footerElem","empty","ceil","startPage","max","endPage","paginationList","i","activeClass","pageLinkElem","append","setFontSize","triggerCardElem","css","rootElem","renderingCompleted","unbindDestroy","$on","off","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4lBA,WAASA,cAAT,CAAwBC,QAAxB,EAAkCC,aAAlC,EAAiD;AAC/C,QAAIC,MAAMC,OAAN,CAAcF,aAAd,CAAJ,EAAkC;AAChC,aAAOG,EAAEC,MAAF,CAASL,QAAT,EAAmB,UAASM,OAAT,EAAkB;AAC1C,eAAOJ,MAAMK,UAAN,CAAiBN,aAAjB,EAAgCO,IAAhC,CAAqCF,QAAQG,WAA7C,CAAP;AACD,OAFM,CAAP;AAGD,KAJD,MAIO;AACL,aAAOL,EAAEC,MAAF,CAASL,QAAT,EAAmB,UAASM,OAAT,EAAkB;AAC1C,eAAOA,QAAQG,WAAR,KAAwBR,aAA/B;AACD,OAFM,CAAP;AAGD;AACF;;;AAtmBMG,O;;AACAM,O;;AACAC,Y;;AACKT,W;;AACJU,e,kBAAAA,S;;AACAC,4B,gBAAAA,sB;;AACAC,6B,iBAAAA,uB;;AACAC,wB,eAAAA,kB;AAAoBC,4B,eAAAA,sB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtBC,kB,GAAe,mC;;gCAERC,c,GAAiB;AAC5BC,eAAO,EAACd,QAAQ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AhB,CAAqB,UAArB,EAAiCwF,GAAjC,CAAqC,EAAC,aAAa,EAAd,EAArC;AACAD,gCAAgBvF,IAAhB,CAAqB,UAArB,EAAiCwF,GAAjC,CAAqC,EAAC,eAAe,EAAhB,EAArC;AACD;AACF;;AAED,qBAASxB,WAAT,GAAuB;AACrB,kBAAIyB,WAAW9B,KAAK3D,IAAL,CAAU,wBAAV,CAAf;AACA,kBAAI2E,aAAahB,KAAK3D,IAAL,CAAU,wBAAV,CAAjB;AACA0E,uCAAyBC,UAAzB;AACAc,uBAASD,GAAT,CAAa,EAAC,cAAcrB,kBAAf,EAAb;AACAsB,uBAASD,GAAT,CAAa,EAAC,UAAUrB,kBAAX,EAAb;AACAmB;AACAzB,mBAAK6B,kBAAL;AACD;;AAED,gBAAIC,gBAAgBvK,MAAMwK,GAAN,CAAU,UAAV,EAAsB,YAAW;AACnDjC,mBAAKkC,GAAL,CAAS,OAAT,EAAkB,2BAAlB;AACAF;AACD,aAHmB,CAApB;AAID;;;;QArhBmC5N,S;;;;AAwhBtC6C,uBAAiBkL,WAAjB,GAA+B,+EAA/B","file":"triggers_panel_ctrl.js","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport moment from 'moment';\nimport * as utils from '../datasource-zabbix/utils';\nimport {PanelCtrl} from 'app/plugins/sdk';\nimport {triggerPanelOptionsTab} from './options_tab';\nimport {triggerPanelTriggersTab} from './triggers_tab';\nimport {migratePanelSchema, CURRENT_SCHEMA_VERSION} from './migrations';\n\nconst ZABBIX_DS_ID = 'alexanderzobnin-zabbix-datasource';\n\nexport const DEFAULT_TARGET = {\n group: {filter: \"\"},\n host: {filter: \"\"},\n application: {filter: \"\"},\n trigger: {filter: \"\"},\n tags: {filter: \"\"},\n};\n\nexport const DEFAULT_SEVERITY = [\n { priority: 0, severity: 'Not classified', color: '#B7DBAB', show: true},\n { priority: 1, severity: 'Information', color: '#82B5D8', show: true},\n { priority: 2, severity: 'Warning', color: '#E5AC0E', show: true},\n { priority: 3, severity: 'Average', color: '#C15C17', show: true},\n { priority: 4, severity: 'High', color: '#BF1B00', show: true},\n { priority: 5, severity: 'Disaster', color: '#890F02', show: true},\n];\n\nconst DEFAULT_TIME_FORMAT = \"DD MMM YYYY HH:mm:ss\";\n\nexport const PANEL_DEFAULTS = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n datasources: [],\n targets: {},\n // Fields\n hostField: true,\n hostTechNameField: false,\n showTags: true,\n statusField: true,\n severityField: true,\n descriptionField: true,\n descriptionAtNewLine: false,\n // Options\n hostsInMaintenance: true,\n showTriggers: 'all triggers',\n sortTriggersBy: { text: 'last change', value: 'lastchange' },\n showEvents: { text: 'Problems', value: '1' },\n limit: 100,\n // View options\n fontSize: '100%',\n pageSize: 10,\n highlightNewEvents: true,\n highlightNewerThan: '1h',\n customLastChangeFormat: false,\n lastChangeFormat: \"\",\n // Triggers severity and colors\n triggerSeverity: DEFAULT_SEVERITY,\n okEventColor: 'rgba(0, 245, 153, 0.45)',\n ackEventColor: 'rgba(0, 0, 0, 0)'\n};\n\nconst triggerStatusMap = {\n '0': 'OK',\n '1': 'PROBLEM'\n};\n\nexport class TriggerPanelCtrl extends PanelCtrl {\n\n /** @ngInject */\n constructor($scope, $injector, $timeout, datasourceSrv, templateSrv, contextSrv, dashboardSrv) {\n super($scope, $injector);\n this.datasourceSrv = datasourceSrv;\n this.templateSrv = templateSrv;\n this.contextSrv = contextSrv;\n this.dashboardSrv = dashboardSrv;\n this.scope = $scope;\n this.$timeout = $timeout;\n\n this.editorTabIndex = 1;\n this.triggerStatusMap = triggerStatusMap;\n this.defaultTimeFormat = DEFAULT_TIME_FORMAT;\n this.pageIndex = 0;\n this.triggerList = [];\n this.currentTriggersPage = [];\n this.datasources = {};\n\n this.panel = migratePanelSchema(this.panel);\n _.defaultsDeep(this.panel, _.cloneDeep(PANEL_DEFAULTS));\n\n this.available_datasources = _.map(this.getZabbixDataSources(), 'name');\n if (this.panel.datasources.length === 0) {\n this.panel.datasources.push(this.available_datasources[0]);\n }\n if (_.isEmpty(this.panel.targets)) {\n this.panel.targets[this.panel.datasources[0]] = DEFAULT_TARGET;\n }\n\n this.initDatasources();\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n this.events.on('refresh', this.onRefresh.bind(this));\n }\n\n initDatasources() {\n let promises = _.map(this.panel.datasources, (ds) => {\n // Load datasource\n return this.datasourceSrv.get(ds)\n .then(datasource => {\n this.datasources[ds] = datasource;\n return datasource;\n });\n });\n return Promise.all(promises);\n }\n\n getZabbixDataSources() {\n return _.filter(this.datasourceSrv.getMetricSources(), datasource => {\n return datasource.meta.id === ZABBIX_DS_ID && datasource.value;\n });\n }\n\n onInitEditMode() {\n this.addEditorTab('Triggers', triggerPanelTriggersTab, 1);\n this.addEditorTab('Options', triggerPanelOptionsTab, 2);\n }\n\n setTimeQueryStart() {\n this.timing.queryStart = new Date().getTime();\n }\n\n setTimeQueryEnd() {\n this.timing.queryEnd = new Date().getTime();\n }\n\n onRefresh() {\n // ignore fetching data if another panel is in fullscreen\n if (this.otherPanelInFullscreenMode()) { return; }\n\n // clear loading/error state\n delete this.error;\n this.loading = true;\n this.setTimeQueryStart();\n this.pageIndex = 0;\n\n return this.getTriggers()\n .then(zabbixTriggers => {\n // Notify panel that request is finished\n this.loading = false;\n this.setTimeQueryEnd();\n\n this.render(zabbixTriggers);\n })\n .catch(err => {\n // if cancelled keep loading set to true\n if (err.cancelled) {\n console.log('Panel request cancelled', err);\n return;\n }\n\n this.loading = false;\n this.error = err.message || \"Request Error\";\n\n if (err.data) {\n if (err.data.message) {\n this.error = err.data.message;\n }\n if (err.data.error) {\n this.error = err.data.error;\n }\n }\n\n this.events.emit('data-error', err);\n console.log('Panel data error:', err);\n });\n }\n\n render(zabbixTriggers) {\n let triggers = _.cloneDeep(zabbixTriggers || this.triggerListUnfiltered);\n this.triggerListUnfiltered = _.cloneDeep(triggers);\n\n triggers = _.map(triggers, this.formatTrigger.bind(this));\n triggers = this.filterTriggersPost(triggers);\n triggers = this.sortTriggers(triggers);\n\n // Limit triggers number\n triggers = triggers.slice(0, this.panel.limit || PANEL_DEFAULTS.limit);\n\n this.triggerList = triggers;\n this.getCurrentTriggersPage();\n\n this.$timeout(() => {\n super.render(this.triggerList);\n });\n }\n\n getTriggers() {\n let promises = _.map(this.panel.datasources, (ds) => {\n return this.datasourceSrv.get(ds)\n .then(datasource => {\n var zabbix = datasource.zabbix;\n var showEvents = this.panel.showEvents.value;\n var triggerFilter = this.panel.targets[ds];\n\n // Replace template variables\n var groupFilter = datasource.replaceTemplateVars(triggerFilter.group.filter);\n var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);\n var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);\n\n let triggersOptions = {\n showTriggers: showEvents\n };\n\n return zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions);\n }).then((triggers) => {\n return this.getAcknowledges(triggers, ds);\n }).then((triggers) => {\n return this.setMaintenanceStatus(triggers);\n }).then((triggers) => {\n return this.filterTriggersPre(triggers, ds);\n }).then((triggers) => {\n return this.addTriggerDataSource(triggers, ds);\n });\n });\n\n return Promise.all(promises)\n .then(results => _.flatten(results));\n }\n\n getAcknowledges(triggerList, ds) {\n // Request acknowledges for trigger\n var eventids = _.map(triggerList, trigger => {\n return trigger.lastEvent.eventid;\n });\n\n return this.datasources[ds].zabbix.getAcknowledges(eventids)\n .then(events => {\n\n // Map events to triggers\n _.each(triggerList, trigger => {\n var event = _.find(events, event => {\n return event.eventid === trigger.lastEvent.eventid;\n });\n\n if (event) {\n trigger.acknowledges = _.map(event.acknowledges, ack => {\n let timestamp = moment.unix(ack.clock);\n if (this.panel.customLastChangeFormat) {\n ack.time = timestamp.format(this.panel.lastChangeFormat);\n } else {\n ack.time = timestamp.format(this.defaultTimeFormat);\n }\n ack.user = ack.alias + ' (' + ack.name + ' ' + ack.surname + ')';\n return ack;\n });\n }\n\n if (!trigger.lastEvent.eventid) {\n trigger.lastEvent = null;\n }\n });\n\n return triggerList;\n });\n }\n\n filterTriggersPre(triggerList, ds) {\n // Filter triggers by description\n let triggerFilter = this.panel.targets[ds].trigger.filter;\n triggerFilter = this.datasources[ds].replaceTemplateVars(triggerFilter);\n if (triggerFilter) {\n triggerList = filterTriggers(triggerList, triggerFilter);\n }\n\n // Filter by tags\n const target = this.panel.targets[ds];\n if (target.tags.filter) {\n let tagsFilter = this.datasources[ds].replaceTemplateVars(target.tags.filter);\n // replaceTemplateVars() builds regex-like string, so we should trim it.\n tagsFilter = tagsFilter.replace('/^', '').replace('$/', '');\n const tags = this.parseTags(tagsFilter);\n triggerList = _.filter(triggerList, trigger => {\n return _.every(tags, (tag) => {\n return _.find(trigger.tags, {tag: tag.tag, value: tag.value});\n });\n });\n }\n\n return triggerList;\n }\n\n filterTriggersPost(triggers) {\n let triggerList = _.cloneDeep(triggers);\n\n // Filter acknowledged triggers\n if (this.panel.showTriggers === 'unacknowledged') {\n triggerList = _.filter(triggerList, trigger => {\n return !trigger.acknowledges;\n });\n } else if (this.panel.showTriggers === 'acknowledged') {\n triggerList = _.filter(triggerList, 'acknowledges');\n } else {\n triggerList = triggerList;\n }\n\n // Filter by maintenance status\n if (!this.panel.hostsInMaintenance) {\n triggerList = _.filter(triggerList, (trigger) => trigger.maintenance === false);\n }\n\n // Filter triggers by severity\n triggerList = _.filter(triggerList, trigger => {\n return this.panel.triggerSeverity[trigger.priority].show;\n });\n\n return triggerList;\n }\n\n setMaintenanceStatus(triggers) {\n _.each(triggers, (trigger) => {\n let maintenance_status = _.some(trigger.hosts, (host) => host.maintenance_status === '1');\n trigger.maintenance = maintenance_status;\n });\n return triggers;\n }\n\n addTriggerDataSource(triggers, ds) {\n _.each(triggers, (trigger) => {\n trigger.datasource = ds;\n });\n return triggers;\n }\n\n sortTriggers(triggerList) {\n if (this.panel.sortTriggersBy.value === 'priority') {\n triggerList = _.orderBy(triggerList, ['priority', 'lastchangeUnix', 'triggerid'], ['desc', 'desc', 'desc']);\n } else {\n triggerList = _.orderBy(triggerList, ['lastchangeUnix', 'priority', 'triggerid'], ['desc', 'desc', 'desc']);\n }\n return triggerList;\n }\n\n formatTrigger(zabbixTrigger) {\n let trigger = _.cloneDeep(zabbixTrigger);\n let triggerObj = trigger;\n\n // Set host that the trigger belongs\n if (trigger.hosts && trigger.hosts.length) {\n triggerObj.host = trigger.hosts[0].name;\n triggerObj.hostTechName = trigger.hosts[0].host;\n }\n\n // Set tags if present\n if (trigger.tags && trigger.tags.length === 0) {\n trigger.tags = null;\n }\n\n // Handle multi-line description\n if (trigger.comments) {\n trigger.comments = trigger.comments.replace('\\n', '
');\n }\n\n // Format last change and age\n trigger.lastchangeUnix = Number(trigger.lastchange);\n triggerObj = this.setTriggerLastChange(triggerObj);\n triggerObj = this.setTriggerSeverity(triggerObj);\n return triggerObj;\n }\n\n updateTriggerFormat(trigger) {\n trigger = this.setTriggerLastChange(trigger);\n trigger = this.setTriggerSeverity(trigger);\n return trigger;\n }\n\n setTriggerSeverity(trigger) {\n if (trigger.value === '1') {\n // Problem state\n trigger.color = this.panel.triggerSeverity[trigger.priority].color;\n } else {\n // OK state\n trigger.color = this.panel.okEventColor;\n }\n trigger.severity = this.panel.triggerSeverity[trigger.priority].severity;\n\n // Mark acknowledged triggers with different color\n if (this.panel.markAckEvents && trigger.acknowledges && trigger.acknowledges.length) {\n trigger.color = this.panel.ackEventColor;\n }\n\n return trigger;\n }\n\n setTriggerLastChange(trigger) {\n if (!trigger.lastchangeUnix) {\n trigger.lastchange = \"\";\n trigger.age = \"\";\n return trigger;\n }\n\n let timestamp = moment.unix(trigger.lastchangeUnix);\n if (this.panel.customLastChangeFormat) {\n // User defined format\n trigger.lastchange = timestamp.format(this.panel.lastChangeFormat);\n } else {\n trigger.lastchange = timestamp.format(this.defaultTimeFormat);\n }\n trigger.age = timestamp.fromNow(true);\n return trigger;\n }\n\n parseTags(tagStr) {\n let tags = _.map(tagStr.split(','), (tag) => tag.trim());\n tags = _.map(tags, (tag) => {\n const tagParts = tag.split(':');\n return {tag: tagParts[0].trim(), value: tagParts[1].trim()};\n });\n return tags;\n }\n\n tagsToString(tags) {\n return _.map(tags, (tag) => `${tag.tag}:${tag.value}`).join(', ');\n }\n\n switchComment(trigger) {\n trigger.showComment = !trigger.showComment;\n }\n\n acknowledgeTrigger(trigger, message) {\n let eventid = trigger.lastEvent ? trigger.lastEvent.eventid : null;\n let grafana_user = this.contextSrv.user.name;\n let ack_message = grafana_user + ' (Grafana): ' + message;\n return this.datasourceSrv.get(trigger.datasource)\n .then(datasource => {\n if (eventid) {\n return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);\n } else {\n return Promise.reject({message: 'Trigger has no events. Nothing to acknowledge.'});\n }\n })\n .then(this.onRefresh.bind(this))\n .catch((err) => {\n this.error = err.message || \"Acknowledge Error\";\n this.events.emit('data-error', err);\n console.log('Panel data error:', err);\n });\n }\n\n getCurrentTriggersPage() {\n let pageSize = this.panel.pageSize || PANEL_DEFAULTS.pageSize;\n let startPos = this.pageIndex * pageSize;\n let endPos = Math.min(startPos + pageSize, this.triggerList.length);\n this.currentTriggersPage = this.triggerList.slice(startPos, endPos);\n return this.currentTriggersPage;\n }\n\n formatHostName(trigger) {\n if (this.panel.hostField && this.panel.hostTechNameField) {\n return `${trigger.host} (${trigger.hostTechName})`;\n } else if (this.panel.hostField || this.panel.hostTechNameField) {\n return this.panel.hostField ? trigger.host : trigger.hostTechName;\n } else {\n return \"\";\n }\n }\n\n getAlertIconClass(trigger) {\n const triggerValue = Number(trigger.value);\n let iconClass = '';\n if (triggerValue || trigger.color) {\n if (trigger.priority >= 3) {\n iconClass = 'icon-gf-critical';\n } else {\n iconClass = 'icon-gf-warning';\n }\n } else {\n iconClass = 'icon-gf-online';\n }\n\n if (this.panel.highlightNewEvents && this.isNewTrigger(trigger)) {\n iconClass += ' zabbix-trigger--blinked';\n }\n return iconClass;\n }\n\n getAlertStateClass(trigger) {\n let statusClass = '';\n\n if (trigger.value === '1') {\n statusClass = 'alert-state-critical';\n } else {\n statusClass = 'alert-state-ok';\n }\n\n if (this.panel.highlightNewEvents && this.isNewTrigger(trigger)) {\n statusClass += ' zabbix-trigger--blinked';\n }\n\n return statusClass;\n }\n\n isNewTrigger(trigger) {\n try {\n const highlightIntervalMs = utils.parseInterval(this.panel.highlightNewerThan || PANEL_DEFAULTS.highlightNewerThan);\n const durationSec = (Date.now() - trigger.lastchangeUnix * 1000);\n return durationSec < highlightIntervalMs;\n } catch (e) {\n return false;\n }\n }\n\n link(scope, elem, attrs, ctrl) {\n let panel = ctrl.panel;\n let pageCount = 0;\n let triggerList = ctrl.triggerList;\n\n scope.$watchGroup(['ctrl.currentTriggersPage', 'ctrl.triggerList'], renderPanel);\n elem.on('click', '.triggers-panel-page-link', switchPage);\n ctrl.events.on('render', (renderData) => {\n triggerList = renderData || triggerList;\n renderPanel();\n });\n\n function getContentHeight() {\n let panelHeight = ctrl.height;\n if (pageCount > 1) {\n panelHeight -= 36;\n }\n return panelHeight + 'px';\n }\n\n function switchPage(e) {\n let el = $(e.currentTarget);\n ctrl.pageIndex = (parseInt(el.text(), 10)-1);\n\n let pageSize = panel.pageSize || 10;\n let startPos = ctrl.pageIndex * pageSize;\n let endPos = Math.min(startPos + pageSize, triggerList.length);\n ctrl.currentTriggersPage = triggerList.slice(startPos, endPos);\n\n scope.$apply(() => {\n renderPanel();\n });\n }\n\n function appendPaginationControls(footerElem) {\n footerElem.empty();\n\n let pageSize = panel.pageSize || 5;\n pageCount = Math.ceil(triggerList.length / pageSize);\n if (pageCount === 1) {\n return;\n }\n\n let startPage = Math.max(ctrl.pageIndex - 3, 0);\n let endPage = Math.min(pageCount, startPage + 9);\n\n let paginationList = $('');\n\n for (let i = startPage; i < endPage; i++) {\n let activeClass = i === ctrl.pageIndex ? 'active' : '';\n let pageLinkElem = $('
  • ' + (i+1) + '
  • ');\n paginationList.append(pageLinkElem);\n }\n\n footerElem.append(paginationList);\n }\n\n function setFontSize() {\n const fontSize = parseInt(panel.fontSize.slice(0, panel.fontSize.length - 1));\n let triggerCardElem = elem.find('.card-item-wrapper');\n if (fontSize && fontSize !== 100) {\n triggerCardElem.find('.alert-list-icon').css({'font-size': fontSize + '%'});\n triggerCardElem.find('.alert-list-title').css({'font-size': fontSize + '%'});\n triggerCardElem.find('.alert-list-text').css({'font-size': fontSize * 0.8 + '%'});\n triggerCardElem.find('.zbx-tag').css({'font-size': fontSize * 0.6 + '%'});\n triggerCardElem.find('.zbx-tag').css({'line-height': fontSize / 100 * 16 + 'px'});\n } else {\n // remove css\n triggerCardElem.find('.alert-list-icon').css({'font-size': ''});\n triggerCardElem.find('.alert-list-title').css({'font-size': ''});\n triggerCardElem.find('.alert-list-text').css({'font-size': ''});\n triggerCardElem.find('.zbx-tag').css({'font-size': ''});\n triggerCardElem.find('.zbx-tag').css({'line-height': ''});\n }\n }\n\n function renderPanel() {\n let rootElem = elem.find('.triggers-panel-scroll');\n let footerElem = elem.find('.triggers-panel-footer');\n appendPaginationControls(footerElem);\n rootElem.css({'max-height': getContentHeight()});\n rootElem.css({'height': getContentHeight()});\n setFontSize();\n ctrl.renderingCompleted();\n }\n\n let unbindDestroy = scope.$on('$destroy', function() {\n elem.off('click', '.triggers-panel-page-link');\n unbindDestroy();\n });\n }\n}\n\nTriggerPanelCtrl.templateUrl = 'public/plugins/alexanderzobnin-zabbix-app/panel-triggers/partials/module.html';\n\nfunction filterTriggers(triggers, triggerFilter) {\n if (utils.isRegex(triggerFilter)) {\n return _.filter(triggers, function(trigger) {\n return utils.buildRegex(triggerFilter).test(trigger.description);\n });\n } else {\n return _.filter(triggers, function(trigger) {\n return trigger.description === triggerFilter;\n });\n }\n}\n"]} \ No newline at end of file +{"version":3,"sources":["../../src/panel-triggers/triggers_panel_ctrl.js"],"names":["filterTriggers","triggers","triggerFilter","utils","isRegex","_","filter","trigger","buildRegex","test","description","$","moment","PanelCtrl","triggerPanelOptionsTab","triggerPanelTriggersTab","migratePanelSchema","CURRENT_SCHEMA_VERSION","ZABBIX_DS_ID","DEFAULT_TARGET","group","host","application","tags","DEFAULT_SEVERITY","priority","severity","color","show","DEFAULT_TIME_FORMAT","PANEL_DEFAULTS","schemaVersion","datasources","targets","hostField","hostTechNameField","showTags","statusField","severityField","descriptionField","descriptionAtNewLine","hostsInMaintenance","showTriggers","sortTriggersBy","text","value","showEvents","limit","fontSize","pageSize","highlightNewEvents","highlightNewerThan","customLastChangeFormat","lastChangeFormat","triggerSeverity","okEventColor","ackEventColor","triggerStatusMap","TriggerPanelCtrl","$scope","$injector","$timeout","datasourceSrv","templateSrv","contextSrv","dashboardSrv","scope","editorTabIndex","defaultTimeFormat","pageIndex","triggerList","currentTriggersPage","panel","defaultsDeep","cloneDeep","available_datasources","map","getZabbixDataSources","length","push","isEmpty","initDatasources","events","on","onInitEditMode","bind","onRefresh","promises","ds","get","then","datasource","Promise","all","getMetricSources","meta","id","addEditorTab","timing","queryStart","Date","getTime","queryEnd","otherPanelInFullscreenMode","error","loading","setTimeQueryStart","getTriggers","setTimeQueryEnd","render","zabbixTriggers","catch","err","cancelled","console","log","message","data","emit","triggerListUnfiltered","formatTrigger","filterTriggersPost","sortTriggers","slice","getCurrentTriggersPage","zabbix","groupFilter","replaceTemplateVars","hostFilter","appFilter","triggersOptions","getAcknowledges","setMaintenanceStatus","filterTriggersPre","addTriggerDataSource","flatten","results","eventids","lastEvent","eventid","each","event","find","acknowledges","timestamp","unix","ack","clock","time","format","user","alias","name","surname","target","tagsFilter","replace","parseTags","every","tag","maintenance","maintenance_status","some","hosts","orderBy","zabbixTrigger","triggerObj","hostTechName","comments","lastchangeUnix","Number","lastchange","setTriggerLastChange","setTriggerSeverity","markAckEvents","age","fromNow","tagStr","split","trim","tagParts","join","tagFilter","targetTags","newTag","uniqWith","isEqual","newFilter","tagsToString","refresh","showComment","grafana_user","ack_message","zabbixAPI","acknowledgeEvent","reject","startPos","endPos","Math","min","triggerValue","iconClass","isNewTrigger","statusClass","highlightIntervalMs","parseInterval","durationSec","now","e","elem","attrs","ctrl","pageCount","$watchGroup","renderPanel","switchPage","renderData","getContentHeight","panelHeight","height","el","currentTarget","parseInt","$apply","appendPaginationControls","footerElem","empty","ceil","startPage","max","endPage","paginationList","i","activeClass","pageLinkElem","append","setFontSize","triggerCardElem","css","rootElem","renderingCompleted","unbindDestroy","$on","off","templateUrl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2mBA,WAASA,cAAT,CAAwBC,QAAxB,EAAkCC,aAAlC,EAAiD;AAC/C,QAAIC,MAAMC,OAAN,CAAcF,aAAd,CAAJ,EAAkC;AAChC,aAAOG,EAAEC,MAAF,CAASL,QAAT,EAAmB,UAASM,OAAT,EAAkB;AAC1C,eAAOJ,MAAMK,UAAN,CAAiBN,aAAjB,EAAgCO,IAAhC,CAAqCF,QAAQG,WAA7C,CAAP;AACD,OAFM,CAAP;AAGD,KAJD,MAIO;AACL,aAAOL,EAAEC,MAAF,CAASL,QAAT,EAAmB,UAASM,OAAT,EAAkB;AAC1C,eAAOA,QAAQG,WAAR,KAAwBR,aAA/B;AACD,OAFM,CAAP;AAGD;AACF;;;AArnBMG,O;;AACAM,O;;AACAC,Y;;AACKT,W;;AACJU,e,kBAAAA,S;;AACAC,4B,gBAAAA,sB;;AACAC,6B,iBAAAA,uB;;AACAC,wB,eAAAA,kB;AAAoBC,4B,eAAAA,sB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtBC,kB,GAAe,mC;;gCAERC,c,GAAiB;AAC5BC,eAAO,EAACd,QAAQ,EAAT,EADqB;AAE5Be,cAAM,EAACf,QAAQ,EAAT,EAFsB;AAG5BgB,qBAAa,EAAChB,QAAQ,EAAT,EAHe;AAI5BC,iBAAS,EAACD,QAAQ,EAAT,EAJmB;AAK5BiB,cAAM,EAACjB,QAAQ,EAAT;AALsB,O;;;;kCAQjBkB,gB,GAAmB,CAC9B,EAAEC,UAAU,CAAZ,EAAeC,UAAU,gBAAzB,EAA4CC,OAA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,WAAW,GAAX,GAAiB,EAAjB,GAAsB,IAAtC,EAArC;AACD,eAND,MAMO;AACL;AACA6L,gCAAgB/F,IAAhB,CAAqB,kBAArB,EAAyCgG,GAAzC,CAA6C,EAAC,aAAa,EAAd,EAA7C;AACAD,gCAAgB/F,IAAhB,CAAqB,mBAArB,EAA0CgG,GAA1C,CAA8C,EAAC,aAAa,EAAd,EAA9C;AACAD,gCAAgB/F,IAAhB,CAAqB,kBAArB,EAAyCgG,GAAzC,CAA6C,EAAC,aAAa,EAAd,EAA7C;AACAD,gCAAgB/F,IAAhB,CAAqB,UAArB,EAAiCgG,GAAjC,CAAqC,EAAC,aAAa,EAAd,EAArC;AACAD,gCAAgB/F,IAAhB,CAAqB,UAArB,EAAiCgG,GAAjC,CAAqC,EAAC,eAAe,EAAhB,EAArC;AACD;AACF;;AAED,qBAASxB,WAAT,GAAuB;AACrB,kBAAIyB,WAAW9B,KAAKnE,IAAL,CAAU,wBAAV,CAAf;AACA,kBAAImF,aAAahB,KAAKnE,IAAL,CAAU,wBAAV,CAAjB;AACAkF,uCAAyBC,UAAzB;AACAc,uBAASD,GAAT,CAAa,EAAC,cAAcrB,kBAAf,EAAb;AACAsB,uBAASD,GAAT,CAAa,EAAC,UAAUrB,kBAAX,EAAb;AACAmB;AACAzB,mBAAK6B,kBAAL;AACD;;AAED,gBAAIC,gBAAgB/K,MAAMgL,GAAN,CAAU,UAAV,EAAsB,YAAW;AACnDjC,mBAAKkC,GAAL,CAAS,OAAT,EAAkB,2BAAlB;AACAF;AACD,aAHmB,CAApB;AAID;;;;QApiBmCpO,S;;;;AAuiBtC6C,uBAAiB0L,WAAjB,GAA+B,+EAA/B","file":"triggers_panel_ctrl.js","sourcesContent":["import _ from 'lodash';\nimport $ from 'jquery';\nimport moment from 'moment';\nimport * as utils from '../datasource-zabbix/utils';\nimport {PanelCtrl} from 'app/plugins/sdk';\nimport {triggerPanelOptionsTab} from './options_tab';\nimport {triggerPanelTriggersTab} from './triggers_tab';\nimport {migratePanelSchema, CURRENT_SCHEMA_VERSION} from './migrations';\n\nconst ZABBIX_DS_ID = 'alexanderzobnin-zabbix-datasource';\n\nexport const DEFAULT_TARGET = {\n group: {filter: \"\"},\n host: {filter: \"\"},\n application: {filter: \"\"},\n trigger: {filter: \"\"},\n tags: {filter: \"\"},\n};\n\nexport const DEFAULT_SEVERITY = [\n { priority: 0, severity: 'Not classified', color: '#B7DBAB', show: true},\n { priority: 1, severity: 'Information', color: '#82B5D8', show: true},\n { priority: 2, severity: 'Warning', color: '#E5AC0E', show: true},\n { priority: 3, severity: 'Average', color: '#C15C17', show: true},\n { priority: 4, severity: 'High', color: '#BF1B00', show: true},\n { priority: 5, severity: 'Disaster', color: '#890F02', show: true},\n];\n\nconst DEFAULT_TIME_FORMAT = \"DD MMM YYYY HH:mm:ss\";\n\nexport const PANEL_DEFAULTS = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n datasources: [],\n targets: {},\n // Fields\n hostField: true,\n hostTechNameField: false,\n showTags: true,\n statusField: true,\n severityField: true,\n descriptionField: true,\n descriptionAtNewLine: false,\n // Options\n hostsInMaintenance: true,\n showTriggers: 'all triggers',\n sortTriggersBy: { text: 'last change', value: 'lastchange' },\n showEvents: { text: 'Problems', value: '1' },\n limit: 100,\n // View options\n fontSize: '100%',\n pageSize: 10,\n highlightNewEvents: true,\n highlightNewerThan: '1h',\n customLastChangeFormat: false,\n lastChangeFormat: \"\",\n // Triggers severity and colors\n triggerSeverity: DEFAULT_SEVERITY,\n okEventColor: 'rgba(0, 245, 153, 0.45)',\n ackEventColor: 'rgba(0, 0, 0, 0)'\n};\n\nconst triggerStatusMap = {\n '0': 'OK',\n '1': 'PROBLEM'\n};\n\nexport class TriggerPanelCtrl extends PanelCtrl {\n\n /** @ngInject */\n constructor($scope, $injector, $timeout, datasourceSrv, templateSrv, contextSrv, dashboardSrv) {\n super($scope, $injector);\n this.datasourceSrv = datasourceSrv;\n this.templateSrv = templateSrv;\n this.contextSrv = contextSrv;\n this.dashboardSrv = dashboardSrv;\n this.scope = $scope;\n this.$timeout = $timeout;\n\n this.editorTabIndex = 1;\n this.triggerStatusMap = triggerStatusMap;\n this.defaultTimeFormat = DEFAULT_TIME_FORMAT;\n this.pageIndex = 0;\n this.triggerList = [];\n this.currentTriggersPage = [];\n this.datasources = {};\n\n this.panel = migratePanelSchema(this.panel);\n _.defaultsDeep(this.panel, _.cloneDeep(PANEL_DEFAULTS));\n\n this.available_datasources = _.map(this.getZabbixDataSources(), 'name');\n if (this.panel.datasources.length === 0) {\n this.panel.datasources.push(this.available_datasources[0]);\n }\n if (_.isEmpty(this.panel.targets)) {\n this.panel.targets[this.panel.datasources[0]] = DEFAULT_TARGET;\n }\n\n this.initDatasources();\n this.events.on('init-edit-mode', this.onInitEditMode.bind(this));\n this.events.on('refresh', this.onRefresh.bind(this));\n }\n\n initDatasources() {\n let promises = _.map(this.panel.datasources, (ds) => {\n // Load datasource\n return this.datasourceSrv.get(ds)\n .then(datasource => {\n this.datasources[ds] = datasource;\n return datasource;\n });\n });\n return Promise.all(promises);\n }\n\n getZabbixDataSources() {\n return _.filter(this.datasourceSrv.getMetricSources(), datasource => {\n return datasource.meta.id === ZABBIX_DS_ID && datasource.value;\n });\n }\n\n onInitEditMode() {\n this.addEditorTab('Triggers', triggerPanelTriggersTab, 1);\n this.addEditorTab('Options', triggerPanelOptionsTab, 2);\n }\n\n setTimeQueryStart() {\n this.timing.queryStart = new Date().getTime();\n }\n\n setTimeQueryEnd() {\n this.timing.queryEnd = new Date().getTime();\n }\n\n onRefresh() {\n // ignore fetching data if another panel is in fullscreen\n if (this.otherPanelInFullscreenMode()) { return; }\n\n // clear loading/error state\n delete this.error;\n this.loading = true;\n this.setTimeQueryStart();\n this.pageIndex = 0;\n\n return this.getTriggers()\n .then(zabbixTriggers => {\n // Notify panel that request is finished\n this.loading = false;\n this.setTimeQueryEnd();\n\n this.render(zabbixTriggers);\n })\n .catch(err => {\n // if cancelled keep loading set to true\n if (err.cancelled) {\n console.log('Panel request cancelled', err);\n return;\n }\n\n this.loading = false;\n this.error = err.message || \"Request Error\";\n\n if (err.data) {\n if (err.data.message) {\n this.error = err.data.message;\n }\n if (err.data.error) {\n this.error = err.data.error;\n }\n }\n\n this.events.emit('data-error', err);\n console.log('Panel data error:', err);\n });\n }\n\n render(zabbixTriggers) {\n let triggers = _.cloneDeep(zabbixTriggers || this.triggerListUnfiltered);\n this.triggerListUnfiltered = _.cloneDeep(triggers);\n\n triggers = _.map(triggers, this.formatTrigger.bind(this));\n triggers = this.filterTriggersPost(triggers);\n triggers = this.sortTriggers(triggers);\n\n // Limit triggers number\n triggers = triggers.slice(0, this.panel.limit || PANEL_DEFAULTS.limit);\n\n this.triggerList = triggers;\n this.getCurrentTriggersPage();\n\n this.$timeout(() => {\n super.render(this.triggerList);\n });\n }\n\n getTriggers() {\n let promises = _.map(this.panel.datasources, (ds) => {\n return this.datasourceSrv.get(ds)\n .then(datasource => {\n var zabbix = datasource.zabbix;\n var showEvents = this.panel.showEvents.value;\n var triggerFilter = this.panel.targets[ds];\n\n // Replace template variables\n var groupFilter = datasource.replaceTemplateVars(triggerFilter.group.filter);\n var hostFilter = datasource.replaceTemplateVars(triggerFilter.host.filter);\n var appFilter = datasource.replaceTemplateVars(triggerFilter.application.filter);\n\n let triggersOptions = {\n showTriggers: showEvents\n };\n\n return zabbix.getTriggers(groupFilter, hostFilter, appFilter, triggersOptions);\n }).then((triggers) => {\n return this.getAcknowledges(triggers, ds);\n }).then((triggers) => {\n return this.setMaintenanceStatus(triggers);\n }).then((triggers) => {\n return this.filterTriggersPre(triggers, ds);\n }).then((triggers) => {\n return this.addTriggerDataSource(triggers, ds);\n });\n });\n\n return Promise.all(promises)\n .then(results => _.flatten(results));\n }\n\n getAcknowledges(triggerList, ds) {\n // Request acknowledges for trigger\n var eventids = _.map(triggerList, trigger => {\n return trigger.lastEvent.eventid;\n });\n\n return this.datasources[ds].zabbix.getAcknowledges(eventids)\n .then(events => {\n\n // Map events to triggers\n _.each(triggerList, trigger => {\n var event = _.find(events, event => {\n return event.eventid === trigger.lastEvent.eventid;\n });\n\n if (event) {\n trigger.acknowledges = _.map(event.acknowledges, ack => {\n let timestamp = moment.unix(ack.clock);\n if (this.panel.customLastChangeFormat) {\n ack.time = timestamp.format(this.panel.lastChangeFormat);\n } else {\n ack.time = timestamp.format(this.defaultTimeFormat);\n }\n ack.user = ack.alias + ' (' + ack.name + ' ' + ack.surname + ')';\n return ack;\n });\n }\n\n if (!trigger.lastEvent.eventid) {\n trigger.lastEvent = null;\n }\n });\n\n return triggerList;\n });\n }\n\n filterTriggersPre(triggerList, ds) {\n // Filter triggers by description\n let triggerFilter = this.panel.targets[ds].trigger.filter;\n triggerFilter = this.datasources[ds].replaceTemplateVars(triggerFilter);\n if (triggerFilter) {\n triggerList = filterTriggers(triggerList, triggerFilter);\n }\n\n // Filter by tags\n const target = this.panel.targets[ds];\n if (target.tags.filter) {\n let tagsFilter = this.datasources[ds].replaceTemplateVars(target.tags.filter);\n // replaceTemplateVars() builds regex-like string, so we should trim it.\n tagsFilter = tagsFilter.replace('/^', '').replace('$/', '');\n const tags = this.parseTags(tagsFilter);\n triggerList = _.filter(triggerList, trigger => {\n return _.every(tags, (tag) => {\n return _.find(trigger.tags, {tag: tag.tag, value: tag.value});\n });\n });\n }\n\n return triggerList;\n }\n\n filterTriggersPost(triggers) {\n let triggerList = _.cloneDeep(triggers);\n\n // Filter acknowledged triggers\n if (this.panel.showTriggers === 'unacknowledged') {\n triggerList = _.filter(triggerList, trigger => {\n return !trigger.acknowledges;\n });\n } else if (this.panel.showTriggers === 'acknowledged') {\n triggerList = _.filter(triggerList, 'acknowledges');\n } else {\n triggerList = triggerList;\n }\n\n // Filter by maintenance status\n if (!this.panel.hostsInMaintenance) {\n triggerList = _.filter(triggerList, (trigger) => trigger.maintenance === false);\n }\n\n // Filter triggers by severity\n triggerList = _.filter(triggerList, trigger => {\n return this.panel.triggerSeverity[trigger.priority].show;\n });\n\n return triggerList;\n }\n\n setMaintenanceStatus(triggers) {\n _.each(triggers, (trigger) => {\n let maintenance_status = _.some(trigger.hosts, (host) => host.maintenance_status === '1');\n trigger.maintenance = maintenance_status;\n });\n return triggers;\n }\n\n addTriggerDataSource(triggers, ds) {\n _.each(triggers, (trigger) => {\n trigger.datasource = ds;\n });\n return triggers;\n }\n\n sortTriggers(triggerList) {\n if (this.panel.sortTriggersBy.value === 'priority') {\n triggerList = _.orderBy(triggerList, ['priority', 'lastchangeUnix', 'triggerid'], ['desc', 'desc', 'desc']);\n } else {\n triggerList = _.orderBy(triggerList, ['lastchangeUnix', 'priority', 'triggerid'], ['desc', 'desc', 'desc']);\n }\n return triggerList;\n }\n\n formatTrigger(zabbixTrigger) {\n let trigger = _.cloneDeep(zabbixTrigger);\n let triggerObj = trigger;\n\n // Set host that the trigger belongs\n if (trigger.hosts && trigger.hosts.length) {\n triggerObj.host = trigger.hosts[0].name;\n triggerObj.hostTechName = trigger.hosts[0].host;\n }\n\n // Set tags if present\n if (trigger.tags && trigger.tags.length === 0) {\n trigger.tags = null;\n }\n\n // Handle multi-line description\n if (trigger.comments) {\n trigger.comments = trigger.comments.replace('\\n', '
    ');\n }\n\n // Format last change and age\n trigger.lastchangeUnix = Number(trigger.lastchange);\n triggerObj = this.setTriggerLastChange(triggerObj);\n triggerObj = this.setTriggerSeverity(triggerObj);\n return triggerObj;\n }\n\n updateTriggerFormat(trigger) {\n trigger = this.setTriggerLastChange(trigger);\n trigger = this.setTriggerSeverity(trigger);\n return trigger;\n }\n\n setTriggerSeverity(trigger) {\n if (trigger.value === '1') {\n // Problem state\n trigger.color = this.panel.triggerSeverity[trigger.priority].color;\n } else {\n // OK state\n trigger.color = this.panel.okEventColor;\n }\n trigger.severity = this.panel.triggerSeverity[trigger.priority].severity;\n\n // Mark acknowledged triggers with different color\n if (this.panel.markAckEvents && trigger.acknowledges && trigger.acknowledges.length) {\n trigger.color = this.panel.ackEventColor;\n }\n\n return trigger;\n }\n\n setTriggerLastChange(trigger) {\n if (!trigger.lastchangeUnix) {\n trigger.lastchange = \"\";\n trigger.age = \"\";\n return trigger;\n }\n\n let timestamp = moment.unix(trigger.lastchangeUnix);\n if (this.panel.customLastChangeFormat) {\n // User defined format\n trigger.lastchange = timestamp.format(this.panel.lastChangeFormat);\n } else {\n trigger.lastchange = timestamp.format(this.defaultTimeFormat);\n }\n trigger.age = timestamp.fromNow(true);\n return trigger;\n }\n\n parseTags(tagStr) {\n if (!tagStr) {\n return [];\n }\n\n let tags = _.map(tagStr.split(','), (tag) => tag.trim());\n tags = _.map(tags, (tag) => {\n const tagParts = tag.split(':');\n return {tag: tagParts[0].trim(), value: tagParts[1].trim()};\n });\n return tags;\n }\n\n tagsToString(tags) {\n return _.map(tags, (tag) => `${tag.tag}:${tag.value}`).join(', ');\n }\n\n addTagFilter(tag, ds) {\n let tagFilter = this.panel.targets[ds].tags.filter;\n let targetTags = this.parseTags(tagFilter);\n let newTag = {tag: tag.tag, value: tag.value};\n targetTags.push(newTag);\n targetTags = _.uniqWith(targetTags, _.isEqual);\n let newFilter = this.tagsToString(targetTags);\n this.panel.targets[ds].tags.filter = newFilter;\n this.refresh();\n }\n\n switchComment(trigger) {\n trigger.showComment = !trigger.showComment;\n }\n\n acknowledgeTrigger(trigger, message) {\n let eventid = trigger.lastEvent ? trigger.lastEvent.eventid : null;\n let grafana_user = this.contextSrv.user.name;\n let ack_message = grafana_user + ' (Grafana): ' + message;\n return this.datasourceSrv.get(trigger.datasource)\n .then(datasource => {\n if (eventid) {\n return datasource.zabbix.zabbixAPI.acknowledgeEvent(eventid, ack_message);\n } else {\n return Promise.reject({message: 'Trigger has no events. Nothing to acknowledge.'});\n }\n })\n .then(this.onRefresh.bind(this))\n .catch((err) => {\n this.error = err.message || \"Acknowledge Error\";\n this.events.emit('data-error', err);\n console.log('Panel data error:', err);\n });\n }\n\n getCurrentTriggersPage() {\n let pageSize = this.panel.pageSize || PANEL_DEFAULTS.pageSize;\n let startPos = this.pageIndex * pageSize;\n let endPos = Math.min(startPos + pageSize, this.triggerList.length);\n this.currentTriggersPage = this.triggerList.slice(startPos, endPos);\n return this.currentTriggersPage;\n }\n\n formatHostName(trigger) {\n if (this.panel.hostField && this.panel.hostTechNameField) {\n return `${trigger.host} (${trigger.hostTechName})`;\n } else if (this.panel.hostField || this.panel.hostTechNameField) {\n return this.panel.hostField ? trigger.host : trigger.hostTechName;\n } else {\n return \"\";\n }\n }\n\n getAlertIconClass(trigger) {\n const triggerValue = Number(trigger.value);\n let iconClass = '';\n if (triggerValue || trigger.color) {\n if (trigger.priority >= 3) {\n iconClass = 'icon-gf-critical';\n } else {\n iconClass = 'icon-gf-warning';\n }\n } else {\n iconClass = 'icon-gf-online';\n }\n\n if (this.panel.highlightNewEvents && this.isNewTrigger(trigger)) {\n iconClass += ' zabbix-trigger--blinked';\n }\n return iconClass;\n }\n\n getAlertStateClass(trigger) {\n let statusClass = '';\n\n if (trigger.value === '1') {\n statusClass = 'alert-state-critical';\n } else {\n statusClass = 'alert-state-ok';\n }\n\n if (this.panel.highlightNewEvents && this.isNewTrigger(trigger)) {\n statusClass += ' zabbix-trigger--blinked';\n }\n\n return statusClass;\n }\n\n isNewTrigger(trigger) {\n try {\n const highlightIntervalMs = utils.parseInterval(this.panel.highlightNewerThan || PANEL_DEFAULTS.highlightNewerThan);\n const durationSec = (Date.now() - trigger.lastchangeUnix * 1000);\n return durationSec < highlightIntervalMs;\n } catch (e) {\n return false;\n }\n }\n\n link(scope, elem, attrs, ctrl) {\n let panel = ctrl.panel;\n let pageCount = 0;\n let triggerList = ctrl.triggerList;\n\n scope.$watchGroup(['ctrl.currentTriggersPage', 'ctrl.triggerList'], renderPanel);\n elem.on('click', '.triggers-panel-page-link', switchPage);\n ctrl.events.on('render', (renderData) => {\n triggerList = renderData || triggerList;\n renderPanel();\n });\n\n function getContentHeight() {\n let panelHeight = ctrl.height;\n if (pageCount > 1) {\n panelHeight -= 36;\n }\n return panelHeight + 'px';\n }\n\n function switchPage(e) {\n let el = $(e.currentTarget);\n ctrl.pageIndex = (parseInt(el.text(), 10)-1);\n\n let pageSize = panel.pageSize || 10;\n let startPos = ctrl.pageIndex * pageSize;\n let endPos = Math.min(startPos + pageSize, triggerList.length);\n ctrl.currentTriggersPage = triggerList.slice(startPos, endPos);\n\n scope.$apply(() => {\n renderPanel();\n });\n }\n\n function appendPaginationControls(footerElem) {\n footerElem.empty();\n\n let pageSize = panel.pageSize || 5;\n pageCount = Math.ceil(triggerList.length / pageSize);\n if (pageCount === 1) {\n return;\n }\n\n let startPage = Math.max(ctrl.pageIndex - 3, 0);\n let endPage = Math.min(pageCount, startPage + 9);\n\n let paginationList = $('');\n\n for (let i = startPage; i < endPage; i++) {\n let activeClass = i === ctrl.pageIndex ? 'active' : '';\n let pageLinkElem = $('
  • ' + (i+1) + '
  • ');\n paginationList.append(pageLinkElem);\n }\n\n footerElem.append(paginationList);\n }\n\n function setFontSize() {\n const fontSize = parseInt(panel.fontSize.slice(0, panel.fontSize.length - 1));\n let triggerCardElem = elem.find('.card-item-wrapper');\n if (fontSize && fontSize !== 100) {\n triggerCardElem.find('.alert-list-icon').css({'font-size': fontSize + '%'});\n triggerCardElem.find('.alert-list-title').css({'font-size': fontSize + '%'});\n triggerCardElem.find('.alert-list-text').css({'font-size': fontSize * 0.8 + '%'});\n triggerCardElem.find('.zbx-tag').css({'font-size': fontSize * 0.6 + '%'});\n triggerCardElem.find('.zbx-tag').css({'line-height': fontSize / 100 * 16 + 'px'});\n } else {\n // remove css\n triggerCardElem.find('.alert-list-icon').css({'font-size': ''});\n triggerCardElem.find('.alert-list-title').css({'font-size': ''});\n triggerCardElem.find('.alert-list-text').css({'font-size': ''});\n triggerCardElem.find('.zbx-tag').css({'font-size': ''});\n triggerCardElem.find('.zbx-tag').css({'line-height': ''});\n }\n }\n\n function renderPanel() {\n let rootElem = elem.find('.triggers-panel-scroll');\n let footerElem = elem.find('.triggers-panel-footer');\n appendPaginationControls(footerElem);\n rootElem.css({'max-height': getContentHeight()});\n rootElem.css({'height': getContentHeight()});\n setFontSize();\n ctrl.renderingCompleted();\n }\n\n let unbindDestroy = scope.$on('$destroy', function() {\n elem.off('click', '.triggers-panel-page-link');\n unbindDestroy();\n });\n }\n}\n\nTriggerPanelCtrl.templateUrl = 'public/plugins/alexanderzobnin-zabbix-app/panel-triggers/partials/module.html';\n\nfunction filterTriggers(triggers, triggerFilter) {\n if (utils.isRegex(triggerFilter)) {\n return _.filter(triggers, function(trigger) {\n return utils.buildRegex(triggerFilter).test(trigger.description);\n });\n } else {\n return _.filter(triggers, function(trigger) {\n return trigger.description === triggerFilter;\n });\n }\n}\n"]} \ No newline at end of file diff --git a/src/panel-triggers/partials/module.html b/src/panel-triggers/partials/module.html index 6ec3ad344..29e517141 100644 --- a/src/panel-triggers/partials/module.html +++ b/src/panel-triggers/partials/module.html @@ -18,7 +18,8 @@
    - + {{tag.tag}}: {{tag.value}} diff --git a/src/panel-triggers/triggers_panel_ctrl.js b/src/panel-triggers/triggers_panel_ctrl.js index 6081e769a..998c649d7 100644 --- a/src/panel-triggers/triggers_panel_ctrl.js +++ b/src/panel-triggers/triggers_panel_ctrl.js @@ -408,6 +408,10 @@ export class TriggerPanelCtrl extends PanelCtrl { } parseTags(tagStr) { + if (!tagStr) { + return []; + } + let tags = _.map(tagStr.split(','), (tag) => tag.trim()); tags = _.map(tags, (tag) => { const tagParts = tag.split(':'); @@ -420,6 +424,17 @@ export class TriggerPanelCtrl extends PanelCtrl { return _.map(tags, (tag) => `${tag.tag}:${tag.value}`).join(', '); } + addTagFilter(tag, ds) { + let tagFilter = this.panel.targets[ds].tags.filter; + let targetTags = this.parseTags(tagFilter); + let newTag = {tag: tag.tag, value: tag.value}; + targetTags.push(newTag); + targetTags = _.uniqWith(targetTags, _.isEqual); + let newFilter = this.tagsToString(targetTags); + this.panel.targets[ds].tags.filter = newFilter; + this.refresh(); + } + switchComment(trigger) { trigger.showComment = !trigger.showComment; }