Merge branch 'develop' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oggui into develop
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
testing/ogGui-multibranch/pipeline/head There was a failure building this commit
Details
commit
9fcfeb7f4e
|
@ -177,12 +177,15 @@ export class ManageOrganizationalUnitComponent implements OnInit {
|
|||
}
|
||||
|
||||
onParentChange(event: any): void {
|
||||
this.setOrganizationalUnitDefaults(event.value);
|
||||
if (!this.isEditMode) {
|
||||
this.setOrganizationalUnitDefaults(event.value);
|
||||
}
|
||||
}
|
||||
|
||||
setOrganizationalUnitDefaults(unitId: string): void {
|
||||
const selectedUnit: any = this.parentUnitsWithPaths.find(unit => unit.id === unitId);
|
||||
if (selectedUnit) {
|
||||
const exclude = this.generalFormGroup.get('excludeParentChanges')?.value;
|
||||
if (selectedUnit && !exclude) {
|
||||
this.networkSettingsFormGroup.patchValue({
|
||||
repository: selectedUnit.repository || null,
|
||||
hardwareProfile: selectedUnit.hardwareProfile || null,
|
||||
|
@ -204,6 +207,127 @@ export class ManageOrganizationalUnitComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
loadData(uuid: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = `${this.baseUrl}/organizational-units/${uuid}`;
|
||||
|
||||
this.http.get<any>(url).subscribe(
|
||||
data => {
|
||||
const exclude = data.excludeParentChanges;
|
||||
|
||||
this.generalFormGroup.patchValue({
|
||||
name: data.name,
|
||||
parent: data.parent ? data.parent['@id'] : '',
|
||||
description: data.description,
|
||||
type: data.type,
|
||||
excludeParentChanges: exclude
|
||||
});
|
||||
|
||||
this.additionalInfoFormGroup.patchValue({
|
||||
comments: data.comments
|
||||
});
|
||||
|
||||
this.networkSettingsFormGroup.patchValue({
|
||||
proxy: data.networkSettings?.proxy,
|
||||
dns: data.networkSettings?.dns,
|
||||
netmask: data.networkSettings?.netmask,
|
||||
router: data.networkSettings?.router,
|
||||
ntp: data.networkSettings?.ntp,
|
||||
netiface: data.networkSettings?.netiface,
|
||||
p2pMode: data.networkSettings?.p2pMode,
|
||||
p2pTime: data.networkSettings?.p2pTime,
|
||||
mcastIp: data.networkSettings?.mcastIp,
|
||||
mcastSpeed: data.networkSettings?.mcastSpeed,
|
||||
mcastPort: data.networkSettings?.mcastPort,
|
||||
mcastMode: data.networkSettings?.mcastMode,
|
||||
menu: data.networkSettings?.menu ? data.networkSettings.menu['@id'] : null,
|
||||
hardwareProfile: data.networkSettings?.hardwareProfile ? data.networkSettings.hardwareProfile['@id'] : null,
|
||||
ogLive: data.networkSettings?.ogLive ? data.networkSettings.ogLive['@id'] : null,
|
||||
repository: data.networkSettings?.repository ? data.networkSettings.repository['@id'] : null,
|
||||
pxeTemplate: data.networkSettings?.pxeTemplate ? data.networkSettings.pxeTemplate['@id'] : null
|
||||
});
|
||||
|
||||
this.classroomInfoFormGroup.patchValue({
|
||||
location: data.location,
|
||||
projector: data.projector,
|
||||
board: data.board,
|
||||
capacity: data.capacity,
|
||||
remoteCalendar: data.remoteCalendar ? data.remoteCalendar['@id'] : null
|
||||
});
|
||||
|
||||
resolve();
|
||||
},
|
||||
|
||||
error => {
|
||||
console.error('Error fetching data for edit:', error);
|
||||
this.toastService.error('Error fetching data');
|
||||
reject(error);
|
||||
this.onNoClick();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
if (this.generalFormGroup.valid && this.additionalInfoFormGroup.valid && this.networkSettingsFormGroup.valid) {
|
||||
const parentValue = this.generalFormGroup.value.parent;
|
||||
const formData = {
|
||||
name: this.generalFormGroup.value.name,
|
||||
excludeParentChanges: this.generalFormGroup.value.excludeParentChanges,
|
||||
parent: parentValue || null,
|
||||
description: this.generalFormGroup.value.description,
|
||||
comments: this.additionalInfoFormGroup.value.comments,
|
||||
remoteCalendar: this.generalFormGroup.value.remoteCalendar,
|
||||
type: this.generalFormGroup.value.type,
|
||||
networkSettings: this.networkSettingsFormGroup.value,
|
||||
location: this.classroomInfoFormGroup.value.location,
|
||||
projector: this.classroomInfoFormGroup.value.projector,
|
||||
board: this.classroomInfoFormGroup.value.board,
|
||||
capacity: this.classroomInfoFormGroup.value.capacity,
|
||||
};
|
||||
|
||||
if (this.isEditMode) {
|
||||
const putUrl = `${this.baseUrl}/organizational-units/${this.data.uuid}`;
|
||||
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
|
||||
|
||||
this.http.put<any>(putUrl, formData, { headers }).subscribe(
|
||||
response => {
|
||||
this.unitAdded.emit();
|
||||
this.dialogRef.close({ success: true });
|
||||
this.toastService.success('Editado exitosamente', 'Éxito');
|
||||
},
|
||||
error => {
|
||||
console.error('Error al realizar PUT:', error);
|
||||
const errorMessages = error.error['hydra:description'].split('\n');
|
||||
errorMessages.forEach((message: string) => {
|
||||
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
|
||||
this.toastService.error(cleanedMessage);
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
const postUrl = `${this.baseUrl}/organizational-units`;
|
||||
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
|
||||
|
||||
this.http.post<any>(postUrl, formData, { headers }).subscribe(
|
||||
response => {
|
||||
this.unitAdded.emit(response);
|
||||
this.dialogRef.close({ success: true });
|
||||
this.toastService.success('Creado exitosamente', 'Éxito');
|
||||
},
|
||||
error => {
|
||||
console.error('Error al realizar POST:', error);
|
||||
const errorMessages = error.error['hydra:description'].split('\n');
|
||||
errorMessages.forEach((message: string) => {
|
||||
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
|
||||
this.toastService.error(cleanedMessage);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getSelectedParentName(): string | undefined {
|
||||
const parentId = this.generalFormGroup.get('parent')?.value;
|
||||
return this.parentUnitsWithPaths.find(unit => unit.id === parentId)?.name;
|
||||
|
@ -229,14 +353,14 @@ export class ManageOrganizationalUnitComponent implements OnInit {
|
|||
const url = `${this.baseUrl}/pxe-templates?page=1&itemsPerPage=10000`;
|
||||
|
||||
this.http.get<any>(url).subscribe(
|
||||
response => {
|
||||
response => {
|
||||
this.pxeTemplates = response['hydra:member'];
|
||||
resolve();
|
||||
},
|
||||
error => {
|
||||
},
|
||||
error => {
|
||||
console.error('Error fetching pxe templates:', error);
|
||||
reject(error);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -325,121 +449,6 @@ export class ManageOrganizationalUnitComponent implements OnInit {
|
|||
this.networkSettingsFormGroup.value.pxeTemplate = event.value;
|
||||
}
|
||||
|
||||
loadData(uuid: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const url = `${this.baseUrl}/organizational-units/${uuid}`;
|
||||
|
||||
this.http.get<any>(url).subscribe(
|
||||
data => {
|
||||
this.generalFormGroup.patchValue({
|
||||
name: data.name,
|
||||
parent: data.parent ? data.parent['@id'] : '',
|
||||
description: data.description,
|
||||
type: data.type,
|
||||
excludeParentChanges: data.excludeParentChanges
|
||||
});
|
||||
this.additionalInfoFormGroup.patchValue({
|
||||
comments: data.comments
|
||||
});
|
||||
this.networkSettingsFormGroup.patchValue({
|
||||
proxy: data.networkSettings?.proxy,
|
||||
dns: data.networkSettings?.dns,
|
||||
netmask: data.networkSettings?.netmask,
|
||||
router: data.networkSettings?.router,
|
||||
ntp: data.networkSettings?.ntp,
|
||||
netiface: data.networkSettings?.netiface,
|
||||
p2pMode: data.networkSettings?.p2pMode,
|
||||
p2pTime: data.networkSettings?.p2pTime,
|
||||
mcastIp: data.networkSettings?.mcastIp,
|
||||
mcastSpeed: data.networkSettings?.mcastSpeed,
|
||||
mcastPort: data.networkSettings?.mcastPort,
|
||||
mcastMode: data.networkSettings?.mcastMode,
|
||||
menu: data.networkSettings?.menu ? data.networkSettings.menu['@id'] : null,
|
||||
hardwareProfile: data.networkSettings?.hardwareProfile ? data.networkSettings.hardwareProfile['@id'] : null,
|
||||
ogLive: data.networkSettings?.ogLive ? data.networkSettings.ogLive['@id'] : null,
|
||||
repository: data.networkSettings?.repository ? data.networkSettings.repository['@id'] : null,
|
||||
pxeTemplate: data.networkSettings?.pxeTemplate ? data.networkSettings.pxeTemplate['@id'] : null
|
||||
});
|
||||
this.classroomInfoFormGroup.patchValue({
|
||||
location: data.location,
|
||||
projector: data.projector,
|
||||
board: data.board,
|
||||
capacity: data.capacity,
|
||||
remoteCalendar: data.remoteCalendar ? data.remoteCalendar['@id'] : null
|
||||
});
|
||||
resolve();
|
||||
},
|
||||
|
||||
error => {
|
||||
console.error('Error fetching data for edit:', error);
|
||||
this.toastService.error('Error fetching data');
|
||||
reject(error);
|
||||
this.onNoClick();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
if (this.generalFormGroup.valid && this.additionalInfoFormGroup.valid && this.networkSettingsFormGroup.valid) {
|
||||
const parentValue = this.generalFormGroup.value.parent;
|
||||
const formData = {
|
||||
name: this.generalFormGroup.value.name,
|
||||
excludeParentChanges: this.generalFormGroup.value.excludeParentChanges,
|
||||
parent: parentValue || null,
|
||||
description: this.generalFormGroup.value.description,
|
||||
comments: this.additionalInfoFormGroup.value.comments,
|
||||
remoteCalendar: this.generalFormGroup.value.remoteCalendar,
|
||||
type: this.generalFormGroup.value.type,
|
||||
networkSettings: this.networkSettingsFormGroup.value,
|
||||
location: this.classroomInfoFormGroup.value.location,
|
||||
projector: this.classroomInfoFormGroup.value.projector,
|
||||
board: this.classroomInfoFormGroup.value.board,
|
||||
capacity: this.classroomInfoFormGroup.value.capacity,
|
||||
};
|
||||
|
||||
if (this.isEditMode) {
|
||||
const putUrl = `${this.baseUrl}/organizational-units/${this.data.uuid}`;
|
||||
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
|
||||
|
||||
this.http.put<any>(putUrl, formData, { headers }).subscribe(
|
||||
response => {
|
||||
this.unitAdded.emit();
|
||||
this.dialogRef.close({ success: true });
|
||||
this.toastService.success('Editado exitosamente', 'Éxito');
|
||||
},
|
||||
error => {
|
||||
console.error('Error al realizar PUT:', error);
|
||||
const errorMessages = error.error['hydra:description'].split('\n');
|
||||
errorMessages.forEach((message: string) => {
|
||||
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
|
||||
this.toastService.error(cleanedMessage);
|
||||
});
|
||||
}
|
||||
);
|
||||
} else {
|
||||
const postUrl = `${this.baseUrl}/organizational-units`;
|
||||
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
|
||||
|
||||
this.http.post<any>(postUrl, formData, { headers }).subscribe(
|
||||
response => {
|
||||
this.unitAdded.emit(response);
|
||||
this.dialogRef.close({ success: true });
|
||||
this.toastService.success('Creado exitosamente', 'Éxito');
|
||||
},
|
||||
error => {
|
||||
console.error('Error al realizar POST:', error);
|
||||
const errorMessages = error.error['hydra:description'].split('\n');
|
||||
errorMessages.forEach((message: string) => {
|
||||
const cleanedMessage = message.replace(/networkSettings\.(\w+):/, 'Error $1:');
|
||||
this.toastService.error(cleanedMessage);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onNoClick(): void {
|
||||
this.dialogRef.close({ success: false });
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ export class ClientTaskLogsComponent implements OnInit {
|
|||
mode: ProgressBarMode = 'buffer';
|
||||
progress = 0;
|
||||
bufferValue = 0;
|
||||
dateRange = new FormControl();
|
||||
|
||||
filteredCommands2 = Object.keys(COMMAND_TYPES).map(key => ({
|
||||
name: key,
|
||||
|
@ -135,7 +134,9 @@ export class ClientTaskLogsComponent implements OnInit {
|
|||
}
|
||||
|
||||
onOptionCommandSelected(selectedCommand: any): void {
|
||||
this.filters['command'] = selectedCommand.id;
|
||||
this.filters['command'] = selectedCommand.name;
|
||||
console.log('Comando seleccionado:', selectedCommand);
|
||||
console.log('Valor que se usará para el filtro:', selectedCommand.name);
|
||||
this.loadTraces();
|
||||
}
|
||||
|
||||
|
@ -191,22 +192,13 @@ export class ClientTaskLogsComponent implements OnInit {
|
|||
.set('itemsPerPage', this.itemsPerPage.toString());
|
||||
|
||||
if (this.filters['command']) {
|
||||
params = params.set('command.id', this.filters['command']);
|
||||
params = params.set('command.name', this.filters['command']);
|
||||
}
|
||||
|
||||
if (this.filters['status']) {
|
||||
params = params.set('status', this.filters['status']);
|
||||
}
|
||||
|
||||
const range = this.dateRange?.value;
|
||||
if (range?.start && range?.end) {
|
||||
const fromDate = this.datePipe.transform(range.start, 'yyyy-MM-dd');
|
||||
const toDate = this.datePipe.transform(range.end, 'yyyy-MM-dd');
|
||||
|
||||
params = params.set('executedAt[after]', fromDate!);
|
||||
params = params.set('executedAt[before]', toDate!);
|
||||
}
|
||||
|
||||
const url = `${this.baseUrl}/traces`;
|
||||
|
||||
this.http.get<any>(url, { params }).subscribe(
|
||||
|
@ -240,7 +232,6 @@ export class ClientTaskLogsComponent implements OnInit {
|
|||
this.loading = true;
|
||||
clientSearchCommandInput.value = null;
|
||||
clientSearchStatusInput.value = null;
|
||||
this.dateRange.reset();
|
||||
this.filters = {};
|
||||
this.loadTraces();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue