Skip to content

Commit 7e2a6c1

Browse files
sfeilmeiersebastianasenlukasrgr
authored
FEMS Backports (OpenEMS#2373)
- Add null-safe Round.HALF_UP to IntUtils - UI: Fix bug with notch color in PWA - UI: Fix initial routing - UI: Improve overview search filter Co-authored-by: Sebastian Asen <[email protected]> Co-authored-by: Lukas Rieger <[email protected]>
1 parent a6d051b commit 7e2a6c1

File tree

27 files changed

+284
-102
lines changed

27 files changed

+284
-102
lines changed

io.openems.common/src/io/openems/common/utils/IntUtils.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class IntUtils {
44

55
public enum Round {
6-
AWAY_FROM_ZERO, TOWARDS_ZERO
6+
AWAY_FROM_ZERO, TOWARDS_ZERO, HALF_UP
77
}
88

99
/**
@@ -22,6 +22,10 @@ public static int roundToPrecision(double value, Round round, int precision) {
2222
return (int) value;
2323
}
2424

25+
if (round.equals(Round.HALF_UP)) {
26+
return (int) Math.round(value / precision) * precision;
27+
}
28+
2529
if (value < 0 && round == Round.AWAY_FROM_ZERO || value > 0 && round == Round.TOWARDS_ZERO) {
2630
return (int) Math.floor(value / precision) * precision;
2731
}

ui/package-lock.json

+89-50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/src/app/edge/history/shared.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export type ChartOptions = {
136136
afterTitle?(item: ChartTooltipItem[], data: Data): string | string[],
137137
footer?(item: ChartTooltipItem[], data: ChartData): string | string[]
138138
}
139-
}
139+
},
140+
legendCallback?(chart: Chart): string
140141
}
141142

142143
export const DEFAULT_TIME_CHART_OPTIONS: ChartOptions = {

ui/src/app/edge/live/energymonitor/chart/section/consumption.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<svg:defs>
55
<svg:linearGradient [attr.id]="sectionId" [attr.x1]="energyFlow.gradient.x1" [attr.y1]="energyFlow.gradient.y1"
66
[attr.x2]="energyFlow.gradient.x2" [attr.y2]="energyFlow.gradient.y2">
7-
<svg:stop offset="0%" stop-color="var(--ion-background-color)" />
7+
<svg:stop offset="0%" stop-color="var(--ion-color-background)" />
88
<svg:stop offset="100%" stop-color="var(--ion-color-warning)" />
99
</svg:linearGradient>
1010
</svg:defs>
1111
<svg:polygon [attr.points]="energyFlow.points" attr.fill="{{ fillRef }}" />
1212
<svg:polygon [@Consumption]="stateName" [attr.points]="energyFlow.animationPoints"
13-
style="fill:var(--ion-background-color)" />
13+
style="fill:var(--ion-color-background)" />
1414
</svg:g>
1515
<svg:g *ngIf="isEnabled && squarePosition && square"
1616
attr.transform="translate({{squarePosition.x}},{{squarePosition.y}})">

ui/src/app/edge/live/energymonitor/chart/section/grid.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<svg:defs>
55
<svg:linearGradient [attr.id]="sectionId" [attr.x1]="energyFlow.gradient.x1" [attr.y1]="energyFlow.gradient.y1"
66
[attr.x2]="energyFlow.gradient.x2" [attr.y2]="energyFlow.gradient.y2">
7-
<svg:stop offset="0%" stop-color="var(--ion-background-color)" />
7+
<svg:stop offset="0%" stop-color="var(--ion-color-background)" />
88
<svg:stop offset="100%" stop-color="var(--ion-color-dark)" />
99
</svg:linearGradient>
1010
</svg:defs>
1111
<svg:polygon [attr.points]="energyFlow.points" attr.fill="{{ fillRef }}" />
1212
<ng-container *ngIf="buyAnimationTrigger">
1313
<svg:polygon [@GridBuy]="stateNameBuy" [attr.points]="energyFlow.animationPoints"
14-
style="fill:var(--ion-background-color)" />
14+
style="fill:var(--ion-color-background)" />
1515
</ng-container>
1616
<ng-container *ngIf="sellAnimationTrigger">
1717
<svg:polygon [@GridSell]="stateNameSell" [attr.points]="energyFlow.animationPoints"
18-
style="fill:var(--ion-background-color)" />
18+
style="fill:var(--ion-color-background)" />
1919
</ng-container>
2020
</svg:g>
2121
<svg:g *ngIf="isEnabled && squarePosition && square"

ui/src/app/edge/live/energymonitor/chart/section/production.component.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
<svg:defs>
55
<svg:linearGradient [attr.id]="sectionId" [attr.x1]="energyFlow.gradient.x1" [attr.y1]="energyFlow.gradient.y1"
66
[attr.x2]="energyFlow.gradient.x2" [attr.y2]="energyFlow.gradient.y2">
7-
<svg:stop offset="0%" stop-color="var(--ion-background-color)" />
7+
<svg:stop offset="0%" stop-color="var(--ion-color-background)" />
88
<svg:stop offset="100%" stop-color="var(--ion-color-production)" />
99
</svg:linearGradient>
1010
</svg:defs>
1111
<svg:polygon [attr.points]="energyFlow.points" attr.fill="{{ fillRef }}" />
1212
<svg:polygon [@Production]="stateName" [attr.points]="energyFlow.animationPoints"
13-
style="fill:var(--ion-background-color)" />
13+
style="fill:var(--ion-color-background)" />
1414
</svg:g>
1515
<svg:g *ngIf="isEnabled && squarePosition && square"
1616
attr.transform="translate({{squarePosition.x}},{{squarePosition.y}})">

ui/src/app/edge/live/energymonitor/chart/section/storage.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
<svg:defs>
55
<svg:linearGradient [attr.id]="sectionId" [attr.x1]="energyFlow.gradient.x1" [attr.y1]="energyFlow.gradient.y1"
66
[attr.x2]="energyFlow.gradient.x2" [attr.y2]="energyFlow.gradient.y2">
7-
<svg:stop offset="0%" stop-color="var(--ion-background-color)" />
7+
<svg:stop offset="0%" stop-color="var(--ion-color-background)" />
88
<svg:stop offset="100%" stop-color="var(--ion-color-success)" />
99
</svg:linearGradient>
1010
</svg:defs>
1111
<svg:polygon [attr.points]="energyFlow.points" attr.fill="{{ fillRef }}" />
1212
<ng-container *ngIf="chargeAnimationTrigger">
1313
<svg:polygon [@Charge]="stateNameCharge" [attr.points]="energyFlow.animationPoints"
14-
style="fill:var(--ion-background-color)" />
14+
style="fill:var(--ion-color-background)" />
1515
</ng-container>
1616
<ng-container *ngIf="dischargeAnimationTrigger">
1717
<svg:polygon [@Discharge]="stateNameDischarge" [attr.points]="energyFlow.animationPoints"
18-
style="fill:var(--ion-background-color)" />
18+
style="fill:var(--ion-color-background)" />
1919
</ng-container>
2020
</svg:g>
2121
<svg:g *ngIf="isEnabled && squarePosition && square"

ui/src/app/index/login.component.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ export class LoginComponent implements OnInit, AfterContentChecked, OnDestroy {
3232

3333
ngOnInit() {
3434

35-
if (this.websocket.status === 'online') {
36-
this.router.navigateByUrl('/overview');
37-
}
35+
// TODO add websocket status observable
36+
const interval = setInterval(() => {
37+
if (this.websocket.status === 'online') {
38+
this.router.navigateByUrl('/overview');
39+
clearInterval(interval);
40+
}
41+
}, 1000);
3842

3943
this.service.setCurrentComponent('', this.route);
4044
}

ui/src/app/index/overview/overview.component.html

+13-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ion-content>
33
<ion-grid>
44
<ion-row class="ion-justify-content-center">
5-
<ion-col size="12" size-md="6" size-lg="4">
5+
<ion-col size="12" size-md="8" size-lg="6">
66
<ng-container *ngIf="environment.backend === 'OpenEMS Backend'">
77
<ng-container *ngIf="noEdges; else showEdges">
88
<ion-card class="ion-justify-content-center">
@@ -40,11 +40,17 @@
4040
<ion-grid>
4141
<ion-row class="ion-justify-content-center">
4242
<ion-col>
43-
<ion-searchbar [(ngModel)]="filter" (ionChange)="searchOnChange($event)">
43+
<ion-searchbar [(ngModel)]="query" (ionChange)="searchOnChange($event)">
4444
</ion-searchbar>
4545
</ion-col>
4646
</ion-row>
4747

48+
<!-- Filter -->
49+
<ng-container *ngIf="(service.metadata | async)?.user as user">
50+
<oe-filter (setSearchParams)="searchOnChange($event)"
51+
*ngIf="user.globalRole === 'admin'"></oe-filter>
52+
</ng-container>
53+
4854
<ion-row class="ion-justify-content-center">
4955
<ion-col>
5056
<ion-list lines="full">
@@ -68,17 +74,17 @@ <h2 class="ion-text-wrap">{{ edge.comment }}</h2>
6874
<ng-container *ngIf="environment.backend === 'OpenEMS Backend'">
6975
<p>ID: {{ edge.id }}</p>
7076
<p class="ion-text-wrap">
71-
<ion-text translate>Index.type</ion-text> {{
77+
<ion-text translate>Index.TYPE</ion-text>: {{
7278
edge.producttype }}
7379
</p>
7480
</ng-container>
7581
<p class="ion-text-wrap">
76-
<ion-text translate>Index.loggedInAs</ion-text> {{
77-
edge.getRoleString() }}.
82+
<ion-text translate>Index.LOGGED_IN_AS</ion-text>: {{
83+
edge.getRoleString() }}
7884
</p>
7985
</ion-label>
80-
<ion-icon slot="end" name="play-outline" color="primary"></ion-icon>
81-
</ion-item>
86+
<oe-sum-state [sumState]="edge.sumState"
87+
[isEdgeOnline]="edge.isOnline"></oe-sum-state> </ion-item>
8288
</ng-container>
8389
<ion-infinite-scroll (ionInfinite)="doInfinite($event)"
8490
[disabled]="limitReached">

0 commit comments

Comments
 (0)