Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 97x 1x 1x 1x 1x 1x 1x 188x 187x 185x | import { Component, inject, OnInit } from '@angular/core';
import { TwinpadApiService } from '../../services/twinpad-api.service';
import { ActivatedRoute, Router } from '@angular/router';
import { MessageService } from 'primeng/api';
import { NgxJsonViewerModule } from 'ngx-json-viewer';
import { Configuration } from '../../models/configuration';
import { NgIf } from '@angular/common';
import { LoaderComponent } from '../loader/loader.component';
@Component({
selector: 'app-configuration',
imports: [NgxJsonViewerModule, NgIf, LoaderComponent],
templateUrl: './configuration.component.html',
styleUrl: './configuration.component.scss'
})
export class ConfigurationComponent implements OnInit {
configurationId: string;
configuration: Configuration;
configurationFile: JSON;
messageService = inject(MessageService);
constructor(private twinpadApiService: TwinpadApiService, private route: ActivatedRoute, private router: Router){}
ngOnInit(): void {
this.configurationId = this.route.snapshot.params['configuration_id'] || null;
this.twinpadApiService.getConfig(this.configurationId).subscribe({
'next': value => {
this.configuration = value;
this.configurationFile = JSON.parse(JSON.stringify(
this.configuration,
(key, value) => {
if (key === "in_use_by_devices") return undefined; // Don't include 'in_use_by_devices' in JSON representation
else if (key === "id") return undefined;
return value;
}, 2));
},
'error': _ => {
this.messageService.add({severity:'error', summary: 'Loading config', detail: 'No configuration found'});
this.router.navigate(['/configurations']);
}
});
}
}
|