This commit is contained in:
Peter Maquiran
2023-08-18 17:37:11 +01:00
parent eb77736a60
commit 8d35abbdd0
12 changed files with 269 additions and 163 deletions
@@ -19,6 +19,8 @@ import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera
import { Filesystem, Directory } from '@capacitor/filesystem';
import { NgxImageCompressService } from "ngx-image-compress";
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
const IMAGE_DIR = 'stored-images';
@@ -87,14 +89,15 @@ export class NewPublicationPage implements OnInit {
private platform: Platform,
private loadingCtrl: LoadingController,
public imageCompress: NgxImageCompressService,
private httpErrorHandle: HttpErrorHandle
private httpErrorHandle: HttpErrorHandle,
public PublicationFolderService: PublicationFolderService
) {
this.publicationType = this.navParams.get('publicationType');
this.folderId = this.navParams.get('folderId');
this.publication = this.navParams.get('publication');
this.publicationTitle = 'Nova Publicação';
this.convertBlobToBase64Worker = new Worker(new URL('./convertBlobToBase64.worker.js', import.meta.url));
}
@@ -151,27 +154,6 @@ export class NewPublicationPage implements OnInit {
});
/* async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
} */
async laodPicture() {
const capturedImage = await Camera.getPhoto({
@@ -295,8 +277,6 @@ export class NewPublicationPage implements OnInit {
FileBase64: this.capturedImage,
FileExtension: 'jpeg',
}
const loader = this.toastService.loading()
@@ -312,6 +292,8 @@ export class NewPublicationPage implements OnInit {
}
}
this.PublicationFolderService.loadPublication(this.publication.DocumentId, this.publication.ProcessId)
}
else {
@@ -76,33 +76,54 @@ export class PublicationDetailPage implements OnInit {
}
getPublicationDetail() {
this.showLoader = true;
this.publications.GetPublicationById(this.publicationId).subscribe(res => {
/* this.publication = res; */
const folderId = this.folderId
const localPublication = this.publicationFolderService.getLocalPublication(folderId, this.publicationId);
if(localPublication?.DocumentId) {
this.publication = {
DateIndex: res.DateIndex,
DocumentId: res.DocumentId,
ProcessId:res.ProcessId,
Title:res.Title,
Message: res.Message,
DatePublication: res.DatePublication,
FileBase64: "data:image/jpg;base64," + res.FileBase64,
OriginalFileName: res.OriginalFileName,
DateIndex: localPublication.DateIndex,
DocumentId: localPublication.DocumentId,
ProcessId:localPublication.ProcessId,
Title:localPublication.Title,
Message: localPublication.Message,
DatePublication: localPublication.DatePublication,
FileBase64: localPublication.FileBase64,
OriginalFileName: localPublication.OriginalFileName,
FileExtension: 'jpeg',
}
console.log('PUBLICATIO ImG',this.publication.FileBase64)
this.showLoader = false;
}, (error) => {
} else {
if(error.status == 404) {
this.publicationFolderService.deletePost(this.folderId, this.publicationId)
}
this.showLoader = true;
this.publications.GetPublicationById(this.publicationId).subscribe(res => {
/* this.publication = res; */
this.publication = {
DateIndex: res.DateIndex,
DocumentId: res.DocumentId,
ProcessId:res.ProcessId,
Title:res.Title,
Message: res.Message,
DatePublication: res.DatePublication,
FileBase64: "data:image/jpg;base64," + res.FileBase64,
OriginalFileName: res.OriginalFileName,
FileExtension: 'jpeg',
}
this.showLoader = false;
}, (error) => {
this.showLoader = false;
if(error.status == 404) {
this.publicationFolderService.deletePost(this.folderId, this.publicationId)
}
this.goBack();
this.httpErrorHandle.httpStatusHandle(error)
});
}
this.goBack();
this.httpErrorHandle.httpStatusHandle(error)
});
}
close() {
@@ -110,7 +131,7 @@ export class PublicationDetailPage implements OnInit {
}
goBack() {
if(!window.location.href.includes('/home/publications/view-publications')) {
if(this.isModal) {
this.close()
} else {
this.RouteService.goBack();
@@ -179,9 +200,4 @@ export class PublicationDetailPage implements OnInit {
modal.present();
}
}
@@ -7,9 +7,8 @@
<ion-icon class="font-35-em" *ngIf="ThemeService.currentTheme == 'doneIt' " src="assets/images/theme/doneIt/icons-calendar-arrow-left.svg"></ion-icon>
<ion-icon class="font-35-em" *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
</div>
<div *ngIf="publicationFolderService.FolderDetails[folderId]?.DateBegin != null" class="div-title flex-grow-1">
<div *ngIf="publicationFolderService.FolderDetails[folderId]?.DateBegin != null" class="div-title flex-grow-1">
<p class="title font-25-em mb-10-em">{{publicationFolderService.FolderDetails[folderId].Description}}</p>
<p class="item-content-detail font-14-em">{{publicationFolderService.FolderDetails[folderId].Detail}}</p>
<p class="item-content-date font-13-em" >{{publicationFolderService.FolderDetails[folderId].DateBegin | date: 'dd-MM-yyyy HH:mm'}}</p>
</div>
<div *ngIf="p.userPermission([p.permissionList.Actions.createPost]) && publicationFolderService.FolderDetails[folderId]" class="cursor-pointer font-35-em" (click)="AddPublication('2',publicationFolderService.FolderDetails[folderId].ProcessId)">
@@ -30,6 +29,9 @@
</ion-refresher>
<div class="main-container background-white height-100 overflow-y-auto viewport-font-size">
<ion-content *ngIf="publicationFolderService.FolderDetails[folderId]">
<p class="px-20 item-content-detail font-14-em">{{publicationFolderService.FolderDetails[folderId].Detail}}</p>
<ion-card *ngFor="let publication of publicationFolderService.publicationList[folderId] let i = index"
(click)="goToPublicationDetail(publication.DocumentId)"
>
@@ -51,65 +53,6 @@
</ion-card-content>
</ion-card>
</ion-content>
<!-- <ion-list>
<div class="post-item cursor-pointer"
*ngFor="let publication of getpublication"
(click)="goToPublicationDetail(publication.DocumentId)"
>
<div class="post-img">
<img [defaultImage]=defaultImage [lazyLoad]="publication.FileBase64">
<ng-template #imageLoaded>
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
<img [defaultImage]=defaultImage [lazyLoad]="publication.FileBase64">
</div>
</ng-template>
</div>
<div class="post-content px-20">
<div class="post-title-time">
<div class="post-title">
<ion-label>{{publication.Title}}</ion-label>
</div>
<div class="post-data">{{publication.DatePublication | date: 'dd-MM-yyyy HH:mm'}}</div>
</div>
<div class="post-description">
<p>{{publication.Message}}</p>
</div>
</div>
</div>
<div *ngIf="showLoader" class="post-item">
<div class="post-img">
<img src="/assets/icon/icon-no-image.svg" alt="image">
</div>
<div class="post-content px-20">
<div class="post-title-time">
<div class="post-title">
<ion-label><ion-skeleton-text animated animated style="width: 60%;"></ion-skeleton-text></ion-label>
</div>
<div class="post-data"><ion-skeleton-text animated style="width: 25%; float: right;"></ion-skeleton-text></div>
</div>
<div class="post-description">
<p><ion-skeleton-text animated></ion-skeleton-text></p>
<p><ion-skeleton-text animated></ion-skeleton-text></p>
</div>
</div>
<div class="post-img">
<img src="/assets/icon/icon-no-image.svg" alt="image">
</div>
<div class="post-content px-20">
<div class="post-title-time">
<div class="post-title">
<ion-label><ion-skeleton-text animated animated style="width: 60%;"></ion-skeleton-text></ion-label>
</div>
<div class="post-data"><ion-skeleton-text animated style="width: 25%; float: right;"></ion-skeleton-text></div>
</div>
<div class="post-description">
<p><ion-skeleton-text animated></ion-skeleton-text></p>
<p><ion-skeleton-text animated></ion-skeleton-text></p>
</div>
</div>
</div>
</ion-list> -->
</div>
</ion-content>
@@ -100,6 +100,7 @@ export class ViewPublicationsPage implements OnInit {
createPublicationList(folderId = this.folderId) {
console.log('create')
if(!this.publicationFolderService.publicationList[folderId]) {
this.publicationFolderService.publicationList[folderId] = []
}
@@ -132,7 +133,6 @@ export class ViewPublicationsPage implements OnInit {
getPublicationDetail() {
const folderId = this.folderId
this.publications.GetPresidentialAction(folderId).subscribe(res =>{
this.publicationFolderService.FolderDetails[folderId] = res
this.storage.set(folderId+"name", res)
}, (error) => {