Skip to content

Commit

Permalink
moved device ids and increased dialog width for edit device; fix #SNR…
Browse files Browse the repository at this point in the history
…GY-3219, #SNRGY-3246
  • Loading branch information
hahahannes committed Apr 12, 2024
1 parent 06b2148 commit da7c04c
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export class DeviceInstancesComponent implements OnInit, AfterViewInit {
}

showInfoOfDevice(device: DeviceInstancesModel): void {
this.deviceInstancesDialogService.openDeviceServiceDialog(device.device_type.id, device.id);
this.deviceInstancesDialogService.openDeviceServiceDialog(device);
}

editDevice(device: DeviceInstancesModel): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@ <h2 mat-dialog-title>Edit Device</h2>

<mat-dialog-content>
<form class="form">
<div *ngIf="false">
<mat-form-field class="full-width" color="accent">
<mat-label>ID</mat-label>
<input matInput placeholder="ID" disabled value="{{device.id}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Short ID</mat-label>
<input matInput placeholder="ShortID" disabled value="{{getShortId(device.id)}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Devicetype ID</mat-label>
<input matInput placeholder="Devicetype ID" disabled value="{{device.device_type.id}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Devicetype Name</mat-label>
<input matInput placeholder="Devicetype Name" disabled value="{{device.device_type.name}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Origin Name</mat-label>
<input matInput placeholder="Origin Name" [(ngModel)]="device.name" disabled [ngModelOptions]="{standalone: true}">
</mat-form-field>
</div>

<div *ngIf="userHasUpdateDisplayNameAuthorization">
<mat-form-field class="full-width" color="accent">
<mat-label>Display Name</mat-label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class DeviceInstancesEditDialogComponent implements OnInit {

constructor(
private dialogRef: MatDialogRef<DeviceInstancesEditDialogComponent>,
private deviceInstancesService: DeviceInstancesService,
private deviceTypeService: DeviceTypeService,

@Inject(MAT_DIALOG_DATA) private data: {
Expand Down Expand Up @@ -77,10 +76,6 @@ export class DeviceInstancesEditDialogComponent implements OnInit {

ngOnInit() {}

getShortId(id: string): string {
return this.deviceInstancesService.convertToShortId(id);
}

close(): void {
this.dialogRef.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@
::ng-deep .example-custom-date-class {
background:rgba(0,0,0,.38)!important;
}

#id-container {
display: flex;
justify-content: space-between;
}

#id-container mat-form-field {
width: 18%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,29 @@
</div>

<mat-dialog-content>
<div id="id-container">
<mat-form-field class="full-width" color="accent">
<mat-label>ID</mat-label>
<input matInput placeholder="ID" disabled value="{{device.id}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Short ID</mat-label>
<input matInput placeholder="ShortID" disabled value="{{getShortId(device.id)}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Devicetype ID</mat-label>
<input matInput placeholder="Devicetype ID" disabled value="{{device.device_type.id}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Devicetype Name</mat-label>
<input matInput placeholder="Devicetype Name" disabled value="{{device.device_type.name}}">
</mat-form-field>
<mat-form-field class="full-width" color="accent">
<mat-label>Origin Name</mat-label>
<input matInput placeholder="Origin Name" [(ngModel)]="device.name" disabled [ngModelOptions]="{standalone: true}">
</mat-form-field>
</div>

<mat-accordion>
<mat-expansion-panel *ngFor="let service of services; let i = index" [expanded]="services.length === 1">
<mat-expansion-panel-header>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {FormBuilder, FormControl, FormGroup} from '@angular/forms';
import {environment} from '../../../../../environments/environment';
import {AuthorizationService} from '../../../../core/services/authorization.service';
import {ErrorHandlerService} from '../../../../core/services/error-handler.service';
import { DeviceInstancesModel } from '../shared/device-instances.model';
import { DeviceInstancesService } from '../shared/device-instances.service';

@Component({
templateUrl: './device-instances-service-dialog.component.html',
Expand All @@ -49,7 +51,7 @@ export class DeviceInstancesServiceDialogComponent implements OnInit {
from: [{value: new Date(new Date().setHours(new Date().getTimezoneOffset() / -60, 0, 0, 0)), disabled: true}],
to: [{value: new Date(new Date().setHours(new Date().getTimezoneOffset() / -60, 0, 0, 0)), disabled: true}],
});
deviceId = '';
device: DeviceInstancesModel;
descriptions: string[][];
availability: { serviceId: string; from?: Date; to?: Date; groupType?: string; groupTime?: string }[] = [];
availabilityControl = new FormControl<{
Expand All @@ -60,7 +62,7 @@ export class DeviceInstancesServiceDialogComponent implements OnInit {
constructor(
private dialogRef: MatDialogRef<DeviceInstancesServiceDialogComponent>,
@Inject(MAT_DIALOG_DATA) data: {
deviceId: string;
device: DeviceInstancesModel;
services: DeviceTypeServiceModel[];
lastValueElements: LastValuesRequestElementTimescaleModel[];
deviceType: DeviceTypeModel;
Expand All @@ -71,12 +73,13 @@ export class DeviceInstancesServiceDialogComponent implements OnInit {
private fb: FormBuilder,
private errorHandlerService: ErrorHandlerService,
private authorizationService: AuthorizationService,
private deviceInstancesService: DeviceInstancesService
) {
this.services = data.services;
this.lastValueElements = data.lastValueElements;
this.deviceType = data.deviceType;
this.serviceOutputCounts = data.serviceOutputCounts;
this.deviceId = data.deviceId;
this.device = data.device;
this.descriptions = data.descriptions;
}

Expand Down Expand Up @@ -105,7 +108,7 @@ export class DeviceInstancesServiceDialogComponent implements OnInit {
counter += this.serviceOutputCounts[serviceIndex];
});
});
this.exportDataService.getTimescaleDataAvailability(this.deviceId).subscribe(availability => {
this.exportDataService.getTimescaleDataAvailability(this.device.id).subscribe(availability => {
this.availability = availability;
});
}
Expand All @@ -123,7 +126,7 @@ export class DeviceInstancesServiceDialogComponent implements OnInit {
const token = await this.authorizationService.getToken();
const f = await fetch(environment.timescaleAPIURL + '/prepare-download?query=' + JSON.stringify({
serviceId: this.services[i].id,
deviceId: this.deviceId,
deviceId: this.device.id,
columns,
time: {
start: fromIso,
Expand Down Expand Up @@ -204,4 +207,8 @@ export class DeviceInstancesServiceDialogComponent implements OnInit {
}): boolean {
return a.groupTime === b.groupTime && a.groupType === b.groupType;
}

getShortId(id: string): string {
return this.deviceInstancesService.convertToShortId(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ export class DeviceInstancesDialogService {
return editDialogRef.afterClosed();
}

openDeviceServiceDialog(deviceTypeId: string, deviceId: string): void {
openDeviceServiceDialog(device: DeviceInstancesModel): void {
const obs: Observable<any>[] = [];
const deviceTypeId = device.device_type.id;
const deviceId = device.id;
obs.push(this.deviceTypeService.getMeasuringFunctions());
obs.push(this.deviceTypeService.getAspectNodesWithMeasuringFunction());
obs.push(this.deviceTypeService.getLeafCharacteristics());
Expand Down Expand Up @@ -117,7 +119,7 @@ export class DeviceInstancesDialogService {
dialogConfig.minWidth = '650px';
if (deviceType) {
dialogConfig.data = {
deviceId,
device,
services: deviceType.services,
lastValueElements,
deviceType,
Expand All @@ -135,6 +137,7 @@ export class DeviceInstancesDialogService {
display_name: string;
}
const dialogConfig = new MatDialogConfig();
dialogConfig.width = "50vh";
dialogConfig.disableClose = false;
dialogConfig.data = {
device: JSON.parse(JSON.stringify(device)), // create copy of object
Expand Down

0 comments on commit da7c04c

Please sign in to comment.