Skip to content

Commit

Permalink
show trigger tags, #487
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Dec 14, 2017
1 parent e6794b1 commit 3f140c8
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 6 deletions.
5 changes: 5 additions & 0 deletions dist/css/grafana-zabbix.dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/css/grafana-zabbix.dark.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions dist/css/grafana-zabbix.light.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/css/grafana-zabbix.light.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion dist/datasource-zabbix/zabbixAPI.service.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/datasource-zabbix/zabbixAPI.service.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions dist/panel-triggers/partials/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<i ng-if="trigger.maintenance" class="fa fa-wrench zbx-maintenance-icon"></i>
{{ ctrl.formatHostName(trigger) }}
</span>

<span class="zbx-trigger-tags" ng-if="ctrl.panel.showTags && trigger.tags">
<span ng-repeat="tag in trigger.tags" tag-color-from-name="tag.tag+tag.value" class="label label-tag zbx-tag">
{{tag.tag}}: {{tag.value}}
</span>
</span>
</p>

<p class="alert-list-text">
Expand Down
6 changes: 6 additions & 0 deletions dist/panel-triggers/partials/options_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ <h5 class="section-heading">Show fields</h5>
checked="ctrl.panel.hostTechNameField"
on-change="ctrl.render()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label-class="width-9"
label="Tags"
checked="ctrl.panel.showTags"
on-change="ctrl.render()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label-class="width-9"
label="Status"
Expand Down
2 changes: 2 additions & 0 deletions dist/panel-triggers/specs/migrations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('Triggers Panel schema migration', () => {
},
hostField: true,
hostTechNameField: false,
showTags: true,
statusField: false,
severityField: false,
descriptionField: true,
Expand Down Expand Up @@ -86,6 +87,7 @@ describe('Triggers Panel schema migration', () => {
},
hostField: true,
hostTechNameField: false,
showTags: true,
statusField: true,
severityField: true,
descriptionField: true,
Expand Down
10 changes: 10 additions & 0 deletions dist/panel-triggers/triggers_panel_ctrl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/panel-triggers/triggers_panel_ctrl.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/datasource-zabbix/zabbixAPI.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
selectGroups: ['name'],
selectHosts: ['name', 'host', 'maintenance_status'],
selectItems: ['name', 'key_', 'lastvalue'],
selectLastEvent: 'extend'
selectLastEvent: 'extend',
selectTags: 'extend'
};

if (showTriggers) {
Expand Down
6 changes: 6 additions & 0 deletions src/panel-triggers/partials/module.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<i ng-if="trigger.maintenance" class="fa fa-wrench zbx-maintenance-icon"></i>
{{ ctrl.formatHostName(trigger) }}
</span>

<span class="zbx-trigger-tags" ng-if="ctrl.panel.showTags && trigger.tags">
<span ng-repeat="tag in trigger.tags" tag-color-from-name="tag.tag+tag.value" class="label label-tag zbx-tag">
{{tag.tag}}: {{tag.value}}
</span>
</span>
</p>

<p class="alert-list-text">
Expand Down
6 changes: 6 additions & 0 deletions src/panel-triggers/partials/options_tab.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ <h5 class="section-heading">Show fields</h5>
checked="ctrl.panel.hostTechNameField"
on-change="ctrl.render()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label-class="width-9"
label="Tags"
checked="ctrl.panel.showTags"
on-change="ctrl.render()">
</gf-form-switch>
<gf-form-switch class="gf-form"
label-class="width-9"
label="Status"
Expand Down
2 changes: 2 additions & 0 deletions src/panel-triggers/specs/migrations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('Triggers Panel schema migration', () => {
},
hostField: true,
hostTechNameField: false,
showTags: true,
statusField: false,
severityField: false,
descriptionField: true,
Expand Down Expand Up @@ -86,6 +87,7 @@ describe('Triggers Panel schema migration', () => {
},
hostField: true,
hostTechNameField: false,
showTags: true,
statusField: true,
severityField: true,
descriptionField: true,
Expand Down
10 changes: 10 additions & 0 deletions src/panel-triggers/triggers_panel_ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const PANEL_DEFAULTS = {
// Fields
hostField: true,
hostTechNameField: false,
showTags: true,
statusField: true,
severityField: true,
descriptionField: true,
Expand Down Expand Up @@ -332,6 +333,11 @@ export class TriggerPanelCtrl extends PanelCtrl {
triggerObj.hostTechName = trigger.hosts[0].host;
}

// Set tags if present
if (trigger.tags && trigger.tags.length === 0) {
trigger.tags = null;
}

// Handle multi-line description
if (trigger.comments) {
trigger.comments = trigger.comments.replace('\n', '<br>');
Expand Down Expand Up @@ -537,11 +543,15 @@ export class TriggerPanelCtrl extends PanelCtrl {
triggerCardElem.find('.alert-list-icon').css({'font-size': fontSize + '%'});
triggerCardElem.find('.alert-list-title').css({'font-size': fontSize + '%'});
triggerCardElem.find('.alert-list-text').css({'font-size': fontSize * 0.8 + '%'});
triggerCardElem.find('.zbx-tag').css({'font-size': fontSize * 0.6 + '%'});
triggerCardElem.find('.zbx-tag').css({'line-height': fontSize / 100 * 16 + 'px'});
} else {
// remove css
triggerCardElem.find('.alert-list-icon').css({'font-size': ''});
triggerCardElem.find('.alert-list-title').css({'font-size': ''});
triggerCardElem.find('.alert-list-text').css({'font-size': ''});
triggerCardElem.find('.zbx-tag').css({'font-size': ''});
triggerCardElem.find('.zbx-tag').css({'line-height': ''});
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/sass/_panel-triggers.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
color: $gray-3;
}

.zbx-trigger-tags {
margin-left: 0.6rem;

.zbx-tag {
color: $zbx-tag-color;
// opacity: 0.9;
padding: 0px 6px;
}
}

.alert-list-footer {
justify-content: flex-start;
}
Expand Down
1 change: 1 addition & 0 deletions src/sass/_variables.dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ $text-color: $gray-4;
$tight-form-func-bg: #333;
$grafanaListAccent: lighten($dark-2, 2%);

$zbx-tag-color: $gray-5;
2 changes: 2 additions & 0 deletions src/sass/_variables.light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ $body-color: $gray-1;
$text-color: $gray-1;
$tight-form-func-bg: $gray-5;
$grafanaListAccent: $gray-5;

$zbx-tag-color: $gray-6;

0 comments on commit 3f140c8

Please sign in to comment.