Merge branch 'develop' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oggui into develop
commit
38dcf8d277
|
@ -9,6 +9,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
styleUrls: ['./add-role-modal.component.css']
|
styleUrls: ['./add-role-modal.component.css']
|
||||||
})
|
})
|
||||||
export class AddRoleModalComponent {
|
export class AddRoleModalComponent {
|
||||||
|
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
|
||||||
roleForm: FormGroup;
|
roleForm: FormGroup;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -49,7 +50,7 @@ export class AddRoleModalComponent {
|
||||||
enabled: true
|
enabled: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.http.post('http://127.0.0.1:8001/user-groups', payload).subscribe(
|
this.http.post(`${this.baseUrl}/user-groups`, payload).subscribe(
|
||||||
(response) => {
|
(response) => {
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class CreateCommandGroupComponent implements OnInit {
|
||||||
groupName: string = '';
|
groupName: string = '';
|
||||||
enabled: boolean = true;
|
enabled: boolean = true;
|
||||||
editing: boolean = false;
|
editing: boolean = false;
|
||||||
private apiUrl = 'http://127.0.0.1:8001/commands';
|
private apiUrl = `${this.baseUrl}/commands`;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
|
@ -70,7 +70,7 @@ export class CreateCommandGroupComponent implements OnInit {
|
||||||
|
|
||||||
if (this.editing) {
|
if (this.editing) {
|
||||||
const groupId = this.data.group.uuid;
|
const groupId = this.data.group.uuid;
|
||||||
this.http.patch(`http://127.0.0.1:8001/command-groups/${groupId}`, payload).subscribe({
|
this.http.patch(`${this.baseUrl}/command-groups/${groupId}`, payload).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.toastService.success('Grupo de comandos actualizado con éxito');
|
this.toastService.success('Grupo de comandos actualizado con éxito');
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
@ -80,7 +80,7 @@ export class CreateCommandGroupComponent implements OnInit {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.http.post('http://127.0.0.1:8001/command-groups', payload).subscribe({
|
this.http.post(`${this.baseUrl}/command-groups`, payload).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.toastService.success('Grupo de comandos creado con éxito');
|
this.toastService.success('Grupo de comandos creado con éxito');
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
|
|
|
@ -73,7 +73,7 @@ export class CreateTaskComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadOrganizationalUnits(): void {
|
loadOrganizationalUnits(): void {
|
||||||
this.http.get<any>('http://127.0.0.1:8001/organizational-units?page=1&itemsPerPage=30').subscribe(
|
this.http.get<any>(`${this.baseUrl}/organizational-units?page=1&itemsPerPage=30`).subscribe(
|
||||||
(data) => {
|
(data) => {
|
||||||
this.availableOrganizationalUnits = data['hydra:member'].filter((unit: any) => unit['type'] === 'organizational-unit');
|
this.availableOrganizationalUnits = data['hydra:member'].filter((unit: any) => unit['type'] === 'organizational-unit');
|
||||||
},
|
},
|
||||||
|
@ -139,16 +139,14 @@ export class CreateTaskComponent implements OnInit {
|
||||||
const dateTime = this.combineDateAndTime(formData.date, formData.time);
|
const dateTime = this.combineDateAndTime(formData.date, formData.time);
|
||||||
const selectedCommands = formData.extraCommands && formData.extraCommands.length > 0
|
const selectedCommands = formData.extraCommands && formData.extraCommands.length > 0
|
||||||
? formData.extraCommands.map((id: any) => `/commands/${id}`)
|
? formData.extraCommands.map((id: any) => `/commands/${id}`)
|
||||||
: null; // No asignamos nada si no hay comandos seleccionados
|
: null;
|
||||||
|
|
||||||
// Creamos el objeto payload
|
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
commandGroups: formData.commandGroup ? [`/command-groups/${formData.commandGroup}`] : null,
|
commandGroups: formData.commandGroup ? [`/command-groups/${formData.commandGroup}`] : null,
|
||||||
dateTime: dateTime,
|
dateTime: dateTime,
|
||||||
notes: formData.notes || ''
|
notes: formData.notes || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
// Solo agregamos commands al payload si hay comandos seleccionados
|
|
||||||
if (selectedCommands) {
|
if (selectedCommands) {
|
||||||
payload.commands = selectedCommands;
|
payload.commands = selectedCommands;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ export class CommandDetailComponent implements OnInit {
|
||||||
scheduleTime: ['']
|
scheduleTime: ['']
|
||||||
});
|
});
|
||||||
|
|
||||||
this.http.get<any>('http://127.0.0.1:8001/clients?page=1&itemsPerPage=30').subscribe(response => {
|
this.http.get<any>(`${this.baseUrl}/clients?page=1&itemsPerPage=30`).subscribe(response => {
|
||||||
this.clients = response['hydra:member'];
|
this.clients = response['hydra:member'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class AcctionsModalComponent {
|
||||||
selectedElements: any;
|
selectedElements: any;
|
||||||
commands: any[] = [];
|
commands: any[] = [];
|
||||||
displayedColumns: string[] = ['name', 'createdBy', 'createdAt'];
|
displayedColumns: string[] = ['name', 'createdBy', 'createdAt'];
|
||||||
private apiUrl = 'http://127.0.0.1:8001/commands?page=1&itemsPerPage=30';
|
private apiUrl = `${this.baseUrl}/commands?page=1&itemsPerPage=40`;
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.loadCommands();
|
this.loadCommands();
|
||||||
|
|
|
@ -47,14 +47,14 @@
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<!-- Campo nuevo para seleccionar el calendario asociado -->
|
<!-- Campo nuevo para seleccionar el calendario asociado -->
|
||||||
<!-- <mat-form-field appearance="fill">
|
<mat-form-field appearance="fill">
|
||||||
<mat-label>Calendario Asociado</mat-label>
|
<mat-label>Calendario Asociado</mat-label>
|
||||||
<mat-select (selectionChange)="onCalendarChange($event)">
|
<mat-select formControlName="calendarSelect" (selectionChange)="onCalendarChange($event)">
|
||||||
<mat-option *ngFor="let calendar of calendars" [value]="calendar.uuid">
|
<mat-option *ngFor="let calendar of calendars" [value]="calendar.uuid">
|
||||||
{{ calendar.name }}
|
{{ calendar.name }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field> -->
|
</mat-form-field>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button mat-button matStepperPrevious i18n="@@backButton">Atrás</button>
|
<button mat-button matStepperPrevious i18n="@@backButton">Atrás</button>
|
||||||
|
|
|
@ -32,6 +32,7 @@ export class EditOrganizationalUnitComponent implements OnInit {
|
||||||
{"name": 'Full duplex', "value": "full-duplex"},
|
{"name": 'Full duplex', "value": "full-duplex"},
|
||||||
];
|
];
|
||||||
@Output() unitAdded = new EventEmitter(); // Event emitter to notify parent component about unit addition
|
@Output() unitAdded = new EventEmitter(); // Event emitter to notify parent component about unit addition
|
||||||
|
calendars: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
|
@ -75,7 +76,8 @@ export class EditOrganizationalUnitComponent implements OnInit {
|
||||||
location: [''],
|
location: [''],
|
||||||
projector: [false],
|
projector: [false],
|
||||||
board: [false],
|
board: [false],
|
||||||
capacity: [0, Validators.min(0)]
|
capacity: [0, Validators.min(0)],
|
||||||
|
calendarSelect: [null]
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.isEditMode) {
|
if (this.isEditMode) {
|
||||||
|
@ -84,8 +86,9 @@ export class EditOrganizationalUnitComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loadParentUnits(); // Load parent units when component initializes
|
this.loadParentUnits();
|
||||||
this.loadHardwareProfiles();
|
this.loadHardwareProfiles();
|
||||||
|
this.loadCalendars();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadParentUnits() {
|
loadParentUnits() {
|
||||||
|
@ -112,11 +115,29 @@ export class EditOrganizationalUnitComponent implements OnInit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadCalendars() {
|
||||||
|
const apiUrl = `${this.baseUrl}/remote-calendars?page=1&itemsPerPage=30`;
|
||||||
|
this.http.get<any>(apiUrl).subscribe(
|
||||||
|
response => this.calendars = response['hydra:member'],
|
||||||
|
error => {
|
||||||
|
console.error('Error loading calendars', error);
|
||||||
|
this.openSnackBar(true, 'Error loading calendars');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCalendarChange(event: any) {
|
||||||
|
const selectedCalendarId = event.value;
|
||||||
|
console.log('Selected calendar ID:', selectedCalendarId);
|
||||||
|
// Aquí puedes agregar la lógica adicional para manejar el cambio de calendario si es necesario
|
||||||
|
}
|
||||||
|
|
||||||
loadData(uuid: string) {
|
loadData(uuid: string) {
|
||||||
const url = `${this.baseUrl}/organizational-units/${uuid}`;
|
const url = `${this.baseUrl}/organizational-units/${uuid}`;
|
||||||
|
|
||||||
this.http.get<any>(url).subscribe(
|
this.http.get<any>(url).subscribe(
|
||||||
data => {
|
data => {
|
||||||
|
console.log('Data fetched for edit:', data);
|
||||||
this.generalFormGroup.patchValue({
|
this.generalFormGroup.patchValue({
|
||||||
name: data.name,
|
name: data.name,
|
||||||
parent: data.parent ? data.parent['@id'] : '',
|
parent: data.parent ? data.parent['@id'] : '',
|
||||||
|
@ -143,10 +164,11 @@ export class EditOrganizationalUnitComponent implements OnInit {
|
||||||
validation: data.networkSettings.validation
|
validation: data.networkSettings.validation
|
||||||
});
|
});
|
||||||
this.classroomInfoFormGroup.patchValue({
|
this.classroomInfoFormGroup.patchValue({
|
||||||
location: data.classroomInfo.location,
|
location: data.location,
|
||||||
projector: data.classroomInfo.projector,
|
projector: data.projector,
|
||||||
board: data.classroomInfo.board,
|
board: data.board,
|
||||||
capacity: data.classroomInfo.capacity
|
capacity: data.capacity,
|
||||||
|
calendarSelect: data.remoteCalendar['@id']
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
|
|
Loading…
Reference in New Issue