Skip to content

Commit

Permalink
Merge pull request Vonage#82 from PeteBa/fix-depreciated-imports
Browse files Browse the repository at this point in the history
Align with Grafana 4.6.0 plug-in changes
  • Loading branch information
YehonatanVonage authored Nov 6, 2017
2 parents 4ecb061 + cb4b245 commit 08f4765
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 46 deletions.
10 changes: 5 additions & 5 deletions dist/editor.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
<div>
<strong>Note:</strong> Every metric has to have a unique <strong>Alias</strong> to be used<br/><br/>
</div>

Expand Down Expand Up @@ -70,16 +70,16 @@ <h5 class="section-heading">Threshold Colors</h5>
<div class="gf-form">
<label class="gf-form-label width-8">Colors</label>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.crit" bs-tooltip="'Critical'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.crit" bs-tooltip="'Critical'" onChange="ctrl.onColorChange('crit')"></color-picker>
</span>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.warn" bs-tooltip="'Warning'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.warn" bs-tooltip="'Warning'" onChange="ctrl.onColorChange('warn')"></color-picker>
</span>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.ok" bs-tooltip="'OK'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.ok" bs-tooltip="'OK'" onChange="ctrl.onColorChange('ok')"></color-picker>
</span>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.disable" bs-tooltip="'Disabled'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.disable" bs-tooltip="'Disabled'" onChange="ctrl.onColorChange('disable')"></color-picker>
</span>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion dist/module.js.map

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

65 changes: 37 additions & 28 deletions dist/status_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/status_ctrl.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/editor.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div>
<div>
<strong>Note:</strong> Every metric has to have a unique <strong>Alias</strong> to be used<br/><br/>
</div>

Expand Down Expand Up @@ -70,16 +70,16 @@ <h5 class="section-heading">Threshold Colors</h5>
<div class="gf-form">
<label class="gf-form-label width-8">Colors</label>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.crit" bs-tooltip="'Critical'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.crit" bs-tooltip="'Critical'" onChange="ctrl.onColorChange('crit')"></color-picker>
</span>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.warn" bs-tooltip="'Warning'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.warn" bs-tooltip="'Warning'" onChange="ctrl.onColorChange('warn')"></color-picker>
</span>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.ok" bs-tooltip="'OK'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.ok" bs-tooltip="'OK'" onChange="ctrl.onColorChange('ok')"></color-picker>
</span>
<span class="gf-form-label">
<spectrum-picker ng-model="ctrl.panel.colors.disable" bs-tooltip="'Disabled'" ng-change="ctrl.onRender()"></spectrum-picker>
<color-picker color="ctrl.panel.colors.disable" bs-tooltip="'Disabled'" onChange="ctrl.onColorChange('disable')"></color-picker>
</span>
</div>
</div>
Expand Down
18 changes: 12 additions & 6 deletions src/status_ctrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {MetricsPanelCtrl} from "app/plugins/sdk";
import "app/plugins/panel/graph/legend";
import "app/plugins/panel/graph/series_overrides_ctrl";
import {MetricsPanelCtrl} from "app/plugins/sdk";
import _ from "lodash";
import TimeSeries from "app/core/time_series2";
import coreModule from "app/core/core_module";
Expand Down Expand Up @@ -58,6 +56,8 @@ export class StatusPluginCtrl extends MetricsPanelCtrl {
this.events.on('data-snapshot-load', this.onDataReceived.bind(this));
this.events.on('init-edit-mode', this.onInitEditMode.bind(this));

this.onColorChange = this.onColorChange.bind(this);

this.addFilters()
}

Expand Down Expand Up @@ -136,12 +136,12 @@ export class StatusPluginCtrl extends MetricsPanelCtrl {
}

onInitEditMode() {
this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);
this.addEditorTab('Options', 'public/plugins/vonage-status-panel/editor.html', 2);
// Load in the supported units-of-measure formats so they can be displayed in the editor
this.unitFormats = kbn.getUnitFormats();
}

setUnitFormat(measurement, subItem) {
setUnitFormat(measurement, subItem) {
measurement.units = subItem.value;
this.render();
}
Expand Down Expand Up @@ -176,6 +176,13 @@ export class StatusPluginCtrl extends MetricsPanelCtrl {
this.onRender();
}

onColorChange(item) {
return (color) => {
this.panel.colors[item] = color;
this.render();
};
}

onRender() {
this.setElementHeight();
this.setTextMaxWidth();
Expand Down Expand Up @@ -402,7 +409,6 @@ export class StatusPluginCtrl extends MetricsPanelCtrl {
}

updatePanelState() {

if(this.duplicates) {
this.panelState = 'error-state';
} else if (this.disabled.length > 0) {
Expand Down

0 comments on commit 08f4765

Please sign in to comment.