This commit is contained in:
tiago.kayaya
2022-02-17 10:48:37 +01:00
34 changed files with 333 additions and 285 deletions
+1
View File
@@ -1,3 +1,4 @@
<ion-tabs class="tab">
<ion-tab-bar class="bottoms" slot="bottom">
<ion-tab-button tab="events" [class.active]="pathname === '/home/events' ">
+2 -2
View File
@@ -100,9 +100,9 @@ export class HomePage implements OnInit {
private processservice: ProcessesService,
private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService,
private RouteService: RouteService,
public RouteService: RouteService,
private WsChatService: WsChatService,
private NativeNotificationService: NativeNotificationService) {
private NativeNotificationService: NativeNotificationService,) {
/* this.webNotificationPopupService.askNotificationPermission() */
+1
View File
@@ -58,6 +58,7 @@ export class UserSession {
UserName: string
Password: string
RochetChatUser: string
RochetChatUserId: string
Profile: any;
LoginPreference: 'None' | 'Password' | 'Pin' | null;
PIN: string
@@ -52,7 +52,7 @@
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getDmRoom(this.roomId).messages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId" >
<div (press)="handlePress(msg._id)" class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' (click)="downloadFileMsg(msg)" *ngIf="msg.msg !=''">
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<ion-label (click)="hkellor()">{{msg.u.name}}</ion-label>
<span class="time">{{msg.duration}}</span>
</div>
<div>
@@ -856,6 +856,12 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
// dialogTitle: 'Share with buddies',
// });
// }
hkellor() {
// alert('cool!')
}
}
+4 -4
View File
@@ -102,8 +102,8 @@ export class LoginPage implements OnInit {
if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
await this.authService.loginChat();
await this.authService.loginToChatWs()
// await this.authService.loginChat();
// await this.authService.loginToChatWs()
this.getToken();
SessionStore.setInativity(true);
@@ -117,8 +117,8 @@ export class LoginPage implements OnInit {
await this.authService.SetSession(attempt, this.userattempt);
this.changeProfileService.run()
await this.authService.loginChat();
await this.authService.loginToChatWs()
// await this.authService.loginChat();
// await this.authService.loginToChatWs()
this.getToken();
this.router.navigateByUrl('/pin', { replaceUrl: true });
}
@@ -11,8 +11,6 @@ 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';
import { SqliteService } from 'src/app/services/sqlite.service';
import { BackgroundService } from 'src/app/services/background.service';
import { ThemeService } from 'src/app/services/theme.service'
@@ -39,8 +37,6 @@ export class PublicationsPage implements OnInit {
months: string[];
days: string[];
publicationEventFolderStorage = PublicationEventFolderStorage
publicationTravelFolderService = PublicationTravelFolderStore
desktopComponent: any = {
showViewPublication: false,
@@ -5,9 +5,6 @@ import { Publication } from 'src/app/models/publication';
import { PublicationFolder } from 'src/app/models/publicationfolder';
import { PublicationPipe } from 'src/app/pipes/publication.pipe';
import { PublicationsService } from 'src/app/services/publications.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 { NewPublicationPage } from '../new-publication/new-publication.page';
import { PublicationDetailPage } from './publication-detail/publication-detail.page';
import { SqliteService } from 'src/app/services/sqlite.service';
@@ -31,11 +28,6 @@ export class ViewPublicationsPage implements OnInit {
id: string;
error: any;
publicationListStorage = PublicationListStorage
//
publicationEventFolderStorage = PublicationEventFolderStorage
publicationTravelFolderService = PublicationTravelFolderStore
publicationPipe = new PublicationPipe()
publicationDitails: any;
getpublication = [];
@@ -168,7 +160,6 @@ export class ViewPublicationsPage implements OnInit {
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList;
this.showLoader = false;
@@ -208,7 +199,6 @@ export class ViewPublicationsPage implements OnInit {
});
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList;
this.showLoader = false;
@@ -220,7 +210,6 @@ export class ViewPublicationsPage implements OnInit {
if (error.status == '404') {
this.error = 'Sem publicações disponíveis!';
this.publicationList = [];
this.publicationListStorage.add(folderId, this.publicationList)
}
this.showLoader = false;
});
+3 -3
View File
@@ -228,7 +228,7 @@ export class AuthService {
}, 1) */
}
autologout(expirationDate:number){
autologout(expirationDate:number) {
setTimeout(()=>{
this.logout();
}, expirationDate)
@@ -248,13 +248,13 @@ export class AuthService {
}
//Get user data from RocketChat | global object
getUserData(){
getUserData() {
this.storageService.get(AuthConnstants.AUTH).then(res=>{
this.userData$.next(res);
});
}
logoutChat(){
logoutChat() {
//this.storageService.clear();
/* this.storageService.removeStorageItem(AuthConnstants.AUTH).then(res =>{
this.userData$.next('');
+54 -3
View File
@@ -18,7 +18,13 @@ export class MessageService {
msg = ''
rid = ''
ts = {}
u = {}
u = {
name: '',
username: '',
_id: ""
}
t = ''
_id =''
_updatedAt
@@ -35,6 +41,8 @@ export class MessageService {
loadHistory = false
duration = ''
localReference = null
viewed = []
received = []
constructor(private storage: Storage,
private NfService: NfService,
@@ -78,6 +86,7 @@ export class MessageService {
}
}
this.calDateDuration()
}
@@ -140,9 +149,9 @@ export class MessageService {
console.log('message', message)
let ChatMessage = message.result
if (environment.chatOffline) {
// this.redefinedMessage(ChatMessage)
this.redefinedMessage(ChatMessage)
this.offline = false
}
@@ -189,5 +198,47 @@ export class MessageService {
this.duration = showDateDuration(date || this._updatedAt);
}
private messageReceptor() {
return this.u.username != SessionStore.user.RochetChatUser
}
receptorReceive() {
if(this.messageReceptor()) {
let newMessage = {
rid: this._id,
msg: this.msg,
attachments: this.attachments,
file: this.file,
localReference: this.localReference,
viewed: this.viewed.push('123'),
received: this.viewed.push('123'),
}
this.WsChatService.updateMessage(newMessage).then(()=>{
console.log('newMessage', newMessage)
})
}
}
receptorView() {
if(this.messageReceptor()) {
let newMessage = {
rid: this._id,
msg: this.msg,
attachments: this.attachments,
file: this.file,
localReference: this.localReference,
viewed: this.viewed.push('123'),
received: this.viewed.push('123'),
}
this.WsChatService.updateMessage(newMessage).then(()=>{
console.log('newMessage', newMessage)
})
}
}
}
+53 -2
View File
@@ -201,6 +201,40 @@ export class RoomService {
})
}
}
async updateViewedMessage(id, userId) {
if (environment.chatOffline) {
this.storage.get('chatmsg' + this.id).then((messages: any = []) => {
if(!Array.isArray(messages)) {
messages = []
}
let index;
const find = messages.find((message, _index)=> {
if(message._id == id) {
index = _index
return true
}
return false
})
if(find) {
if(!messages[index].hasOwnProperty('viewed') || !Array.isArray(messages[index].viewed)) {
messages.viewed = []
}
messages.viewed.push(userId)
this.storage.set('chatmsg' + this.id, messages)
}
})
}
}
/**
@@ -279,11 +313,16 @@ export class RoomService {
attachments,
file,
temporaryData,
localReference
localReference,
viewed: [],
received: []
}
const message: MessageService = this.prepareMessage(offlineChatMessage, environment.chatOffline)
/**
* @description redefine message offline data "offlineChatMessage" with live ChatMessage
*/
message.send().then((ChatMessage) => {
this.updateMessageDB(ChatMessage, localReference)
})
@@ -305,6 +344,13 @@ export class RoomService {
this.message= ''
}
/**
*
* @param message
* @param ChatMessage
* @description when creating message we use offline data, then we need redefined with live data
*/
redefinedMessage (message: MessageService, ChatMessage) {
ChatMessage = this.fix_updatedAt(ChatMessage)
@@ -448,7 +494,12 @@ export class RoomService {
}
/**
* @description find or create message
* @param message
* @param save
* @returns
*/
prepareMessage(message, save = true): MessageService {
message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage, this.NfService, this.WsChatService)
@@ -22,8 +22,8 @@ export class WsChatMethodsService {
dm: {[key: string]: RoomService} = {}
group: {[key: string]: RoomService} = {}
_dm = []
_group = []
_dm: RoomService[] = []
_group: RoomService[] = []
loadingWholeList = false
@@ -71,7 +71,9 @@ export class WsChatMethodsService {
}
})
this.changeProfileService.registerCallback(()=>{
// on change profile remove a rooms
this.changeProfileService.registerCallback(() => {
this.clearChat()
this.ReLoadChat()
this.storage.remove('Rooms');
@@ -142,13 +144,6 @@ export class WsChatMethodsService {
this.users = []
}
getRoomFromDb() {
this.storage.get('Rooms').then((rooms) => {
rooms.result.update.forEach((roomData: room) => {
this.prepareRoom(roomData);
});
})
}
openRoom(roomId) {
@@ -186,7 +181,6 @@ export class WsChatMethodsService {
async getAllRooms () {
this.loadingWholeList = true
//this.getRoomFromDb();
const rooms = await this.WsChatService.getRooms();
await this.storage.remove('Rooms');
await this.storage.set('Rooms', rooms);
@@ -266,6 +260,9 @@ export class WsChatMethodsService {
prepareRoom(roomData) {
/**
* @description data used to define or create room
*/
const setData = {
customFields: roomData.customFields,
id: this.getRoomId(roomData),
@@ -277,13 +274,16 @@ export class WsChatMethodsService {
let roomId = this.getRoomId(roomData)
if(!this.dm[roomId] && !this.group[roomId]) {
// create room
if(!this.roomExist(roomId)) {
let room:RoomService = new RoomService(this.WsChatService, new MessageService(this.storage, this.NfService, this.WsChatService), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService, this.ChatService, this.NfService)
room.setData(setData)
room.receiveMessage()
room.getAllUsers = this.getUsers
room.receiveMessageDelete();
room.sortRoomList = this.sortRoomList
// create individual room
if(this.isIndividual(roomData)) {
@@ -292,12 +292,16 @@ export class WsChatMethodsService {
this.dmCount++
} else {
// create group room
this.group[roomId] = room
this._group.push(room)
this.groupCount++
}
} else {
// in this case room is already present, therefor it will only be necessary,
// to redefine
if(this.dm[roomId]) {
this.dm[roomId].setData(setData)
@@ -306,11 +310,11 @@ export class WsChatMethodsService {
}
}
}
roomExist(roomId) {
return this.dm[roomId] && this.group[roomId]
}
getReceptorName(roomData) {
try {
@@ -326,20 +330,20 @@ export class WsChatMethodsService {
*/
private getUserStatus(id?:string) {
// this.WsChatService.getUserStatus((d) => {
this.WsChatService.getUserStatus((d) => {
// const username = d.fields.args[0][1]
// const statusNum = d.fields.args[0][2]
const username = d.fields.args[0][1]
const statusNum = d.fields.args[0][2]
// const statusText = this.statusNumberToText(statusNum)
const statusText = this.statusNumberToText(statusNum)
// const user = this.getUserByName(username)
const user = this.getUserByName(username)
// if(user) {
// user.status = statusText
// }
if(user) {
user.status = statusText
}
// })
})
}
@@ -393,8 +397,11 @@ export class WsChatMethodsService {
}
hidingRoom(id?) {
//this.hideRoom(id);
return this.WsChatService.hidingRoom(id);
return this.WsChatService.hidingRoom(id).then(()=>{
// this.hideRoom(id)
})
}
addRoomOwner(roomid, userId){
@@ -420,7 +427,7 @@ export class WsChatMethodsService {
getRoomName(roomData: room) {
if(this.isIndividual(roomData)) {
const names: String[] = roomData.usernames
const roomName = names.filter((name)=>{
const roomName = names.filter((name, index)=>{
return name != SessionStore.user.RochetChatUser
})[0]
+23
View File
@@ -186,6 +186,29 @@ export class WsChatService {
});
}
updateMessage(messageObject) {
const requestId = uuidv4()
var message = {
msg: "method",
method: "updateMessage",
id: requestId,
params: [messageObject]
}
this.ws.send({message, requestId});
return new Promise((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId ) { // same request send
resolve({message, requestId})
return true
}
}})
})
}
leaveRoom(roomId) {
const requestId = uuidv4()
+50 -15
View File
@@ -1,6 +1,7 @@
import { Injectable } from '@angular/core';
import { NavigationEnd, Router, NavigationStart } from '@angular/router';
import { NavigationEnd, Router, NavigationStart, NavigationExtras } from '@angular/router';
import { LocalstoreService } from '../store/localstore.service';
import { Location } from '@angular/common'
@Injectable({
providedIn: 'root'
@@ -8,11 +9,15 @@ import { NavigationEnd, Router, NavigationStart } from '@angular/router';
export class RouteService {
history: any = [];
isGoBack = false;
constructor(
private router: Router,
private LocalstoreService: LocalstoreService,
private Location: Location
) {
this.history = this.LocalstoreService.get('history', [])
this.router.events.forEach((event) => {
if (event instanceof NavigationEnd) {
@@ -20,6 +25,7 @@ export class RouteService {
if(event.url != lastRoute) {
this.history.push(event.url)
this.reduceHistory()
}
}
@@ -30,27 +36,56 @@ export class RouteService {
}
/**
* @param url [string] incase no history to go back
* @param option [Object] some options to the url
*/
goBack(url = null, option: object = {}) {
console.log(url);
* @param url [string] incase no history to go back */
goBack(url = null) {
if(this.history.length >= 2) {
console.log(this.history);
this.history.pop();
const goTo = this.history.pop();
this.isGoBack = true;
this.router.navigate([goTo]);
const url = this.history.pop();
this.goTo(url)
} else if(url) {
this.goTo({url})
this.goTo(url)
}
this.reduceHistory()
}
goTo({url}) {
this.router.navigate([url]);
goTo(url) {
let navigationExtras: NavigationExtras = {
queryParams: this.queryParams(url)
}
const urlObject = new URL('http://localhost:8100'+url);
this.router.navigate([urlObject.pathname], navigationExtras);
}
reduceHistory() {
if(this.history.length >= 15) {
this.history = this.history.slice(5, this.history.length)
}
this.LocalstoreService.set('history', this.history)
}
queryParams(url) {
const urlObject = new URL('http://localhost:8100'+url);
const paramsString = urlObject.search;
let searchParams: any = new URLSearchParams(paramsString);
let params = {}
for (let [key, value] of searchParams) {
params[key] = value
}
console.log('params', params)
return params
}
}
@@ -48,11 +48,16 @@
</mat-menu>
</div>
<div class="title">
<ion-label>{{msg.u.name}}</ion-label>
<ion-label (click)="testEditMessage(msg)">{{msg.u.name}}</ion-label>
<span class="time">{{msg.duration}}</span>
</div>
<div>
<ion-label>{{msg.msg}}</ion-label>
<div class="d-flex justify-space-between">
<ion-label class="flex-0">{{msg.msg}}</ion-label>
<ion-label class="float-status-all float-status" >
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon>
</ion-label>
{{last ? scrollToBottom() : ''}}
</div>
</div>
@@ -75,6 +80,11 @@
<div *ngFor="let file of msg.attachments">
<div *ngIf="msg.file.type == 'application/img'" (click)="openPreview(msg)" dfsdvsvs>
<img src={{msg.attachments[0].image_url}} alt="image">
<ion-label class="float-status-image float-status-all">
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon>
</ion-label>
</div>
<div *ngIf="msg.file.type != 'application/img'">
<div class="file">
@@ -99,6 +109,11 @@
<span
*ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label>
<ion-label class="float-status-webtrix float-status-all">
<ion-icon *ngIf="!msg.offline && msg.viewed.length == 0" src="assets/images/check-double-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.offline && msg.viewed.length == 0" src="assets/images/check-solid.svg"></ion-icon>
<ion-icon *ngIf="msg.viewed.length == 1" src="assets/images/check-double-solid -viewed.svg"></ion-icon>
</ion-label>
</div>
</div>
</div>
@@ -287,3 +287,29 @@ display: block;
padding-left: 10px;
}
.float-status{
position: relative !important;
float: right;
display: flex;
align-items: self-end;
}
.float-status-image{
position: relative !important;
float: right;
display: flex;
align-items: self-end;
top: -15px;
}
.float-status-webtrix {
position: relative !important;
top: 0px !important;
float: right;
display: flex;
align-items: self-end;
}
.float-status-all {
font-size: 10pt !important;
}
@@ -769,6 +769,12 @@ console.log(msg);
}
}
testEditMessage(msg:MessageService) {
msg.receptorReceive()
// alert('cool!')
}
}
@@ -18,8 +18,8 @@ import { Storage } from '@ionic/storage';
export class EventsToApprovePage implements OnInit {
showLoader: boolean;
eventsPRList: any[] = [];
eventsMDGPRList: any[] = [];
eventsPRList: any = []
eventsMDGPRList: any = []
eventPerson: EventPerson;
eventBody: EventBody;
categories: string[];
@@ -155,6 +155,10 @@ export class EventsToApprovePage implements OnInit {
}
close(){
this.modalController.dismiss(null);
// this.RouteService.goBack('/home/gabinetedigital')
}
+1
View File
@@ -133,4 +133,5 @@
</div>
</div>
<div class="header-bottom-line"></div>
<!-- {{ RouteService.history | json }} -->
</div>
+3 -1
View File
@@ -11,6 +11,7 @@ import { environment } from 'src/environments/environment';
import { EventTrigger } from '../../services/eventTrigger.service';
import { ThemeService } from '../../services/theme.service';
import { interval } from 'rxjs';
import { RouteService } from 'src/app/services/route.service';
@Component({
selector: 'app-header',
@@ -39,7 +40,8 @@ export class HeaderPage implements OnInit {
private platform: Platform,
//private notificationsService: NotificationsService,
private eventrigger: EventTrigger,
public ThemeService: ThemeService
public ThemeService: ThemeService,
public RouteService: RouteService
) {
this.loggeduser = SessionStore.user;
router.events.subscribe((val) => {
@@ -6,9 +6,6 @@ import { LoadingService } from 'src/app/services/loading.service';
import { PublicationsService } from 'src/app/services/publications.service';
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';
import { PublicationPipe } from 'src/app/pipes/publication.pipe';
import { ThemeService } from 'src/app/services/theme.service'
import { ToastService } from 'src/app/services/toast.service';
@@ -38,11 +35,6 @@ export class ViewPublicationsPage implements OnInit {
@Output() goBacktoPublicationDetails = new EventEmitter<any>();
publicationListStorage = PublicationListStorage
//
publicationEventFolderStorage = PublicationEventFolderStorage
publicationTravelFolderService = PublicationTravelFolderStore
publicationPipe = new PublicationPipe()
constructor(
@@ -136,7 +128,6 @@ export class ViewPublicationsPage implements OnInit {
this.storage.set('view_publications', this.publicationList);
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList;
this.showLoader = false;
},() => {
@@ -162,7 +153,6 @@ export class ViewPublicationsPage implements OnInit {
this.publicationList.push(item);
});
this.publicationListStorage.add(folderId, this.publicationList)
await this.storage.remove('view_publications');
await this.storage.set('view_publications', this.publicationList);
//this.getFromDB();
@@ -172,7 +162,6 @@ export class ViewPublicationsPage implements OnInit {
if(error.status == '404') {
this.error = 'Sem publicações disponíveis!';
this.publicationList= [];
this.publicationListStorage.add(folderId, this.publicationList)
}
this.showLoader = false;
@@ -1,45 +0,0 @@
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.list || []
}, 10)
}
get list() {
return this._list || []
}
reset(list: PublicationFolder[]) {
this._list = list || []
this.save()
}
private save() {
setTimeout(()=> {
localstoreService.set(this.keyName, {
list: this._list || []
})
}, 10)
}
}
export const PublicationEventFolderStorage = new PublicationEventFolderService()
@@ -1,16 +0,0 @@
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();
});
});
-50
View File
@@ -1,50 +0,0 @@
import { Injectable } from '@angular/core'
import { localstoreService } from './localstore.service'
import { SHA1 } from 'crypto-js'
@Injectable({
providedIn: 'root'
})
export class PublicationListService {
// main data
private _document = {}
// local storage keyName
private keyName: string;
constructor() {
this.keyName = (SHA1(this.constructor.name+ 'view-publication-list/local')).toString()
setTimeout(()=>{
let restore = localstoreService.get(this.keyName, {})
this._document = restore.document || {}
}, 10)
}
get documents() {
return this._document
}
getDocument(folderId) {
return this._document[folderId]
}
add(folderId, document = []) {
this._document[folderId] = document
setTimeout(()=> {
localstoreService.set(this.keyName, {
document: this._document
})
}, 100)
}
}
export const PublicationListStorage = new PublicationListService()
@@ -1,16 +0,0 @@
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();
});
});
@@ -1,48 +0,0 @@
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.list
}, 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: this._list
})
}, 10)
}
}
export const PublicationTravelFolderStore = new PublicationTravelFolderService()