Merge branch 'develop' of ssh://ognproject.evlt.uma.es:21987/opengnsys/oggui into develop

oggui/calendar
Manuel Aranda Rosales 2024-10-02 10:24:53 +02:00
commit 38dcf8d277
7 changed files with 41 additions and 20 deletions

View File

@ -9,6 +9,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
styleUrls: ['./add-role-modal.component.css']
})
export class AddRoleModalComponent {
baseUrl: string = import.meta.env.NG_APP_BASE_API_URL;
roleForm: FormGroup;
constructor(
@ -49,7 +50,7 @@ export class AddRoleModalComponent {
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) => {
this.dialogRef.close();
},

View File

@ -15,7 +15,7 @@ export class CreateCommandGroupComponent implements OnInit {
groupName: string = '';
enabled: boolean = true;
editing: boolean = false;
private apiUrl = 'http://127.0.0.1:8001/commands';
private apiUrl = `${this.baseUrl}/commands`;
constructor(
private http: HttpClient,
@ -70,7 +70,7 @@ export class CreateCommandGroupComponent implements OnInit {
if (this.editing) {
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: () => {
this.toastService.success('Grupo de comandos actualizado con éxito');
this.dialogRef.close();
@ -80,7 +80,7 @@ export class CreateCommandGroupComponent implements OnInit {
}
});
} else {
this.http.post('http://127.0.0.1:8001/command-groups', payload).subscribe({
this.http.post(`${this.baseUrl}/command-groups`, payload).subscribe({
next: () => {
this.toastService.success('Grupo de comandos creado con éxito');
this.dialogRef.close();

View File

@ -73,7 +73,7 @@ export class CreateTaskComponent implements OnInit {
}
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) => {
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 selectedCommands = formData.extraCommands && formData.extraCommands.length > 0
? formData.extraCommands.map((id: any) => `/commands/${id}`)
: null; // No asignamos nada si no hay comandos seleccionados
: null;
// Creamos el objeto payload
const payload: any = {
commandGroups: formData.commandGroup ? [`/command-groups/${formData.commandGroup}`] : null,
dateTime: dateTime,
notes: formData.notes || ''
};
// Solo agregamos commands al payload si hay comandos seleccionados
if (selectedCommands) {
payload.commands = selectedCommands;
}

View File

@ -35,7 +35,7 @@ export class CommandDetailComponent implements OnInit {
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'];
});

View File

@ -15,7 +15,7 @@ export class AcctionsModalComponent {
selectedElements: any;
commands: any[] = [];
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 {
this.loadCommands();

View File

@ -47,14 +47,14 @@
</mat-form-field>
<!-- Campo nuevo para seleccionar el calendario asociado -->
<!-- <mat-form-field appearance="fill">
<mat-form-field appearance="fill">
<mat-label>Calendario Asociado</mat-label>
<mat-select (selectionChange)="onCalendarChange($event)">
<mat-option *ngFor="let calendar of calendars" [value]="calendar.uuid">
<mat-select formControlName="calendarSelect" (selectionChange)="onCalendarChange($event)">
<mat-option *ngFor="let calendar of calendars" [value]="calendar.uuid">
{{ calendar.name }}
</mat-option>
</mat-select>
</mat-form-field> -->
</mat-form-field>
<div>
<button mat-button matStepperPrevious i18n="@@backButton">Atrás</button>

View File

@ -32,6 +32,7 @@ export class EditOrganizationalUnitComponent implements OnInit {
{"name": 'Full duplex', "value": "full-duplex"},
];
@Output() unitAdded = new EventEmitter(); // Event emitter to notify parent component about unit addition
calendars: any;
constructor(
private _formBuilder: FormBuilder,
@ -75,7 +76,8 @@ export class EditOrganizationalUnitComponent implements OnInit {
location: [''],
projector: [false],
board: [false],
capacity: [0, Validators.min(0)]
capacity: [0, Validators.min(0)],
calendarSelect: [null]
});
if (this.isEditMode) {
@ -84,8 +86,9 @@ export class EditOrganizationalUnitComponent implements OnInit {
}
ngOnInit() {
this.loadParentUnits(); // Load parent units when component initializes
this.loadParentUnits();
this.loadHardwareProfiles();
this.loadCalendars();
}
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) {
const url = `${this.baseUrl}/organizational-units/${uuid}`;
this.http.get<any>(url).subscribe(
data => {
console.log('Data fetched for edit:', data);
this.generalFormGroup.patchValue({
name: data.name,
parent: data.parent ? data.parent['@id'] : '',
@ -143,10 +164,11 @@ export class EditOrganizationalUnitComponent implements OnInit {
validation: data.networkSettings.validation
});
this.classroomInfoFormGroup.patchValue({
location: data.classroomInfo.location,
projector: data.classroomInfo.projector,
board: data.classroomInfo.board,
capacity: data.classroomInfo.capacity
location: data.location,
projector: data.projector,
board: data.board,
capacity: data.capacity,
calendarSelect: data.remoteCalendar['@id']
});
},
error => {