Skip to content

Commit

Permalink
SNRGY-3644 add time range start and end date
Browse files Browse the repository at this point in the history
  • Loading branch information
zsco committed Nov 28, 2024
1 parent 773a9e6 commit 443a0f4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,22 @@
<mat-error senergyError label="Time Frame Unit"></mat-error>
</mat-form-field>
</div>
<div role="group" class="form-grouping">
<mat-form-field fxFlex color="accent" appearance="outline">
<mat-label>Start Date</mat-label>
<input matInput [matDatepicker]="picker_start" [(ngModel)]="data.query!.time!.start">
<mat-hint>DD/MM/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker_start"></mat-datepicker-toggle>
<mat-datepicker #picker_start></mat-datepicker>
</mat-form-field>
<mat-form-field fxFlex color="accent" appearance="outline">
<mat-label>End Date</mat-label>
<input matInput [matDatepicker]="picker_end" [(ngModel)]="data.query!.time!.end">
<mat-hint>DD/MM/YYYY</mat-hint>
<mat-datepicker-toggle matIconSuffix [for]="picker_end"></mat-datepicker-toggle>
<mat-datepicker #picker_end></mat-datepicker>
</mat-form-field>
</div>
</div>

<div *ngIf="inputType === 'value'" fxLayout="column">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class ReportObjectComponent implements OnInit, OnChanges {
queryDeviceType: DeviceTypeModel = {} as DeviceTypeModel;
queryPreview = '';
fieldGroupTypes = ['mean', 'sum', 'count', 'median', 'min', 'max', 'first', 'last', 'difference-first', 'difference-last', 'difference-min', 'difference-max', 'difference-count', 'difference-mean', 'difference-sum', 'difference-median', 'time-weighted-mean-linear', 'time-weighted-mean-locf'];
groupingTime = {number: '12', unit: 'months'};
groupingTime = {number: '', unit: ''};
timeUnits = [
new TimeUnit('ms', 'Milliseconds'),
new TimeUnit('s', 'Seconds'),
Expand All @@ -73,7 +73,7 @@ export class ReportObjectComponent implements OnInit, OnChanges {
new TimeUnit('months', 'Months'),
new TimeUnit('y', 'Years'),
];
timeframe = {number: '1', unit: 'months'};
timeframe = {number: '', unit: ''};


constructor(
Expand Down Expand Up @@ -230,7 +230,12 @@ export class ReportObjectComponent implements OnInit, OnChanges {

setGroupingTime() {
if (this.data?.query !== undefined) {
this.data.query.groupTime = this.groupingTime.number + this.groupingTime.unit;
if (this.groupingTime.number === '') {
delete this.data.query.groupTime;
this.getGroupingTime();
} else {
this.data.query.groupTime = this.groupingTime.number + this.groupingTime.unit;
}
}
}

Expand All @@ -245,7 +250,12 @@ export class ReportObjectComponent implements OnInit, OnChanges {

setTimeframe() {
if (this.data?.query?.time !== undefined) {
this.data.query.time.last = this.timeframe.number + this.timeframe.unit;
if(this.timeframe.number === ''){
delete this.data.query.time.last;
this.getTimeframe();
} else {
this.data.query.time.last = this.timeframe.number + this.timeframe.unit;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/app/modules/reporting/reporting.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {QueryPreviewDialogComponent} from './report/report-object/query-preview/
import {MatDialogModule} from '@angular/material/dialog';
import {MatExpansionModule} from '@angular/material/expansion';
import {MatFormFieldModule} from '@angular/material/form-field';
import {MatDatepickerModule} from "@angular/material/datepicker";

const templateList: Route = { path: 'reporting/templates', pathMatch: 'full', component: TemplatesComponent, data: { header: 'Templates' } };
const reportsList: Route = { path: 'reporting/reports', pathMatch: 'full', component: ReportsComponent, data: { header: 'Reports' } };
Expand Down Expand Up @@ -71,7 +72,8 @@ const reportFilesList: Route = { path: 'reporting/files/:reportId', pathMatch: '
MatRadioModule,
CoreModule,
MatDialogModule,
MatExpansionModule
MatExpansionModule,
MatDatepickerModule
]
})
export class ReportingModule { }

0 comments on commit 443a0f4

Please sign in to comment.