Skip to content

Commit

Permalink
fix refresh of gauge without init value
Browse files Browse the repository at this point in the history
  • Loading branch information
unocelli committed Nov 15, 2023
1 parent b470c92 commit 69f8ce4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
</div>
</div>
</app-root>
<script src="runtime.8ef63094e52a66ba.js" type="module"></script><script src="polyfills.2696a6f9dc75535e.js" type="module"></script><script src="scripts.1c3385254ff4c93c.js" defer></script><script src="main.3226cff231378eb5.js" type="module"></script>
<script src="runtime.8ef63094e52a66ba.js" type="module"></script><script src="polyfills.2696a6f9dc75535e.js" type="module"></script><script src="scripts.1c3385254ff4c93c.js" defer></script><script src="main.4380c778e1ad8e5e.js" type="module"></script>

</body></html>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuxa",
"version": "1.1.15-1355",
"version": "1.1.15-1356",
"keywords": [],
"author": "frangoteam <[email protected]>",
"description": "Web-based Process Visualization (SCADA/HMI/Dashboard) software",
Expand Down
23 changes: 19 additions & 4 deletions client/src/app/gui-helpers/ngx-gauge/ngx-gauge.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Component, OnInit, AfterViewInit, OnChanges, ViewChild, HostListener, ElementRef, Input, SimpleChanges } from '@angular/core';
import { Component, OnInit, AfterViewInit, OnChanges, ViewChild, HostListener, ElementRef, Input, SimpleChanges, OnDestroy } from '@angular/core';

import { GaugeOptions, GaugeType } from './gaugeOptions';
import { Utils } from '../../_helpers/utils';
import { Subject, interval, take, takeUntil } from 'rxjs';

declare const Gauge: any;
declare const Donut: any;
Expand All @@ -11,7 +12,7 @@ declare const Donut: any;
templateUrl: './ngx-gauge.component.html',
styleUrls: ['./ngx-gauge.component.css']
})
export class NgxGaugeComponent implements OnInit, AfterViewInit, OnChanges {
export class NgxGaugeComponent implements OnInit, AfterViewInit, OnDestroy, OnChanges {

@Input() public id: string;
@Input() public options: GaugeOptions;
Expand All @@ -20,6 +21,8 @@ export class NgxGaugeComponent implements OnInit, AfterViewInit, OnChanges {
@ViewChild('gauge', {static: false}) public canvas: ElementRef;
@ViewChild('gaugetext', {static: false}) public gaugetext: ElementRef;

private destroy$ = new Subject<void>();

gauge: any;
type = GaugeType.Gauge;
defOptions = new GaugeOptions();
Expand All @@ -32,10 +35,22 @@ export class NgxGaugeComponent implements OnInit, AfterViewInit, OnChanges {
}

ngAfterViewInit() {
setTimeout(() => {
interval(100).pipe(
take(10),
takeUntil(this.destroy$)
).subscribe(() => {
this.onResize(null);
this.setOptions(this.options);
}, 100);
});
}

ngOnDestroy() {
try {
this.destroy$.next();
this.destroy$.unsubscribe();
} catch (e) {
console.error(e);
}
}

ngOnChanges(changes: SimpleChanges) {
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuxa-server",
"version": "1.1.15-1355",
"version": "1.1.15-1356",
"description": "Web-based Process Visualization (SCADA/HMI/Dashboard) software",
"main": "main.js",
"scripts": {
Expand Down

0 comments on commit 69f8ce4

Please sign in to comment.