mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 05:16:07 +00:00
Add publication to localstorage
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<div class="aside overflow-y-auto d-flex flex-wrap width-100">
|
||||
<!-- <ion-list class="width-100"> -->
|
||||
<ion-item-sliding disabled="{{showSlidingOptions}}" class="item width-100 cursor-pointer"
|
||||
*ngFor="let viagem of publicationsTravelFolderList">
|
||||
*ngFor="let viagem of publicationTravelFolderService.list">
|
||||
<ion-item lines="none"
|
||||
class="width-100 d-flex ion-no-border ion-no-margin ion-no-padding">
|
||||
<div (click)="goToPublicationsList(viagem.ProcessId)" class="item-icon cursor-pointer">
|
||||
@@ -82,7 +82,8 @@
|
||||
</div>
|
||||
</div> -->
|
||||
<ion-item-sliding disabled="{{showSlidingOptions}}" class="item width-100"
|
||||
*ngFor="let evento of publicationsEventFolderList">
|
||||
*ngFor="let evento of publicationEventFolderStorage.list"
|
||||
>
|
||||
<ion-item lines="none"
|
||||
class="width-100 d-flex ion-no-border ion-no-margin ion-no-padding"
|
||||
(click)="viewPublications(evento)">
|
||||
@@ -200,10 +201,8 @@
|
||||
>
|
||||
</app-edit-action>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</ion-content>
|
||||
</ion-content>
|
||||
@@ -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 = {
|
||||
|
||||
@@ -33,8 +33,9 @@
|
||||
<ion-list>
|
||||
<!-- [routerLink]="['/home/publications/view-publications/publication-detail', publication.publicationId]" -->
|
||||
<div class="post-item"
|
||||
*ngFor="let publication of publicationList"
|
||||
(click)="goToPublicationDetail(publication.DocumentId)">
|
||||
*ngFor="let publication of publicationList"
|
||||
(click)="goToPublicationDetail(publication.DocumentId)"
|
||||
>
|
||||
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
|
||||
<img src="{{publication.FileBase64}}" alt="image">
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ class ExpedienteStorageServiceService {
|
||||
setTimeout(()=>{
|
||||
localstoreService.set(this.keyName, list)
|
||||
}, 10)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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()
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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()
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user