Add counter to localstorage

This commit is contained in:
Peter Maquiran
2021-07-21 22:44:24 +01:00
parent f604c72575
commit fe211ae53d
6 changed files with 23 additions and 32 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<ion-tab-button tab="events"> <ion-tab-button tab="events">
<!-- <ion-icon name="home"></ion-icon> --> <!-- <ion-icon name="home"></ion-icon> -->
<ion-icon class="nav-icon" src="assets/images/icons-nav-home.svg"></ion-icon> <ion-icon class="nav-icon" src="assets/images/icons-nav-home.svg"></ion-icon>
<ion-badge color="danger">{{totalEvent}}</ion-badge> <ion-badge color="danger">{{toDayEventStorage.eventsList.length}}</ion-badge>
<ion-label>Início</ion-label> <ion-label>Início</ion-label>
</ion-tab-button> </ion-tab-button>
+4 -27
View File
@@ -10,6 +10,7 @@ import { NotificationsService } from '../services/notifications.service';
import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular'; import { ModalController, AlertController, AnimationController, Platform } from '@ionic/angular';
import { NavigationExtras,Router,ActivatedRoute } from '@angular/router'; import { NavigationExtras,Router,ActivatedRoute } from '@angular/router';
import { ToastService } from '../services/toast.service'; import { ToastService } from '../services/toast.service';
import { ToDayEventStorage } from '../store/to-day-event-storage.service';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@@ -25,6 +26,9 @@ export class HomePage implements OnInit {
totalExpediente = 0; totalExpediente = 0;
profile: string; profile: string;
toDayEventStorage = ToDayEventStorage
adding: "intervenient" | "CC" = "intervenient"; adding: "intervenient" | "CC" = "intervenient";
mobileComponent = { mobileComponent = {
showAddNewEvent: false, showAddNewEvent: false,
@@ -71,33 +75,6 @@ export class HomePage implements OnInit {
this.mobilefirstConnect(); this.mobilefirstConnect();
this.notificatinsservice.onReceviNotification(); this.notificatinsservice.onReceviNotification();
} }
this.count();
}
async count() {
// let date = new Date();
// date.setMonth(date.getMonth() + 1);
// let start = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
// let end = date.getFullYear() + "-" + date.getMonth() + "-" + date.getDate() + " 23:59:59";
// this.profile = "mdgpr";
// if (this.profile == "mdgpr") {
// let mdOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise();
// let mdPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
// this.eventsList = mdOficialEvents.concat(mdPessoalEvents)
// this.totalEvent = this.eventsList.length;
// }
// else {
// let prOficialEvents = await this.eventService.getAllPrOficialEvents(start, end).toPromise();
// let prPessoalEvents = await this.eventService.getAllPrPessoalEvents(start, end).toPromise();
// this.eventsList = prOficialEvents.concat(prPessoalEvents)
// this.totalEvent = this.eventsList.length;
// }
} }
@@ -5,6 +5,7 @@ import { ProcessesService } from 'src/app/services/processes.service';
import { ModalController } from '@ionic/angular'; import { ModalController } from '@ionic/angular';
import { AlertService } from 'src/app/services/alert.service'; import { AlertService } from 'src/app/services/alert.service';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { ExpedienteStorage } from 'src/app/store/expediente-storage-service.service';
@Component({ @Component({
selector: 'app-expediente', selector: 'app-expediente',
@@ -21,6 +22,8 @@ export class ExpedientePage implements OnInit {
taskslist:DailyWorkTask[] = []; taskslist:DailyWorkTask[] = [];
serialNumber:string; serialNumber:string;
expedienteStorage = ExpedienteStorage
constructor( constructor(
private processes:ProcessesService, private processes:ProcessesService,
private modalController: ModalController, private modalController: ModalController,
@@ -7,7 +7,6 @@ import { NewActionPage } from './new-action/new-action.page';
import { ViewPublicationsPage } from './view-publications/view-publications.page'; import { ViewPublicationsPage } from './view-publications/view-publications.page';
import { AnimationController } from '@ionic/angular'; import { AnimationController } from '@ionic/angular';
import { LoadingService } from 'src/app/services/loading.service';
import { Publication } from 'src/app/models/publication'; import { Publication } from 'src/app/models/publication';
import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page'; import { ActionsOptionsPage } from 'src/app/shared/popover/actions-options/actions-options.page';
import { EditActionPage } from './edit-action/edit-action.page'; import { EditActionPage } from './edit-action/edit-action.page';
@@ -5,7 +5,6 @@ import { Publication } from 'src/app/models/publication';
import { PublicationFolder } from 'src/app/models/publicationfolder'; 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 { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service'; import { PublicationEventFolderStorage } from 'src/app/store/publication-event-folder.service';
import { PublicationListStorage } from 'src/app/store/publication-list.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';
@@ -12,6 +12,7 @@ class ExpedienteStorageServiceService {
// main data // main data
private _list: Event[] private _list: Event[]
private _count = 0
// local storage keyName // local storage keyName
private keyName: string; private keyName: string;
@@ -21,7 +22,8 @@ class ExpedienteStorageServiceService {
setTimeout(()=>{ setTimeout(()=>{
let restore = localstoreService.get(this.keyName, []) let restore = localstoreService.get(this.keyName, [])
this._list = restore this._list = restore.list
this._count = restore.count
}, 10) }, 10)
} }
@@ -30,15 +32,26 @@ class ExpedienteStorageServiceService {
return this._list return this._list
} }
get count() {
return this._count
}
set count(value) {
this._count = value
}
reset(list: any) { reset(list: any) {
this._list = list this._list = list
this.count = this._list.length
this.save(this._list) this.save(this._list)
} }
private save(list: any) { private save(list: any) {
setTimeout(()=>{ setTimeout(()=>{
localstoreService.set(this.keyName, list) localstoreService.set(this.keyName, {
list: list,
count: this.count
})
}, 10) }, 10)
} }