This commit is contained in:
Peter Maquiran
2023-08-10 16:46:55 +01:00
parent 8b3989de3b
commit 19ddb18148
33 changed files with 257 additions and 222 deletions
-1
View File
@@ -36,7 +36,6 @@
"output": "./svg" "output": "./svg"
}, },
"src/manifest.webmanifest", "src/manifest.webmanifest",
"src/combined-sw.js",
"src/firebase-messaging-sw.js" "src/firebase-messaging-sw.js"
], ],
"styles": [ "styles": [
-60
View File
@@ -1,60 +0,0 @@
// if ("serviceWorker" in navigator) {
// navigator.serviceWorker
// .register("./firebase-messaging-sw.js")
// .then(function(registration) {
// console.log("Registration successful, scope is:", registration.scope);
// messaging.getToken({vapidKey: 'BEuyzkUKcx4FSs-6GaIz_si2oV5Ut7e5ZEtcrVvr5L_tMVWZtS1NTqdtQkih5QCt2FZKuRUxZIaLm5GaxI6nJEw', serviceWorkerRegistration : registration })
// .then((currentToken) => {
// if (currentToken) {
// console.log('current token for client: ', currentToken);
// // Track the token -> client mapping, by sending to backend server
// // show on the UI that permission is secured
// } else {
// console.log('No registration token available. Request permission to generate one.');
// // shows on the UI that permission is required
// }
// }).catch((err) => {
// console.log('An error occurred while retrieving token. ', err);
// // catch error while creating client token
// });
// })
// .catch(function(err) {
// console.log("Service worker registration failed, error:" , err );
// });
// }
// Scripts for firebase and firebase messaging
/* importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/8.2.0/firebase-messaging.js');
// Initialize the Firebase app in the service worker by passing the generated config
var firebaseConfig = {
apiKey: "AIzaSyAAdHmTFznCMerdT99nrewJgISRvtxPqoY",
authDomain: "gabinete-digital-2020.firebaseapp.com",
databaseURL: "https://gabinete-digital-2020.firebaseio.com",
projectId: "gabinete-digital-2020",
storageBucket: "gabinete-digital-2020.appspot.com",
messagingSenderId: "800733765231",
appId: "1:800733765231:web:28e7792ab150006513779a",
measurementId: "G-8QN4BLZ8XK"
};
firebase.initializeApp(firebaseConfig);
// Retrieve firebase messaging
const messaging = firebase.messaging();
messaging.onBackgroundMessage(function(payload) {
console.log('Received background message ', payload);
const notificationTitle = payload.notification.title;
const notificationOptions = {
body: payload.notification.body,
};
self.registration.showNotification(notificationTitle,
notificationOptions);
}); */
+8
View File
@@ -123,6 +123,14 @@ export class HomePage implements OnInit {
} }
navigator.serviceWorker.ready.then((registration) => {
console.log('yes please')
registration.active.postMessage(
"Test message sent immediately after creation",
);
});
} }
goto(url) { goto(url) {
+42 -45
View File
@@ -54,61 +54,58 @@ models.register({
// // acçoes // // acçoes
// export class ActionModel extends models.Model{ export class ActionModel extends models.Model{
// static $tableName = '' static $tableName = 'ActionModel11'
// ProcessId = models.IntegerField({unique: true}) ProcessId = models.IntegerField({unique: true})
// Description = models.CharField() Description = models.CharField()
// Detail = models.CharField() Detail = models.CharField()
// DateBegin = models.CharField() DateBegin = models.CharField()
// DateEnd = models.CharField() DateEnd = models.CharField()
// ActionType = models.CharField() ActionType = models.CharField()
// } }
// export class PublicationFolderModel extends models.Model{ export class PublicationFolderModel extends models.Model{
// static $tableName = ''
// DateBegin = models.CharField() DateBegin = models.CharField()
// Description = models.CharField() Description = models.CharField()
// Detail = models.CharField() Detail = models.CharField()
// } }
// export class PublicationDetailsModel extends models.Model{ export class PublicationDetailsModel extends models.Model{
// static $tableName = ''
// DateIndex = models.CharField() DateIndex = models.CharField()
// DocumentId = models.IntegerField({unique: true}) DocumentId = models.IntegerField({unique: true})
// ProcessId = models.CharField() ProcessId = models.CharField()
// Title = models.CharField() Title = models.CharField()
// Message = models.CharField() Message = models.CharField()
// DatePublication = models.CharField() DatePublication = models.CharField()
// OriginalFileName = models.CharField() OriginalFileName = models.CharField()
// FileBase64 = models.CharField() FileBase64 = models.CharField()
// FileExtension = models.CharField() FileExtension = models.CharField()
// OrganicEntityId = models.IntegerField() OrganicEntityId = models.IntegerField()
// } }
// export class WebtrixUserModel extends models.Model { export class WebtrixUserModel extends models.Model {
// static $tableName = ''
// FullName = models.CharField() FullName = models.CharField()
// Role = models.CharField() Role = models.CharField()
// } }
// models.register({ models.register({
// databaseName: 'webtrix'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction), databaseName: 'webtrix'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
// type: 'indexedDB', type: 'indexedDB',
// version: 1, version: 1,
// models: [WebtrixUserModel] models: [WebtrixUserModel]
// }) })
// models.register({ models.register({
// databaseName: 'actions'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction), databaseName: 'actions'+environment.version.lastCommitNumber + environment.id + Number(environment.storageProduction),
// type: 'indexedDB', type: 'indexedDB',
// version: 14, version: 14,
// models: [PublicationDetailsModel, ActionModel, PublicationFolderModel] models: [PublicationDetailsModel, ActionModel, PublicationFolderModel]
// }) })
@@ -148,9 +148,9 @@ ion-content {
font-size: rem(13); font-size: rem(13);
color: #797979; color: #797979;
padding: 10px; padding: 10px;
margin: 0 auto; margin: 0 auto !important;
line-height: 1.2rrem; line-height: 1.2rem;
margin: 20px 39px 25px; // margin: 20px 39px 25px;
border-radius: 8px; border-radius: 8px;
} }
+3 -3
View File
@@ -26,7 +26,7 @@
<div class="main-content justify-center d-flex height-100"> <div class="main-content justify-center d-flex height-100">
<div class="box-container width-100 d-flex mx-20 overflow-hidden" style="padding: 0px;overflow: hidden;"> <div class="box-container width-100 d-flex mx-20 overflow-hidden" style="padding: 0px;overflow: hidden;">
<ion-progress-bar type="indeterminate" *ngIf="loadingAllTask || TaskService.showLoader"></ion-progress-bar> <ion-progress-bar type="indeterminate" *ngIf="loadingAllTask || TaskService.showLoaderNum != 0"></ion-progress-bar>
<div class="px-20 pb-20 container-filters"> <div class="px-20 pb-20 container-filters">
<p class="time ion-text-left font-18-em">{{customDate}}</p> <p class="time ion-text-left font-18-em">{{customDate}}</p>
<div class="filters-box wrap d-flex float-left"> <div class="filters-box wrap d-flex float-left">
@@ -137,7 +137,7 @@
</div> </div>
<div class="flex-1"> <div class="flex-1">
<div *ngIf="p.userPermission([p.permissionList.Gabinete.access])" class="schedule schedule-1 height-100"> <div *ngIf="p.userPermission([p.permissionList.Gabinete.access])" class="schedule schedule-1 height-100">
<ion-progress-bar type="indeterminate" *ngIf="showCorrespondenciasLoader"></ion-progress-bar> <ion-progress-bar type="indeterminate" *ngIf="loadingAllTask || TaskService.showLoaderNum != 0"></ion-progress-bar>
<div class="schedule-header"> <div class="schedule-header">
<div class="title"> <div class="title">
<ion-icon class="icon" slot="end" src="assets/images/icons-correspondencias.svg"></ion-icon> <ion-icon class="icon" slot="end" src="assets/images/icons-correspondencias.svg"></ion-icon>
@@ -292,7 +292,7 @@
<div class="content overflow-y-auto flex-grow-1 height-100"> <div class="content overflow-y-auto flex-grow-1 height-100">
<ion-list> <ion-list>
<ion-item class="item-hover cursor-pointer" lines="none" *ngFor = "let task of AllProcess" <ion-item class="item-hover cursor-pointer" lines="none" *ngFor = "let task of AllProcess"
(click)="goToExpediente(task.SerialNumber)"> (click)="TaskService.goToProcess(task.SerialNumber || task.serialNumber, task.WorkflowName || task.workflowName || task.workflowDisplayName || task.workflowName, task.activityInstanceName)">
<div class="item-exp d-flex"> <div class="item-exp d-flex">
<div class="schedule-date"> <div class="schedule-date">
<div class="time-end">{{task.TaskStartDate | date: 'dd-MM-yy'}}</div> <div class="time-end">{{task.TaskStartDate | date: 'dd-MM-yy'}}</div>
+1 -25
View File
@@ -54,7 +54,6 @@ export class EventsPage implements OnInit {
expedienteGdStore = ExpedienteGdStore expedienteGdStore = ExpedienteGdStore
listToPresent = []; listToPresent = [];
listToPresentexpediente = []
expedienteTaskPipe = new ExpedienteTaskPipe() expedienteTaskPipe = new ExpedienteTaskPipe()
@@ -103,7 +102,6 @@ export class EventsPage implements OnInit {
this.changeProfileService.registerCallback(() => { this.changeProfileService.registerCallback(() => {
this.listToPresent = []; this.listToPresent = [];
this.listToPresentexpediente = []
}) })
@@ -275,12 +273,6 @@ export class EventsPage implements OnInit {
// //
}) })
this.storage.get('process').then((process: any[] = []) => {
//
if(Array.isArray(process)) {
this.listToPresentexpediente = process;
}
})
this.showLoader = false; this.showLoader = false;
@@ -355,21 +347,8 @@ export class EventsPage implements OnInit {
LoadList() { LoadList() {
if(this.firstEnter) { if(this.firstEnter) {
this.showCorrespondenciasLoader = true this.showCorrespondenciasLoader = true
this.processes.GetTaskListExpediente(false).subscribe(result => {
let ExpedienteTask = result.map(e => this.expedienteTaskPipe.transform(e)) this.getEventsFromLocalDb();
this.listToPresentexpediente = ExpedienteTask;
this.storage.set('process', ExpedienteTask)
this.showCorrespondenciasLoader = false
}, ((error) => {
this.showCorrespondenciasLoader = false
//
this.getEventsFromLocalDb();
}));
} }
this.firstEnter = true this.firstEnter = true
@@ -404,9 +383,6 @@ export class EventsPage implements OnInit {
this.router.navigate(['/home/gabinete-digital'], navigationExtras); this.router.navigate(['/home/gabinete-digital'], navigationExtras);
} }
goToExpediente(SerialNumber: any) {
this.router.navigate(['/home/events/expediente', SerialNumber, 'events']);
}
viewExpedientListPage() { viewExpedientListPage() {
@@ -9,7 +9,8 @@
<!-- Aside left --> <!-- Aside left -->
<div class="aside-wrapper d-flex flex-column width-md-40 flex-grow-1"> <div class="aside-wrapper d-flex flex-column width-md-40 flex-grow-1">
<ion-progress-bar type="indeterminate" *ngIf="TaskService.showLoader"></ion-progress-bar> {{ TaskService.showLoaderNum }}
<ion-progress-bar type="indeterminate" *ngIf="TaskService.showLoaderNum != 0"></ion-progress-bar>
<div class="title-container"> <div class="title-container">
<div class="title d-flex justify-center"> <div class="title d-flex justify-center">
<ion-label *ngIf="hideRefreshBtn">Gabinete Digital</ion-label> <ion-label *ngIf="hideRefreshBtn">Gabinete Digital</ion-label>
@@ -1,5 +1,4 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ModalController } from '@ionic/angular';
import {NavigationEnd, NavigationExtras, Router } from '@angular/router'; import {NavigationEnd, NavigationExtras, Router } from '@angular/router';
import { LoginUserRespose } from 'src/app/models/user.model'; import { LoginUserRespose } from 'src/app/models/user.model';
@@ -221,6 +220,7 @@ export class GabineteDigitalPage implements OnInit {
this.waitForDomService.selector({ this.waitForDomService.selector({
selector: 'app-gabinete-digital ion-content .aside-wrapper', selector: 'app-gabinete-digital ion-content .aside-wrapper',
callback: () => { callback: () => {
this.loadAllProcesses()
if(this.NotificationsService.active === false) { if(this.NotificationsService.active === false) {
this.checkRoutes(); this.checkRoutes();
// this.LoadCounts(); // this.LoadCounts();
@@ -302,9 +302,8 @@ export class GabineteDigitalPage implements OnInit {
goToProcess(serialNumber: string, workflowName: string, activityName: string) { goToProcess(serialNumber: string, workflowName: string, activityName: string) {
if (workflowName == 'Despacho') { if (workflowName == 'Despacho') {
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') { if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho' || activityName == 'Reexecutar Despacho') {
this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
} }
} }
+2
View File
@@ -122,6 +122,8 @@ export class LoginPage implements OnInit {
loader.remove() loader.remove()
console.log('attempt', attempt)
if (attempt) { if (attempt) {
if (attempt.UserId == SessionStore.user.UserId) { if (attempt.UserId == SessionStore.user.UserId) {
@@ -70,7 +70,7 @@
} }
.container-div{ .container-div{
margin-bottom: rem(15); margin-bottom: rem(15);
overflow: auto; overflow: hidden;
} }
.ion-item-container{ .ion-item-container{
margin: rem(15) auto; margin: rem(15) auto;
-1
View File
@@ -202,7 +202,6 @@ export class MessageService {
} else { } else {
console.log('send', this)
let uploadSuccessfully = await this.sendRequestAttachment() let uploadSuccessfully = await this.sendRequestAttachment()
if(uploadSuccessfully) { if(uploadSuccessfully) {
+1 -4
View File
@@ -1,10 +1,9 @@
/* eslint-disable */ /* eslint-disable */
/* tslint:disable */ /* tslint:disable */
import { EventEmitter, Injectable, NgZone } from '@angular/core'; import { EventEmitter, Injectable, NgZone } from '@angular/core';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { StorageService } from 'src/app/services/storage.service'; import { StorageService } from 'src/app/services/storage.service';
import { AuthConnstants } from 'src/app/config/auth-constants';
import { Tokenn } from '../models/token.model'; import { Tokenn } from '../models/token.model';
import { AlertController, Platform } from '@ionic/angular'; import { AlertController, Platform } from '@ionic/angular';
import { NavigationExtras, Router } from '@angular/router'; import { NavigationExtras, Router } from '@angular/router';
@@ -12,10 +11,8 @@ import { EventTrigger } from '../services/eventTrigger.service';
import { SessionStore } from '../store/session.service'; import { SessionStore } from '../store/session.service';
import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications'; import { ActionPerformed, PushNotificationSchema, PushNotifications, Token, } from '@capacitor/push-notifications';
import { notificationObject } from '../models/notifications'; import { notificationObject } from '../models/notifications';
import { v4 as uuidv4 } from 'uuid'
import { Capacitor } from '@capacitor/core'; import { Capacitor } from '@capacitor/core';
import { AngularFireMessaging } from '@angular/fire/messaging'; import { AngularFireMessaging } from '@angular/fire/messaging';
import { Subject } from 'rxjs';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
+22 -2
View File
@@ -44,6 +44,7 @@ export class TaskService {
AllProcess = [] AllProcess = []
showLoader: boolean = false showLoader: boolean = false
showLoaderNum = 0
loadCount = false loadCount = false
loadNum = 0 loadNum = 0
@@ -213,14 +214,20 @@ export class TaskService {
} }
async loadDespachos() { async loadDespachos() {
this.showLoaderNum++
let despachos = await this.despachoRule.getList({ updateStore: true }) let despachos = await this.despachoRule.getList({ updateStore: true })
if (despachos) { if (despachos) {
this.despachoStore.reset(despachos) this.despachoStore.reset(despachos)
} }
this.showLoaderNum--
} }
async loadExpedientes() { async loadExpedientes() {
this.showLoaderNum++
try { try {
let expedientes; let expedientes;
expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise() expedientes = await this.processesbackend.GetTaskListExpediente(false).toPromise()
@@ -240,10 +247,13 @@ export class TaskService {
} }
this.showLoaderNum--
} }
async loadPedidos() { async loadPedidos() {
this.showLoader = true
this.showLoaderNum++
try { try {
let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise(); let pareceres = await this.processesbackend.GetTasksList("Pedido de Parecer", false).toPromise();
@@ -264,11 +274,13 @@ export class TaskService {
})); }));
} catch (error) {} } catch (error) {}
this.showLoaderNum--
} }
async loadPendestes() { async loadPendestes() {
this.showLoaderNum++
try { try {
let pendentes = await this.processesbackend.GetPendingTasks(false).toPromise(); let pendentes = await this.processesbackend.GetPendingTasks(false).toPromise();
@@ -281,10 +293,13 @@ export class TaskService {
} }
this.showLoaderNum--
} }
async loadEventosParaAprovacao() { async loadEventosParaAprovacao() {
this.showLoaderNum++
// PR dont have event to approve // PR dont have event to approve
if(this.SessionStore.user.Profile != 'PR') { if(this.SessionStore.user.Profile != 'PR') {
@@ -319,11 +334,14 @@ export class TaskService {
} }
} }
this.showLoaderNum--
} }
async loadDiplomas() { async loadDiplomas() {
this.showLoaderNum++
try { try {
@@ -384,6 +402,7 @@ export class TaskService {
this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados) this.deplomasStore.resetDiplomasAssinadoList(diplomasAssinados)
} catch (error) {} } catch (error) {}
this.showLoaderNum--
} }
@@ -391,9 +410,10 @@ export class TaskService {
goToProcess(serialNumber: string, workflowName: string, activityName: string) { goToProcess(serialNumber: string, workflowName: string, activityName: string) {
console.log({workflowName, serialNumber, activityName})
if (workflowName == 'Despacho') { if (workflowName == 'Despacho') {
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') { if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho' || activityName == 'Reexecutar Despacho') {
this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
} }
} }
@@ -161,7 +161,7 @@ export class EditEventPage implements OnInit {
} }
ngOnChanges(changes: any): void { ngOnChanges(changes: any): void {
this.loadedEventAttachments = this._postEvent.Attachments this.loadedEventAttachments = this._postEvent?.Attachments
} }
close() { close() {
@@ -336,7 +336,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.chatService.getAllUsers().subscribe(res => { this.chatService.getAllUsers().subscribe(res => {
// //
this.allUsers = res['users'].filter(data => data.username != SessionStore.user.UserName); this.allUsers = res['users']
// //
}); });
} }
@@ -33,6 +33,8 @@ export class AttendeePage implements OnInit {
@Input() footer: boolean; @Input() footer: boolean;
@Input() selectLogUser: boolean = true;
@ViewChild('Searchbar') searchbar: Searchbar; @ViewChild('Searchbar') searchbar: Searchbar;
LtaskParticipants: EventPerson[] = []; LtaskParticipants: EventPerson[] = [];
@@ -180,12 +180,12 @@
</ion-item-sliding> </ion-item-sliding>
</div> </div>
<div *ngIf="!TaskService.showLoader && AllProcess.length == 0" <div *ngIf="!TaskService.showLoaderNum != 0 && AllProcess.length == 0"
class="empty-list d-flex height-100 align-center justify-content-center"> class="empty-list d-flex height-100 align-center justify-content-center">
<span>Lista vazia</span> <span>Lista vazia</span>
</div> </div>
<div *ngIf="TaskService.showLoader && AllProcess.length == 0"> <div *ngIf="TaskService.showLoaderNum != 0 && AllProcess.length == 0">
<ion-list> <ion-list>
<ion-item> <ion-item>
@@ -140,7 +140,7 @@ export class AllProcessesPage implements OnInit {
if (workflowName == 'Despacho') { if (workflowName == 'Despacho') {
if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho') { if (activityName == 'Tarefa de Despacho' || activityName == 'Concluir Despacho' || activityName == 'Reexecutar Despacho') {
this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']); this.router.navigate(['/home/gabinete-digital/despachos', serialNumber, 'gabinete-digital']);
} }
} }
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { customTask } from '../../../models/dailyworktask.model'; import { customTask } from '../../../models/dailyworktask.model';
import { NavigationEnd, NavigationStart, Router } from '@angular/router'; import { NavigationStart, Router } from '@angular/router';
import { DespachoService } from 'src/app/Rules/despacho.service'; import { DespachoService } from 'src/app/Rules/despacho.service';
import { TaskService } from 'src/app/services/task.service'; import { TaskService } from 'src/app/services/task.service';
import { ThemeService } from 'src/app/services/theme.service' import { ThemeService } from 'src/app/services/theme.service'
@@ -73,7 +73,7 @@
} }
.container-div{ .container-div{
margin-bottom: rem(15); margin-bottom: rem(15);
overflow: auto; overflow: hidden;
} }
.ion-item-container{ .ion-item-container{
margin: rem(15) auto; margin: rem(15) auto;
@@ -79,6 +79,9 @@ export class PublicationDetailPage implements OnInit {
} }
this.showLoader = false; this.showLoader = false;
},(error) => { },(error) => {
if(window['_deletePublication']) {
window['_deletePublication'](this.folderId, this.publicationId)
}
this.goBack(); this.goBack();
this.httpErrorHandle.httpStatusHandle(error) this.httpErrorHandle.httpStatusHandle(error)
}); });
@@ -95,6 +98,15 @@ export class PublicationDetailPage implements OnInit {
try { try {
await this.publications.DeletePublication(this.folderId, this.publicationId).toPromise(); await this.publications.DeletePublication(this.folderId, this.publicationId).toPromise();
this.httpErrorHandle.httpsSucessMessagge('Eliminar publicação') this.httpErrorHandle.httpsSucessMessagge('Eliminar publicação')
if(window['_deletePublication']) {
window['_deletePublication'](this.folderId, this.publicationId)
}
if(window['app-view-publications-page-doRefresh']) {
window['app-view-publications-page-doRefresh']()
}
this.goBackToViewPublications.emit(); this.goBackToViewPublications.emit();
} catch (error) { } catch (error) {
this.httpErrorHandle.httpStatusHandle(error) this.httpErrorHandle.httpStatusHandle(error)
@@ -25,8 +25,8 @@ export class ViewPublicationsPage implements OnInit {
publicationList: {[key: string]: Publication[] } = {}; publicationList: {[key: string]: Publication[] } = {};
publicationItem: {[key: string]: PublicationFolder } = {}; publicationItem: {[key: string]: PublicationFolder } = {};
getpublication = [];
error: any; error: any;
oldpublicationIds = []
@Input() folderId: any; @Input() folderId: any;
@Output() addNewPublication = new EventEmitter<any>(); @Output() addNewPublication = new EventEmitter<any>();
@@ -59,6 +59,9 @@ export class ViewPublicationsPage implements OnInit {
this.createPublicationList() this.createPublicationList()
window['app-view-publications-page-doRefresh'] = this.doRefresh window['app-view-publications-page-doRefresh'] = this.doRefresh
window['_deletePublication'] = (a, b) => {
this._deletePublication(a, b)
}
this.getFromDB(); this.getFromDB();
} }
@@ -124,6 +127,7 @@ export class ViewPublicationsPage implements OnInit {
try { try {
const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise(); const publicationIds = await this.publications.GetPublicationsList(folderId).toPromise();
this.publicationList[folderId] = []
this.createPublicationList(folderId) this.createPublicationList(folderId)
let loadLater = [] let loadLater = []
@@ -144,13 +148,22 @@ export class ViewPublicationsPage implements OnInit {
this.showLoader = false; this.showLoader = false;
this.storage.set(folderId, this.publicationList[folderId]); this.storage.set(folderId, this.publicationList[folderId]);
this.getpublication = this.publicationList[folderId];
this.oldpublicationIds = publicationIds
} catch(error) { } catch(error) {
this.showLoader = false; this.showLoader = false;
} }
} }
_deletePublication = (folderId, publicationId) => {
this.publicationList[folderId] = this.publicationList[folderId].filter( e => e.DocumentId != publicationId)
console.log('this.publicationList[folderId]', this.publicationList[folderId].length)
}
publicationIsPresent(publicationId, folderId) { publicationIsPresent(publicationId, folderId) {
return this.publicationList[folderId].find( e => e.DocumentId == publicationId ) return this.publicationList[folderId].find( e => e.DocumentId == publicationId )
} }
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PublicationFolderService } from './publication-folder.service';
describe('PublicationFolderService', () => {
let service: PublicationFolderService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PublicationFolderService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,82 @@
import { Injectable } from '@angular/core';
import { PublicationFolder } from '../models/publicationfolder';
import { Storage } from '@ionic/storage';
import { Publication } from '../models/publication';
@Injectable({
providedIn: 'root'
})
export class PublicationFolderService {
publicationList: {[key: string]: Publication[] } = {};
FolderDetails: {[key: string]: PublicationFolder } = {};
keyName: string
constructor(
private storage: Storage,
) {}
getFromDB(folderId: any) {
if(!this.publicationList[folderId]) {
this.publicationList[folderId] = []
}
if(!this.FolderDetails[folderId]) {
this.FolderDetails[folderId] = new PublicationFolder();
}
this.storage.get(folderId).then((viewPublications) => {
this.publicationList[folderId] = viewPublications
})
this.storage.get(folderId+"name").then((viewPublications) => {
this.FolderDetails[folderId] = viewPublications
})
}
updateFolderDetails(folderId, res) {
this.FolderDetails[folderId] = res
this.storage.set(folderId+"name", res)
}
save(folderId) {
this.storage.set(folderId+"name", this.FolderDetails)
this.storage.set(folderId, this.publicationList[folderId]);
}
publicationIsPresent(publicationId, folderId) {
return this.publicationList[folderId].find( e => e.DocumentId == publicationId )
}
publicationFind(publicationId, folderId) {
return this.publicationList[folderId].find( e => e.DocumentId == publicationId )
}
publicationFindIndex(publicationId, folderId) {
return this.publicationList[folderId].findIndex( e => e.DocumentId == publicationId )
}
PublicationAddOrUpdate(folderId, publicationId, Publication: Publication) {
const findIndex = this.publicationFindIndex(publicationId, folderId)
const found = this.publicationIsPresent(publicationId, folderId)
if(!found) {
console.log('push',folderId, Publication)
this.publicationList[folderId].push(Publication)
} else {
console.log('update',folderId, Publication)
this.publicationList[folderId][findIndex] = Publication
}
}
deletePost(publicationId: any, folderId) {
for (let i = 0; i <= this.publicationList[folderId].length; i++) {
if(this.publicationList[folderId][i].DocumentId == publicationId) {
this.publicationList[folderId].splice(i, 1)
}
}
}
}
-1
View File
@@ -1,2 +1 @@
importScripts('ngsw-worker.js'); importScripts('ngsw-worker.js');
importScripts('firebase-messaging-sw.js');
+1 -1
View File
@@ -30,7 +30,7 @@ export declare class Model {
static get(arg: getParams): Promise<any>; static get(arg: getParams): Promise<any>;
static getOrCreate(arg: getParams): Promise<any>; static getOrCreate(arg: getParams): Promise<any>;
private static getId; private static getId;
static getModelName(): string; static getModelName(): any;
static filter(...arg: any[]): { static filter(...arg: any[]): {
filter: (...args: any[]) => void; filter: (...args: any[]) => void;
execute: () => Promise<any[]>; execute: () => Promise<any[]>;
+1 -1
View File
@@ -173,7 +173,7 @@ export class Model {
return hashCode(this.toString()); return hashCode(this.toString());
} }
static getModelName() { static getModelName() {
return this.toString().split('(' || /s+/)[0].split(' ' || /s+/)[1]; return this['$tableName'] || this.toString().split('(' || /s+/)[0].split(' ' || /s+/)[1];
} }
static filter(...arg) { static filter(...arg) {
const queryId = uniqueGenerator(); const queryId = uniqueGenerator();
+1 -1
View File
@@ -1,7 +1,7 @@
import { FieldsMap, AttributesMap } from './field/fields.interface.js'; import { FieldsMap, AttributesMap } from './field/fields.interface.js';
export declare class ModelReader { export declare class ModelReader {
static read(modelClassRepresentation: any): { static read(modelClassRepresentation: any): {
modelName: string; modelName: any;
fields: { fields: {
[key: string]: any; [key: string]: any;
}; };
+1 -10
View File
@@ -1,5 +1,5 @@
import { Model, LocalStorage } from './model.js'; import { Model, LocalStorage } from './model.js';
import { DatabaseSchema, DatabaseSchemaLocalStorage, TableSchema, TableSchemaLocalStorage } from './register-modal.interface.js'; import { DatabaseSchema, DatabaseSchemaLocalStorage, TableSchemaLocalStorage } from './register-modal.interface.js';
import { OneToOneField, ForeignKey, ManyToManyField } from './field/allFields.js'; import { OneToOneField, ForeignKey, ManyToManyField } from './field/allFields.js';
interface register { interface register {
databaseName: string; databaseName: string;
@@ -13,15 +13,6 @@ interface register {
ignoreFieldsStartWidth?: string[]; ignoreFieldsStartWidth?: string[];
} }
export declare const objModels: {}; export declare const objModels: {};
export declare const modelsConfig: {
[key: string]: {
DatabaseSchema: DatabaseSchema;
TableSchema: TableSchema;
OneToOneField?: {
[key: string]: {};
};
};
};
export declare function migrate(register: register): void; export declare function migrate(register: register): void;
export declare class registerModel { export declare class registerModel {
static ModalName(): void; static ModalName(): void;
+21 -39
View File
@@ -9,9 +9,7 @@ import { transactionOnCommit } from '../triggers/transaction.js';
import { DatabaseManagerSchema } from './schema/databae-manager-schema.js'; import { DatabaseManagerSchema } from './schema/databae-manager-schema.js';
const models = {}; const models = {};
export const objModels = {}; export const objModels = {};
export const modelsConfig = {};
const modelsLocalStorage = {}; const modelsLocalStorage = {};
const modelsConfigLocalStorage = {};
export function migrate(register) { export function migrate(register) {
if (register.type == 'indexedDB') { if (register.type == 'indexedDB') {
registerModel.register(register); registerModel.register(register);
@@ -30,15 +28,19 @@ export class registerModel {
type: entries.type, type: entries.type,
stores: [] stores: []
}; };
const storeNames = [];
let index = 0; let index = 0;
for (const modelClassRepresentations of entries.models) { for (const modelClassRepresentations of entries.models) {
const ModelName = modelClassRepresentations.getModelName(); let ModelName = modelClassRepresentations.getModelName();
if (storeNames.includes(ModelName)) {
ModelName = uniqueGenerator();
}
models[ModelName] = modelClassRepresentations; models[ModelName] = modelClassRepresentations;
const { fields, modelName, attributes, fieldTypes } = ModelReader.read(modelClassRepresentations); const { fields, attributes, fieldTypes } = ModelReader.read(modelClassRepresentations);
const idFieldName = (_a = attributes === null || attributes === void 0 ? void 0 : attributes.primaryKey) === null || _a === void 0 ? void 0 : _a.shift(); const idFieldName = (_a = attributes === null || attributes === void 0 ? void 0 : attributes.primaryKey) === null || _a === void 0 ? void 0 : _a.shift();
databaseSchema.stores.push({ databaseSchema.stores.push({
databaseName: databaseSchema.databaseName, databaseName: databaseSchema.databaseName,
name: modelName, name: ModelName,
id: { id: {
keyPath: idFieldName || 'id', keyPath: idFieldName || 'id',
autoIncrement: fields[idFieldName] ? ((_b = fields[idFieldName]) === null || _b === void 0 ? void 0 : _b.primaryKey) == true : true, autoIncrement: fields[idFieldName] ? ((_b = fields[idFieldName]) === null || _b === void 0 ? void 0 : _b.primaryKey) == true : true,
@@ -67,28 +69,24 @@ export class registerModel {
}); });
} }
if (Field instanceof OneToOneField) { if (Field instanceof OneToOneField) {
await ModelEditor.addMethodOneToOneField(Field, fieldName, modelName, databaseSchema); await ModelEditor.addMethodOneToOneField(Field, fieldName, ModelName, databaseSchema);
} }
else if (Field instanceof ForeignKey) { else if (Field instanceof ForeignKey) {
await ModelEditor.addMethodForeignKey(Field, fieldName, modelName, databaseSchema); await ModelEditor.addMethodForeignKey(Field, fieldName, ModelName, databaseSchema);
} }
else if (Field instanceof ManyToManyField) { else if (Field instanceof ManyToManyField) {
await ModelEditor.addMethodManyToManyField(Field, fieldName, modelName, databaseSchema); await ModelEditor.addMethodManyToManyField(Field, fieldName, ModelName, databaseSchema);
} }
} }
models[ModelName] = modelClassRepresentations; models[ModelName] = modelClassRepresentations;
const tableSchema = databaseSchema.stores.find((e) => e.name == ModelName); const tableSchema = databaseSchema.stores.find((e) => e.name == ModelName);
modelsConfig[ModelName] = {
DatabaseSchema: databaseSchema,
TableSchema: tableSchema
};
index++; index++;
} }
DatabaseManagerSchema.prepare(databaseSchema); DatabaseManagerSchema.prepare(databaseSchema);
for (const stores of databaseSchema.stores) { for (const stores of databaseSchema.stores) {
const model = models[stores.name]; const model = models[stores.name];
const DbName = databaseSchema.databaseName; const DbName = databaseSchema.databaseName;
ModelEditor.setTableSchema(model, DbName, stores, databaseSchema, entries); ModelEditor.setTableSchema(model, DbName);
ModelEditor.getDBSchema(model, DbName); ModelEditor.getDBSchema(model, DbName);
// ModelEditor.setModel(model, DbName) // ModelEditor.setModel(model, DbName)
DatabaseManagerSchema.getDb(DbName).getTable(stores.name).setModel(model); DatabaseManagerSchema.getDb(DbName).getTable(stores.name).setModel(model);
@@ -213,10 +211,6 @@ export class registerLocalStorage {
modelClassRepresentations.getModelName = () => { modelClassRepresentations.getModelName = () => {
return ModelName; return ModelName;
}; };
modelsConfigLocalStorage[ModelName] = {
DatabaseSchema: databaseSchema,
TableSchema: tableSchema
};
modelsLocalStorage[ModelName] = modelClassRepresentations; modelsLocalStorage[ModelName] = modelClassRepresentations;
if (entries === null || entries === void 0 ? void 0 : entries.restore) { if (entries === null || entries === void 0 ? void 0 : entries.restore) {
modelClassRepresentations.get(null); modelClassRepresentations.get(null);
@@ -241,28 +235,16 @@ export class ModelEditor {
return DatabaseSchema; return DatabaseSchema;
}; };
} }
static setTableSchema(ModelToEdit, DbName, store, databaseSchema, entries) { static setTableSchema(ModelToEdit, DbName) {
try { const ModelName = ModelToEdit.getModelName();
const DBSchema = DatabaseManagerSchema.getDb(DbName);
const ModelName = ModelToEdit.getModelName(); const TableSchemaClass = DBSchema.getTable(ModelName);
const DBSchema = DatabaseManagerSchema.getDb(DbName); ModelToEdit.prototype.getTableSchema = () => {
const TableSchemaClass = DBSchema.getTable(ModelName); return TableSchemaClass.config;
ModelToEdit.prototype.getTableSchema = () => { };
return TableSchemaClass.config; ModelToEdit.getTableSchema = () => {
}; return TableSchemaClass.config;
ModelToEdit.getTableSchema = () => { };
return TableSchemaClass.config;
};
} catch (error) {
console.log('databaseSchema', databaseSchema)
console.log('error', error)
console.log('ModelToEdit', ModelToEdit)
console.log(DbName, 'DbName')
console.log('store', store)
console.log('models', models)
console.log('entries', entries)
}
} }
static getDBSchema(ModelToEdit, DbName) { static getDBSchema(ModelToEdit, DbName) {
const ModelName = ModelToEdit.getModelName(); const ModelName = ModelToEdit.getModelName();
File diff suppressed because one or more lines are too long
+7 -7
View File
@@ -1,12 +1,12 @@
export let versionData = { export let versionData = {
"shortSHA": "a2dd41393", "shortSHA": "8b3989de3",
"SHA": "a2dd41393b51e274d2627fa68375cda77266e2c2", "SHA": "8b3989de3beea56ec3168c107af73145f41aba8b",
"branch": "developer", "branch": "developer-bug",
"lastCommitAuthor": "'Peter Maquiran'", "lastCommitAuthor": "'Peter Maquiran'",
"lastCommitTime": "'Tue Aug 8 16:32:57 2023 +0100'", "lastCommitTime": "'Wed Aug 9 10:00:39 2023 +0100'",
"lastCommitMessage": "update", "lastCommitMessage": "fix",
"lastCommitNumber": "5141", "lastCommitNumber": "5144",
"change": "", "change": "",
"changeStatus": "On branch developer\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/pages/chat/group-messages/group-messages.page.scss\n\tmodified: src/app/services/chat/room.service.ts\n\tmodified: src/app/services/native-notification.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/shared/chat/group-messages/group-messages.page.scss\n\tmodified: src/app/shared/chat/messages/messages.page.scss\n\tmodified: src/app/tiny-mce/tiny-mce.page.html\n\tmodified: src/app/tiny-mce/tiny-mce.page.ts\n\tmodified: src/firebase-messaging-sw.js\n\tmodified: src/main.ts", "changeStatus": "On branch developer-bug\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: angular.json\n\tdeleted: firebase-messaging-sw.js\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/models/beast-orm.ts\n\tmodified: src/app/pages/chat/messages/messages.page.scss\n\tmodified: src/app/pages/events/events.page.html\n\tmodified: src/app/pages/events/events.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.ts\n\tmodified: src/app/pages/login/login.page.ts\n\tmodified: src/app/pages/publications/edit-action/edit-action.page.scss\n\tmodified: src/app/services/chat/message.service.ts\n\tmodified: src/app/services/notifications.service.ts\n\tmodified: src/app/services/task.service.ts\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/shared/chat/group-messages/group-messages.page.ts\n\tmodified: src/app/shared/event/attendee-modal/attendee-modal.page.ts\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.html\n\tmodified: src/app/shared/gabinete-digital/all-processes/all-processes.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos/despachos.page.ts\n\tmodified: src/app/shared/publication/edit-action/edit-action.page.scss\n\tmodified: src/app/shared/publication/view-publications/publication-detail/publication-detail.page.ts\n\tmodified: src/app/shared/publication/view-publications/view-publications.page.ts\n\tnew file: src/app/store/publication-folder.service.spec.ts\n\tnew file: src/app/store/publication-folder.service.ts\n\tmodified: src/combined-sw.js\n\tmodified: src/plugin/src/models/model.d.ts\n\tmodified: src/plugin/src/models/model.js\n\tmodified: src/plugin/src/models/model.reader.d.ts\n\tmodified: src/plugin/src/models/register-model.d.ts\n\tmodified: src/plugin/src/models/register-model.js\n\tmodified: src/plugin/src/tsconfig.tsbuildinfo",
"changeAuthor": "peter.maquiran" "changeAuthor": "peter.maquiran"
} }