Skip to content

Commit

Permalink
reporting: add cron & emaiL
Browse files Browse the repository at this point in the history
  • Loading branch information
franzmueller committed Jan 23, 2025
1 parent ebb6c86 commit 8dad77b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/app/modules/reporting/report/report.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<input matInput [(ngModel)]="reportName">
<mat-error senergyError label="Report Name"></mat-error>
</mat-form-field>
<mat-form-field fxFlex color="accent" appearance="outline">
<mat-label>Cron Schedule</mat-label>
<input matInput [(ngModel)]="cron">
<mat-error senergyError label="Cron Schedule"></mat-error>
</mat-form-field>
<mat-checkbox [(ngModel)]="emailAfterCron">Email Report after Cronjob</mat-checkbox>
</div>
</mat-card-content>
</mat-card>
Expand Down
13 changes: 10 additions & 3 deletions src/app/modules/reporting/report/report.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export class ReportComponent implements OnInit {
templateId: string | null = '';
requestObject: Map<string, any> = new Map<string, any>();
allDevices: DeviceInstanceModel[] = [];
cron: string | undefined;
emailAfterCron = false;
constructor(
private route: ActivatedRoute,
public snackBar: MatSnackBar,
Expand All @@ -66,6 +68,8 @@ export class ReportComponent implements OnInit {
this.report = resp.data;
this.templateId = this.report.templateId;
this.reportName = this.report.name;
this.cron = this.report.cron;
this.emailAfterCron = this.report.emailAfterCron;
this.template.data = { dataJsonString: '', dataStructured: {} as Map<string, ReportObjectModel>, id: '', name: '' };
this.template.data.dataStructured = this.report.data;
this.reportingService.getTemplate(this.templateId).subscribe((resp2: TemplateResponseModel | null) => {
Expand All @@ -89,7 +93,8 @@ export class ReportComponent implements OnInit {
create() {
this.reportingService.createReport({
id: this.reportId, templateId: this.templateId, name: this.reportName,
templateName: this.template.name, data: this.template.data?.dataStructured
templateName: this.template.name, data: this.template.data?.dataStructured,
cron: this.cron, emailAfterCron: this.emailAfterCron,
} as ReportModel).subscribe(resp => {
if (resp !== null) {
this.snackBar.open('Report created', 'ReportCreate', {
Expand All @@ -111,7 +116,8 @@ export class ReportComponent implements OnInit {
save() {
this.reportingService.saveReport({
templateId: this.templateId, name: this.reportName,
templateName: this.template.name, data: this.template.data?.dataStructured
templateName: this.template.name, data: this.template.data?.dataStructured,
cron: this.cron, emailAfterCron: this.emailAfterCron,
} as ReportModel).subscribe(resp => {
if (resp !== null) {
if (resp.status === 200) {
Expand All @@ -126,7 +132,8 @@ export class ReportComponent implements OnInit {
update() {
this.reportingService.updateReport({
id: this.reportId, templateId: this.templateId, name: this.reportName,
templateName: this.template.name, data: this.template.data?.dataStructured
templateName: this.template.name, data: this.template.data?.dataStructured,
cron: this.cron, emailAfterCron: this.emailAfterCron,
} as ReportModel).subscribe(resp => {
if (resp !== null) {
if (resp.status === 200) {
Expand Down
2 changes: 2 additions & 0 deletions src/app/modules/reporting/shared/reporting.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export interface ReportModel {
templateId: string;
data: Map<string, ReportObjectModel>;
reportFiles: ReportFileModel[];
cron?: string;
emailAfterCron: boolean;
createdAt: string;
updatedAt: string;
}
Expand Down

0 comments on commit 8dad77b

Please sign in to comment.