This commit is contained in:
Peter Maquiran
2024-01-29 17:25:05 +01:00
19 changed files with 706 additions and 445 deletions
+2 -1
View File
@@ -19,7 +19,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true">
<activity
android:name=".MainActivity"
+1 -1
View File
@@ -62,7 +62,7 @@
"@capacitor/push-notifications": "^5.1.0",
"@capacitor/share": "^4.1.0",
"@capacitor/storage": "^1.2.5",
"@capawesome/capacitor-file-picker": "^5.1.1",
"@capawesome/capacitor-file-picker": "^5.3.0",
"@fortawesome/angular-fontawesome": "^0.9.0",
"@fortawesome/fontawesome-free": "^5.15.3",
"@fortawesome/fontawesome-svg-core": "^1.2.35",
+2 -1
View File
@@ -170,7 +170,8 @@ export interface expedienteTask {
Status : string
DispatchNumber: any
AttachmentsProcessLastInstanceID: any
InstanceID: any
InstanceID: any,
DraftIds: string
}
export interface ExpedienteTask {
+1 -1
View File
@@ -140,7 +140,7 @@
</thead>
</table>
<div class="calendar-conteiner-height overflow-hidden" [style.height]="listBoxService.height">
<div class="calendar-conteiner-height overflow-hidden" [style.height]="listBoxService.height">
<calendar
class="calendar-component"
[eventSource]="listToPresent"
+18 -4
View File
@@ -239,6 +239,14 @@ export class AgendaPage implements OnInit {
}
this.weekToShow()
this.eventService.registerOnLoadCalendars(()=> {
this.setCalendarByDefault(true)
const selectedCalendarIds = this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
this.tigerUpdate()
})
}
tigerUpdate() {
@@ -257,7 +265,7 @@ export class AgendaPage implements OnInit {
ngOnInit() {
this.setCalendarByDefault()
this.setCalendarByDefault(false)
const selectedCalendarIds = this.getSelectedAgendaCalendars();
this.listToPresent = this.CalendarStore.getEventsByCalendarIds(selectedCalendarIds)
@@ -338,14 +346,20 @@ export class AgendaPage implements OnInit {
}, 250)
}
setCalendarByDefault() {
if (!this.CalendarName) {
if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
setCalendarByDefault(force) {
if (!this.CalendarName || force) {
const prObject = this.eventService.calendarNamesAry.find(e => e?.RoleId == 100000014)
if(prObject) {
console.log({prObject})
this.CalendarName = prObject.Fullname
} else if (this.eventService.calendarNamesAry.includes('Meu calendario')) {
this.CalendarName = 'Meu calendario';
} else {
this.CalendarName = this.eventService.calendarNamesAry[0]
}
}
}
//Go to the next view of the calendar month/week/day
@@ -129,11 +129,14 @@ export class DiplomaAssinarPage implements OnInit {
"TaskStartDate": res.taskStartDate,
"InstanceID": res.workflowInstanceDataFields.InstanceID,
"FolderID": res.workflowInstanceDataFields.FolderID,
"DraftIds": res.workflowInstanceDataFields?.DraftIds
}
console.log('draftidsss',res.workflowInstanceDataFields.DraftIds);
this.fulltask = res;
let stringDraft = res.workflowInstanceDataFields.DraftIds;
this.DraftIds = stringDraft
this.DraftIds = res.workflowInstanceDataFields.DraftIds
console.log('draftidsss 111',this.DraftIds);
let split_stringDraft = stringDraft?.split(";").filter(Boolean);
@@ -233,11 +236,9 @@ export class DiplomaAssinarPage implements OnInit {
"dataFields": {
"ReviewUserComment": '',
"InstanceIDNew": this.task.InstanceID,
"DraftIds": "",
},
"AttachmentList": {
"ProcessInstanceID": this.task.InstanceID,
"DraftIds": null,
"Attachments": []
},
}
@@ -269,10 +270,11 @@ export class DiplomaAssinarPage implements OnInit {
modal.onDidDismiss().then(async (res) => {
const data = res.data
if (data == "Yes") {
console.log(' diploma Draft draft',this.task.DraftIds)
let body = {
"InstanceId": this.task.InstanceID,
"FolderId": this.task.FolderID,
"DraftIds": this.DraftIds,
"DraftIds": this.task.DraftIds,
"OriginalFileName": this.DraftNames
}
@@ -479,6 +481,8 @@ export class DiplomaAssinarPage implements OnInit {
try {
const resd = await this.processes.GetDraftByID(strg).toPromise();
console.log('DRAFT FFF',resd)
let object = {
"ApplicationId": "",
"Assunto": resd.data.description,
@@ -137,6 +137,7 @@ export class DiplomaPage implements OnInit {
"WorkflowName": res.workflowDisplayName,
"DeadlineType": res.workflowInstanceDataFields.DeadlineType,
"activityInstanceName": res.activityInstanceName,
"DraftIds": res.workflowInstanceDataFields?.DraftIds
}
this.fulltask = res;
console.log('Diploma anexo',this.fulltask.Documents )
@@ -537,6 +538,7 @@ export class DiplomaPage implements OnInit {
console.log('List of ids', strg)
const resd = await this.processes.GetDraftByID(strg).toPromise()
console.log('DRAFT FFF',resd)
let object = {
"ApplicationId": "",
"Assunto": resd.data.description,
@@ -370,7 +370,8 @@ export class ExpedienteDetailPage implements OnInit {
"Status": res.workflowInstanceDataFields.Status,
"DispatchNumber": res.workflowInstanceDataFields.DispatchNumber,
"AttachmentsProcessLastInstanceID": res.workflowInstanceDataFields.AttachmentsProcessLastInstanceID,
"InstanceID": res.workflowInstanceDataFields.InstanceID
"InstanceID": res.workflowInstanceDataFields.InstanceID,
"DraftIds": res.workflowInstanceDataFields?.DraftIds
}
this.fulltask = res;
@@ -132,7 +132,8 @@ export class ExpedientePrPage implements OnInit {
"activityInstanceName": res.activityInstanceName,
"Status": res.workflowInstanceDataFields.Status,
"Deadline": res.deadline,
"TaskStartDate": res.taskStartDate
"TaskStartDate": res.taskStartDate,
"DraftIds": res.workflowInstanceDataFields?.DraftIds
}
this.fulltask = res;
File diff suppressed because one or more lines are too long
@@ -81,7 +81,7 @@ export class PublicationsPage implements OnInit {
) {
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
this.intent = window["sharedContent"]
}
+80 -62
View File
@@ -35,10 +35,10 @@ export class EventsService {
headersSharedOficial: HttpHeaders;
headersSharedPessoal: HttpHeaders;
calendarIds = []
usersCalendarIds = []
hasSharedCalendar = false;
hasSharedOficial: boolean = false;
hasSharedPessoal: boolean = false;
@@ -48,7 +48,7 @@ export class EventsService {
hasOwnCalendar = false
calendarNames = {}
calendarNamesAry = []
calendarNamesAryNoPr = []
calendarNamesAryNoPrNMD = []
@@ -62,9 +62,13 @@ export class EventsService {
myCalendarNames = {}
hasAnyCalendar = false
HasMdGPR = false
onLoadCalendars: Function[] =[]
loadCalendars = false
onCalendarFinishLoad = new Subscribe({execute : false, deleteOnExecute: true})
constructor(
@@ -81,7 +85,7 @@ export class EventsService {
}
async setHeader () {
this.headers = new HttpHeaders();;
this.headersMdOficial = new HttpHeaders();;
this.headersMdPessoal = new HttpHeaders();;
@@ -95,7 +99,7 @@ export class EventsService {
this.headerOwnOficial= new HttpHeaders();;
this.headerOwnPessoal= new HttpHeaders();;
this.headerSharedOficial= new HttpHeaders();;
this.headerSharedPessoal= new HttpHeaders();;
@@ -106,7 +110,7 @@ export class EventsService {
this.calendarRole = []
this.calendrFullName = [];
this.calendarIds = []
this.calendarNamesAry = []
this.calendarNamesType = {}
this.calendarNamesAryNoPr = []
@@ -151,10 +155,10 @@ export class EventsService {
}
}
for (let sharedCalendar of SessionStore.user.SharedCalendars) {
this.hasAnyCalendar = true
if (sharedCalendar.CalendarName == 'Oficial') {
this.hasSharedOficial = true
@@ -288,17 +292,17 @@ export class EventsService {
this.calendarNames[sharedCalendar.CalendarId] = e.FullName
this.myCalendarNames[sharedCalendar.CalendarId] = e.FullName
if(!this.calendarNamesAry.find(x => x.Role == e.Role)) {
let objectShared = {
"Fullname": e.FullName,
"Role": e.Role,
"OwnerUserId": sharedCalendar.OwnerUserId,
"RoleId": sharedCalendar.CalendarRoleId
}
this.calendarNamesAry.push(objectShared)
if(e.Role == 'Presidente da República') {
@@ -306,7 +310,7 @@ export class EventsService {
} else {
this.calendarNamesAryNoPr.push(objectShared)
}
this.calendarNamesType[e.FullName] = {}
}
@@ -315,7 +319,7 @@ export class EventsService {
this.calendarNamesType[e.FullName]['RoleId'] = sharedCalendar.CalendarRoleId
this.calendarNamesType[e.FullName]['OwnerId'] = sharedCalendar.OwnerUserId
}
}
this.calendarNamesAryNoPrNMD = this.calendarNamesAryNoPr.filter((e)=> {
@@ -329,7 +333,7 @@ export class EventsService {
this.HasMdGPR = this.calendarNamesAryNoPr.find( (e)=> {
if(e.Role == 'Ministro e Director do Gabinete do PR') {
return true
return true
}
return false
})
@@ -341,7 +345,7 @@ export class EventsService {
this.hasAnyCalendar = true
}
this.calendarNamesAryReverse = this.calendarNamesAry.reverse();
this.onCalendarFinishLoad.executor();
@@ -366,8 +370,22 @@ export class EventsService {
}
})();
}
this.onLoadCalendars.forEach(e=> e());
this.loadCalendars = true
}
registerOnLoadCalendars(e: Function) {
if( this.loadCalendars) {
e()
} else {
this.onLoadCalendars.push(e)
}
}
@@ -397,7 +415,7 @@ export class EventsService {
isMyEvent(event: any) {
for (let calendar of SessionStore.user.OwnerCalendars) {
if(event.CalendarId == calendar.CalendarId) {
return true
@@ -409,14 +427,14 @@ export class EventsService {
return false
}
}
return false
}
detectCalendarNameByCalendarId(calendarId) {
for ( const property in this.calendarNamesType) {
if(this.calendarNamesType[property]?.['Oficial']) {
if(this.calendarNamesType[property]['OficialId'] == calendarId) {
@@ -429,7 +447,7 @@ export class EventsService {
}
}
}
}
@@ -542,7 +560,7 @@ export class EventsService {
}
}
}
const resFinal = prO.concat(prP);
return new Promise(resolve => {
return resolve(resFinal)
@@ -621,14 +639,14 @@ export class EventsService {
header = header.set('CalendarRoleId', agendasCalendar.CalendarRoleId);
header = header.set('CalendarName', agendasCalendar.CalendarName);
let geturl = environment.apiURL + 'calendar/GetEvents';
let params = new HttpParams();
params = params.set("StartDate", startdate);
params = params.set("EndDate", enddate);
let options = {
headers: header,
params: params
@@ -655,12 +673,12 @@ export class EventsService {
header = header.set('CalendarName', sharedCalendar.CalendarName);
let geturl = environment.apiURL + 'calendar/GetEvents';
let params = new HttpParams();
params = params.set("StartDate", startdate);
params = params.set("EndDate", enddate);
let options = {
headers: header,
params: params
@@ -686,7 +704,7 @@ export class EventsService {
params = params.set("StartDate", startdate);
params = params.set("EndDate", enddate);
let options = {
headers: this.headerSharedOficial,
@@ -725,7 +743,7 @@ export class EventsService {
}
}
const resFinal = prO.concat(prP);
return new Promise(resolve => {
@@ -746,7 +764,7 @@ export class EventsService {
headers: this.headersSharedOficial,
params: params
};
return this.http.get<Event[]>(`${geturl}`, options);
}
@@ -814,13 +832,13 @@ export class EventsService {
const calendar = this.DetectCalendars(calendarId)
const header = this.makeHeader(calendar)
if(header) {
let options = {
headers: header,
params: params
}
return this.http.get<Event>(`${geturl}`, options);
} else {
@@ -875,18 +893,18 @@ export class EventsService {
else if (SessionStore.user.Profile == 'PR') {
this.headers = this.headersPrOficial;
} else {
const headers = [
this.headerSharedOficial,
this.headerSharedPessoal,
this.headerOwnPessoal,
this.headerOwnOficial
]
]
const header = headers.find((header)=> {
return header?.get('CalendarId')?.includes(CalendarId)
})
this.headers = header
}
}
@@ -903,12 +921,12 @@ export class EventsService {
this.headerSharedPessoal,
this.headerOwnPessoal,
this.headerOwnOficial
]
]
const header = headers.find((header)=> {
return header?.get('CalendarId')?.includes(CalendarId)
})
this.headers = header
}
}
@@ -920,13 +938,13 @@ export class EventsService {
return this.http.put<Event>(`${puturl}`, event, options).pipe(
catchError(err => {
this.offlinemanager.storeRequestData('eventEdit', arrayReq);
throw new Error(err);
})
)
}
changeAgenda(body: any) {
const puturl = environment.apiURL + 'Calendar/MoveEvent';
@@ -948,7 +966,7 @@ export class EventsService {
let options: any;
switch (calendarName) {
case 'Oficial':
options = {
headers: this.headersMdOficial,
params: params
@@ -956,14 +974,14 @@ export class EventsService {
break;
case 'Pessoal':
options = {
headers: this.headersMdPessoal,
params: params
};
break;
}
return this.http.post<string>(`${puturl}`, event, options)
}
@@ -980,7 +998,7 @@ export class EventsService {
let options: any;
switch (calendarName) {
case 'Oficial':
options = {
headers: this.headersPrOficial,
params: params
@@ -988,7 +1006,7 @@ export class EventsService {
break;
case 'Pessoal':
options = {
headers: this.headersPrPessoal,
params: params
@@ -1006,7 +1024,7 @@ export class EventsService {
let params = new HttpParams();
const now = new Date();
event.TimeZone = now.toString().match(/([A-Z]+[\+-][0-9]+.*)/)[1];
event.Organizer = {
"Id": SessionStore.user.UserId,
@@ -1028,11 +1046,11 @@ export class EventsService {
headers: header,
params: params
};
return this.http.post<string>(`${puturl}`, event, options)
}
deleteEvent(eventid: string, eventDeleteType: number, calendarName: string) {
let arrayReq = [];
@@ -1084,7 +1102,7 @@ export class EventsService {
return this.http.delete(`${puturl}`, options).pipe(
catchError(err => {
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
throw new Error(err);
})
@@ -1143,8 +1161,8 @@ export class EventsService {
this.headerSharedPessoal,
this.headerOwnPessoal,
this.headerOwnOficial
]
]
const header = headers.find((header)=> {
return header?.get('CalendarId')?.includes(calendarId)
})
@@ -1159,20 +1177,20 @@ export class EventsService {
return this.http.delete(`${puturl}`, options).pipe(
catchError(err => {
this.offlinemanager.storeRequestData('eventDelete', arrayReq);
throw new Error(err);
})
)
} else {
}
throw('header not found')
}
}
@@ -1230,7 +1248,7 @@ export class EventsService {
const calendar = this.DetectCalendars(CalendarId)
const header = this.makeHeader(calendar)
options = {
headers: header,
params: params
@@ -1277,7 +1295,7 @@ export class EventsService {
}
break;
}
return this.http.post<any>(`${geturl}`, body, options)
}
@@ -1326,4 +1344,4 @@ const token = {
}
// decryptept token 873845982739845723987459823ouhfouidskfdjasklhdjfkusdhfliasdhfkljashdfkjhaskfhaskjdhfkasjdfhkjasdf
// decryptept token 873845982739845723987459823ouhfouidskfdjasklhdjfkusdhfliasdhfkljashdfkjhaskfhaskjdhfkasjdfhkjasdf
+13
View File
@@ -218,6 +218,8 @@ GetIdsPublicationNext(id:any){
//my last tries
CreatePublication(folderId:any,body:any){
console.log('body publi', body)
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/v2/posts';
let params = new HttpParams();
@@ -226,6 +228,17 @@ GetIdsPublicationNext(id:any){
headers: this.headers,
/* params: params */
};
/* this.http.post<any>(`${geturl}`, body, options).subscribe(
(resposta) => {
console.log('Resposta da solicitação POST:', resposta);
},
(erro) => {
console.error('Erro na solicitação POST:', erro);
});
*/
return this.http.post<any>(`${geturl}`, body, options)
}
@@ -217,11 +217,11 @@ export class DiplomaOptionsPage implements OnInit {
"dataFields": {
"ReviewUserComment": note,
"InstanceIDNew": this.task.InstanceID,
"DraftIds": "",
/* "DraftIds": "", */
},
"AttachmentList": {
"ProcessInstanceID": this.task.InstanceID,
"DraftIds": null,
/* "DraftIds": null, */
"Attachments": []
},
}
@@ -256,10 +256,12 @@ export class DiplomaOptionsPage implements OnInit {
modal.onDidDismiss().then(async (res) => {
const data = res.data
if (data == "Yes") {
console.log(' diploma options Draft draft',this.DraftIds)
let body = {
"InstanceId": this.task.InstanceID,
"FolderId": this.task.FolderID,
"DraftIds": this.DraftIds,
"DraftIds": this.task.DraftIds,
"OriginalFileName": this.DraftNames
}
const loader = this.toastService.loading()
@@ -148,6 +148,8 @@ export class EventDetailsDocumentsOptionsPage implements OnInit {
modal.onDidDismiss().then(async (res) => {
const data = res.data
if(data == "Yes") {
console.log(' event detais Draft draft',this.DraftIds)
let body = {
"InstanceId": this.InstanceID,
"FolderId": this.FolderID,
@@ -76,11 +76,16 @@
</div>
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video'" width="70" height="70"
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && checkDesktop() == true" width="70" height="70"
preload="metadata" webkit-playsinline="webkit-playsinline">
<source type="video/mp4" [src]="seleted.FileBase64">
</video>
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video' && checkTableDivice() == true" width="70" height="70"
preload="metadata" webkit-playsinline="webkit-playsinline">
<source type="video/mp4" [src]="'data:video/mp4;base64,' +seleted.FileBase64">
</video>
</div>
@@ -106,44 +111,43 @@
</div>
<!-- Current -->
<!-- <div *ngIf="!captureContent">
<div class="ion-item-container-no-border mb-20"
*ngIf="publication && !( publication.FileBase64 == 'data:image/jpg;base64,null' || publication.FileBase64 == '' ) && !capturedImage">
<ion-label class="attached-title pb-10">Fotografia Anexada</ion-label>
<div class="d-flex justify-content-between">
<div class="d-flex">
<ion-thumbnail slot="start">
<ion-img [(ngModel)]="publication.FileBase64" name="image" ngDefaultControl
[src]="publication.FileBase64"></ion-img>
</ion-thumbnail>
<ion-label class="pl-10">
<p>{{publication.OriginalFileName}}.{{publication.FileExtension}}</p>
<p hidden>size</p>
</ion-label>
</div>
<button class="btn-no-color" (click)="deletePublicationImage()">
<ion-icon name="close"></ion-icon>
</button>
</div>
</div>
</div> -->
<div class="hide-desktop">
<ion-label (click)="loadVideo()">
<div *ngIf="checkTableDivice()" style="display: flex;">
<div (click)="chossePhotoOrVideo()">
<div class="attach-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-add-photo.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'default' "
src="assets/images/icons-add-photo.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' "
src="assets/images/theme/gov/icons-add-photo.svg"></ion-icon>
</div>
<div class="attach-document">
<ion-label>Câmera</ion-label>
</div>
</div>
</div>
<div *ngIf="photoOrVideo" class="container-multiselect pt-10" style="width: 200px;">
<button id="container-multiselect" class="multiselect-button" (click)="takePicture()">Fotografia</button>
<button id="container-multiselect" class="multiselect-button" (click)="startVideoRecording()">Video</button>
</div>
<div *ngIf="checkTableDivice()" >
<ion-label (click)="loadVideoTablet()" class="cursor-pointer">
<div class="attach-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-add-photos.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' "
src="assets/images/theme/gov/icons-add-photos.svg"></ion-icon>
</div>
<div class="attach-document cursor-pointer">
<ion-label>Tirar Fotografia</ion-label>
<ion-label>Galeria</ion-label>
</div>
</ion-label>
</div>
<div >
<div *ngIf="checkDesktop()" >
<ion-label (click)="loadVideo()" class="cursor-pointer">
<div class="attach-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-add-photos.svg"></ion-icon>
@@ -151,7 +155,7 @@
src="assets/images/theme/gov/icons-add-photos.svg"></ion-icon>
</div>
<div class="attach-document cursor-pointer">
<ion-label>Anexar Fotografia</ion-label>
<ion-label>Galeria</ion-label>
</div>
</ion-label>
</div>
@@ -156,6 +156,10 @@ font-size: rem(25);
display: block;
}
.container-multiselect {
display: grid;
}
@@ -14,12 +14,17 @@ import { FileValidatorService } from "src/app/services/file/file-validator.servi
import { MiddlewareServiceService } from "src/app/shared/API/middleware/middleware-service.service";
import { LakefsRepositoryService } from '../../repository/lakefs/lakefs-repository.service';
import { ok, err, Result } from 'neverthrow';
import { ObjectMergeNotification, SocketConnectionMCRService } from "src/app/services/socket-connection-mcr.service"
import { CMAPIService } from '../../repository/CMAPI/cmapi.service';
import { environment } from 'src/environments/environment';
import { CaptureError, CaptureImageOptions, MediaCapture, MediaFile } from '@awesome-cordova-plugins/media-capture/ngx';
import { Filesystem, Directory, Encoding, FilesystemDirectory } from '@capacitor/filesystem';
import { Platform } from '@ionic/angular';
import { Capacitor } from '@capacitor/core';
enum ActionType {
enum ActionType {
newRapid = "1",
new = "2",
edit = "3"
@@ -62,6 +67,8 @@ export class NewPublicationPage implements OnInit {
seletedContent: PublicationAttachmentEntity[] = []
displayLimit = 4;
filesSizeSum = 0;
photoOrVideo: boolean = false;
video: any;
publicationFormMV = new PublicationFormMV()
@@ -78,7 +85,10 @@ export class NewPublicationPage implements OnInit {
private MiddlewareServiceService: MiddlewareServiceService,
private LakefsRepositoryService: LakefsRepositoryService,
private SocketConnectionMCRService: SocketConnectionMCRService,
private CMAPIService: CMAPIService
private CMAPIService: CMAPIService,
private mediaCapture: MediaCapture,
private httpErrorHandle: HttpErrorHandle,
private platform: Platform,
) {
this.publicationTitle = 'Nova Publicação';
@@ -136,9 +146,9 @@ export class NewPublicationPage implements OnInit {
OriginalFileName: res.OriginalFileName,
FileExtension: res.FileExtension,
}
console.log('edit',this.publication)
console.log('edit', this.publication)
this.pub = this.publication;
this.seletedContent = this.publication.Files.map( e => {
this.seletedContent = this.publication.Files.map(e => {
return new PublicationAttachmentEntity(
{
base64: e.FileBase64,
@@ -175,12 +185,14 @@ export class NewPublicationPage implements OnInit {
800, // maxHeight
0.9 // quality
).then((picture) => {
this.photoOrVideo = false;
let fileObject = {
FileBase64: picture,
FileExtension: this.removeTextBeforeSlash('jpeg','/')
FileExtension: this.removeTextBeforeSlash('jpeg', '/'),
OriginalFileName: 'imagem'
}
const FileExtension = this.removeTextBeforeSlash('jpeg','/')
const FileExtension = this.removeTextBeforeSlash('jpeg', '/')
const newAttachment = new PublicationAttachmentEntity(
{
@@ -196,9 +208,9 @@ export class NewPublicationPage implements OnInit {
this.seletedContent.push(newAttachment)
});
/* } else {
this.toastService._badRequest("Imagem inválida")
} */
/* } else {
this.toastService._badRequest("Imagem inválida")
} */
}
async laodPicture() {
@@ -221,10 +233,11 @@ export class NewPublicationPage implements OnInit {
).then((picture) => {
let fileObject = {
FileBase64: picture,
FileExtension: this.removeTextBeforeSlash('jpeg','/')
FileExtension: this.removeTextBeforeSlash('jpeg', '/'),
OriginalFileName: 'image'
}
const FileExtension = this.removeTextBeforeSlash('jpeg','/')
const FileExtension = this.removeTextBeforeSlash('jpeg', '/')
const newAttachment = new PublicationAttachmentEntity(
{
@@ -248,36 +261,56 @@ export class NewPublicationPage implements OnInit {
multiple: true,
});
console.log(result)
result.files.forEach(async blobFile => {
if(this.checkFileType.checkFileType(blobFile.mimeType) == 'image' || this.checkFileType.checkFileType(blobFile.mimeType) == 'video') {
console.log(blobFile)
if (this.checkFileType.checkFileType(blobFile.mimeType) == 'image' || this.checkFileType.checkFileType(blobFile.mimeType) == 'video') {
/* console.log('converte new way',this.getBase64(blobFile)) */
/* const blob = await fetch(
Capacitor.convertFileSrc(blobFile.path)
).then(r => r.blob()); */
/* console.log(await blob.arrayBuffer());
console.log("base64 :data:video/mp4;base64,",this.arrayBufferToBase64(await blob.arrayBuffer())) */
this.convertBlobToBase64(blobFile.blob).then((value) => {
console.log(value)
this.filesSizeSum = this.filesSizeSum + blobFile.size
if(this.fileSizeToMB(this.filesSizeSum) <= 20) {
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
const FileExtension = this.removeTextBeforeSlash(blobFile.mimeType,'/')
const FileExtension = this.removeTextBeforeSlash(blobFile.mimeType, '/')
const file = new File([blobFile.blob], blobFile.name);
const file = new File([blobFile.blob], blobFile.name);
const newAttachment = new PublicationAttachmentEntity(
{
base64: value,
extension: FileExtension,
blobFile: file,
FileType: this.checkFileType.checkFileType(FileExtension)
}
)
const newAttachment = new PublicationAttachmentEntity(
{
base64: value,
extension: FileExtension,
blobFile: file,
FileType: this.checkFileType.checkFileType(FileExtension)
}
)
newAttachment.needUpload()
newAttachment.needUpload()
this.seletedContent.push(newAttachment)
this.filecontent = true;
} else {
if(this.seletedContent.length === 0)
this.filesSizeSum = 0
this.seletedContent.push(newAttachment)
console.log(this.seletedContent)
this.filecontent = true;
} else {
if (this.seletedContent.length === 0)
this.filesSizeSum = 0
this.httpErroHandle.validationMessagge('filessize');
}
this.httpErroHandle.validationMessagge('filessize');
}
}).catch((erro) => {
console.log(erro)
})
} else {
this.httpErroHandle.validationMessagge('filetype');
@@ -285,6 +318,9 @@ export class NewPublicationPage implements OnInit {
});
/* this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = 'foto';
@@ -308,6 +344,49 @@ export class NewPublicationPage implements OnInit {
};
async loadVideoTablet() {
const result = await FilePicker.pickMedia
({
multiple: true,
});
console.log(result.files)
result.files.forEach(element => {
this.filesSizeSum = this.filesSizeSum + element.size
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
if (this.checkFileType.checkFileType(element.mimeType) == 'image' || this.checkFileType.checkFileType(element.mimeType) == 'video') {
let resultUrl = decodeURIComponent(element.path);
try {
Filesystem.readFile({ path: resultUrl })
.then(async (content) => {
console.log(result)
console.log('load video tablet base64',content)
this.filecontent = true;
let fileObject = new PublicationAttachmentEntity ({
base64: content.data,
extension: this.removeTextBeforeSlash(element.mimeType, '/'),
OriginalFileName: 'video',
FileType: this.checkFileType.checkFileType( this.removeTextBeforeSlash(element.mimeType, '/'))
})
this.seletedContent.push(fileObject)
})
.catch((err) => console.error(err));
} catch (error) {
console.log('upload video error: ', error)
}
}
} else {
if (this.seletedContent.length === 0)
this.filesSizeSum = 0
this.httpErrorHandle.validationMessagge('filessize')
}
});
};
runValidation() {
this.validateFrom = true
@@ -340,8 +419,7 @@ export class NewPublicationPage implements OnInit {
}
if(this.seletedContent.length == 0) {
if (this.seletedContent.length == 0) {
const newAttachment = new PublicationAttachmentEntity(
{
@@ -390,7 +468,7 @@ export class NewPublicationPage implements OnInit {
}
this.publication.Files = this.publication.Files.map( e => ({
this.publication.Files = this.publication.Files.map(e => ({
FileBase64: e.FileBase64,
FileExtension: e.FileExtension,
OriginalFileName: 'foto'
@@ -451,7 +529,7 @@ export class NewPublicationPage implements OnInit {
console.log("this.publication.Files", this.publication.Files)
}
this.publication.Files = this.publication.Files.map( e => ({
this.publication.Files = this.publication.Files.map(e => ({
FileBase64: e.FileBase64,
FileExtension: e.FileExtension,
OriginalFileName: 'foto'
@@ -563,6 +641,7 @@ export class NewPublicationPage implements OnInit {
}
convertBlobToBase64(blob: Blob) {
console.log('Convert blob ',blob)
return new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
@@ -570,10 +649,19 @@ export class NewPublicationPage implements OnInit {
resolve(reader.result)
}
reader.readAsDataURL(blob)
})
},)
}
removeTextBeforeSlash(inputString,mark) {
getBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
}
removeTextBeforeSlash(inputString, mark) {
if (inputString.includes(mark)) {
const parts = inputString.split(mark);
return parts.length > 1 ? parts[1] : inputString;
@@ -652,57 +740,195 @@ export class NewPublicationPage implements OnInit {
/* async compressVideoBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
// Decode the base64 video string to an ArrayBuffer
const videoBuffer = this.base64ToArrayBuffer(this.removeTextBeforeSlash(base64String,','));
/* async compressVideoBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
// Decode the base64 video string to an ArrayBuffer
const videoBuffer = this.base64ToArrayBuffer(this.removeTextBeforeSlash(base64String,','));
// Create a Blob from the ArrayBuffer
const videoBlob = new Blob([videoBuffer], { type: 'video/mp4' });
// Create a Blob from the ArrayBuffer
const videoBlob = new Blob([videoBuffer], { type: 'video/mp4' });
// Create an object URL from the Blob
const videoObjectUrl = URL.createObjectURL(videoBlob);
// Create an object URL from the Blob
const videoObjectUrl = URL.createObjectURL(videoBlob);
// Create a video element
const video = document.createElement('video');
// Create a video element
const video = document.createElement('video');
// Create a source element and set its type attribute
const source = document.createElement('source');
source.type = 'video/mp4';
// Create a source element and set its type attribute
const source = document.createElement('source');
source.type = 'video/mp4';
// Set the source URL
source.src = videoObjectUrl;
// Set the source URL
source.src = videoObjectUrl;
// Append the source element to the video element
video.appendChild(source);
// Append the source element to the video element
video.appendChild(source);
// Wait for the video to load
video.addEventListener('loadedmetadata', async () => {
const canvas = document.createElement('canvas');
let newWidth = video.videoWidth;
let newHeight = video.videoHeight;
// Wait for the video to load
video.addEventListener('loadedmetadata', async () => {
const canvas = document.createElement('canvas');
let newWidth = video.videoWidth;
let newHeight = video.videoHeight;
if (newWidth > maxWidth) {
newHeight *= maxWidth / newWidth;
newWidth = maxWidth;
}
if (newWidth > maxWidth) {
newHeight *= maxWidth / newWidth;
newWidth = maxWidth;
}
if (newHeight > maxHeight) {
newWidth *= maxHeight / newHeight;
newHeight = maxHeight;
}
if (newHeight > maxHeight) {
newWidth *= maxHeight / newHeight;
newHeight = maxHeight;
}
canvas.width = newWidth;
canvas.height = newHeight;
canvas.width = newWidth;
canvas.height = newHeight;
const context = canvas.getContext('2d');
const context = canvas.getContext('2d');
// Create a function to draw each video frame onto the canvas
const drawFrame = () => {
// Create a function to draw each video frame onto the canvas
const drawFrame = () => {
context?.drawImage(video, 0, 0, newWidth, newHeight);
// Convert the canvas to a Blob with the correct MIME type
canvas.toBlob(async (blob) => {
if (blob) {
// Read the Blob as an ArrayBuffer
const compressedVideoBuffer = await this.readBlobAsArrayBuffer(blob);
// Convert the ArrayBuffer back to base64
const compressedBase64 = this.arrayBufferToBase64(compressedVideoBuffer);
resolve(compressedBase64);
} else {
reject('Error creating compressed video blob.');
}
}, 'video/mp4', quality);
// Request the next video frame
requestAnimationFrame(drawFrame);
};
// Start drawing frames
drawFrame();
// Start playing the video
video.play();
});
} catch (error) {
reject(error);
}
});
} */
/* async compressVideoBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
// Decode the base64 video string to an ArrayBuffer
const videoBuffer = this.base64ToArrayBuffer(this.removeTextBeforeSlash(base64String,','));
// Create a Blob from the ArrayBuffer
const videoBlob = new Blob([videoBuffer], { type: 'video/mp4' });
// Create an object URL from the Blob
const videoObjectUrl = URL.createObjectURL(videoBlob);
// Create a video element
const video = document.createElement('video');
video.src = videoObjectUrl;
// Wait for the video to load metadata
video.addEventListener('loadedmetadata', async () => {
const canvas = document.createElement('canvas');
let newWidth = video.videoWidth;
let newHeight = video.videoHeight;
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(video, 0, 0, newWidth, newHeight);
// Convert the canvas to a Blob with the correct MIME type
canvas.toBlob(async (blob) => {
if (blob) {
// Read the Blob as an ArrayBuffer
const compressedVideoBuffer = await this.readBlobAsArrayBuffer(blob);
// Convert the ArrayBuffer back to base64
const compressedBase64 = this.arrayBufferToBase64(compressedVideoBuffer);
resolve(compressedBase64);
} else {
reject('Error creating compressed video blob.');
}
}, 'video/mp4', quality);
});
} catch (error) {
reject(error);
}
});
} */
/* async compressVideoBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
// Decode the base64 video string to an ArrayBuffer
const trimmedBase64 = base64String.trim();
console.log(this.removeTextBeforeSlash(trimmedBase64,','))
const videoBuffer = this.base64ToArrayBuffer(this.removeTextBeforeSlash(trimmedBase64,','));
// Create a Blob from the ArrayBuffer
const videoBlob = new Blob([videoBuffer], { type: 'video/mp4' });
// Create an object URL from the Blob
const videoObjectUrl = URL.createObjectURL(videoBlob);
// Create a video element
const video = document.createElement('video');
video.src = videoObjectUrl;
// Wait for the video to load metadata
video.addEventListener('loadedmetadata', async () => {
const canvas = document.createElement('canvas');
let newWidth = video.videoWidth;
let newHeight = video.videoHeight;
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(video, 0, 0, newWidth, newHeight);
// Convert the canvas to a Blob with the correct MIME type
// Convert the canvas to a Blob
canvas.toBlob(async (blob) => {
if (blob) {
// Read the Blob as an ArrayBuffer
@@ -717,151 +943,13 @@ export class NewPublicationPage implements OnInit {
}
}, 'video/mp4', quality);
// Request the next video frame
requestAnimationFrame(drawFrame);
};
});
// Start drawing frames
drawFrame();
// Start playing the video
video.play();
});
} catch (error) {
reject(error);
}
});
} */
/* async compressVideoBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
// Decode the base64 video string to an ArrayBuffer
const videoBuffer = this.base64ToArrayBuffer(this.removeTextBeforeSlash(base64String,','));
// Create a Blob from the ArrayBuffer
const videoBlob = new Blob([videoBuffer], { type: 'video/mp4' });
// Create an object URL from the Blob
const videoObjectUrl = URL.createObjectURL(videoBlob);
// Create a video element
const video = document.createElement('video');
video.src = videoObjectUrl;
// Wait for the video to load metadata
video.addEventListener('loadedmetadata', async () => {
const canvas = document.createElement('canvas');
let newWidth = video.videoWidth;
let newHeight = video.videoHeight;
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(video, 0, 0, newWidth, newHeight);
// Convert the canvas to a Blob with the correct MIME type
canvas.toBlob(async (blob) => {
if (blob) {
// Read the Blob as an ArrayBuffer
const compressedVideoBuffer = await this.readBlobAsArrayBuffer(blob);
// Convert the ArrayBuffer back to base64
const compressedBase64 = this.arrayBufferToBase64(compressedVideoBuffer);
resolve(compressedBase64);
} else {
reject('Error creating compressed video blob.');
}
}, 'video/mp4', quality);
});
} catch (error) {
reject(error);
}
});
} */
/* async compressVideoBase64(base64String: string, maxWidth: number, maxHeight: number, quality: number): Promise<string> {
return new Promise(async (resolve, reject) => {
try {
// Decode the base64 video string to an ArrayBuffer
const trimmedBase64 = base64String.trim();
console.log(this.removeTextBeforeSlash(trimmedBase64,','))
const videoBuffer = this.base64ToArrayBuffer(this.removeTextBeforeSlash(trimmedBase64,','));
// Create a Blob from the ArrayBuffer
const videoBlob = new Blob([videoBuffer], { type: 'video/mp4' });
// Create an object URL from the Blob
const videoObjectUrl = URL.createObjectURL(videoBlob);
// Create a video element
const video = document.createElement('video');
video.src = videoObjectUrl;
// Wait for the video to load metadata
video.addEventListener('loadedmetadata', async () => {
const canvas = document.createElement('canvas');
let newWidth = video.videoWidth;
let newHeight = video.videoHeight;
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(video, 0, 0, newWidth, newHeight);
// Convert the canvas to a Blob
canvas.toBlob(async (blob) => {
if (blob) {
// Read the Blob as an ArrayBuffer
const compressedVideoBuffer = await this.readBlobAsArrayBuffer(blob);
// Convert the ArrayBuffer back to base64
const compressedBase64 = this.arrayBufferToBase64(compressedVideoBuffer);
resolve(compressedBase64);
} else {
reject('Error creating compressed video blob.');
}
}, 'video/mp4', quality);
});
} catch (error) {
reject(error);
}
});
} */
} catch (error) {
reject(error);
}
});
} */
private base64ToArrayBuffer(base64: string): ArrayBuffer {
const binaryString = window.atob(base64);
@@ -922,8 +1010,65 @@ export class NewPublicationPage implements OnInit {
}
}
chossePhotoOrVideo() {
this.photoOrVideo = !this.photoOrVideo
}
async startVideoRecording() {
try {
let options: CaptureImageOptions = { limit: 1 }
const data: any = await this.mediaCapture.captureVideo(options)
this.video = data[0];
console.log(data)
data.forEach(async element => {
this.filesSizeSum = this.filesSizeSum + element.size
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
const savedFile = await Filesystem.copy({
from: element.fullPath, // directory prop removed, Capacitor parses filename for us
to: "video.mp4",
toDirectory: FilesystemDirectory.Data
});
console.log(savedFile.uri)
Filesystem.readFile({ path: savedFile.uri })
.then(async (content) => {
this.filecontent = true;
console.log('',content)
let fileObject = new PublicationAttachmentEntity({
base64: content.data,
extension: 'mp4',
OriginalFileName: 'record',
FileType: 'video'
}
)
this.seletedContent.push(fileObject)
})
.catch((err) => console.error(err));
} else {
if (this.seletedContent.length === 0)
this.filesSizeSum = 0
this.httpErrorHandle.validationMessagge('filessize')
}
});
} catch (error) {
console.log('record video error: ', error)
}
}
checkTableDivice() {
if (!this.platform.is('desktop'))
return true;
}
checkDesktop() {
if (this.platform.is('desktop'))
return true;
}
}
class UploadFileUseCase {
CMAPIService: CMAPIService = window["CMAPIAPIRepository"]
+1 -1
View File
@@ -4,4 +4,4 @@ import { doneITProd } from './suport/doneIt'
import { DevDev } from './suport/dev'
export const environment: Environment = DevDev;
export const environment: Environment = oaprProd;