|
1 |
| -import { Component, OnInit, ViewChild } from '@angular/core'; |
2 |
| -import { ActivatedRoute } from '@angular/router'; |
3 |
| -import { TranslateService } from '@ngx-translate/core'; |
4 |
| -import { HeaderComponent } from 'src/app/shared/header/header.component'; |
5 |
| -import { JsonrpcResponseError } from 'src/app/shared/jsonrpc/base'; |
6 |
| -import { Edge, EdgeConfig, Service, Widgets } from 'src/app/shared/shared'; |
7 |
| -import { environment } from 'src/environments'; |
8 |
| - |
9 |
| -@Component({ |
10 |
| - selector: 'history', |
11 |
| - templateUrl: './history.component.html', |
12 |
| -}) |
13 |
| -export class HistoryComponent implements OnInit { |
14 |
| - |
15 |
| - @ViewChild(HeaderComponent, { static: false }) public HeaderComponent: HeaderComponent; |
16 |
| - |
17 |
| - // is a Timedata service available, i.e. can historic data be queried. |
18 |
| - public isTimedataAvailable: boolean = true; |
19 |
| - protected errorResponse: JsonrpcResponseError | null = null; |
20 |
| - |
21 |
| - // sets the height for a chart. This is recalculated on every window resize. |
22 |
| - public socChartHeight: string = "250px"; |
23 |
| - public energyChartHeight: string = "250px"; |
24 |
| - |
25 |
| - // holds the Widgets |
26 |
| - public widgets: Widgets = null; |
27 |
| - |
28 |
| - // holds the current Edge |
29 |
| - public edge: Edge = null; |
30 |
| - |
31 |
| - // holds Channelthreshold Components to display effective active time in % |
32 |
| - // public channelthresholdComponents: string[] = []; |
33 |
| - |
34 |
| - public config: EdgeConfig = null; |
35 |
| - |
36 |
| - constructor( |
37 |
| - public service: Service, |
38 |
| - public translate: TranslateService, |
39 |
| - private route: ActivatedRoute, |
40 |
| - ) { } |
41 |
| - |
42 |
| - ngOnInit() { |
43 |
| - this.service.setCurrentComponent('', this.route); |
44 |
| - this.service.currentEdge.subscribe((edge) => { |
45 |
| - this.edge = edge; |
46 |
| - }); |
47 |
| - this.service.getConfig().then(config => { |
48 |
| - // gather ControllerIds of Channelthreshold Components |
49 |
| - // for (let controllerId of |
50 |
| - // config.getComponentIdsImplementingNature("io.openems.impl.controller.channelthreshold.ChannelThresholdController") |
51 |
| - // .concat(config.getComponentIdsByFactory("Controller.ChannelThreshold"))) { |
52 |
| - // this.channelthresholdComponents.push(controllerId) |
53 |
| - // } |
54 |
| - this.config = config; |
55 |
| - config.hasStorage(); |
56 |
| - this.widgets = config.widgets; |
57 |
| - // Are we connected to OpenEMS Edge and is a timedata service available? |
58 |
| - if (environment.backend == 'OpenEMS Edge' |
59 |
| - && config.getComponentsImplementingNature('io.openems.edge.timedata.api.Timedata').filter(c => c.isEnabled).length == 0) { |
60 |
| - this.isTimedataAvailable = false; |
61 |
| - } |
62 |
| - }); |
63 |
| - } |
64 |
| - |
65 |
| - protected setErrorResponse(errorResponse: JsonrpcResponseError | null) { |
66 |
| - this.errorResponse = errorResponse; |
67 |
| - } |
68 |
| - |
69 |
| - // checks arrows when ChartPage is closed |
70 |
| - // double viewchild is used to prevent undefined state of PickDateComponent |
71 |
| - ionViewDidEnter() { |
72 |
| - this.HeaderComponent.PickDateComponent.checkArrowAutomaticForwarding(); |
73 |
| - } |
74 |
| - |
75 |
| - updateOnWindowResize() { |
76 |
| - let ref = /* fix proportions */ Math.min(window.innerHeight - 150, |
77 |
| - /* handle grid breakpoints */(window.innerWidth < 768 ? window.innerWidth - 150 : window.innerWidth - 400)); |
78 |
| - this.socChartHeight = |
79 |
| - /* minimum size */ Math.max(150, |
80 |
| - /* maximium size */ Math.min(200, ref), |
81 |
| - ) + "px"; |
82 |
| - this.energyChartHeight = |
83 |
| - /* minimum size */ Math.max(300, |
84 |
| - /* maximium size */ Math.min(600, ref), |
85 |
| - ) + "px"; |
86 |
| - } |
87 |
| -} |
| 1 | +import { Component, OnInit, ViewChild } from '@angular/core'; |
| 2 | +import { ActivatedRoute } from '@angular/router'; |
| 3 | +import { TranslateService } from '@ngx-translate/core'; |
| 4 | +import { HeaderComponent } from 'src/app/shared/header/header.component'; |
| 5 | +import { JsonrpcResponseError } from 'src/app/shared/jsonrpc/base'; |
| 6 | +import { Edge, EdgeConfig, Service, Widgets } from 'src/app/shared/shared'; |
| 7 | +import { environment } from 'src/environments'; |
| 8 | + |
| 9 | +@Component({ |
| 10 | + selector: 'history', |
| 11 | + templateUrl: './history.component.html', |
| 12 | +}) |
| 13 | +export class HistoryComponent implements OnInit { |
| 14 | + |
| 15 | + @ViewChild(HeaderComponent, { static: false }) public HeaderComponent: HeaderComponent; |
| 16 | + |
| 17 | + // is a Timedata service available, i.e. can historic data be queried. |
| 18 | + public isTimedataAvailable: boolean = true; |
| 19 | + protected errorResponse: JsonrpcResponseError | null = null; |
| 20 | + |
| 21 | + // sets the height for a chart. This is recalculated on every window resize. |
| 22 | + public socChartHeight: string = "250px"; |
| 23 | + public energyChartHeight: string = "250px"; |
| 24 | + |
| 25 | + // holds the Widgets |
| 26 | + public widgets: Widgets = null; |
| 27 | + |
| 28 | + // holds the current Edge |
| 29 | + public edge: Edge = null; |
| 30 | + |
| 31 | + // holds Channelthreshold Components to display effective active time in % |
| 32 | + // public channelthresholdComponents: string[] = []; |
| 33 | + |
| 34 | + public config: EdgeConfig = null; |
| 35 | + |
| 36 | + constructor( |
| 37 | + public service: Service, |
| 38 | + public translate: TranslateService, |
| 39 | + private route: ActivatedRoute, |
| 40 | + ) { } |
| 41 | + |
| 42 | + ngOnInit() { |
| 43 | + this.service.setCurrentComponent('', this.route); |
| 44 | + this.service.currentEdge.subscribe((edge) => { |
| 45 | + this.edge = edge; |
| 46 | + }); |
| 47 | + this.service.getConfig().then(config => { |
| 48 | + // gather ControllerIds of Channelthreshold Components |
| 49 | + // for (let controllerId of |
| 50 | + // config.getComponentIdsImplementingNature("io.openems.impl.controller.channelthreshold.ChannelThresholdController") |
| 51 | + // .concat(config.getComponentIdsByFactory("Controller.ChannelThreshold"))) { |
| 52 | + // this.channelthresholdComponents.push(controllerId) |
| 53 | + // } |
| 54 | + this.config = config; |
| 55 | + config.hasStorage(); |
| 56 | + this.widgets = config.widgets; |
| 57 | + // Are we connected to OpenEMS Edge and is a timedata service available? |
| 58 | + if (environment.backend == 'OpenEMS Edge' |
| 59 | + && config.getComponentsImplementingNature('io.openems.edge.timedata.api.Timedata').filter(c => c.isEnabled).length == 0) { |
| 60 | + this.isTimedataAvailable = false; |
| 61 | + } |
| 62 | + }); |
| 63 | + } |
| 64 | + |
| 65 | + protected setErrorResponse(errorResponse: JsonrpcResponseError | null) { |
| 66 | + this.errorResponse = errorResponse; |
| 67 | + } |
| 68 | + |
| 69 | + // checks arrows when ChartPage is closed |
| 70 | + // double viewchild is used to prevent undefined state of PickDateComponent |
| 71 | + ionViewDidEnter() { |
| 72 | + this.HeaderComponent.PickDateComponent.checkArrowAutomaticForwarding(); |
| 73 | + } |
| 74 | + |
| 75 | + updateOnWindowResize() { |
| 76 | + let ref = /* fix proportions */ Math.min(window.innerHeight - 150, |
| 77 | + /* handle grid breakpoints */(window.innerWidth < 768 ? window.innerWidth - 150 : window.innerWidth - 400)); |
| 78 | + this.socChartHeight = |
| 79 | + /* minimum size */ Math.max(150, |
| 80 | + /* maximium size */ Math.min(200, ref), |
| 81 | + ) + "px"; |
| 82 | + this.energyChartHeight = |
| 83 | + /* minimum size */ Math.max(300, |
| 84 | + /* maximium size */ Math.min(600, ref), |
| 85 | + ) + "px"; |
| 86 | + } |
| 87 | +} |
0 commit comments