Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Refactor Info Text Blocks into a Reusable Template #2961

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
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
4 changes: 2 additions & 2 deletions ui/src/app/edge/history/shared.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @ts-strict-ignore
import * as Chart from "chart.js";
/* eslint-disable import/no-duplicates */

// cf. https://github.com/import-js/eslint-plugin-import/issues/1479
import { differenceInDays, differenceInMinutes, startOfDay } from "date-fns";
import { de } from "date-fns/locale";
/* eslint-enable import/no-duplicates */

import { QueryHistoricTimeseriesDataResponse } from "src/app/shared/jsonrpc/response/queryHistoricTimeseriesDataResponse";
import { ChannelAddress, Service } from "src/app/shared/shared";
import { DateUtils } from "src/app/shared/utils/date/dateutils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<ng-container *ngIf="edge">

<!-- Reusable Info Text Template -->
<ng-template #infoStorageText>
<ion-card-content class="underline">
<ion-row class="ion-justify-content-center">
<ion-item class="ion-text-center" lines="none">
<ion-icon color="primary" size="large" slot="start" name="alert-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<ion-row class="ion-text-center" style="white-space: pre !important; width: 100%">
<small translate>Edge.Index.Widgets.InfoStorageForCharge</small>
</ion-row>
<ion-row size="6" class="ion-text-center" style="white-space: pre !important; width: 100%">
<small translate>Edge.Index.Widgets.InfoStorageForDischarge</small>
</ion-row>
</ion-label>
</ion-item>
</ion-row>
</ion-card-content>
</ng-template>

<ion-header>
<ion-toolbar class="ion-justify-content-center" style="--background: var(--ion-color-toolbar-primary);">
<ion-title class="ion-text-start ion-padding-left" style="color: var(--ion-title-color);"
Expand Down Expand Up @@ -36,26 +56,8 @@
<td style="width: 100%" class="ion-padding" translate>General.TOTAL</td>
</tr>
</table>
<storageTotalChart [showPhases]="showPhases" [period]="service.historyPeriod.value">
</storageTotalChart>
<!-- Info Text -->
<ion-row class="ion-justify-content-center">
<ion-item class="ion-text-center" lines="none">
<ion-icon color="primary" size="large" slot="start" name="alert-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<ion-row class="ion-text-center" style="white-space: pre !important; width: 100%">
<small translate>
Edge.Index.Widgets.InfoStorageForCharge
</small>
</ion-row>
<ion-row size="6" class="ion-text-center" style="white-space: pre !important; width: 100%">
<small translate>
Edge.Index.Widgets.InfoStorageForDischarge
</small>
</ion-row>
</ion-label>
</ion-item>
</ion-row>
<storageTotalChart [showPhases]="showPhases" [period]="service.historyPeriod.value"></storageTotalChart>
<ng-container *ngTemplateOutlet="infoStorageText"></ng-container>
</ion-card-content>
</ng-container>
<ng-container *ngIf="!showTotal">
Expand All @@ -69,27 +71,7 @@
<storageSingleChart [showPhases]="showPhases" [period]="service.historyPeriod.value">
</storageSingleChart>
</ion-card-content>
<!-- Info Text -->
<ion-card-content class="underline">
<ion-row class="ion-justify-content-center">
<ion-item class="ion-text-center" lines="none">
<ion-icon color="primary" size="large" slot="start" name="alert-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<ion-row class="ion-text-center" style="white-space: pre !important; width: 100%">
<small translate>
Edge.Index.Widgets.InfoStorageForCharge
</small>
</ion-row>
<ion-row size="6" class="ion-text-center"
style="white-space: pre !important; width: 100%">
<small translate>
Edge.Index.Widgets.InfoStorageForDischarge
</small>
</ion-row>
</ion-label>
</ion-item>
</ion-row>
</ion-card-content>
<ng-container *ngTemplateOutlet="infoStorageText"></ng-container>
</ng-container>
<ng-container *ngIf="essComponents?.length > 1">
<ion-card-content class="underline">
Expand All @@ -114,27 +96,7 @@
[componentId]="component.id"></storageESSChart>
</ion-card-content>
</ng-container>
<!-- Info Text -->
<ion-card-content class="underline">
<ion-row class="ion-justify-content-center">
<ion-item class="ion-text-center" lines="none">
<ion-icon color="primary" size="large" slot="start" name="alert-outline"></ion-icon>
<ion-label class="ion-text-wrap">
<ion-row class="ion-text-center" style="white-space: pre !important; width: 100%">
<small translate>
Edge.Index.Widgets.InfoStorageForCharge
</small>
</ion-row>
<ion-row size="6" class="ion-text-center"
style="white-space: pre !important; width: 100%">
<small translate>
Edge.Index.Widgets.InfoStorageForDischarge
</small>
</ion-row>
</ion-label>
</ion-item>
</ion-row>
</ion-card-content>
<ng-container *ngTemplateOutlet="infoStorageText"></ng-container>
</ng-container>
<ng-container *ngIf="essComponents?.length !== 1">
<ng-container *ngFor="let component of chargerComponents">
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/components/edge/edgeconfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export namespace DummyConfig {
* Factories.
*/
// identifier `Factory` is also used in namespace
// eslint-disable-next-line @typescript-eslint/no-unused-vars

type Factory = {
id: string,
natureIds: string[],
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/service/myerrorhandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class MyErrorHandler implements ErrorHandler {
) { }

// https://v16.angular.io/api/core/ErrorHandler#errorhandler
// eslint-disable-next-line @typescript-eslint/no-explicit-any

handleError(error: any) {
const logger = this.injector.get(Logger);
console.error(error);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/service/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export class Service extends AbstractService {
}

// https://v16.angular.io/api/core/ErrorHandler#errorhandler
// eslint-disable-next-line @typescript-eslint/no-explicit-any

public override handleError(error: any) {
console.error(error);
// TODO: show notification
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/service/test/dummyservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class DummyService extends AbstractService {
throw new Error("Method not implemented.");
}
// https://v16.angular.io/api/core/ErrorHandler#errorhandler
// eslint-disable-next-line @typescript-eslint/no-explicit-any

override handleError(error: any): void {
throw new Error("Method not implemented.");
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/shared/type/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Language {
public readonly json: any,
// Angular is not providing common type for locale.
// https://github.com/angular/angular/issues/30506
// eslint-disable-next-line @typescript-eslint/no-explicit-any

public readonly locale: any,
) {
}
Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/shared/utils/datetime/datetime-utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-strict-ignore
/* eslint-disable import/no-duplicates */

// cf. https://github.com/import-js/eslint-plugin-import/issues/1479
import { differenceInMilliseconds, format, startOfMonth, startOfYear } from "date-fns";
import { de } from "date-fns/locale";
/* eslint-enable import/no-duplicates */

import { ChronoUnit } from "src/app/edge/history/shared";

import { QueryHistoricTimeseriesDataResponse } from "../../jsonrpc/response/queryHistoricTimeseriesDataResponse";
Expand Down
4 changes: 2 additions & 2 deletions ui/src/zone-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
* running with certain Web Component callbacks
* https://ionicframework.com/docs/ja/troubleshooting/runtime#angular-change-detection
*/
// eslint-disable-next-line no-underscore-dangle
// eslint-disable-next-line @typescript-eslint/no-explicit-any


(window as any).__Zone_disable_customElements = true;