Skip to content

Commit

Permalink
Alarms history retention #811 and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
unocelli committed May 19, 2023
1 parent ebc5ba1 commit ee505ee
Show file tree
Hide file tree
Showing 18 changed files with 305 additions and 198 deletions.
16 changes: 16 additions & 0 deletions client/src/app/_models/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class AppSettings {
smtp = new SmtpSettings();
/** Daq store database */
daqstore = new DaqStore();
/** Alarms store settings */
alarms = new AlarmsSettings();
}

export class SmtpSettings {
Expand Down Expand Up @@ -67,6 +69,10 @@ export class DaqStore {
}
}

export class AlarmsSettings {
retention = AlarmsRetentionType.year1;
}

export class StoreCredentials {
token?: string;
username?: string;
Expand Down Expand Up @@ -99,6 +105,16 @@ export enum DaqStoreRetentionType {
year1 = 'year1',
}

export enum AlarmsRetentionType {
none = 'none',
days7 = 'days7',
days30 = 'days30',
days90 = 'days90',
year1 = 'year1',
year3 = 'year3',
year5 = 'year5',
}

export class MailMessage {
from: string;
to: string;
Expand Down
26 changes: 24 additions & 2 deletions client/src/app/editor/app-settings/app-settings.component.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@

::ng-deep .mat-tab-label {
height: 34px !important;
padding: 0;
}

.tabs-container {
min-height: 500px;
min-width: 620px;
}

.tabs-container .tab-system {
width: 320px;
}

.tabs-container .tab-smtp {
padding-right: 10px;
}

.tabs-container .tab-daq {
padding-right: 10px;
}

.tabs-container .tab-alarms {
padding-right: 10px;
}

.input-row {
width: 610px;
}
width: 100%;
}
128 changes: 64 additions & 64 deletions client/src/app/editor/app-settings/app-settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,132 +2,132 @@
<h1 mat-dialog-title style="display:inline-block;cursor:move;" mat-dialog-draggable>{{'dlg.app-settings-title' | translate}}</h1>
<mat-icon (click)="onNoClick()" class="dialog-close-btn" >clear</mat-icon>
<div mat-dialog-content>
<mat-tab-group style="height: 500px; width: 620px;">
<mat-tab-group class="tabs-container">
<mat-tab label="{{'dlg.app-settings-system' | translate}}">
<div style="width: 420px">
<div class="my-form-field blk mt20">
<div class="block mt20 tab-system">
<div class="my-form-field block">
<span>{{'dlg.app-settings-language' | translate}}</span>
<mat-select [(value)]="settings.language" style="width: 320px" (selectionChange)="onLanguageChange($event.value)">
<mat-select [(value)]="settings.language" (selectionChange)="onLanguageChange($event.value)">
<mat-option *ngFor="let language of languageType" [value]="language.value">
{{ language.text }}
</mat-option>
</mat-select>
</div>
<div class="my-form-field blk mt15">
<div class="my-form-field block mt15">
<span>{{'dlg.app-settings-server-port' | translate}}</span>
<input numberOnly [(ngModel)]="settings.uiPort" style="width: 320px" type="text" disabled="true">
</div>
<div class="my-form-field blk mt15">
<div class="my-form-field block mt15">
<span style="display: inline-block;">{{'dlg.app-settings-auth-token' | translate}}</span>
<mat-icon class="my-form-field-info" matTooltip="{{authenticationTooltip}}">error_outline</mat-icon>
<mat-select [(value)]="authentication" style="width: 320px; display: block;">
<mat-icon class="my-form-field-info" style="height: 16px" matTooltip="{{authenticationTooltip}}">error_outline</mat-icon>
<mat-select [(value)]="authentication" style="display: block;">
<mat-option *ngFor="let auth of authType" [value]="auth.value">
{{ auth.text }}
</mat-option>
</mat-select>
</div>
<div class="my-form-field blk mt15">
<div class="my-form-field block mt15">
<span>{{'dlg.app-settings-client-broadcast' | translate}}</span>
<mat-select [(value)]="settings.broadcastAll" style="width: 320px; display: block;">
<mat-select [(value)]="settings.broadcastAll">
<mat-option [value]="true">{{'general.enabled' | translate}}</mat-option>
<mat-option [value]="false">{{'general.disabled' | translate}}</mat-option>
</mat-select>
</div>
<div class="blk mt20 mb20">
<button mat-raised-button color="basic" (click)="onAlarmsClear()">{{'dlg.app-settings-alarms-clear' | translate}}</button>
</div>
</div>
</div>
</mat-tab>
<mat-tab label="{{'dlg.app-settings-smtp' | translate}}">
<div class="blk mt20">
<div class="my-form-field">
<span>{{'dlg.app-settings-smtp-host' | translate}}</span>
<input [(ngModel)]="settings.smtp.host" placeholder="smtp.example.com" style="width: 320px" type="text">
<div class="block mt20 tab-smtp">
<div class="block">
<div class="my-form-field">
<span>{{'dlg.app-settings-smtp-host' | translate}}</span>
<input [(ngModel)]="settings.smtp.host" placeholder="smtp.example.com" style="width: 320px" type="text">
</div>
<div class="my-form-field lbk ml10">
<span>{{'dlg.app-settings-smtp-port' | translate}}</span>
<input numberOnly [(ngModel)]="settings.smtp.port" style="width: 80px" type="text">
</div>
</div>
<div class="my-form-field" style="display: inline-block; padding-left: 10px;">
<span>{{'dlg.app-settings-smtp-port' | translate}}</span>
<input numberOnly [(ngModel)]="settings.smtp.port" style="width: 80px" type="text">
</div>
</div>
<div class="blk mt20">
<div class="my-form-field">
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-smtp-mailsender' | translate}}</span>
<input [(ngModel)]="settings.smtp.mailsender" placeholder="fuxa@example.com" class="input-row" type="text">
</div>
</div>
<div class="blk mt20">
<div class="my-form-field">
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-smtp-user' | translate}}</span>
<input [(ngModel)]="settings.smtp.username" placeholder="fuxa@example.com" class="input-row" type="text">
</div>
</div>
<div class="blk mt20">
<div class="my-form-field">
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-smtp-password' | translate}}</span>
<input autocomplete="off" (keydown)="keyDownStopPropagation($event)" [type]="showPassword ? 'text' : 'password'" [(ngModel)]="settings.smtp.password" class="input-row">
<mat-icon matSuffix (click)="showPassword = !showPassword" class="show-password">{{showPassword ? 'visibility' : 'visibility_off'}}</mat-icon>
</div>
</div>
<div class="blk mt20 mb20">
<div class="my-form-field">
<span>{{'dlg.app-settings-smtp-testaddress' | translate}}</span>
<input [(ngModel)]="smtpTestAddress" style="width: 534px" type="text">
</div>
<div class="my-form-field" style="display: inline-block; padding-left: 10px;">
<button mat-raised-button color="basic" (click)="onSmtpTest()" [disabled]="!isSmtpTestReady()">{{'dlg.app-settings-smtp-test' | translate}}</button>
<div class="block mt15 w100">
<div class="my-form-field lbk">
<span>{{'dlg.app-settings-smtp-testaddress' | translate}}</span>
<input [(ngModel)]="smtpTestAddress" style="width: 320px" type="text">
</div>
<div class="my-form-field lbk ml10">
<button mat-raised-button color="basic" (click)="onSmtpTest()" [disabled]="!isSmtpTestReady()">{{'dlg.app-settings-smtp-test' | translate}}</button>
</div>
</div>
</div>
</mat-tab>
<mat-tab label="{{'dlg.app-settings-daqstore' | translate}}">
<div class="blk mt20" style="overflow: hidden;">
<div class="my-form-field blk">
<div class="block mt20 tab-daq">
<div class="my-form-field block">
<span>{{'dlg.app-settings-daqstore-type' | translate}}</span>
<mat-select [(value)]="settings.daqstore.type" style="width: 200px">
<mat-option *ngFor="let type of daqstoreType | enumToArray" [value]="type.key">
{{ type.value }}
</mat-option>
</mat-select>
</div>
<div *ngIf="settings.daqstore.type" class="blk">
<div *ngIf="settings.daqstore.type" class="block">
<div [ngSwitch]="settings.daqstore.type">
<div *ngSwitchCase="daqstoreType.SQlite" class="my-form-field blk mt20" style="margin-bottom: 10px;">
<div *ngSwitchCase="daqstoreType.SQlite" class="my-form-field block mt15">
<span>{{'dlg.app-settings-daqstore-retention' | translate}}</span>
<mat-select [(value)]="settings.daqstore.retention" style="width: 200px">
<mat-option *ngFor="let retation of retationType | enumToArray" [value]="retation.key">
{{'daqstore.retention-' + retation.value | translate}}
{{'store.retention-' + retation.value | translate}}
</mat-option>
</mat-select>
</div>
<div *ngSwitchCase="daqstoreType.influxDB">
<div class="blk mt20">
<div class="my-form-field">
<span>{{'dlg.app-settings-daqstore-url' | translate}}</span>
<input [(ngModel)]="settings.daqstore.url" placeholder="https://us-west-2-1.aws.cloud2.influxdata.com" class="input-row" type="text">
</div>
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-daqstore-url' | translate}}</span>
<input [(ngModel)]="settings.daqstore.url" placeholder="https://us-west-2-1.aws.cloud2.influxdata.com" class="input-row" type="text">
</div>
<div class="blk mt20">
<div class="my-form-field">
<span>{{'dlg.app-settings-daqstore-token' | translate}}</span>
<input [(ngModel)]="settings.daqstore.credentials.token" placeholder="" class="input-row" type="text">
</div>
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-daqstore-token' | translate}}</span>
<input [(ngModel)]="settings.daqstore.credentials.token" placeholder="" class="input-row" type="text">
</div>
<div class="blk mt20">
<div class="my-form-field">
<span>{{'dlg.app-settings-daqstore-bucket' | translate}}</span>
<input [(ngModel)]="settings.daqstore.bucket" placeholder="" class="input-row" type="text">
</div>
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-daqstore-bucket' | translate}}</span>
<input [(ngModel)]="settings.daqstore.bucket" placeholder="" class="input-row" type="text">
</div>
<div class="blk mt20">
<div class="my-form-field">
<span>{{'dlg.app-settings-daqstore-organization' | translate}}</span>
<input [(ngModel)]="settings.daqstore.organization" placeholder="" class="input-row" type="text">
</div>
<div class="my-form-field block mt15 w100">
<span>{{'dlg.app-settings-daqstore-organization' | translate}}</span>
<input [(ngModel)]="settings.daqstore.organization" placeholder="" class="input-row" type="text">
</div>
</div>
</div>
</div>
</div>
</mat-tab>
<mat-tab label="{{'dlg.app-settings-alarms' | translate}}">
<div class="block mt20 tab-alarms">
<div class="my-form-field block">
<span>{{'dlg.app-settings-daqstore-retention' | translate}}</span>
<mat-select [(value)]="settings.alarms.retention" style="width: 200px">
<mat-option *ngFor="let retation of alarmsRetationType | enumToArray" [value]="retation.key">
{{'store.retention-' + retation.value | translate}}
</mat-option>
</mat-select>
</div>
<div class="block mt20 mb20">
<button mat-raised-button color="basic" (click)="onAlarmsClear()">{{'dlg.app-settings-alarms-clear' | translate}}</button>
</div>
</div>
</mat-tab>
</mat-tab-group>
</div>
<div mat-dialog-actions class="dialog-action">
Expand Down
3 changes: 2 additions & 1 deletion client/src/app/editor/app-settings/app-settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DiagnoseService } from '../../_services/diagnose.service';
import { TranslateService } from '@ngx-translate/core';
import { ToastrService } from 'ngx-toastr';

import { AppSettings, DaqStore, DaqStoreRetentionType, DaqStoreType, MailMessage, SmtpSettings, StoreCredentials } from '../../_models/settings';
import { AlarmsRetentionType, AppSettings, DaqStore, DaqStoreRetentionType, DaqStoreType, MailMessage, SmtpSettings, StoreCredentials } from '../../_models/settings';
import { Utils } from '../../_helpers/utils';

@Component({
Expand All @@ -33,6 +33,7 @@ export class AppSettingsComponent implements OnInit {

daqstoreType = DaqStoreType;
retationType = DaqStoreRetentionType;
alarmsRetationType = AlarmsRetentionType;

constructor(private settingsService: SettingsService,
private diagnoseService: DiagnoseService,
Expand Down
Loading

0 comments on commit ee505ee

Please sign in to comment.