mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-21 13:55:51 +00:00
jwt implemented
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { ModalController } from '@ionic/angular';
|
||||
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
|
||||
import { IonicSlides, ModalController } from '@ionic/angular';
|
||||
import { Publication } from 'src/app/models/publication';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
@@ -14,6 +14,7 @@ import { PermissionService } from 'src/app/services/permission.service';
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
||||
import { AskModalPage } from 'src/app/modals/ask-modal/ask-modal.page';
|
||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-view-publications',
|
||||
@@ -28,31 +29,37 @@ export class ViewPublicationsPage implements OnInit {
|
||||
oldpublicationIds = []
|
||||
|
||||
@Input() folderId: any;
|
||||
@Output() addNewPublication = new EventEmitter<any>();
|
||||
@Output() editPublication = new EventEmitter<any>();
|
||||
@Output() openPublicationDetails= new EventEmitter<any>();
|
||||
@Output() addNewPublication = new EventEmitter<any>();
|
||||
@Output() editPublication = new EventEmitter<any>();
|
||||
@Output() openPublicationDetails = new EventEmitter<any>();
|
||||
@Output() goBackToViewPublications = new EventEmitter();
|
||||
@Output() closeDesktopComponent = new EventEmitter<any>();
|
||||
@Output() closeDesktopComponent = new EventEmitter<any>();
|
||||
@Output() goBacktoPublicationDetails = new EventEmitter<any>();
|
||||
@Output() getActions= new EventEmitter<any>();
|
||||
@Output() getActions = new EventEmitter<any>();
|
||||
|
||||
publicationPipe = new PublicationPipe()
|
||||
|
||||
swiperModules = [IonicSlides];
|
||||
@ViewChild('myVideo') myVideo: any;
|
||||
public lastScrollTop = 0;
|
||||
public isHidden = false;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
private publications: PublicationsService,
|
||||
public ThemeService: ThemeService,
|
||||
private toastService: ToastService,
|
||||
private storage: Storage,
|
||||
public p:PermissionService,
|
||||
public p: PermissionService,
|
||||
private httpErrorHandle: HttpErrorHandle,
|
||||
public publicationFolderService: PublicationFolderService
|
||||
) {
|
||||
this.createPublicationList()
|
||||
}
|
||||
public publicationFolderService: PublicationFolderService,
|
||||
public checkFileType: checkFileTypeService
|
||||
) {
|
||||
this.createPublicationList()
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if(typeof(this.folderId) == 'object') {
|
||||
if (typeof (this.folderId) == 'object') {
|
||||
this.folderId = this.folderId['ProcessId']
|
||||
}
|
||||
|
||||
@@ -69,11 +76,11 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
ngOnChanges(changes: any): void {
|
||||
|
||||
if(typeof(this.folderId) == 'object') {
|
||||
if (typeof (this.folderId) == 'object') {
|
||||
this.folderId = this.folderId['ProcessId']
|
||||
}
|
||||
|
||||
if(!this.publicationFolderService.publicationList[this.folderId]) {
|
||||
if (!this.publicationFolderService.publicationList[this.folderId]) {
|
||||
this.publicationFolderService.FolderDetails[this.folderId] = new PublicationFolder();
|
||||
}
|
||||
|
||||
@@ -89,16 +96,16 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
|
||||
createPublicationList(folderId = this.folderId) {
|
||||
if(!this.publicationFolderService.publicationList[this.folderId]) {
|
||||
if (!this.publicationFolderService.publicationList[this.folderId]) {
|
||||
this.publicationFolderService.publicationList[this.folderId] = []
|
||||
}
|
||||
if(!this.publicationFolderService.FolderDetails[this.folderId]) {
|
||||
if (!this.publicationFolderService.FolderDetails[this.folderId]) {
|
||||
this.publicationFolderService.FolderDetails[this.folderId] = new PublicationFolder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
doRefresh =(event) => {
|
||||
doRefresh = (event) => {
|
||||
|
||||
this.getPublicationDetail();
|
||||
this.getPublicationsIds();
|
||||
@@ -110,11 +117,11 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
getPublicationDetail() {
|
||||
const folderId = this.folderId
|
||||
this.publications.GetPresidentialAction(folderId).subscribe(res=>{
|
||||
this.publications.GetPresidentialAction(folderId).subscribe(res => {
|
||||
|
||||
// PublicationDetailsModel.create(res)
|
||||
this.publicationFolderService.FolderDetails[folderId] = res
|
||||
this.storage.set(folderId+"name", res)
|
||||
this.storage.set(folderId + "name", res)
|
||||
}, (error) => {
|
||||
this.showLoader = false;
|
||||
// this.httpErroHandle.httpStatusHandle(error)
|
||||
@@ -133,7 +140,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
let loadLater = []
|
||||
for (let publicationId of publicationIds) {
|
||||
|
||||
if(!this.publicationIsPresent(publicationId, folderId)) {
|
||||
if (!this.publicationIsPresent(publicationId, folderId)) {
|
||||
await this.loadPublication(publicationId, folderId)
|
||||
|
||||
} else {
|
||||
@@ -141,15 +148,15 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
for( let publicationId of loadLater) {
|
||||
for (let publicationId of loadLater) {
|
||||
await this.loadPublication(publicationId, folderId)
|
||||
}
|
||||
|
||||
|
||||
for(let localPublication of this.publicationFolderService.publicationList[folderId]) {
|
||||
for (let localPublication of this.publicationFolderService.publicationList[folderId]) {
|
||||
|
||||
const apiPublication = publicationIds.includes(localPublication.DocumentId)
|
||||
if(!apiPublication) {
|
||||
if (!apiPublication) {
|
||||
this.publicationFolderService.deletePost(folderId, localPublication.DocumentId)
|
||||
}
|
||||
}
|
||||
@@ -159,7 +166,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
this.storage.set(folderId, this.publicationFolderService.publicationList[folderId]);
|
||||
|
||||
this.oldpublicationIds = publicationIds
|
||||
} catch(error) {
|
||||
} catch (error) {
|
||||
this.showLoader = false;
|
||||
}
|
||||
|
||||
@@ -167,27 +174,27 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
_deletePublication = (folderId, publicationId) => {
|
||||
|
||||
this.publicationFolderService.publicationList[folderId] = this.publicationFolderService.publicationList[folderId].filter( e => e.DocumentId != publicationId)
|
||||
this.publicationFolderService.publicationList[folderId] = this.publicationFolderService.publicationList[folderId].filter(e => e.DocumentId != publicationId)
|
||||
|
||||
}
|
||||
|
||||
publicationIsPresent(publicationId, folderId) {
|
||||
return this.publicationFolderService.publicationList[folderId].find( e => e.DocumentId == publicationId )
|
||||
return this.publicationFolderService.publicationList[folderId].find(e => e.DocumentId == publicationId)
|
||||
}
|
||||
publicationFind(publicationId, folderId) {
|
||||
return this.publicationFolderService.publicationList[folderId].find( e => e.DocumentId == publicationId )
|
||||
return this.publicationFolderService.publicationList[folderId].find(e => e.DocumentId == publicationId)
|
||||
}
|
||||
publicationFindIndex(publicationId, folderId) {
|
||||
return this.publicationFolderService.publicationList[folderId].findIndex( e => e.DocumentId == publicationId )
|
||||
return this.publicationFolderService.publicationList[folderId].findIndex(e => e.DocumentId == publicationId)
|
||||
}
|
||||
|
||||
async loadPublication(publicationId, folderId) {
|
||||
let Publication = await this.publications.GetPublicationById(publicationId).toPromise();
|
||||
let Publication = await this.publications.GetPublicationWithArrayOfFilesById(publicationId).toPromise();
|
||||
let publicationDetails: Publication = this.publicationPipe.itemList(Publication)
|
||||
|
||||
const findIndex = this.publicationFindIndex(publicationId, folderId)
|
||||
const found = this.publicationIsPresent(publicationId, folderId)
|
||||
if(!found) {
|
||||
if (!found) {
|
||||
this.publicationFolderService.publicationList[folderId].push(publicationDetails)
|
||||
} else {
|
||||
this.publicationFolderService.publicationList[folderId][findIndex] = publicationDetails
|
||||
@@ -202,12 +209,12 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}
|
||||
|
||||
|
||||
async AddPublication(publicationType:any, folderId:any) {
|
||||
async AddPublication(publicationType: any, folderId: any) {
|
||||
|
||||
if( window.innerWidth < 701) {
|
||||
if (window.innerWidth < 701) {
|
||||
const modal = await this.modalController.create({
|
||||
component: NewPublicationPage,
|
||||
componentProps:{
|
||||
componentProps: {
|
||||
publicationType: publicationType,
|
||||
folderId: folderId,
|
||||
},
|
||||
@@ -215,7 +222,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
backdropDismiss: false
|
||||
});
|
||||
|
||||
modal.onDidDismiss().then(()=>{
|
||||
modal.onDidDismiss().then(() => {
|
||||
this.doRefresh(event);
|
||||
});
|
||||
|
||||
@@ -229,9 +236,9 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async openEditPublication(folderId?:any){
|
||||
async openEditPublication(folderId?: any) {
|
||||
|
||||
if( window.innerWidth < 701) {
|
||||
if (window.innerWidth < 701) {
|
||||
const modal = await this.modalController.create({
|
||||
component: EditActionPage,
|
||||
componentProps: {
|
||||
@@ -251,7 +258,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
async deletePublication(folderId?:any) {
|
||||
async deletePublication(folderId?: any) {
|
||||
|
||||
const modal = await this.modalController.create({
|
||||
component: AskModalPage,
|
||||
@@ -264,7 +271,7 @@ export class ViewPublicationsPage implements OnInit {
|
||||
});
|
||||
|
||||
modal.onDidDismiss().then((res) => {
|
||||
if(res.data == 'Yes') {
|
||||
if (res.data == 'Yes') {
|
||||
const loader = this.toastService.loading();
|
||||
try {
|
||||
this.publications.DeletePresidentialAction(folderId).toPromise();
|
||||
@@ -284,10 +291,25 @@ export class ViewPublicationsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
async viewPublicationDetail(DocumentId:string, ProcessId: string) {
|
||||
async viewPublicationDetail(DocumentId: string, ProcessId: string) {
|
||||
|
||||
this.openPublicationDetails.emit({DocumentId, ProcessId});
|
||||
this.openPublicationDetails.emit({ DocumentId, ProcessId });
|
||||
|
||||
}
|
||||
|
||||
stopVideo() {
|
||||
this.myVideo.nativeElement.pause();
|
||||
this.myVideo.nativeElement.currentTime = 0;
|
||||
}
|
||||
|
||||
public onScroll(event): void {
|
||||
if(this.lastScrollTop < event.detail.scrollTop) {
|
||||
console.log("scrolling down")
|
||||
} else {
|
||||
console.log("scrolling up")
|
||||
}
|
||||
|
||||
this.lastScrollTop = event.detail.scrollTop;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user