mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
add try catch to video.foreach and video.pause
This commit is contained in:
@@ -31,6 +31,9 @@ import { File } from '@ionic-native/file/ngx';
|
||||
import { Media } from '@ionic-native/media/ngx';
|
||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { App } from '@capacitor/app';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
maxWidth: 800,
|
||||
@@ -133,7 +136,8 @@ export class NewPublicationPage implements OnInit {
|
||||
public FileService: FileService,
|
||||
private mediaCapture: MediaCapture,
|
||||
public checkFileType: checkFileTypeService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
private FileValidatorService: FileValidatorService,
|
||||
private router: Router,
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -536,11 +540,12 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||
this.close();
|
||||
this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
|
||||
window["sharedContent"] = null;
|
||||
window["endSharedContent"] = null;
|
||||
|
||||
if(window["sharedContent"]) {
|
||||
this.router.navigate(['/home/publications', this.folderId]);
|
||||
return
|
||||
}
|
||||
|
||||
this.close();
|
||||
} catch (error) {
|
||||
this.httpErrorHandle.httpStatusHandle(error)
|
||||
@@ -562,6 +567,10 @@ export class NewPublicationPage implements OnInit {
|
||||
this.modalController.dismiss(this.publication).then(() => {
|
||||
this.showLoader = true;
|
||||
});
|
||||
|
||||
if(window["sharedContent"]) {
|
||||
this.closeApp();
|
||||
}
|
||||
}
|
||||
|
||||
clear() {
|
||||
@@ -782,5 +791,9 @@ export class NewPublicationPage implements OnInit {
|
||||
this.seletedContent.splice(index, 1)
|
||||
}
|
||||
|
||||
closeApp() {
|
||||
App.exitApp()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div *ngIf="!intent" class="div-icon">
|
||||
<div class="div-icon">
|
||||
<button *ngIf="p.userPermission([p.permissionList.Actions.create])" title="Adicionar nova ação presidencial" class="btn-no-color" (click)="AddPublicationFolder()">
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " slot="icon-only" src='assets/images/icons-add.svg'></ion-icon>
|
||||
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="icon-only" src='assets/images/theme/gov/icons-add.svg'></ion-icon>
|
||||
@@ -34,12 +34,12 @@
|
||||
<ion-icon class=" font-45-em" src="assets/images/theme/gov/icon-reload.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div *ngIf="intent" class="div-icon">
|
||||
<!-- <div *ngIf="intent" class="div-icon">
|
||||
|
||||
<button title="Atualizar" class="btn-no-color" (click)="close()">
|
||||
<ion-icon class=" font-45-em" src="assets/images/icons-search-close.svg"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -349,7 +349,7 @@ export class PublicationsPage implements OnInit {
|
||||
componentProps: {
|
||||
publicationType: publicationType,
|
||||
folderId: folderId,
|
||||
intent: intent
|
||||
intent: window["sharedContent"]
|
||||
},
|
||||
cssClass: 'new-publication modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
@@ -362,8 +362,8 @@ export class PublicationsPage implements OnInit {
|
||||
}
|
||||
|
||||
goToPublicationsList(folderId: string) {
|
||||
if(this.intent){
|
||||
this.AddPublication('2',folderId,this.intent)
|
||||
if(window["sharedContent"]){
|
||||
this.AddPublication('2',folderId,window["sharedContent"])
|
||||
return
|
||||
}
|
||||
if (window.innerWidth < 701) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, ElementRef, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { ModalController,IonicSlides } from '@ionic/angular';
|
||||
import { ModalController, IonicSlides } from '@ionic/angular';
|
||||
import { Publication } from 'src/app/models/publication';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationPipe } from 'src/app/pipes/publication.pipe';
|
||||
@@ -16,9 +16,10 @@ import { Storage } from '@ionic/storage';
|
||||
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
||||
// import { CapacitorVideoPlayer } from 'capacitor-video-player';
|
||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
||||
import { PublicationVideoManagerService } from "src/app/services/publication/publication-video-manager.service"
|
||||
import { PublicationVideoManagerService } from "src/app/services/publication/publication-video-manager.service"
|
||||
import { StopvideoService } from "src/app/services/stopvideo.service"
|
||||
import { Result } from 'neverthrow';
|
||||
import { App } from '@capacitor/app';
|
||||
@Component({
|
||||
selector: 'app-view-publications',
|
||||
templateUrl: './view-publications.page.html',
|
||||
@@ -43,7 +44,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
initialSlide: 0,
|
||||
speed: 400,
|
||||
loop: true,
|
||||
pagination : {
|
||||
pagination: {
|
||||
el: '.swiper-pagination',
|
||||
clickable: true
|
||||
}
|
||||
@@ -70,13 +71,13 @@ export class ViewPublicationsPage implements OnInit {
|
||||
public stopvideoService: StopvideoService) {
|
||||
|
||||
|
||||
/* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */
|
||||
/* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */
|
||||
|
||||
|
||||
setTimeout(() => {
|
||||
setTimeout(() => {
|
||||
|
||||
console.log(this.VideoManager.nativeElement)
|
||||
}, 2000)
|
||||
console.log(this.VideoManager.nativeElement)
|
||||
}, 2000)
|
||||
|
||||
this.createPublicationList()
|
||||
|
||||
@@ -122,7 +123,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
onVisibilityChange = (e: boolean) => {
|
||||
|
||||
console.log("nice to have", e)
|
||||
if(!e) {
|
||||
if (!e) {
|
||||
this.stopVideo()
|
||||
}
|
||||
}
|
||||
@@ -131,26 +132,30 @@ export class ViewPublicationsPage implements OnInit {
|
||||
stopVideo() {
|
||||
var videos = document.querySelectorAll('video');
|
||||
|
||||
// Pause each video
|
||||
videos.forEach(function (video) {
|
||||
video.pause();
|
||||
})
|
||||
try {
|
||||
// Pause each video
|
||||
videos.forEach(function (video) {
|
||||
video.pause();
|
||||
})
|
||||
|
||||
|
||||
this.videoElements.forEach(videoElement => {
|
||||
// You can access the native HTML video element using videoElement.nativeElement
|
||||
const video: HTMLVideoElement = videoElement.nativeElement;
|
||||
this.videoElements.forEach(videoElement => {
|
||||
// You can access the native HTML video element using videoElement.nativeElement
|
||||
const video: HTMLVideoElement = videoElement.nativeElement;
|
||||
|
||||
video.pause()
|
||||
// Do something with each video element
|
||||
// console.log(video);
|
||||
});
|
||||
video.pause()
|
||||
// Do something with each video element
|
||||
// console.log(video);
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
|
||||
if (typeof (this.folderId) == 'object') {
|
||||
this.folderId = (this.folderId as any )['ProcessId']
|
||||
this.folderId = (this.folderId as any)['ProcessId']
|
||||
}
|
||||
|
||||
this.createPublicationList()
|
||||
@@ -186,6 +191,10 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}
|
||||
|
||||
goBack() {
|
||||
if (window["sharedContent"]) {
|
||||
App.exitApp();
|
||||
return
|
||||
}
|
||||
this.router.navigate(['/home/publications']);
|
||||
}
|
||||
|
||||
@@ -274,13 +283,13 @@ export class ViewPublicationsPage implements OnInit {
|
||||
} else {
|
||||
|
||||
|
||||
let a: any = Object.assign({},this.publicationFolderService.publicationList[folderId][findIndex])
|
||||
let a: any = Object.assign({}, this.publicationFolderService.publicationList[folderId][findIndex])
|
||||
let b: any = Object.assign({}, publicationDetails)
|
||||
|
||||
a.Files = a.Files.length
|
||||
b.Files = b.Files.length
|
||||
|
||||
if(JSON.stringify(a) != JSON.stringify(b)) {
|
||||
if (JSON.stringify(a) != JSON.stringify(b)) {
|
||||
|
||||
// console.log({a, b})
|
||||
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
||||
@@ -350,9 +359,9 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
getSortedPublications(): Publication[] {
|
||||
getSortedPublications(): Publication[] {
|
||||
const unsortedPublications = this.publicationFolderService.publicationList[this.folderId];
|
||||
|
||||
|
||||
if (unsortedPublications) {
|
||||
// Copiar a lista original para evitar alterações indesejadas
|
||||
const publicationsCopy = [...unsortedPublications];
|
||||
|
||||
Reference in New Issue
Block a user