diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 15dd524b6..43cda3bc2 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/package-lock.json b/package-lock.json index 0206d79da..1cc583623 100644 --- a/package-lock.json +++ b/package-lock.json @@ -151,6 +151,7 @@ "lite-server": "^2.6.1", "minisearch": "^6.0.1", "moment": "^2.29.3", + "neverthrow": "^6.1.0", "ng-lazyload-image": "^9.1.2", "ng2-pdf-viewer": "^3.0.8", "ngx-cookie-service": "^12.0.3", @@ -26954,6 +26955,11 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, + "node_modules/neverthrow": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/neverthrow/-/neverthrow-6.1.0.tgz", + "integrity": "sha512-xNbNjp/6M5vUV+mststgneJN9eJeJCDSYSBTaf3vxgvcKooP+8L0ATFpM8DGfmH7UWKJeoa24Qi33tBP9Ya3zA==" + }, "node_modules/next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", @@ -64285,6 +64291,11 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, + "neverthrow": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/neverthrow/-/neverthrow-6.1.0.tgz", + "integrity": "sha512-xNbNjp/6M5vUV+mststgneJN9eJeJCDSYSBTaf3vxgvcKooP+8L0ATFpM8DGfmH7UWKJeoa24Qi33tBP9Ya3zA==" + }, "next-tick": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", diff --git a/package.json b/package.json index c726aafe9..005d29067 100644 --- a/package.json +++ b/package.json @@ -165,6 +165,7 @@ "lite-server": "^2.6.1", "minisearch": "^6.0.1", "moment": "^2.29.3", + "neverthrow": "^6.1.0", "ng-lazyload-image": "^9.1.2", "ng2-pdf-viewer": "^3.0.8", "ngx-cookie-service": "^12.0.3", diff --git a/src/app/services/directives/visibility.directive.ts b/src/app/services/directives/visibility.directive.ts index cd75c19aa..b7820eb48 100644 --- a/src/app/services/directives/visibility.directive.ts +++ b/src/app/services/directives/visibility.directive.ts @@ -1,5 +1,5 @@ import { Directive, ElementRef, Input } from '@angular/core'; - +import { StopvideoService } from "src/app/services/stopvideo.service"; @Directive({ selector: '[appVisibility]' }) @@ -8,7 +8,10 @@ export class VisibilityDirective { intersectionObserver: IntersectionObserver; @Input() appVisibility: (arg: any) => void; - constructor(private elementRef: ElementRef) { + constructor( + private elementRef: ElementRef, + private stopvideoService: StopvideoService + ) { const options = { root: null, rootMargin: '0px', @@ -16,12 +19,13 @@ export class VisibilityDirective { }; - console.log(this.elementRef.nativeElement.parentElement, "=1=") + // this.stopvideoService.registerVideo() this.intersectionObserver = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { this.appVisibility(true); + this.stopvideoService.registerVideo(this.elementRef.nativeElement); } else { this.elementRef.nativeElement.pause() // Pause video when not visible diff --git a/src/app/services/directives/visibility1.directive.ts b/src/app/services/directives/visibility1.directive.ts index cd75c19aa..5711c2ba5 100644 --- a/src/app/services/directives/visibility1.directive.ts +++ b/src/app/services/directives/visibility1.directive.ts @@ -1,4 +1,5 @@ import { Directive, ElementRef, Input } from '@angular/core'; +import { StopvideoService } from '../stopvideo.service'; @Directive({ selector: '[appVisibility]' @@ -8,7 +9,10 @@ export class VisibilityDirective { intersectionObserver: IntersectionObserver; @Input() appVisibility: (arg: any) => void; - constructor(private elementRef: ElementRef) { + constructor( + private elementRef: ElementRef, + private stopvideoService: StopvideoService + ) { const options = { root: null, rootMargin: '0px', @@ -16,12 +20,11 @@ export class VisibilityDirective { }; - console.log(this.elementRef.nativeElement.parentElement, "=1=") - this.intersectionObserver = new IntersectionObserver(entries => { entries.forEach(entry => { if (entry.isIntersecting) { this.appVisibility(true); + this.stopvideoService.registerVideo(this.elementRef.nativeElement) } else { this.elementRef.nativeElement.pause() // Pause video when not visible diff --git a/src/app/services/http/http-service.service.ts b/src/app/services/http/http-service.service.ts index 2f981a4dd..ed4edbeb1 100644 --- a/src/app/services/http/http-service.service.ts +++ b/src/app/services/http/http-service.service.ts @@ -1,6 +1,6 @@ -import { HttpClient, HttpContext, HttpHeaders, HttpParams } from '@angular/common/http'; +import { HttpContext, HttpHeaders, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; -// import { Result, err, ok } from 'neverthrow' +import { HttpClient, HttpResponse, HttpErrorResponse } from '@angular/common/http'; import { tap, shareReplay, catchError } from "rxjs/operators"; import { Observable, of } from "rxjs"; diff --git a/src/app/services/stopvideo.service.spec.ts b/src/app/services/stopvideo.service.spec.ts new file mode 100644 index 000000000..c5e784d87 --- /dev/null +++ b/src/app/services/stopvideo.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { StopvideoService } from './stopvideo.service'; + +describe('StopvideoService', () => { + let service: StopvideoService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(StopvideoService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/stopvideo.service.ts b/src/app/services/stopvideo.service.ts new file mode 100644 index 000000000..1950ce903 --- /dev/null +++ b/src/app/services/stopvideo.service.ts @@ -0,0 +1,45 @@ +import { Injectable } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; + +@Injectable({ + providedIn: 'root' +}) +export class StopvideoService { + + video: HTMLVideoElement[] = [] + + constructor( + private router: Router + ) { + + this.router.events.forEach((event) => { + if (event instanceof NavigationEnd && !event.url.includes('/home/publications')) { + this.stopAndRemoveAllVideos(); + + } + }); + } + + + registerVideo(tagVideo: HTMLVideoElement) { + this.video.push(tagVideo); + } + + stopAndRemoveAllVideos() { + for (let i = 0; i < this.video.length; i++) { + const video = this.video[i]; + + // Pause the video + video.pause(); + + // Optionally, you can also reset the current time to start from the beginning + video.currentTime = 0; + + // Remove the video from the array + this.video.splice(i, 1); + + // Decrement the index to properly continue the loop + i--; + } + } +} diff --git a/src/app/shared/API/middleware/interface.d.ts b/src/app/shared/API/middleware/interface.d.ts index 6685a347f..d2c93d116 100644 --- a/src/app/shared/API/middleware/interface.d.ts +++ b/src/app/shared/API/middleware/interface.d.ts @@ -1,5 +1,103 @@ -export interface refreshToken { +export interface refreshTokenDTO { Authorization: string, refreshToken: null } + + +export interface EventsDTO { + HasAttachments: boolean + IsAllDayEvent: boolean + EventId: string + Subject: string + Location: string + CalendarId: string + CalendarName: string + StartDate: string + EndDate: string + Schedule: string + RequiredAttendees: any + OptionalAttendees: any + HumanDate: string + TimeZone: string + IsPrivate: boolean +} + + +export interface EventDetailsDTO { + HasAttachments: boolean + EventComunicationId: number + EventId: string + Subject: string + Body: EventDetailsBody + Location: string + CalendarId: string + CalendarName: string + StartDate: string + EndDate: string + EventType: string + Attendees: EventDetailsAttendee[] + IsMeeting: boolean + IsRecurring: boolean + IsAllDayEvent: boolean + AppointmentState: number + TimeZone: string + Organizer: EventDetailsOrganizer + InstanceId: any + Category: string + EventRecurrence: EventDetailsEventRecurrence + Attachments: EventDetailsAttachment[] + IsPrivate: boolean +} + +interface EventDetailsBodyDTO { + BodyType: number + Text: string +} + +interface EventDetailsAttendee { + Id: number + EmailAddress: string + Name: string + IsRequired: boolean + UserType: string + IsPR: boolean + Entity: any + Acknowledgment: boolean + RoleDescription: any +} + +interface EventDetailsOrganizer { + Id: number + EmailAddress: string + Name: string + IsRequired: boolean + UserType: any + IsPR: boolean + Entity: any + Acknowledgment: boolean + RoleDescription: any +} + +interface EventDetailsEventRecurrence { + Type: number + Day: any + DayOfWeek: any + Month: any + LastOccurrence: any +} + +interface EventDetailsAttachment { + Id: number + ParentId: string + Source: number + SourceId: string + Description: string + SourceName: string + CreateDate: string + Stakeholders: string + Link: string + Data: any + ApplicationId: number + FileSize: number +} diff --git a/src/app/shared/API/middleware/middleware-service.service.ts b/src/app/shared/API/middleware/middleware-service.service.ts index 22bdaa921..0e9607f68 100644 --- a/src/app/shared/API/middleware/middleware-service.service.ts +++ b/src/app/shared/API/middleware/middleware-service.service.ts @@ -1,8 +1,16 @@ import { Injectable } from '@angular/core'; import { environment } from 'src/environments/environment'; import { HttpServiceService } from 'src/app/services/http/http-service.service'; -import { Observable } from "rxjs"; -import { refreshToken } from "./interface" +import { Observable} from 'rxjs'; +import { EventsDTO, refreshTokenDTO } from "./interface"; +import { HttpParams } from '@angular/common/http'; +import { DetectCalendars, makeHeaderForCalendar } from '../../utils/utils'; +import { z } from "zod"; +import { ok, err } from 'neverthrow'; + +// let a = z +// let b = ok + @Injectable({ providedIn: 'root' }) @@ -12,12 +20,42 @@ export class MiddlewareServiceService { private HttpServiceService: HttpServiceService, ) {} - - refreshToken(refreshToken: string): Observable { + refreshToken(refreshToken: string): Observable { const data = { refreshToken: refreshToken } return this.HttpServiceService.put(environment.apiURL + "UserAuthentication/RefreshToken", data, {}) + // .pipe( + // map((response: HttpResponse) => { + // return response.body + // }) + // ); } + + // ================================ Calendar ================================================= + + GetEvents(startDate: string, endDate: string, calendarId): Observable { + + let geturl = environment.apiURL + 'calendar/GetEvents'; + geturl = geturl.replace('/V4/', '/V5/') + + let params = new HttpParams(); + + params = params.set("StartDate", startDate); + params = params.set("EndDate", endDate); + + const calendar = DetectCalendars(calendarId) + const header = makeHeaderForCalendar(calendar) + + let options = { + headers: header, + params: params + }; + + // return this.HttpServiceService.get(`${geturl}`, options); + + return {} as any + } + } diff --git a/src/app/shared/publication/edit-action/edit-action.page.html b/src/app/shared/publication/edit-action/edit-action.page.html index 16a5f0e76..2b44d84aa 100644 --- a/src/app/shared/publication/edit-action/edit-action.page.html +++ b/src/app/shared/publication/edit-action/edit-action.page.html @@ -68,7 +68,7 @@ displayFormat="D MMM YYYY H:mm" minuteValues="0,5,10,15,20,25,30,35,40,45,50,55" monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez" - min="{{endMinDate}}" + min="{{minDate}}" max="2025"> @@ -104,10 +104,9 @@ + - - @@ -122,6 +121,6 @@ Cancelar - + diff --git a/src/app/shared/publication/edit-action/edit-action.page.ts b/src/app/shared/publication/edit-action/edit-action.page.ts index d0baa1892..fa91e2b7e 100644 --- a/src/app/shared/publication/edit-action/edit-action.page.ts +++ b/src/app/shared/publication/edit-action/edit-action.page.ts @@ -41,7 +41,7 @@ export class EditActionPage implements OnInit { public touchUi = false; public enableMeridian = false; public minDate = new Date().toISOString().slice(0,10) - public endMinDate = new Date(new Date().getTime() + 15 * 60000); + public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0,10) public maxDate: any; public stepHour = 1; public stepMinute = 15; diff --git a/src/app/shared/utils/utils.ts b/src/app/shared/utils/utils.ts new file mode 100644 index 000000000..3d05c7d8c --- /dev/null +++ b/src/app/shared/utils/utils.ts @@ -0,0 +1,17 @@ +import { HttpHeaders } from "@angular/common/http"; +import { calendarInterface } from "src/app/models/user.model"; +import { SessionStore } from "src/app/store/session.service"; + +export function DetectCalendars(CalendarId) { + const calendars = SessionStore.user.OwnerCalendars.concat(SessionStore.user.SharedCalendars) + return calendars.find((e) => e.CalendarId == CalendarId) +} + +export function makeHeaderForCalendar(calendar: calendarInterface) { + let header = new HttpHeaders();; + header = header.set('Authorization', 'Bearer ' + SessionStore.user.Authorization); + header = header.set('CalendarId', calendar.CalendarId); + header = header.set('CalendarRoleId', calendar.CalendarRoleId); + header = header.set('CalendarName', calendar.CalendarName); + return header +}