mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Add publication to local storage
This commit is contained in:
@@ -136,6 +136,7 @@ export class PublicationsPage implements OnInit {
|
|||||||
DateEnd: this.theEndDate.getDate() +" de " + ( this.months[this.theEndDate.getMonth()])+" de " +this.theEndDate.getFullYear(),
|
DateEnd: this.theEndDate.getDate() +" de " + ( this.months[this.theEndDate.getMonth()])+" de " +this.theEndDate.getFullYear(),
|
||||||
ActionType: data.ActionType,
|
ActionType: data.ActionType,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(data.ActionType == "Evento") {
|
if(data.ActionType == "Evento") {
|
||||||
this.publicationsEventFolderList.push(folder);
|
this.publicationsEventFolderList.push(folder);
|
||||||
}
|
}
|
||||||
@@ -209,6 +210,8 @@ export class PublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
goToPublicationsList(folderId: string){
|
goToPublicationsList(folderId: string){
|
||||||
|
this.folderId = folderId
|
||||||
|
|
||||||
if( window.innerWidth <= 800){
|
if( window.innerWidth <= 800){
|
||||||
this.router.navigate(['/home/publications',folderId]);
|
this.router.navigate(['/home/publications',folderId]);
|
||||||
} else {
|
} else {
|
||||||
@@ -220,6 +223,7 @@ export class PublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async viewPublications(folderId: string) {
|
async viewPublications(folderId: string) {
|
||||||
|
this.folderId = folderId
|
||||||
|
|
||||||
const enterAnimation = (baseEl: any) => {
|
const enterAnimation = (baseEl: any) => {
|
||||||
const backdropAnimation = this.animationController.create()
|
const backdropAnimation = this.animationController.create()
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<ion-list>
|
<ion-list>
|
||||||
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
||||||
<div class="post-item"
|
<div class="post-item"
|
||||||
*ngFor="let publication of publicationList"
|
*ngFor="let publication of publicationListStorage.documents[folderId]"
|
||||||
(click)="goToPublicationDetail(publication.DocumentId)"
|
(click)="goToPublicationDetail(publication.DocumentId)"
|
||||||
>
|
>
|
||||||
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import { PublicationFolder } from 'src/app/models/publicationfolder';
|
|||||||
import { LoadingService } from 'src/app/services/loading.service';
|
import { LoadingService } from 'src/app/services/loading.service';
|
||||||
import { PublicationsService } from 'src/app/services/publications.service';
|
import { PublicationsService } from 'src/app/services/publications.service';
|
||||||
import { PresidentialActionsStore } from 'src/app/store/presidential-actions-store.service';
|
import { PresidentialActionsStore } from 'src/app/store/presidential-actions-store.service';
|
||||||
|
import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
|
||||||
|
import { PublicationListStorage } from 'src/app/store/publication-list.service';
|
||||||
import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
|
import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
|
||||||
import { NewPublicationPage } from '../new-publication/new-publication.page';
|
import { NewPublicationPage } from '../new-publication/new-publication.page';
|
||||||
import { PublicationDetailPage } from './publication-detail/publication-detail.page';
|
import { PublicationDetailPage } from './publication-detail/publication-detail.page';
|
||||||
@@ -24,8 +26,10 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
folderId:string;
|
folderId:string;
|
||||||
error: any;
|
error: any;
|
||||||
|
|
||||||
presidentialActionsStore = PresidentialActionsStore
|
publicationListStorage = PublicationListStorage
|
||||||
publicationTravelFolderStore = PublicationTravelFolderStore
|
//
|
||||||
|
publicationEventFolderStorage = PublicationEventFolderStorage
|
||||||
|
publicationTravelFolderService = PublicationTravelFolderStore
|
||||||
|
|
||||||
constructor( private loadingController: LoadingService,
|
constructor( private loadingController: LoadingService,
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
@@ -71,7 +75,6 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
this.getPublications();
|
this.getPublications();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getPublications();
|
|
||||||
this.getPublicationDetail();
|
this.getPublicationDetail();
|
||||||
event.target.complete();
|
event.target.complete();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
@@ -89,15 +92,13 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPublicationDetail() {
|
getPublicationDetail() {
|
||||||
this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{
|
let allActions = this.publicationEventFolderStorage.list.concat(this.publicationTravelFolderService.list)
|
||||||
console.log(res);
|
this.item = allActions.find((e)=> e.ProcessId == this.folderId)
|
||||||
this.item = res;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPublications() {
|
getPublications() {
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
|
const folderId = this.folderId
|
||||||
this.publications.GetPublications(this.folderId).subscribe(res=>{
|
this.publications.GetPublications(this.folderId).subscribe(res=>{
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|
||||||
@@ -126,7 +127,8 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
data.push(item)
|
data.push(item)
|
||||||
|
|
||||||
});
|
});
|
||||||
this.presidentialActionsStore.reset(data)
|
|
||||||
|
this.publicationListStorage.add(folderId, this.publicationList)
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -87,7 +87,6 @@ export class PublicationsService {
|
|||||||
params: params
|
params: params
|
||||||
};
|
};
|
||||||
return this.http.get<any>(`${geturl}`, options)
|
return this.http.get<any>(`${geturl}`, options)
|
||||||
.pipe(catchError(this.handleError));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetPublicationById( publicationId:any){
|
GetPublicationById( publicationId:any){
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
<ion-list>
|
<ion-list>
|
||||||
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
||||||
<div class="post-item d-md-block mb-10"
|
<div class="post-item d-md-block mb-10"
|
||||||
*ngFor="let publication of publicationList"
|
*ngFor="let publication of publicationListStorage.documents[folderId]"
|
||||||
(click)="viewPublicationDetail(publication.DocumentId)">
|
(click)="viewPublicationDetail(publication.DocumentId)">
|
||||||
<div *ngIf="publication.FileBase64.length > 30" class="mb-10 post-img width-md-100">
|
<div *ngIf="publication.FileBase64.length > 30" class="mb-10 post-img width-md-100">
|
||||||
<img src="{{publication.FileBase64}}" alt="image">
|
<img src="{{publication.FileBase64}}" alt="image">
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import { LoadingService } from 'src/app/services/loading.service';
|
|||||||
import { PublicationsService } from 'src/app/services/publications.service';
|
import { PublicationsService } from 'src/app/services/publications.service';
|
||||||
import { PublicationDetailPage } from 'src/app/pages/publications/publication-detail/publication-detail.page';
|
import { PublicationDetailPage } from 'src/app/pages/publications/publication-detail/publication-detail.page';
|
||||||
import { NewPublicationPage } from 'src/app/pages/publications/new-publication/new-publication.page';
|
import { NewPublicationPage } from 'src/app/pages/publications/new-publication/new-publication.page';
|
||||||
|
import { PublicationListStorage } from 'src/app/store/publication-list.service'
|
||||||
|
import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
|
||||||
|
import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-view-publications',
|
selector: 'app-view-publications',
|
||||||
templateUrl: './view-publications.page.html',
|
templateUrl: './view-publications.page.html',
|
||||||
@@ -28,6 +30,13 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
@Output() closeDesktopComponent = new EventEmitter<any>();
|
@Output() closeDesktopComponent = new EventEmitter<any>();
|
||||||
@Output() goBacktoPublicationDetails = new EventEmitter<any>();
|
@Output() goBacktoPublicationDetails = new EventEmitter<any>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
publicationListStorage = PublicationListStorage
|
||||||
|
//
|
||||||
|
publicationEventFolderStorage = PublicationEventFolderStorage
|
||||||
|
publicationTravelFolderService = PublicationTravelFolderStore
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private loadingController: LoadingService,
|
private loadingController: LoadingService,
|
||||||
private modalController: ModalController,
|
private modalController: ModalController,
|
||||||
@@ -48,43 +57,47 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: any): void {
|
ngOnChanges(changes: any): void {
|
||||||
console.log(this.folderId)
|
|
||||||
|
|
||||||
if(typeof(this.folderId) == 'object') {
|
if(typeof(this.folderId) == 'object') {
|
||||||
this.folderId = this.folderId['ProcessId']
|
this.folderId = this.folderId['ProcessId']
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getPublications();
|
setTimeout(()=>{
|
||||||
this.getPublicationDetail();
|
this.getPublications();
|
||||||
|
this.getPublicationDetail();
|
||||||
|
}, 100)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
doRefresh(event) {
|
doRefresh(event) {
|
||||||
this.getPublications();
|
this.getPublications();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.getPublications();
|
|
||||||
this.getPublicationDetail();
|
this.getPublicationDetail();
|
||||||
event.target.complete();
|
event.target.complete();
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(){
|
close() {
|
||||||
this.closeDesktopComponent.emit();
|
this.closeDesktopComponent.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPublicationDetail() {
|
getPublicationDetail() {
|
||||||
this.publications.GetPresidentialAction(this.folderId).subscribe(res=>{
|
|
||||||
console.log(res);
|
let allActions = this.publicationEventFolderStorage.list.concat(this.publicationTravelFolderService.list)
|
||||||
this.item = res;
|
this.item = allActions.find((e)=> e.ProcessId == this.folderId)
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPublications() {
|
getPublications() {
|
||||||
this.showLoader = true;
|
this.showLoader = true;
|
||||||
|
|
||||||
this.publications.GetPublications(this.folderId).subscribe(res=>{
|
const folderId = this.folderId
|
||||||
|
|
||||||
|
this.publications.GetPublications(folderId).subscribe(res=> {
|
||||||
this.publicationList = new Array();
|
this.publicationList = new Array();
|
||||||
console.log(res);
|
|
||||||
res.forEach(element => {
|
res.forEach(element => {
|
||||||
let itemImage = {
|
let itemImage = {
|
||||||
title: 'Title',
|
title: 'Title',
|
||||||
@@ -105,13 +118,15 @@ export class ViewPublicationsPage implements OnInit {
|
|||||||
}
|
}
|
||||||
this.publicationList.push(item);
|
this.publicationList.push(item);
|
||||||
});
|
});
|
||||||
console.log(this.publicationList);
|
|
||||||
|
this.publicationListStorage.add(folderId, this.publicationList)
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
},
|
},
|
||||||
(error)=>{
|
(error)=>{
|
||||||
if(error.status == '404'){
|
if(error.status == '404') {
|
||||||
this.error = 'Sem publicações disponíveis!';
|
this.error = 'Sem publicações disponíveis!';
|
||||||
this.publicationList=null;
|
// this.publicationList = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showLoader = false;
|
this.showLoader = false;
|
||||||
|
|||||||
@@ -9,34 +9,38 @@ import { SHA1 } from 'crypto-js'
|
|||||||
export class PublicationListService {
|
export class PublicationListService {
|
||||||
|
|
||||||
// main data
|
// main data
|
||||||
private _list: Publication[] = []
|
private _document: Publication[] = []
|
||||||
// local storage keyName
|
// local storage keyName
|
||||||
private keyName: string;
|
private keyName: string;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
||||||
this.keyName = (SHA1(this.constructor.name+ ' PublicationTravelFolder/local')).toString()
|
this.keyName = (SHA1(this.constructor.name+ 'view-publication-list/local')).toString()
|
||||||
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
let restore = localstoreService.get(this.keyName, [])
|
let restore = localstoreService.get(this.keyName, [])
|
||||||
this._list = restore
|
this._document = restore
|
||||||
}, 10)
|
}, 10)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get list() {
|
get documents() {
|
||||||
return this._list
|
return this._document
|
||||||
}
|
}
|
||||||
|
|
||||||
reset(list: Publication[]) {
|
getDocument(folderId: string) {
|
||||||
this._list = list
|
return this._document[folderId]
|
||||||
|
|
||||||
this.save(this._list)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private save(list: Publication[]) {
|
add(folderId, document) {
|
||||||
|
this._document[folderId] = document
|
||||||
|
|
||||||
setTimeout(()=> {
|
setTimeout(()=> {
|
||||||
localstoreService.set(this.keyName, list)
|
localstoreService.set(this.keyName, this._document)
|
||||||
}, 10)
|
}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export const PublicationListStorage = new PublicationListService()
|
||||||
Reference in New Issue
Block a user