mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 13:02:56 +00:00
add file chuck upload, file validation, redirect to home page incase route doesnt exist and refresh token interceptor
This commit is contained in:
@@ -228,7 +228,6 @@
|
||||
<!-- {{year.yearInfo.yearName}} -->
|
||||
<div *ngFor="let month of year.months " class="header-day" >
|
||||
<!-- {{ month.monthInfo.monthName | json }} -->
|
||||
<!-- <hr> -->
|
||||
|
||||
<div *ngFor="let day of month.days " class="EventListBox-container" >
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@ import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { sanitize } from "sanitize-filename-ts";
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
templateUrl: './group-messages.page.html',
|
||||
@@ -104,6 +108,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private file: File,
|
||||
private fileOpener: FileOpener,
|
||||
public RouteService: RouteService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
) {
|
||||
this.ChatSystemService.getUser()
|
||||
|
||||
@@ -507,7 +512,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"mimeType": audioFile.value.mimeType,
|
||||
},
|
||||
attachments: [{
|
||||
"title": fileName,
|
||||
"title": sanitize(fileName),
|
||||
"title_link_download": true,
|
||||
"type": "audio"
|
||||
}],
|
||||
@@ -828,37 +833,45 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
|
||||
|
||||
const fileName = file.name
|
||||
|
||||
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
||||
const validation = this.FileValidatorService.fileNameValidation(fileName)
|
||||
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
if(validation.isOk) {
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
||||
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
|
||||
|
||||
this.ChatSystemService.getGroupRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": file.name,
|
||||
"name": file.name,
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: encodedData
|
||||
}
|
||||
});
|
||||
this.ChatSystemService.getGroupRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": sanitize(fileName),
|
||||
"name": sanitize(fileName),
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: encodedData
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
this.toastService._badRequest("ficheiro invalido")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { NewEventPage } from '../../agenda/new-event/new-event.page';
|
||||
import { NotificationsService } from 'src/app/services/notifications.service';
|
||||
import { RochetChatConnectorService } from 'src/app/services/chat/rochet-chat-connector.service'
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { sanitize } from "sanitize-filename-ts";
|
||||
|
||||
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
|
||||
@@ -117,6 +121,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private fileOpener: FileOpener,
|
||||
private router: Router,
|
||||
public RochetChatConnectorService: RochetChatConnectorService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
) {
|
||||
|
||||
try {
|
||||
@@ -413,12 +418,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.fileService.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
|
||||
const validation = await this.FileValidatorService.validateAudioFromBlob(blob)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
@@ -429,7 +435,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"mimeType": audioFile.value.mimeType,
|
||||
},
|
||||
attachments: [{
|
||||
"title": fileName,
|
||||
"title": sanitize(fileName),
|
||||
"title_link_download": true,
|
||||
"type": "audio"
|
||||
}],
|
||||
@@ -759,7 +765,6 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
async addFileToChatMobile(types: typeof FileType[]) {
|
||||
console.log('add image from gallery')
|
||||
const roomId = this.roomId
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
@@ -852,43 +857,41 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
formData.append('blobFile', blob);
|
||||
console.log('add file', fileBase64) */
|
||||
|
||||
const fileName = file.name
|
||||
|
||||
const validation = this.FileValidatorService.fileNameValidation(fileName)
|
||||
|
||||
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
||||
console.log('TYPE', file.type)
|
||||
if(validation.isOk) {
|
||||
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
console.log(encodedData)
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
console.log('BLOB BLOB', blob)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
/* console.log('add file', fileBase64) */
|
||||
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": file.name,
|
||||
"name": file.name,
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: encodedData,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('file not supported')
|
||||
}
|
||||
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch((error) => {
|
||||
console.error(error);
|
||||
})));
|
||||
console.log(encodedData)
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
/* console.log('add file', fileBase64) */
|
||||
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": sanitize(fileName),
|
||||
"name": sanitize(fileName),
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: encodedData,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.toastService._badRequest("ficheiro invalido")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -21,27 +21,27 @@ export class AttendeesPageModal implements OnInit {
|
||||
eventPersons: EventPerson[];
|
||||
adding: "intervenient" | "CC";
|
||||
currentPath = window.location.pathname;
|
||||
|
||||
|
||||
taskParticipants:EventPerson[] = [];
|
||||
taskParticipantsCc:EventPerson[] = [];
|
||||
loggeduser: LoginUserRespose;
|
||||
@Input() loggedAttendSon: boolean;
|
||||
taskType: any;
|
||||
|
||||
|
||||
|
||||
constructor(
|
||||
private modalCtrl: ModalController,
|
||||
private modalCtrl: ModalController,
|
||||
private contactsService: ContactsService,
|
||||
private navParams: NavParams,
|
||||
private modalController: ModalController,
|
||||
public ThemeService: ThemeService,
|
||||
private router: Router,) {
|
||||
|
||||
|
||||
this.adding = this.navParams.get('adding');
|
||||
this.taskParticipants = this.navParams.get('taskParticipants');
|
||||
this.taskParticipantsCc = this.navParams.get('taskParticipantsCc');
|
||||
this.taskType = this.navParams.get('taskType');
|
||||
|
||||
|
||||
this.loggeduser = SessionStore.user;
|
||||
|
||||
}
|
||||
@@ -49,7 +49,7 @@ export class AttendeesPageModal implements OnInit {
|
||||
ngOnInit() {
|
||||
console.log('Pesquisa de contactos current path1',this.router.url)
|
||||
this.fetchContacts("");
|
||||
|
||||
|
||||
if(this.taskParticipants == null || this.taskParticipants == undefined){
|
||||
this.taskParticipants = [];
|
||||
}
|
||||
@@ -57,9 +57,9 @@ export class AttendeesPageModal implements OnInit {
|
||||
if(this.taskParticipantsCc == null || this.taskParticipantsCc == undefined){
|
||||
this.taskParticipantsCc = [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ngOnChanges(event) {}
|
||||
|
||||
save(){
|
||||
@@ -81,16 +81,16 @@ export class AttendeesPageModal implements OnInit {
|
||||
filterSearchList(itm: EventPerson): boolean {
|
||||
|
||||
const result = this.taskParticipants.concat( this.taskParticipantsCc).find((contact, index)=>{
|
||||
|
||||
|
||||
if(contact.Name.toLocaleLowerCase() == itm.Name.toLocaleLowerCase() && contact.EmailAddress.toLocaleLowerCase() == itm.EmailAddress.toLocaleLowerCase()){
|
||||
index = index;
|
||||
return contact;
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
return undefined == result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
remove(itm: EventPerson) {
|
||||
@@ -103,7 +103,7 @@ export class AttendeesPageModal implements OnInit {
|
||||
return contact;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
});
|
||||
|
||||
} else if (this.adding == "CC") {
|
||||
@@ -114,7 +114,7 @@ export class AttendeesPageModal implements OnInit {
|
||||
return contact;
|
||||
}
|
||||
return false;
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ export class AttendeesPageModal implements OnInit {
|
||||
if(this.adding == "intervenient"){
|
||||
itm.IsRequired = true;
|
||||
this.taskParticipants.push(itm);
|
||||
|
||||
|
||||
} else if (this.adding == "CC") {
|
||||
itm.IsRequired = false;
|
||||
this.taskParticipantsCc.push(itm);
|
||||
@@ -142,7 +142,7 @@ export class AttendeesPageModal implements OnInit {
|
||||
const index: number = result.findIndex((cont) => {
|
||||
return cont.EmailAddress.toLocaleLowerCase() == attendee.EmailAddress.toLocaleLowerCase()
|
||||
});
|
||||
|
||||
|
||||
result.splice(index, 1);
|
||||
|
||||
});
|
||||
@@ -153,16 +153,16 @@ export class AttendeesPageModal implements OnInit {
|
||||
this.showLoader = false;
|
||||
} else {
|
||||
this.contacts = result;
|
||||
console.log('Attendes Email',this.loggeduser.Email)
|
||||
// console.log('Attendes Email',this.loggeduser.Email)
|
||||
let filterLoggedUserEmail = this.contacts.filter(item => item.EmailAddress.toLocaleLowerCase() != this.loggeduser.Email.toLocaleLowerCase())
|
||||
if(this.taskType == 0 || this.taskType == 1){
|
||||
filterLoggedUserEmail = this.contacts.filter(item => item.IsPR == false)
|
||||
}
|
||||
console.log('Attendes Email', filterLoggedUserEmail)
|
||||
// console.log('Attendes Email', filterLoggedUserEmail)
|
||||
let filterEmptyEmail = filterLoggedUserEmail.filter(item => item.EmailAddress.toLocaleLowerCase() != "")
|
||||
|
||||
|
||||
this.contacts = filterEmptyEmail;
|
||||
console.log('Attendes Email', this.contacts)
|
||||
//console.log('Attendes Email', this.contacts)
|
||||
this.showLoader = false;
|
||||
|
||||
}
|
||||
@@ -183,4 +183,4 @@ export class AttendeesPageModal implements OnInit {
|
||||
}).reverse()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import { PublicationFolderService } from 'src/app/store/publication-folder.servi
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { FileService } from 'src/app/services/functions/file.service';
|
||||
import { readAndCompressImage } from 'browser-image-resizer';
|
||||
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
maxWidth: 800,
|
||||
@@ -100,7 +100,8 @@ export class NewPublicationPage implements OnInit {
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
public PublicationFolderService: PublicationFolderService,
|
||||
private RouteService: RouteService,
|
||||
public FileService: FileService
|
||||
public FileService: FileService,
|
||||
private FileValidatorService: FileValidatorService
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -132,18 +133,29 @@ export class NewPublicationPage implements OnInit {
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
|
||||
this.capturedImageTitle = 'foto';
|
||||
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
this.capturedImage,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
console.log('taked: ', picture)
|
||||
this.capturedImage = picture
|
||||
});
|
||||
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
|
||||
this.capturedImageTitle = 'foto';
|
||||
|
||||
const validation = await this.FileValidatorService.ValidateImage(this.capturedImage)
|
||||
|
||||
if(validation.isOk) {
|
||||
|
||||
validation.value
|
||||
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
this.capturedImage,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
this.capturedImage = picture
|
||||
});
|
||||
} else if(validation.isError) {
|
||||
validation.error
|
||||
|
||||
this.toastService._badRequest("imagem invalida")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async laodPicture() {
|
||||
@@ -156,15 +168,23 @@ export class NewPublicationPage implements OnInit {
|
||||
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
|
||||
this.capturedImageTitle = 'foto';
|
||||
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
this.capturedImage,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
console.log('Selected: ', picture)
|
||||
this.capturedImage = picture
|
||||
});
|
||||
|
||||
|
||||
const validation = await this.FileValidatorService.ValidateImage(this.capturedImage)
|
||||
if(validation.isOk) {
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
this.capturedImage,
|
||||
800, // maxWidth
|
||||
800, // maxHeight
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
console.log('Selected: ', picture)
|
||||
this.capturedImage = picture
|
||||
});
|
||||
} else {
|
||||
this.toastService._badRequest("imagem invalida")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -189,30 +209,6 @@ export class NewPublicationPage implements OnInit {
|
||||
});
|
||||
|
||||
|
||||
/* // in use
|
||||
async laodPicture() {
|
||||
|
||||
const capturedImage = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Photos
|
||||
});
|
||||
|
||||
const response = await fetch(capturedImage.webPath!);
|
||||
const blob = await response.blob();
|
||||
|
||||
this.convertBlobToBase64Worker.postMessage(blob);
|
||||
this.convertBlobToBase64Worker.onmessage = async (oEvent)=> {
|
||||
this.capturedImage = oEvent.data
|
||||
this.capturedImageTitle = 'foto'
|
||||
|
||||
}
|
||||
|
||||
} */
|
||||
|
||||
|
||||
|
||||
runValidation() {
|
||||
this.validateFrom = true
|
||||
}
|
||||
@@ -316,7 +312,7 @@ export class NewPublicationPage implements OnInit {
|
||||
else {
|
||||
|
||||
const date = formatDate(new Date(), 'yyyy-MM-dd HH:mm:ss')
|
||||
|
||||
|
||||
this.publication = {
|
||||
DateIndex: date,
|
||||
DocumentId: null,
|
||||
@@ -332,7 +328,7 @@ export class NewPublicationPage implements OnInit {
|
||||
const loader = this.toastService.loading()
|
||||
|
||||
try {
|
||||
|
||||
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||
this.close();
|
||||
this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
|
||||
@@ -373,7 +369,7 @@ export class NewPublicationPage implements OnInit {
|
||||
this.publicationTitle = 'Editar Publicação';
|
||||
this.pub = this.navParams.get('publication');
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,11 +379,11 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
//this.imgResultBeforeCompress = image;s
|
||||
this.imageCompress.getOrientation(this.capturedImage).then((orientation) => {
|
||||
|
||||
|
||||
this.imageCompress.compressFile(this.capturedImage, orientation, 90, 90).then(
|
||||
result => {
|
||||
this.capturedImage = result;
|
||||
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@@ -403,36 +399,37 @@ export class NewPublicationPage implements OnInit {
|
||||
return new Promise((resolve, reject) => {
|
||||
const image = new (window as any).Image();
|
||||
image.src = base64String;
|
||||
|
||||
|
||||
image.onload = async () => {
|
||||
const canvas = document.createElement('canvas');
|
||||
let newWidth = image.width;
|
||||
let newHeight = image.height;
|
||||
|
||||
|
||||
if (newWidth > maxWidth) {
|
||||
newHeight *= maxWidth / newWidth;
|
||||
newWidth = maxWidth;
|
||||
}
|
||||
|
||||
|
||||
if (newHeight > maxHeight) {
|
||||
newWidth *= maxHeight / newHeight;
|
||||
newHeight = maxHeight;
|
||||
}
|
||||
|
||||
|
||||
canvas.width = newWidth;
|
||||
canvas.height = newHeight;
|
||||
|
||||
|
||||
const context = canvas.getContext('2d');
|
||||
context?.drawImage(image, 0, 0, newWidth, newHeight);
|
||||
|
||||
|
||||
const compressedBase64 = canvas.toDataURL('image/jpeg', quality);
|
||||
resolve(compressedBase64);
|
||||
};
|
||||
|
||||
|
||||
image.onerror = (error) => {
|
||||
reject(error);
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,11 @@
|
||||
<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 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>
|
||||
|
||||
@@ -14,6 +14,10 @@ import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { Storage } from '@ionic/storage';
|
||||
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';
|
||||
|
||||
|
||||
@@ -68,6 +72,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"];
|
||||
@@ -143,11 +150,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 ()=> {
|
||||
@@ -189,35 +196,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,
|
||||
@@ -244,7 +295,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()
|
||||
}
|
||||
}
|
||||
@@ -252,7 +303,7 @@ export class PublicationsPage implements OnInit {
|
||||
loader.remove()
|
||||
this.refreshing()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async AddPublicationFolder(item?: any) {
|
||||
@@ -270,7 +321,7 @@ export class PublicationsPage implements OnInit {
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
|
||||
modal.onDidDismiss().then(() => {
|
||||
this.getActions();
|
||||
});
|
||||
@@ -336,7 +387,7 @@ export class PublicationsPage implements OnInit {
|
||||
cssClass: 'new-action modal modal-desktop',
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
|
||||
modal.onDidDismiss();
|
||||
await modal.present();
|
||||
|
||||
@@ -470,7 +521,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