diff --git a/ogWebconsole/src/app/app-routing.module.ts b/ogWebconsole/src/app/app-routing.module.ts index 97dbbef..e1f456c 100644 --- a/ogWebconsole/src/app/app-routing.module.ts +++ b/ogWebconsole/src/app/app-routing.module.ts @@ -15,14 +15,10 @@ import { PxeBootFilesComponent } from './components/ogboot/pxe-boot-files/pxe-bo import {OgbootStatusComponent} from "./components/ogboot/ogboot-status/ogboot-status.component"; import { OgdhcpComponent } from './components/ogdhcp/ogdhcp.component'; import { OgDhcpSubnetsComponent } from './components/ogdhcp/og-dhcp-subnets/og-dhcp-subnets.component'; -<<<<<<< HEAD -import { CommandsComponent } from './components/commands/commands.component'; import { CalendarComponent } from "./components/calendar/calendar.component"; -======= import { CommandsComponent } from './components/commands/main-commands/commands.component'; import { CommandsGroupsComponent } from './components/commands/commands-groups/commands-groups.component'; import { CommandsTaskComponent } from './components/commands/commands-task/commands-task.component'; ->>>>>>> 30cd43ff0fcccafbf6d2b7534dd31ba0b3c2c257 const routes: Routes = [ { path: '', redirectTo: 'auth/login', pathMatch: 'full' }, { diff --git a/ogWebconsole/src/app/components/calendar/calendar.component.html b/ogWebconsole/src/app/components/calendar/calendar.component.html index d735aa8..990232f 100644 --- a/ogWebconsole/src/app/components/calendar/calendar.component.html +++ b/ogWebconsole/src/app/components/calendar/calendar.component.html @@ -39,7 +39,7 @@ Acciones - + diff --git a/ogWebconsole/src/app/components/calendar/calendar.component.ts b/ogWebconsole/src/app/components/calendar/calendar.component.ts index 756fcec..0a1671d 100644 --- a/ogWebconsole/src/app/components/calendar/calendar.component.ts +++ b/ogWebconsole/src/app/components/calendar/calendar.component.ts @@ -90,10 +90,10 @@ export class CalendarComponent implements OnInit { console.log('Syncing calendars'); } - editImage(calendar: any): void { + editCalendar(calendar: any): void { const dialogRef = this.dialog.open(CreateCalendarComponent, { width: '700px', - data: calendar + data: calendar['@id'] }); dialogRef.afterClosed().subscribe(result => { @@ -103,28 +103,28 @@ export class CalendarComponent implements OnInit { }); } - deleteCalendar(role: any): void { + deleteCalendar(calendar: any): void { const dialogRef = this.dialog.open(DeleteModalComponent, { - width: '300px', - data: { name: role.name } + width: '400px', + data: { name: calendar.name } }); dialogRef.afterClosed().subscribe(result => { if (result) { - const apiUrl = `${this.baseUrl}/remote-calendars/${role.uuid}`; + const apiUrl = `${this.baseUrl}${calendar['@id']}`; this.http.delete(apiUrl).subscribe({ next: () => { - console.log('Role deleted successfully'); + console.log('Calendar deleted successfully'); this.search(); - this.toastService.success('Role deleted successfully'); + this.toastService.success('Calendar deleted successfully'); }, error: (error) => { - console.error('Error deleting role:', error); + this.toastService.error('Error deleting calendar'); } }); } else { - console.log('Role deletion cancelled'); + console.log('calendar deletion cancelled'); } }); } diff --git a/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.css b/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.css index 8c6148f..13e2689 100644 --- a/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.css +++ b/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.css @@ -16,8 +16,6 @@ } .checkbox-group { - display: flex; - flex-direction: column; margin: 15px 0; align-items: flex-start; } diff --git a/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.html b/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.html index 14fa504..8249a20 100644 --- a/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.html +++ b/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.html @@ -4,12 +4,20 @@
Selecciona los días de la semana -
- - {{ day }} - +
+
+ + {{ day }} + +
+
+ + {{ day }} + +
+
Hora de inicio diff --git a/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.ts b/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.ts index e9ccbb8..6711779 100644 --- a/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.ts +++ b/ogWebconsole/src/app/components/calendar/create-calendar-rule/create-calendar-rule.component.ts @@ -30,7 +30,7 @@ export class CreateCalendarRuleComponent { private toastService: ToastrService, private http: HttpClient, public dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) public data: any + @Inject(MAT_DIALOG_DATA) public data: any, ) { } ngOnInit(): void { @@ -78,7 +78,7 @@ export class CreateCalendarRuleComponent { remoteCalendar: this.calendarId, busyWeekDays: this.selectedDaysIndices, busyFromHour: this.busyFromHour, - busyToHour: this.busyFromHour, + busyToHour: this.busyToHour, availableFromDate: this.availableFromDate, availableToDate: this.availableToDate, isRemoteAvailable: this.isRemoteAvailable, diff --git a/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.html b/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.html index b351cfa..c90baeb 100644 --- a/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.html +++ b/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.html @@ -1,15 +1,21 @@

{{ isEditMode ? 'Editar' : 'Añadir' }} calendario

- - Nombre - + + mode_edit +
+
Reglas
+ +
-
Reglas
- + + +
@@ -23,7 +29,7 @@ -
@@ -35,5 +41,5 @@ - + diff --git a/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.ts b/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.ts index 7af9681..5e7254e 100644 --- a/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.ts +++ b/ogWebconsole/src/app/components/calendar/create-calendar/create-calendar.component.ts @@ -3,6 +3,8 @@ import {ToastrService} from "ngx-toastr"; import {HttpClient} from "@angular/common/http"; import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material/dialog"; import {CreateCalendarRuleComponent} from "../create-calendar-rule/create-calendar-rule.component"; +import {DataService} from "../data.service"; +import {DeleteModalComponent} from "../../../shared/delete_modal/delete-modal/delete-modal.component"; @Component({ selector: 'app-create-calendar', @@ -22,17 +24,29 @@ export class CreateCalendarComponent implements OnInit { public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: any, public dialog: MatDialog, + private dataService: DataService, ) { } ngOnInit(): void { if (this.data) { - this.isEditMode = true; - this.name = this.data.name; - this.remoteCalendarRules = this.data.remoteCalendarRules; - this.calendarId = this.data['@id'] + this.load() } } + load(): void { + this.dataService.getRemoteCalendar(this.data).subscribe({ + next: (response) => { + this.isEditMode = true; + this.name = response.name; + this.remoteCalendarRules = response.remoteCalendarRules; + this.calendarId = this.data; + }, + error: (err) => { + console.error('Error fetching remote calendar:', err); + } + }); + } + onNoClick(): void { this.dialogRef.close(); } @@ -48,6 +62,7 @@ export class CreateCalendarComponent implements OnInit { next: (response) => { this.toastService.success('Calendar updated successfully'); this.dialogRef.close(true); + this.load() }, error: (error) => { console.error('Error:', error); @@ -60,6 +75,7 @@ export class CreateCalendarComponent implements OnInit { next: (response) => { this.toastService.success('Calendar created successfully'); this.dialogRef.close(true); + this.load() }, error: (error) => { console.error('Error:', error); @@ -80,6 +96,32 @@ export class CreateCalendarComponent implements OnInit { dialogRef.afterClosed().subscribe(result => { if (result) { + this.load() + } + }); + } + + deleteCalendarRule(rule: any): void { + const dialogRef = this.dialog.open(DeleteModalComponent, { + width: '400px', + }); + + dialogRef.afterClosed().subscribe(result => { + if (result) { + const apiUrl = `${this.baseUrl}${rule['@id']}`; + + this.http.delete(apiUrl).subscribe({ + next: () => { + console.log('Calendar deleted successfully'); + this.load(); + this.toastService.success('Calendar deleted successfully'); + }, + error: (error) => { + this.toastService.error('Error deleting calendar'); + } + }); + } else { + console.log('calendar deletion cancelled'); } }); } diff --git a/ogWebconsole/src/app/components/calendar/data.service.ts b/ogWebconsole/src/app/components/calendar/data.service.ts index ee82d23..ba9b568 100644 --- a/ogWebconsole/src/app/components/calendar/data.service.ts +++ b/ogWebconsole/src/app/components/calendar/data.service.ts @@ -29,4 +29,20 @@ export class DataService { }) ); } + + getRemoteCalendar(id: string): Observable { + return this.http.get(`${this.baseUrl}${id}`).pipe( + map(response => { + if (response.name && response.remoteCalendarRules) { + return response; + } else { + throw new Error('Unexpected response format'); + } + }), + catchError(error => { + console.error('Error fetching calendar', error); + return throwError(error); + }) + ); + } }