Skip to content

Commit

Permalink
some more
Browse files Browse the repository at this point in the history
  • Loading branch information
mlapaglia committed Jul 21, 2021
1 parent 5933f49 commit 7ab84eb
Show file tree
Hide file tree
Showing 22 changed files with 520 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ <h1 mat-dialog-title>Edit Plate</h1>
<div mat-dialog-actions align="end">
<button mat-raised-button [mat-dialog-close]="false">Cancel</button>
<button mat-raised-button [mat-dialog-close]="true" cdkFocusInitial color="primary">Save</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ export class EditPlateComponent implements OnInit {
ngOnInit(): void {
this.plate = this.data.plate;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class PlateService {
private hydrateDatabaseUrl = "hydration/start";
private getFiltersUrl = 'licenseplates/filters';
private getStatistics = 'licenseplates/statistics';
private enrichPlateUrl = 'licenseplates/enrich';

constructor(private http: HttpClient) { }

Expand Down Expand Up @@ -46,6 +47,10 @@ export class PlateService {
getPlateStatistics(plateNumber: string): Observable<PlateStatistics> {
return this.http.get<PlateStatistics>(`/${this.getStatistics}/${plateNumber}`)
}

enrichPlate(plateId: string): Observable<any> {
return this.http.post(`/${this.enrichPlateUrl}/${plateId}`, null);
}
}

export class PlateRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
(searchPlatesEvent)="searchPlates($event)"></app-plate>
</ng-template>
<mat-action-row style="display:flexbox; flex-wrap: wrap;">
<button mat-button color="primary" (click)="enrichPlate(plate.id)">Enrich plate</button>
<button mat-button color="primary" (click)="editPlate(plate.id)">Edit plate</button>
<button mat-button color="primary" (click)="searchPlates(plate.plateNumber)">Search for plate</button>
<button mat-button color="primary" [disabled]="plate.isIgnore || isAddingToIgnoreList" [class.spinner]="isAddingToIgnoreList" (click)="addToIgnoreList(plate.plateNumber)">Add to ignore list</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { VehicleFilters } from './vehicleFilters';
import { MatDialog } from '@angular/material/dialog';
import { EditPlateComponent } from './edit-plate/edit-plate.component';
import { LocalStorageService } from '@app/_services/local-storage.service';
import { EnrichersService } from '@app/settings/enrichers/enrichers.service';

@Component({
selector: 'app-plates',
Expand Down Expand Up @@ -80,6 +81,8 @@ export class PlatesComponent implements OnInit, OnDestroy, AfterViewInit {
public vehicleFilters: VehicleFilters = {} as VehicleFilters;

public isDeletingPlate: boolean;
public isEnrichingPlate: boolean;

public isAddingToIgnoreList: boolean;
public isAddingToAlertList: boolean;

Expand All @@ -95,6 +98,7 @@ export class PlatesComponent implements OnInit, OnDestroy, AfterViewInit {
@ViewChild(MatPaginator) paginator: MatPaginator;

constructor(
private enricherService: EnrichersService,
private plateService: PlateService,
private signalRHub: SignalrService,
private snackbarService: SnackbarService,
Expand Down Expand Up @@ -279,7 +283,19 @@ export class PlatesComponent implements OnInit, OnDestroy, AfterViewInit {
this.validateSearchPlateNumber();
}

openEditDialog(plateId: string): void {
public enrichPlate(plateId: string) {
this.isEnrichingPlate = true;
this.plateService.enrichPlate(plateId).subscribe(_ => {
this.isEnrichingPlate = false;
this.snackbarService.create("Plate successfully enriched.", SnackBarType.Saved);
},
_ => {
this.isEnrichingPlate = false;
this.snackbarService.create("Failed to enrich plate, check the logs.", SnackBarType.Error);
})
}

public openEditDialog(plateId: string): void {
var plateToEdit = this.plates.find(x => x.id == plateId);

const dialogRef = this.dialog.open(EditPlateComponent, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EnrichmentType } from "./enrichmentType";

export class Enricher {
id: string;
isEnabled: boolean;
apiKey: string;
enrichAlways: boolean;
enrichInNightMode: boolean;
enrichManually: boolean;
enrichmentType: EnrichmentType;

constructor(init?:Partial<Enricher>) {
Object.assign(this, init);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@
<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 fxFlex="80">
<mat-checkbox [(ngModel)]="enricher.runAlways">Enrich every plate</mat-checkbox>
</div>
<div fxFlex="80">
<mat-checkbox [(ngModel)]="enricher.runAtNight">Enrich plates during night mode</mat-checkbox>
</div>
<div fxFlex="80">
<mat-checkbox [(ngModel)]="enricher.runManually">Only enrich manually</mat-checkbox>
</div>
<mat-radio-group [(ngModel)]="enricher.enrichmentType" aria-label="Enrichment type" fxFlex="80" style="display: flex; flex-direction: column;">
<mat-radio-button value="Always">Enrich every plate</mat-radio-button>
<mat-radio-button value="OnlyAtNight">Enrich plates during night mode</mat-radio-button>
<mat-radio-button value="Manually">Only enrich manually</mat-radio-button>
</mat-radio-group>
</div>
</mat-card-content>
<mat-card-actions align="end" *ngIf="enricher.isEnabled" [@inOutAnimation]>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum EnrichmentType {
Unknown = 0,
Always = "Always",
OnlyAtNight = "OnlyAtNight",
Manually = "Manually",
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { SystemLogsComponent } from './systemLogs/systemLogs.component';
import { HighlightModule } from 'ngx-highlightjs';
import { PushoverComponent } from './alerts/pushover/pushover.component';
import { EnrichersComponent } from './enrichers/enrichers.component';
import { MatRadioModule } from '@angular/material/radio';

@NgModule({
declarations: [
Expand Down Expand Up @@ -75,6 +76,7 @@ import { EnrichersComponent } from './enrichers/enrichers.component';
FlexLayoutModule,
MatSlideToggleModule,
MatCheckboxModule,
MatRadioModule,
HighlightModule,
]
})
Expand Down
7 changes: 2 additions & 5 deletions OpenAlprWebhookProcessor/Data/Enricher.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenAlprWebhookProcessor.LicensePlates.Enricher;
using OpenAlprWebhookProcessor.Settings.Enrichers;
using System;

namespace OpenAlprWebhookProcessor.Data
Expand All @@ -13,10 +14,6 @@ public class Enricher

public string ApiKey { get; set; }

public bool RunAlways { get; set; }

public bool RunAtNight { get; set; }

public bool RunManually { get; set; }
public EnrichmentType EnrichmentType { get; set; }
}
}
Loading

0 comments on commit 7ab84eb

Please sign in to comment.