mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +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 { Media } from '@ionic-native/media/ngx';
|
||||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
||||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||||
|
import { App } from '@capacitor/app';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
quality: 0.5,
|
quality: 0.5,
|
||||||
maxWidth: 800,
|
maxWidth: 800,
|
||||||
@@ -133,7 +136,8 @@ export class NewPublicationPage implements OnInit {
|
|||||||
public FileService: FileService,
|
public FileService: FileService,
|
||||||
private mediaCapture: MediaCapture,
|
private mediaCapture: MediaCapture,
|
||||||
public checkFileType: checkFileTypeService,
|
public checkFileType: checkFileTypeService,
|
||||||
private FileValidatorService: FileValidatorService
|
private FileValidatorService: FileValidatorService,
|
||||||
|
private router: Router,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
this.publicationType = this.navParams.get('publicationType');
|
this.publicationType = this.navParams.get('publicationType');
|
||||||
@@ -536,10 +540,11 @@ export class NewPublicationPage implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||||
this.close();
|
|
||||||
this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
|
this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
|
||||||
window["sharedContent"] = null;
|
if(window["sharedContent"]) {
|
||||||
window["endSharedContent"] = null;
|
this.router.navigate(['/home/publications', this.folderId]);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.close();
|
this.close();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -562,6 +567,10 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.modalController.dismiss(this.publication).then(() => {
|
this.modalController.dismiss(this.publication).then(() => {
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if(window["sharedContent"]) {
|
||||||
|
this.closeApp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
@@ -782,5 +791,9 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.seletedContent.splice(index, 1)
|
this.seletedContent.splice(index, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeApp() {
|
||||||
|
App.exitApp()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
</div> -->
|
</div> -->
|
||||||
</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()">
|
<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 == '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>
|
<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>
|
<ion-icon class=" font-45-em" src="assets/images/theme/gov/icon-reload.svg"></ion-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="intent" class="div-icon">
|
<!-- <div *ngIf="intent" class="div-icon">
|
||||||
|
|
||||||
<button title="Atualizar" class="btn-no-color" (click)="close()">
|
<button title="Atualizar" class="btn-no-color" (click)="close()">
|
||||||
<ion-icon class=" font-45-em" src="assets/images/icons-search-close.svg"></ion-icon>
|
<ion-icon class=" font-45-em" src="assets/images/icons-search-close.svg"></ion-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ export class PublicationsPage implements OnInit {
|
|||||||
componentProps: {
|
componentProps: {
|
||||||
publicationType: publicationType,
|
publicationType: publicationType,
|
||||||
folderId: folderId,
|
folderId: folderId,
|
||||||
intent: intent
|
intent: window["sharedContent"]
|
||||||
},
|
},
|
||||||
cssClass: 'new-publication modal modal-desktop',
|
cssClass: 'new-publication modal modal-desktop',
|
||||||
backdropDismiss: false
|
backdropDismiss: false
|
||||||
@@ -362,8 +362,8 @@ export class PublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToPublicationsList(folderId: string) {
|
goToPublicationsList(folderId: string) {
|
||||||
if(this.intent){
|
if(window["sharedContent"]){
|
||||||
this.AddPublication('2',folderId,this.intent)
|
this.AddPublication('2',folderId,window["sharedContent"])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (window.innerWidth < 701) {
|
if (window.innerWidth < 701) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Component, ElementRef, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
import { Component, ElementRef, OnInit, QueryList, ViewChild, ViewChildren } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
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 { Publication } from 'src/app/models/publication';
|
||||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||||
import { PublicationPipe } from 'src/app/pipes/publication.pipe';
|
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 { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
||||||
// import { CapacitorVideoPlayer } from 'capacitor-video-player';
|
// import { CapacitorVideoPlayer } from 'capacitor-video-player';
|
||||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
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 { StopvideoService } from "src/app/services/stopvideo.service"
|
||||||
import { Result } from 'neverthrow';
|
import { Result } from 'neverthrow';
|
||||||
|
import { App } from '@capacitor/app';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-view-publications',
|
selector: 'app-view-publications',
|
||||||
templateUrl: './view-publications.page.html',
|
templateUrl: './view-publications.page.html',
|
||||||
@@ -43,7 +44,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
initialSlide: 0,
|
initialSlide: 0,
|
||||||
speed: 400,
|
speed: 400,
|
||||||
loop: true,
|
loop: true,
|
||||||
pagination : {
|
pagination: {
|
||||||
el: '.swiper-pagination',
|
el: '.swiper-pagination',
|
||||||
clickable: true
|
clickable: true
|
||||||
}
|
}
|
||||||
@@ -70,13 +71,13 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
public stopvideoService: StopvideoService) {
|
public stopvideoService: StopvideoService) {
|
||||||
|
|
||||||
|
|
||||||
/* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */
|
/* this.publicationVideoManagerService.setContainer(this.VideoManager.nativeElement) */
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
||||||
console.log(this.VideoManager.nativeElement)
|
console.log(this.VideoManager.nativeElement)
|
||||||
}, 2000)
|
}, 2000)
|
||||||
|
|
||||||
this.createPublicationList()
|
this.createPublicationList()
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
onVisibilityChange = (e: boolean) => {
|
onVisibilityChange = (e: boolean) => {
|
||||||
|
|
||||||
console.log("nice to have", e)
|
console.log("nice to have", e)
|
||||||
if(!e) {
|
if (!e) {
|
||||||
this.stopVideo()
|
this.stopVideo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,26 +132,30 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
stopVideo() {
|
stopVideo() {
|
||||||
var videos = document.querySelectorAll('video');
|
var videos = document.querySelectorAll('video');
|
||||||
|
|
||||||
// Pause each video
|
try {
|
||||||
videos.forEach(function (video) {
|
// Pause each video
|
||||||
video.pause();
|
videos.forEach(function (video) {
|
||||||
})
|
video.pause();
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
this.videoElements.forEach(videoElement => {
|
this.videoElements.forEach(videoElement => {
|
||||||
// You can access the native HTML video element using videoElement.nativeElement
|
// You can access the native HTML video element using videoElement.nativeElement
|
||||||
const video: HTMLVideoElement = videoElement.nativeElement;
|
const video: HTMLVideoElement = videoElement.nativeElement;
|
||||||
|
|
||||||
video.pause()
|
video.pause()
|
||||||
// Do something with each video element
|
// Do something with each video element
|
||||||
// console.log(video);
|
// console.log(video);
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
|
|
||||||
if (typeof (this.folderId) == 'object') {
|
if (typeof (this.folderId) == 'object') {
|
||||||
this.folderId = (this.folderId as any )['ProcessId']
|
this.folderId = (this.folderId as any)['ProcessId']
|
||||||
}
|
}
|
||||||
|
|
||||||
this.createPublicationList()
|
this.createPublicationList()
|
||||||
@@ -186,6 +191,10 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goBack() {
|
goBack() {
|
||||||
|
if (window["sharedContent"]) {
|
||||||
|
App.exitApp();
|
||||||
|
return
|
||||||
|
}
|
||||||
this.router.navigate(['/home/publications']);
|
this.router.navigate(['/home/publications']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,13 +283,13 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
} else {
|
} 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)
|
let b: any = Object.assign({}, publicationDetails)
|
||||||
|
|
||||||
a.Files = a.Files.length
|
a.Files = a.Files.length
|
||||||
b.Files = b.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})
|
// console.log({a, b})
|
||||||
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
||||||
@@ -350,7 +359,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getSortedPublications(): Publication[] {
|
getSortedPublications(): Publication[] {
|
||||||
const unsortedPublications = this.publicationFolderService.publicationList[this.folderId];
|
const unsortedPublications = this.publicationFolderService.publicationList[this.folderId];
|
||||||
|
|
||||||
if (unsortedPublications) {
|
if (unsortedPublications) {
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class ChunksService {
|
||||||
|
|
||||||
|
chunkSize: number
|
||||||
|
private file: File
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
get totalChunks () {
|
||||||
|
return Math.ceil(this.file.size / this.chunkSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to read a chunk of the file
|
||||||
|
readChunk(start: number, end: number): Promise<ArrayBuffer> {
|
||||||
|
const file = this.file
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onload = () => {
|
||||||
|
if (reader.result instanceof ArrayBuffer) {
|
||||||
|
resolve(reader.result);
|
||||||
|
} else {
|
||||||
|
reject(new Error("Failed to read chunk"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsArrayBuffer(file.slice(start, end));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setFile(file) {
|
||||||
|
this.file = file
|
||||||
|
}
|
||||||
|
|
||||||
|
async getChunks(i: number,chunkSize: number) {
|
||||||
|
i--
|
||||||
|
if(i < this.totalChunks) {
|
||||||
|
const start = i * chunkSize;
|
||||||
|
const end = Math.min(start + chunkSize, this.file.size);
|
||||||
|
const chunk = await this.readChunk(start, end);
|
||||||
|
|
||||||
|
return chunk
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
|||||||
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
||||||
import { AskModalPage } from 'src/app/modals/ask-modal/ask-modal.page';
|
import { AskModalPage } from 'src/app/modals/ask-modal/ask-modal.page';
|
||||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
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 { StopvideoService } from "src/app/services/stopvideo.service";
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-view-publications',
|
selector: 'app-view-publications',
|
||||||
@@ -80,7 +80,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
onVisibilityChange = (e: boolean) => {
|
onVisibilityChange = (e: boolean) => {
|
||||||
|
|
||||||
console.log("nice to have", e)
|
console.log("nice to have", e)
|
||||||
if(!e) {
|
if (!e) {
|
||||||
/* this.stopVideo() */
|
/* this.stopVideo() */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,13 +228,13 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
this.publicationFolderService.revertPublicationOrder(folderId)
|
this.publicationFolderService.revertPublicationOrder(folderId)
|
||||||
} else {
|
} 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)
|
let b: any = Object.assign({}, publicationDetails)
|
||||||
|
|
||||||
a.Files = a.Files.length
|
a.Files = a.Files.length
|
||||||
b.Files = b.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})
|
// console.log({a, b})
|
||||||
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
||||||
@@ -343,7 +343,7 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
|
|
||||||
this.stopVideo();
|
this.stopVideo();
|
||||||
|
|
||||||
setTimeout(()=> {
|
setTimeout(() => {
|
||||||
this.openPublicationDetails.emit({ DocumentId, ProcessId });
|
this.openPublicationDetails.emit({ DocumentId, ProcessId });
|
||||||
}, 200)
|
}, 200)
|
||||||
|
|
||||||
@@ -370,30 +370,35 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
stopVideo() {
|
stopVideo() {
|
||||||
var videos = document.querySelectorAll('video');
|
var videos = document.querySelectorAll('video');
|
||||||
|
|
||||||
// Pause each video
|
try {
|
||||||
videos.forEach(function (video) {
|
// Pause each video
|
||||||
video.pause();
|
videos.forEach(function (video) {
|
||||||
})
|
video.pause();
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
this.videoElements.forEach(videoElement => {
|
this.videoElements.forEach(videoElement => {
|
||||||
// You can access the native HTML video element using videoElement.nativeElement
|
// You can access the native HTML video element using videoElement.nativeElement
|
||||||
const video: HTMLVideoElement = videoElement.nativeElement;
|
const video: HTMLVideoElement = videoElement.nativeElement;
|
||||||
|
|
||||||
video.pause()
|
video.pause()
|
||||||
// Do something with each video element
|
// Do something with each video element
|
||||||
// console.log(video);
|
// console.log(video);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public onScroll(event): void {
|
public onScroll(event): void {
|
||||||
if(this.lastScrollTop < event.detail.scrollTop) {
|
if (this.lastScrollTop < event.detail.scrollTop) {
|
||||||
// console.log("scrolling down")
|
// console.log("scrolling down")
|
||||||
} else {
|
} else {
|
||||||
// console.log("scrolling up")
|
// console.log("scrolling up")
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lastScrollTop = event.detail.scrollTop;
|
this.lastScrollTop = event.detail.scrollTop;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><filter id="a" color-interpolation-filters="sRGB" height="1.2568" width="1.2568" x="-.1284" y="-.1284"><feGaussianBlur stdDeviation="1.177"/></filter><g transform="matrix(.65100396 0 0 .65100396 -206.81858 -480.74574)"><path d="m336.1248 747.43738c-6.07513 0-11 4.92487-11 11s4.92487 11 11 11 11-4.92487 11-11-4.92487-11-11-11z" filter="url(#a)" opacity=".2"/><circle cx="336.1248" cy="757.42456" fill="#fff" r="11"/><path d="m331.1248 748.77713c-4.78293 2.76142-6.42168 8.87732-3.66025 13.66025 2.76142 4.78293 8.87732 6.42168 13.66025 3.66025 4.78293-2.76142 6.42168-8.87732 3.66025-13.66025-2.76142-4.78293-8.87732-6.42168-13.66025-3.66025zm1 1.73205c3.5319-2.03915 7.9742-1.07566 10.37408 2.09342l-13.74816 7.9375c-1.54456-3.66289-.15782-7.99178 3.37408-10.03092zm-2.37408 11.76298 13.74816-7.9375c1.54456 3.66289.15782 7.99178-3.37408 10.03092-3.5319 2.03915-7.9742 1.07566-10.37408-2.09342z" fill="#ed1515"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
Reference in New Issue
Block a user