diff --git a/src/app/pages/events/events.page.ts b/src/app/pages/events/events.page.ts index 92f88a67e..4be02690e 100644 --- a/src/app/pages/events/events.page.ts +++ b/src/app/pages/events/events.page.ts @@ -93,7 +93,6 @@ export class EventsPage implements OnInit { } ngOnInit() { - this.activatedRoute.data.subscribe(data => console.log(data)); //Inicializar segment this.segment = "Combinada"; //Initialize profile as mdgpr diff --git a/src/app/pages/publications/publications.page.html b/src/app/pages/publications/publications.page.html index d85ecac3f..0606c6531 100644 --- a/src/app/pages/publications/publications.page.html +++ b/src/app/pages/publications/publications.page.html @@ -38,7 +38,7 @@
+ *ngFor="let viagem of publicationTravelFolderService.list">
@@ -82,7 +82,8 @@
--> + *ngFor="let evento of publicationEventFolderStorage.list" + > @@ -200,10 +201,8 @@ > - - - + \ No newline at end of file diff --git a/src/app/pages/publications/publications.page.ts b/src/app/pages/publications/publications.page.ts index 99a65d1f6..c49bc6570 100644 --- a/src/app/pages/publications/publications.page.ts +++ b/src/app/pages/publications/publications.page.ts @@ -6,13 +6,14 @@ import { PublicationsService } from 'src/app/services/publications.service'; import { NewActionPage } from './new-action/new-action.page'; import { ViewPublicationsPage } from './view-publications/view-publications.page'; -import { Animation, AnimationController } from '@ionic/angular'; -import { LoadingController } from '@ionic/angular'; +import { AnimationController } from '@ionic/angular'; import { LoadingService } from 'src/app/services/loading.service'; import { Publication } from 'src/app/models/publication'; import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page'; import { EditActionPage } from './edit-action/edit-action.page'; import { ToastService } from 'src/app/services/toast.service'; +import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service'; +import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service'; @Component({ selector: 'app-publications', @@ -24,7 +25,6 @@ export class PublicationsPage implements OnInit { publicationFolder: PublicationFolder; publication: Publication; - publicationFolderList: PublicationFolder[]; publicationsEventFolderList: PublicationFolder[]; publicationsTravelFolderList: PublicationFolder[]; @@ -34,7 +34,9 @@ export class PublicationsPage implements OnInit { months: string[]; days:string[]; - + publicationEventFolderStorage = PublicationEventFolderStorage + publicationTravelFolderService = PublicationTravelFolderStore + desktopComponent: any = { showViewPublication: false, showAddNewPublication: false, @@ -57,9 +59,7 @@ export class PublicationsPage implements OnInit { private router: Router, private modalController: ModalController, private animationController: AnimationController, - private loading: LoadingService, private publications: PublicationsService, - private popoverController:PopoverController, private toastService: ToastService ) { this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"]; @@ -121,10 +121,10 @@ export class PublicationsPage implements OnInit { getActions() { this.showLoader = true; this.publications.GetPublicationFolderList().subscribe(res=>{ - this.publicationFolderList = res; - console.log(res); + this.publicationsEventFolderList = new Array(); this.publicationsTravelFolderList = new Array(); + res.forEach(data => { this.theDate = new Date(data.DateBegin); this.theEndDate = new Date(data.DateEnd); @@ -143,7 +143,12 @@ export class PublicationsPage implements OnInit { this.publicationsTravelFolderList.push(folder); } this.showLoader = false; + + this.publicationEventFolderStorage.reset(this.publicationsEventFolderList) + this.publicationTravelFolderService.reset(this.publicationsTravelFolderList) }); + + }); } @@ -319,7 +324,6 @@ export class PublicationsPage implements OnInit { this.getActions(); } - async closeDesktopComponent (xx?: any){ this.desktopComponent = { diff --git a/src/app/pages/publications/view-publications/view-publications.page.html b/src/app/pages/publications/view-publications/view-publications.page.html index b49b541c0..679a5a061 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.html +++ b/src/app/pages/publications/view-publications/view-publications.page.html @@ -33,8 +33,9 @@
+ *ngFor="let publication of publicationList" + (click)="goToPublicationDetail(publication.DocumentId)" + >
image
diff --git a/src/app/pages/publications/view-publications/view-publications.page.ts b/src/app/pages/publications/view-publications/view-publications.page.ts index 1f5df530a..4995b61bb 100644 --- a/src/app/pages/publications/view-publications/view-publications.page.ts +++ b/src/app/pages/publications/view-publications/view-publications.page.ts @@ -5,6 +5,8 @@ import { Publication } from 'src/app/models/publication'; import { PublicationFolder } from 'src/app/models/publicationfolder'; import { LoadingService } from 'src/app/services/loading.service'; import { PublicationsService } from 'src/app/services/publications.service'; +import { PresidentialActionsStore } from 'src/app/store/presidential-actions-store.service'; +import { PublicationTravelFolderStore } from 'src/app/store/publication-travel-folder.service'; import { NewPublicationPage } from '../new-publication/new-publication.page'; import { PublicationDetailPage } from './publication-detail/publication-detail.page'; @@ -22,24 +24,27 @@ export class ViewPublicationsPage implements OnInit { folderId:string; error: any; + presidentialActionsStore = PresidentialActionsStore + publicationTravelFolderStore = PublicationTravelFolderStore + constructor( private loadingController: LoadingService, private modalController: ModalController, private publications: PublicationsService, private activatedRoute: ActivatedRoute, private router: Router ) { - this.item = new PublicationFolder(); - this.activatedRoute.paramMap.subscribe(params => { - console.log(params); - - if(params["params"]) { - this.folderId = params["params"].folderId; - console.log(params["params"]); - } - - }); - } + this.item = new PublicationFolder(); + this.activatedRoute.paramMap.subscribe(params => { + console.log(params); + + if(params["params"]) { + this.folderId = params["params"].folderId; + console.log(params["params"]); + } + + }); + } ngOnInit() { @@ -94,8 +99,10 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = true; this.publications.GetPublications(this.folderId).subscribe(res=>{ - this.publicationList = new Array(); console.log(res); + + let data = []; + res.forEach(element => { let itemImage = { title: 'Title', @@ -114,15 +121,19 @@ export class ViewPublicationsPage implements OnInit { "OriginalFileName": '', "FileExtension": '', } - this.publicationList.push(item); + + // this.publicationList.push(item); + data.push(item) + }); - console.log(this.publicationList); + this.presidentialActionsStore.reset(data) + this.showLoader = false; }, (error)=>{ if(error.status == '404'){ this.error = 'Sem publicações disponíveis!'; - this.publicationList=null; + this.publicationList= []; } this.showLoader = false; diff --git a/src/app/shared/publication/view-publications/view-publications.page.ts b/src/app/shared/publication/view-publications/view-publications.page.ts index 3cb0a5e9a..433f2dff6 100644 --- a/src/app/shared/publication/view-publications/view-publications.page.ts +++ b/src/app/shared/publication/view-publications/view-publications.page.ts @@ -34,7 +34,6 @@ export class ViewPublicationsPage implements OnInit { private publications: PublicationsService, ) { this.item = new PublicationFolder(); - } ngOnInit() { @@ -68,6 +67,7 @@ export class ViewPublicationsPage implements OnInit { event.target.complete(); }, 3000); } + close(){ this.closeDesktopComponent.emit(); } @@ -79,7 +79,7 @@ export class ViewPublicationsPage implements OnInit { }); } - getPublications(){ + getPublications() { this.showLoader = true; this.publications.GetPublications(this.folderId).subscribe(res=>{ @@ -116,8 +116,8 @@ export class ViewPublicationsPage implements OnInit { this.showLoader = false; - }); - + }) + } async AddPublication(publicationType:any, folderId:any) { @@ -145,7 +145,6 @@ export class ViewPublicationsPage implements OnInit { } - async viewPublicationDetail(publicationId:string) { console.log(publicationId); @@ -170,5 +169,4 @@ export class ViewPublicationsPage implements OnInit { } - } diff --git a/src/app/store/expediente-storage-service.service.ts b/src/app/store/expediente-storage-service.service.ts index 181a737a8..d4c91a99d 100644 --- a/src/app/store/expediente-storage-service.service.ts +++ b/src/app/store/expediente-storage-service.service.ts @@ -40,8 +40,8 @@ class ExpedienteStorageServiceService { setTimeout(()=>{ localstoreService.set(this.keyName, list) }, 10) - } + } diff --git a/src/app/store/presidential-actions-store.service.spec.ts b/src/app/store/presidential-actions-store.service.spec.ts new file mode 100644 index 000000000..eade32cff --- /dev/null +++ b/src/app/store/presidential-actions-store.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { PresidentialActionsStoreService } from './presidential-actions-store.service'; + +describe('PresidentialActionsStoreService', () => { + let service: PresidentialActionsStoreService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(PresidentialActionsStoreService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/store/presidential-actions-store.service.ts b/src/app/store/presidential-actions-store.service.ts new file mode 100644 index 000000000..9e48b54f5 --- /dev/null +++ b/src/app/store/presidential-actions-store.service.ts @@ -0,0 +1,46 @@ +import { Injectable } from '@angular/core'; +import { localstoreService } from './localstore.service' +import { AES, enc, SHA1 } from 'crypto-js' +import { Publication } from 'src/app/models/publication'; + +@Injectable({ + providedIn: 'root' +}) +export class PresidentialActionsStoreService { + + // main data + private _list: Publication[] = [] + // local storage keyName + private keyName: string; + + constructor() { + + this.keyName = (SHA1(this.constructor.name+ 'presidentialActions/local')).toString() + + setTimeout(()=>{ + let restore = localstoreService.get(this.keyName, []) + this._list = restore + }, 10) + + } + + get list() { + return this._list + } + + reset(list: Publication[]) { + this._list = list + + this.save(this._list) + } + + private save(list: Publication[]) { + setTimeout(()=> { + localstoreService.set(this.keyName, list) + }, 10) + } + +} + + +export const PresidentialActionsStore = new PresidentialActionsStoreService() \ No newline at end of file diff --git a/src/app/store/publication-event-folder.service.spec.ts b/src/app/store/publication-event-folder.service.spec.ts new file mode 100644 index 000000000..61516ad83 --- /dev/null +++ b/src/app/store/publication-event-folder.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { PublicationEventFolderService } from './publication-event-folder.service'; + +describe('PublicationEventFolderService', () => { + let service: PublicationEventFolderService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(PublicationEventFolderService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/store/publication-event-folder.service.ts b/src/app/store/publication-event-folder.service.ts new file mode 100644 index 000000000..cabdba605 --- /dev/null +++ b/src/app/store/publication-event-folder.service.ts @@ -0,0 +1,43 @@ +import { Injectable } from '@angular/core'; +import { localstoreService } from './localstore.service' +import { SHA1 } from 'crypto-js' +import { PublicationFolder } from '../models/publicationfolder'; + +@Injectable({ + providedIn: 'root' +}) +export class PublicationEventFolderService { + // main data + private _list: PublicationFolder[] = [] + // local storage keyName + private keyName: string; + + constructor() { + + this.keyName = (SHA1(this.constructor.name+ 'PublicationEventFolder/local')).toString() + + setTimeout(()=>{ + let restore = localstoreService.get(this.keyName, []) + this._list = restore + }, 10) + + } + + get list() { + return this._list + } + + reset(list: PublicationFolder[]) { + this._list = list + + this.save(this._list) + } + + private save(list: PublicationFolder[]) { + setTimeout(()=> { + localstoreService.set(this.keyName, list) + }, 10) + } +} + +export const PublicationEventFolderStorage = new PublicationEventFolderService() \ No newline at end of file diff --git a/src/app/store/publication-list.service.spec.ts b/src/app/store/publication-list.service.spec.ts new file mode 100644 index 000000000..c87726648 --- /dev/null +++ b/src/app/store/publication-list.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { PublicationListService } from './publication-list.service'; + +describe('PublicationListService', () => { + let service: PublicationListService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(PublicationListService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/store/publication-list.service.ts b/src/app/store/publication-list.service.ts new file mode 100644 index 000000000..3dc061079 --- /dev/null +++ b/src/app/store/publication-list.service.ts @@ -0,0 +1,42 @@ +import { Injectable } from '@angular/core' +import { Publication } from 'src/app/models/publication' +import { localstoreService } from './localstore.service' +import { SHA1 } from 'crypto-js' + +@Injectable({ + providedIn: 'root' +}) +export class PublicationListService { + + // main data + private _list: Publication[] = [] + // local storage keyName + private keyName: string; + + constructor() { + + this.keyName = (SHA1(this.constructor.name+ ' PublicationTravelFolder/local')).toString() + + setTimeout(()=>{ + let restore = localstoreService.get(this.keyName, []) + this._list = restore + }, 10) + + } + + get list() { + return this._list + } + + reset(list: Publication[]) { + this._list = list + + this.save(this._list) + } + + private save(list: Publication[]) { + setTimeout(()=> { + localstoreService.set(this.keyName, list) + }, 10) + } +} diff --git a/src/app/store/publication-travel-folder.service.spec.ts b/src/app/store/publication-travel-folder.service.spec.ts new file mode 100644 index 000000000..19bfb9971 --- /dev/null +++ b/src/app/store/publication-travel-folder.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { PublicationTravelFolderService } from './publication-travel-folder.service'; + +describe('PublicationTravelFolderService', () => { + let service: PublicationTravelFolderService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(PublicationTravelFolderService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/store/publication-travel-folder.service.ts b/src/app/store/publication-travel-folder.service.ts new file mode 100644 index 000000000..7bd4dadaa --- /dev/null +++ b/src/app/store/publication-travel-folder.service.ts @@ -0,0 +1,46 @@ +import { Injectable } from '@angular/core'; +import { localstoreService } from './localstore.service' +import { SHA1 } from 'crypto-js' +import { Publication } from 'src/app/models/publication'; +import { PublicationFolder } from '../models/publicationfolder'; + +@Injectable({ + providedIn: 'root' +}) +export class PublicationTravelFolderService { + + // main data + private _list: PublicationFolder[] = [] + // local storage keyName + private keyName: string; + + constructor() { + + this.keyName = (SHA1(this.constructor.name+ ' PublicationTravelFolder/local')).toString() + + setTimeout(()=>{ + let restore = localstoreService.get(this.keyName, []) + this._list = restore + }, 10) + + } + + get list() { + return this._list + } + + reset(list: PublicationFolder[]) { + this._list = list + + this.save(this._list) + } + + private save(list: PublicationFolder[]) { + setTimeout(()=> { + localstoreService.set(this.keyName, list) + }, 10) + } +} + + +export const PublicationTravelFolderStore = new PublicationTravelFolderService() \ No newline at end of file