Skip to content
This repository was archived by the owner on Oct 8, 2023. It is now read-only.

Commit 56d29ce

Browse files
committed
Fix newly introduced frontend bugs.
1 parent 08db606 commit 56d29ce

File tree

13 files changed

+46
-49
lines changed

13 files changed

+46
-49
lines changed

Frontend/src/app/assets/asset-list/asset-list.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ export class AssetListComponent implements OnInit, OnDestroy {
3434
filter: string;
3535
Roles = Roles;
3636

37+
assetsList: Asset[];
3738
selectedAsset: Asset;
3839
selectedAssetState: SelectedAssetState;
40+
3941
private selectedDateRange: DateRange;
4042
private lastCalledFunction: (asset: Asset, filterSelected: Boolean) => void;
4143
private subscription: Subscription;
4244
private isDrawing = false;
4345
private isAlive: boolean;
44-
private assetsList: Asset[];
4546

4647
constructor(
4748
private assetService: AssetService,
@@ -55,7 +56,6 @@ export class AssetListComponent implements OnInit, OnDestroy {
5556
this.assetService.getAssets()
5657
.takeWhile(() => this.isAlive)
5758
.skipWhile(assets => assets.length === 0)
58-
.take(1)
5959
.subscribe(assets => {
6060
this.assetsList = assets.sort((a, b) => {
6161
if (a.name < b.name) { return -1; }

Frontend/src/app/dispatching/dispatching-editor/dispatching-editor.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class DispatchingEditorComponent implements OnInit, OnDestroy {
117117
this.dialogService.showLocationsDialog()
118118
.subscribe(location => {
119119
if (location) {
120-
location.name = this.locationService.normalizeLocationName(location);
120+
location.name = location.name + `(${this.pinsAdded.length + 1})`;
121121
this.pinsAdded.push(location);
122122
this.mapsService.resetDispatchingDraw(this.pinsAdded);
123123
}

Frontend/src/app/dispatching/location-dialog/location-dialog.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<mat-list-item *ngFor="let location of locations | filterList:filter"
1515
(click)="onSelected(location)"
1616
[class.active]="location == selectedLocation">
17-
<span mat-line> {{getLocationName(location)}}</span>
17+
<span mat-line> {{location.name}}</span>
1818
</mat-list-item>
1919
</mat-list>
2020
</div>

Frontend/src/app/dispatching/location-dialog/location-dialog.component.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,4 @@ export class LocationDialogComponent implements OnInit, OnDestroy {
4040
onButtonClicked() {
4141
this.dialogRef.close(this.selectedLocation);
4242
}
43-
44-
getLocationName(location: Location) {
45-
return this.locationService.normalizeLocationName(location);
46-
}
4743
}

Frontend/src/app/geofences/geofence-editor/geofence-editor.component.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ form {
1717
.partial-button {
1818
float:left;
1919
cursor: pointer;
20+
}
21+
22+
h3 {
23+
margin: 0;
2024
}

Frontend/src/app/geofences/geofence-editor/geofence-editor.component.html

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,18 @@
1010
<mat-input-container>
1111
<input matInput placeholder="Name" [(ngModel)]="geofence.name" name="name" required>
1212
</mat-input-container>
13-
<mat-input-container>
14-
<input matInput placeholder="Emails To Notify" [(ngModel)]="joinedEmails" name="email">
15-
</mat-input-container>
16-
<mat-input-container>
17-
<input matInput placeholder="Webhooks To Notify" [(ngModel)]="joinedWebhooks" name="webhook">
18-
</mat-input-container>
19-
<mat-input-container>
20-
<input matInput placeholder="Cooldown in Minutes" [(ngModel)]="geofence.cooldown" name="cooldown" type="number" min="0" required>
21-
</mat-input-container>
2213

2314
<mat-input-container>
24-
<mat-select placeholder="Geofence Area Type" [(ngModel)]="geofence.areaType" name="areaType" (change)="onAreaTypeChanged($event)" required>
15+
<mat-select placeholder="Geofence Area Type" [(ngModel)]="geofence.areaType" name="areaType" (change)="onAreaTypeChanged($event)"
16+
required>
2517
<mat-option [value]="AreaType.Polygon">Polygon</mat-option>
2618
<mat-option [value]="AreaType.Circular">Circular</mat-option>
2719
</mat-select>
2820
</mat-input-container>
2921

3022
<mat-input-container *ngIf="geofence.areaType === AreaType.Circular">
31-
<input matInput type="number" placeholder="Radius In Meters" [(ngModel)]="geofence.radiusInMeters" name="radiusInMeters" (change)="onRadiusChanged($event)" (keyup)="onRadiusChanged($event)" required>
23+
<input matInput type="number" placeholder="Radius In Meters" [(ngModel)]="geofence.radiusInMeters" name="radiusInMeters"
24+
(change)="onRadiusChanged($event)" (keyup)="onRadiusChanged($event)" required>
3225
</mat-input-container>
3326

3427
<mat-input-container *ngIf="geofence.areaType === AreaType.Polygon">
@@ -37,13 +30,25 @@
3730
<a class="partial-button" (click)="clearPoints()">Clear Points</a>
3831
</mat-input-container>
3932

33+
<mat-input-container>
34+
<input matInput placeholder="Cooldown in Minutes" [(ngModel)]="geofence.cooldown" name="cooldown" type="number" min="0" required>
35+
</mat-input-container>
36+
4037
<mat-input-container>
4138
<mat-select placeholder="Fence Type" [(ngModel)]="geofence.fenceType" name="fenceType" required>
4239
<mat-option [value]="FenceType.Inbound">Inbound</mat-option>
4340
<mat-option [value]="FenceType.Outbound">Outbound</mat-option>
4441
</mat-select>
4542
</mat-input-container>
4643

44+
<mat-input-container>
45+
<input matInput placeholder="Emails To Notify" [(ngModel)]="joinedEmails" name="email">
46+
</mat-input-container>
47+
48+
<mat-input-container>
49+
<input matInput placeholder="Webhooks To Notify" [(ngModel)]="joinedWebhooks" name="webhook">
50+
</mat-input-container>
51+
4752
<h3>Available Assets:</h3>
4853
<mat-list>
4954
<mat-list-item *ngFor="let asset of assets">
@@ -56,4 +61,4 @@ <h3>Available Assets:</h3>
5661
<button mat-raised-button class="dispatch-button " type="submit">Submit</button>
5762
</div>
5863
</form>
59-
</section>
64+
</section>

Frontend/src/app/locations/location-editor/location-editor.component.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,19 @@ export class LocationEditorComponent implements OnInit, OnDestroy {
2323
locationString: string;
2424
locationTypeString: string;
2525
private isAlive: boolean;
26-
private readonly undeterminedMessage = 'Undetermined';
2726

2827
constructor(
2928
private locationService: LocationService,
3029
private mapService: MapsService,
3130
private route: ActivatedRoute,
3231
private router: Router,
3332
private toasterService: ToasterService) {
34-
this.location = new Location();
3533
}
3634

3735
ngOnInit() {
3836
this.isAlive = true;
39-
this.mapService.startLocationPinDraw();
37+
this.location = new Location();
38+
4039
this.route.params
4140
.takeWhile(() => this.isAlive)
4241
.subscribe(params => {
@@ -52,9 +51,9 @@ export class LocationEditorComponent implements OnInit, OnDestroy {
5251
this.mapService.showLocationsPositions([this.location]);
5352
}
5453
});
55-
} else {
56-
this.locationString = this.undeterminedMessage;
5754
}
55+
56+
this.mapService.startLocationPinDraw(this.location);
5857
});
5958

6059
this.mapService.getLocationPinResult()
@@ -90,7 +89,7 @@ export class LocationEditorComponent implements OnInit, OnDestroy {
9089
}
9190

9291
submit() {
93-
if (this.locationString === this.undeterminedMessage) {
92+
if (!this.location.latitude || !this.location.longitude) {
9493
this.toasterService.pop('error', 'Invalid Input', 'Please add the location pin on the map');
9594
return;
9695
}

Frontend/src/app/locations/location-list/location-list.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<div *ngFor="let location of locations | filterList:filter | paginate: {itemsPerPage: singlePageSize, currentPage: index}"
2121
[class.active]="location === selectedLocation">
2222
<mat-list-item>
23-
<h3 mat-line (click)="showLocation(location)"> {{getLocationName(location)}}</h3>
23+
<h3 mat-line (click)="showLocation(location)"> {{location.name}}</h3>
2424
<span mat-line class="subtle" (click)="showLocation(location)">address: {{location.address}}</span>
2525
<a [appRoleLimiter]="Roles.Administrator" mat-icon-button mat-tooltip="Edit" [routerLink]="['/locations', location.id]">
2626
<mat-icon>mode_edit</mat-icon>

Frontend/src/app/locations/location-list/location-list.component.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ export class LocationListComponent implements OnInit, OnDestroy {
6262
this.mapsService.showLocationsPositions(locationRange);
6363
}
6464

65-
getLocationName(location: Location) {
66-
return this.locationService.normalizeLocationName(location);
67-
}
68-
6965
showLocation(location: Location) {
7066
if (location === this.selectedLocation) {
7167
this.selectedLocation = null;

Frontend/src/app/locations/location.service.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,4 @@ export class LocationService {
3131
getLocationAssetsCount(location: Location): Observable<Map<string, number>> {
3232
return this.dataSevrice.getSingleNoCache<Map<string, number>>(`locations/${location.id}/assetsCount`);
3333
}
34-
35-
normalizeLocationName(location: Location) {
36-
if (location.name === 'Auto-Generated Location') {
37-
return 'Location ' + location.id;
38-
} else {
39-
return location.name;
40-
}
41-
}
4234
}

0 commit comments

Comments
 (0)