mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
pull from developer-prod made
This commit is contained in:
@@ -30,6 +30,7 @@ import { Capacitor } from '@capacitor/core';
|
||||
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"
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
maxWidth: 800,
|
||||
@@ -130,7 +131,8 @@ export class NewPublicationPage implements OnInit {
|
||||
private RouteService: RouteService,
|
||||
public FileService: FileService,
|
||||
private mediaCapture: MediaCapture,
|
||||
public checkFileType: checkFileTypeService
|
||||
public checkFileType: checkFileTypeService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -695,3 +697,4 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
<div class="title-content width-100 d-flex justify-space-between">
|
||||
<div class="div-title flex-grow-1">
|
||||
<ion-label class="title font-25-em">Acções</ion-label>
|
||||
<!-- <div>
|
||||
<input type="file" (change)="onFileSelect($event)" />
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
<div *ngIf="!intent" class="div-icon">
|
||||
|
||||
@@ -15,6 +15,10 @@ import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { NewPublicationPage } from './new-publication/new-publication.page';
|
||||
import { ChunkService } from 'src/app/services/stream/chunk.service'
|
||||
import { StreamService } from 'src/app/services/stream/stream.service'
|
||||
import { HttpClient, HttpHeaders, HttpEventType } from '@angular/common/http';
|
||||
|
||||
// import { ActionModel } from 'src/app/models/beast-orm';
|
||||
|
||||
|
||||
@@ -70,6 +74,9 @@ export class PublicationsPage implements OnInit {
|
||||
public ThemeService: ThemeService,
|
||||
public p: PermissionService,
|
||||
private storage: Storage,
|
||||
private ChunkService: ChunkService,
|
||||
private StreamService:StreamService,
|
||||
private http: HttpClient,
|
||||
|
||||
) {
|
||||
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
||||
@@ -153,11 +160,11 @@ export class PublicationsPage implements OnInit {
|
||||
this.publications.GetPublicationFolderList().subscribe(async res => {
|
||||
this.showLoader = false;
|
||||
const folders: PublicationFolder[] = this.getPublicationFolderMap(res)
|
||||
|
||||
|
||||
this.publicationsEventFolderList = folders.filter((e)=>e.ActionType == 'Evento')
|
||||
|
||||
await this.storage.set('actionsEvents', this.publicationsEventFolderList);
|
||||
|
||||
|
||||
this.showLoader = false;
|
||||
|
||||
// (async ()=> {
|
||||
@@ -199,35 +206,79 @@ export class PublicationsPage implements OnInit {
|
||||
}
|
||||
|
||||
async getFromDB() {
|
||||
|
||||
|
||||
//const folders: PublicationFolder[] = await ActionModel.all()
|
||||
//this.showLoader = false;
|
||||
// this.publicationsEventFolderList = folders
|
||||
|
||||
|
||||
this.storage.get('actionsEvents').then((events = []) => {
|
||||
|
||||
|
||||
if(Array.isArray(events)) {
|
||||
const folders: PublicationFolder[] = this.getPublicationFolderMap(events)
|
||||
|
||||
this.showLoader = false;
|
||||
this.publicationsEventFolderList = folders
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
this.storage.get('actionsViagens').then((viagens = []) => {
|
||||
|
||||
|
||||
if(Array.isArray(viagens)) {
|
||||
const folders: PublicationFolder[] = this.getPublicationFolderMap(viagens)
|
||||
|
||||
this.publicationsTravelFolderList = folders
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async onFileSelect(event: any) {
|
||||
|
||||
const file:File = event.target.files[0];
|
||||
|
||||
|
||||
const chunkSize = 1024 * 1024; // Adjust the chunk size as needed
|
||||
const chunks = [];
|
||||
let offset = 0;
|
||||
let i = 0;
|
||||
let j = 0;
|
||||
|
||||
function count () {
|
||||
j++
|
||||
return j
|
||||
}
|
||||
|
||||
while (offset < file.size) {
|
||||
const chunk = file.slice(offset, offset + chunkSize);
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = async () => {
|
||||
|
||||
const headers = new HttpHeaders()
|
||||
.append('X-File-Name', "fileName")
|
||||
.append('X-File-Extension', "mp4")
|
||||
.append('X-File-Content-Length', i.toString())
|
||||
.append('X-File-Index', count().toString());
|
||||
|
||||
const a = new Uint8Array(reader.result as ArrayBuffer)
|
||||
await this.http.post('http://localhost:3001/upload', a.buffer, { headers, responseType: 'blob' }).toPromise();
|
||||
|
||||
|
||||
};
|
||||
reader.readAsArrayBuffer(chunk);
|
||||
offset += chunkSize;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async editAction(folderId?: string) {
|
||||
const modal = await this.modalController.create({
|
||||
component: EditActionPage,
|
||||
@@ -254,7 +305,7 @@ export class PublicationsPage implements OnInit {
|
||||
if(error.status == 0) {
|
||||
this.toastService._badRequest('Sem acesso à internet. Por favor verifique sua conexão')
|
||||
} else {
|
||||
|
||||
|
||||
this.toastService._badRequest()
|
||||
}
|
||||
}
|
||||
@@ -262,7 +313,7 @@ export class PublicationsPage implements OnInit {
|
||||
loader.remove()
|
||||
this.refreshing()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async AddPublicationFolder(item?: any) {
|
||||
@@ -280,7 +331,7 @@ export class PublicationsPage implements OnInit {
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
|
||||
modal.onDidDismiss().then(() => {
|
||||
this.getActions();
|
||||
});
|
||||
@@ -368,7 +419,7 @@ export class PublicationsPage implements OnInit {
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
|
||||
modal.onDidDismiss();
|
||||
await modal.present();
|
||||
|
||||
@@ -502,7 +553,7 @@ export class PublicationsPage implements OnInit {
|
||||
},
|
||||
//translucent: true
|
||||
});
|
||||
|
||||
|
||||
modal.onDidDismiss().then(res => {
|
||||
if (res['data'] == 'edit') {
|
||||
this.closeDesktopComponent();
|
||||
|
||||
Reference in New Issue
Block a user