Skip to content

Commit

Permalink
some more over here
Browse files Browse the repository at this point in the history
  • Loading branch information
mlapaglia committed Jul 21, 2021
1 parent 1b78328 commit 5933f49
Show file tree
Hide file tree
Showing 16 changed files with 514 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class Enricher {
id: string;
isEnabled: boolean;
apiKey: string;
enrichAlways: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<mat-slide-toggle
style="padding-top: 10px;"
[(ngModel)]="enricher.isEnabled"
(change)="onPushoverToggle($event)"></mat-slide-toggle>
(change)="onEnricherToggle($event)"></mat-slide-toggle>
</mat-card-header>
<mat-card-content *ngIf="enricher.isEnabled" [@inOutAnimation]>
<div style="margin:16px;" fxLayout="row wrap" fxLayout="row wrap" fxLayoutGap=20px>
Expand All @@ -15,14 +15,14 @@
<input matInput [(ngModel)]="enricher.apiKey">
<mat-icon matTooltip="The LicensePlateData API key, provided via email from provider." style="cursor:default" matSuffix>help_center</mat-icon>
</mat-form-field>
<div>
<mat-checkbox [(ngModel)]="enricher.enrichAlways">Enrich every plate</mat-checkbox>
<div fxFlex="80">
<mat-checkbox [(ngModel)]="enricher.runAlways">Enrich every plate</mat-checkbox>
</div>
<div>
<mat-checkbox [(ngModel)]="enricher.enrichInNightMode">Enrich plates during night mode</mat-checkbox>
<div fxFlex="80">
<mat-checkbox [(ngModel)]="enricher.runAtNight">Enrich plates during night mode</mat-checkbox>
</div>
<div>
<mat-checkbox [(ngModel)]="enricher.enrichManually">Only enrich manually</mat-checkbox>
<div fxFlex="80">
<mat-checkbox [(ngModel)]="enricher.runManually">Only enrich manually</mat-checkbox>
</div>
</div>
</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { animate, style, transition, trigger } from '@angular/animations';
import { Component, OnInit } from '@angular/core';
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
import { SnackbarService } from '@app/snackbar/snackbar.service';
import { SnackBarType } from '@app/snackbar/snackbartype';
import { Enricher } from './enricher';
import { EnrichersService } from './enrichers.service';

Expand Down Expand Up @@ -29,19 +32,53 @@ export class EnrichersComponent implements OnInit {

public enricher: Enricher;

constructor(private enricherService: EnrichersService) { }
constructor(
private enricherService: EnrichersService,
private snackbarService: SnackbarService) { }

ngOnInit(): void {
this.getEnricher();
}

private getEnricher() {
this.enricherService.getEnricher().subscribe(result => {
this.enricher = result;
})
}

public testEnricher() {
this.isTesting = true;

this.enricherService.testEnricher(this.enricher.id).subscribe(_ => {
this.isTesting = false;
this.snackbarService.create("Enricher test succeeded.", SnackBarType.Saved);
}, _ => {
this.isSaving = false;
this.snackbarService.create("Enricher test failed, check the logs.", SnackBarType.Error);
});
}

public saveEnricher() {
this.isSaving = true;

this.enricherService.upsertEnricher(this.enricher).subscribe(_ => {
this.isSaving = false;
this.snackbarService.create("Enricher client saved.", SnackBarType.Successful);
this.getEnricher();
},
_ => {
this.isSaving = false;
this.snackbarService.create("Enricher client test failed, check the logs.", SnackBarType.Error);
});
}

public onEnricherToggle(event: MatSlideToggleChange) {
if (!event.checked) {
this.enricher.isEnabled = event.checked;
this.isSaving = true;
this.enricherService.upsertEnricher(this.enricher).subscribe(_ => {
this.isSaving = false;
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,12 @@ export class EnrichersService {
public getEnricher(): Observable<Enricher> {
return this.http.get<Enricher>('/settings/enrichers');
}

public upsertEnricher(enricher: Enricher): Observable<any> {
return this.http.post("/settings/enrichers", enricher);
}

public testEnricher(enricherId: string): Observable<any> {
return this.http.post(`/settings/enrichers/${enricherId}/test`, null)
}
}
2 changes: 2 additions & 0 deletions OpenAlprWebhookProcessor/Data/Enricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class Enricher
{
public Guid Id { get; set; }

public bool IsEnabled { get; set; }

public EnricherType EnricherType { get; set; }

public string ApiKey { get; set; }
Expand Down
Loading

0 comments on commit 5933f49

Please sign in to comment.