Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

app/
oragin_src/
node_modules/

archive.zip
82 changes: 55 additions & 27 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,49 @@ module.exports = function(grunt) {
expand: true,
cwd: 'src',
src: ['**/*.ts', '**/*.d.ts'],
dest: 'dist'
dest: 'dist',
},
dist_html: {
expand: true,
flatten: true,
cwd: 'src/partials',
src: ['*.html'],
dest: 'dist/partials/'
dest: 'dist/partials/',
},
dist_css: {
expand: true,
flatten: true,
cwd: 'src/css',
src: ['*.css'],
dest: 'dist/css/'
dest: 'dist/css/',
},
dist_img: {
expand: true,
flatten: true,
cwd: 'src/img',
src: ['*.*'],
dest: 'dist/img/'
dest: 'dist/img/',
},
dist_statics: {
expand: true,
flatten: true,
src: ['src/plugin.json', 'LICENSE', 'README.md'],
dest: 'dist/'
}
src: ['src/*.json', 'LICENSE', 'README.md'],
dest: 'dist/',
},
app_core_utils: {
expand: true,
flatten: true,
cwd: 'reference',
src: ['fontsize.ts', 'operationURL.ts'],
dest: 'node_modules/grafana-sdk-mocks/app/core/utils/',
},
app_headers: {
expand: true,
flatten: true,
cwd: 'reference',
src: ['common.d.ts'],
dest: 'node_modules/grafana-sdk-mocks/app/headers/',
},
},

typescript: {
Expand All @@ -60,47 +74,61 @@ module.exports = function(grunt) {
experimentalDecorators: true,
sourceMap: true,
noImplicitAny: false,
}
}
},
},
},

'string-replace': {
dist: {
files: [{
cwd: 'src',
expand: true,
src: ["**/plugin.json"],
dest: 'dist'
}],
files: [
{
cwd: 'src',
expand: true,
src: ['**/plugin.json'],
dest: 'dist',
},
],
options: {
replacements: [{
pattern: '%VERSION%',
replacement: pkgJson.version
},{
pattern: '%TODAY%',
replacement: '<%= grunt.template.today("yyyy-mm-dd") %>'
}]
}
}
replacements: [
{
pattern: '%VERSION%',
replacement: pkgJson.version,
},
{
pattern: '%TODAY%',
replacement: '<%= grunt.template.today("yyyy-mm-dd") %>',
},
],
},
},
},

watch: {
files: ['src/**/*.ts', 'src/**/*.html', 'src/**/*.css', 'src/img/*.*', 'src/plugin.json', 'README.md'],
files: [
'src/**/*.ts',
'src/**/*.html',
'src/**/*.css',
'src/img/*.*',
'src/plugin.json',
'README.md',
],
tasks: ['default'],
options: {
debounceDelay: 250,
},
}
},
});

grunt.registerTask('default', [
'clean',
'copy:dist_js',
'copy:app_core_utils',
'copy:app_headers',
'typescript:build',
'copy:dist_html',
'copy:dist_css',
'copy:dist_img',
'copy:dist_statics',
'string-replace'
'string-replace',
]);
};
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ To complie, run:

```
npm install -g yarn
npm install -g grunt-cli
yarn install --pure-lockfile
grunt
```
Expand All @@ -31,6 +32,16 @@ yarn pretty

#### Changelog

##### rebuild v0.0.7 with Advantech v1.1.1 source code

* Add replaceCodes function that can use system variable $code with panel values and colors mapping.
* The $code format like: groupname|$No.|status, for example: FX|$1|started.
* The function will check without-number legendInfo with groupname.

##### v0.0.8 (not released yet)

* TODO... annotations

##### v0.0.7

* Switch to typescript
Expand Down
10 changes: 10 additions & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ yarn pretty

#### Changelog

##### rebuild v0.0.7 with Advantech v1.1.1 source code

* Add replaceCodes function that can use system variable $code with panel values and colors mapping.
* The $code format like: groupname|$No.|status, for example: FX|$1|started.
* The function will check without-number legendInfo with groupname.

##### v0.0.8 (not released yet)

* TODO... annotations

##### v0.0.7

* Switch to typescript
Expand Down
1 change: 1 addition & 0 deletions dist/canvas-metric.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export declare class CanvasPanelCtrl extends MetricsPanelCtrl {
roundDate(timeStamp: any, roundee: any): any;
formatDate(d: any, fmt: any): any;
leftPad(n: any, pad: any): any;
initDefaultI18n(): void;
}
38 changes: 25 additions & 13 deletions dist/canvas-metric.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/canvas-metric.js.map

Large diffs are not rendered by default.

35 changes: 20 additions & 15 deletions dist/canvas-metric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import moment from 'moment';
import $ from 'jquery';

import appEvents from 'app/core/app_events';
import {initAttrI18n} from './i18n';

// Expects a template with:
// <div class="canvas-spot"></div>
Expand All @@ -21,7 +22,6 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {

constructor($scope, $injector) {
super($scope, $injector);

this.data = null;
this.mouse = {
position: null,
Expand Down Expand Up @@ -150,6 +150,7 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
}

link(scope, elem, attrs, ctrl) {
ctrl.initDefaultI18n();
this.wrap = elem.find('.canvas-spot')[0];
this.canvas = document.createElement('canvas');
this.wrap.appendChild(this.canvas);
Expand Down Expand Up @@ -298,7 +299,6 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
};
//console.log( "Calculate mouseInfo", event, this.mouse.position);
}

this.onGraphHover(
event,
isThis || !this.dashboard.sharedCrosshairModeOnly(),
Expand All @@ -318,17 +318,8 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
},
scope
);

// scope.$on('$destroy', () => {
// this.$tooltip.destroy();
// elem.off();
// elem.remove();
// });
}

// Utility Functions for time axis
//---------------------------------

time_format(range: number, secPerTick: number): string {
let oneDay = 86400000;
let oneYear = 31536000000;
Expand Down Expand Up @@ -431,7 +422,7 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
'Dec',
];
let dayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
if (typeof d.strftime == 'function') {
if (typeof d.strftime === 'function') {
return d.strftime(fmt);
}

Expand Down Expand Up @@ -465,7 +456,7 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {

if (hours > 12) {
hours12 = hours - 12;
} else if (hours == 0) {
} else if (hours === 0) {
hours12 = 12;
} else {
hours12 = hours;
Expand Down Expand Up @@ -530,7 +521,7 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
r.push(c);
escape = false;
} else {
if (c == '%') {
if (c === '%') {
escape = true;
} else {
r.push(c);
Expand All @@ -544,6 +535,20 @@ export class CanvasPanelCtrl extends MetricsPanelCtrl {
leftPad(n, pad) {
n = '' + n;
pad = '' + (pad == null ? '0' : pad);
return n.length == 1 ? pad + n : n;
return n.length === 1 ? pad + n : n;
}

initDefaultI18n() {
const lang = this.dashboard.panelLanguage;
if (lang) {
for (const valueMap of this.panel.valueMaps) {
initAttrI18n(valueMap, 'text', lang);
}
for (const rangeMap of this.panel.rangeMaps) {
initAttrI18n(rangeMap, 'text', lang);
}
initAttrI18n(this.panel, 'FontSize', lang);
initAttrI18n(this.panel, 'FontSizeValue', lang);
}
}
}
3 changes: 3 additions & 0 deletions dist/css/discrete.dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.discrete-Theme {
color: #d8d9da;
}
Loading