Refacturation of the notifications route

This commit is contained in:
Eudes Inácio
2021-02-03 15:13:23 +01:00
parent ee949e5a41
commit 71bc6f9dcc
599 changed files with 172410 additions and 74251 deletions
+22 -17
View File
@@ -13,7 +13,7 @@ import { Plugins, PushNotification, PushNotificationToken, PushNotificationActio
import { Router } from '@angular/router';
import { MethodCall } from '@angular/compiler';
const { PushNotifications, LocalNotifications } = Plugins;
const { PushNotifications, LocalNotifications, LocalNotificationAction } = Plugins;
@Component({
selector: 'app-home',
@@ -74,7 +74,7 @@ export class HomePage implements OnInit {
'pushNotificationReceived',
(notification: PushNotification) => {
//alert('Push received: ' + JSON.stringify(notification));
//this.localNotificationPresent(notification);
this.localNotificationPresent(notification);
},
);
@@ -92,28 +92,30 @@ export class HomePage implements OnInit {
console.log('FOLDER PROCESS', folder.ProcessId)
if (service != null) {
//if (service != null) {
if (service === "events") {
if (service === "agenda") {
this.router.navigate(['/home/', service, idObject, 'home']);
} else if (service === "agenda") {
this.router.navigate(['/home/', service, idObject, 'home']);
} else if (service === "gabinete-digital" && object != "expediente") {
} else if (service === "gabinete-digital" && object != "expediente") {
this.router.navigate(['/home/', service]);
} else if (service === "gabinete-digital" && object === "expediente") {
this.viewExpedientDetail(idObject)
} else if (service === "accoes" && object === "accao") {
this.viewPublications(idObject)
} else if (service === "accoes" && object === "publicacao") {
this.viewPublicationDetail(idObject)
}
} else {
/*} else {
if (processId || publicationId != null) {
this.viewPublicationDetail(processId, publicationId)
this.viewPublicationDetail(idObject)
}
if (notification.notification.data.folder.ProcessId != null) {
this.viewPublications(folder)
this.viewPublications(idObject)
}
}
}*/
@@ -152,6 +154,8 @@ export class HomePage implements OnInit {
async localNotificationPresent(notification) {
LocalNotificationAction.
LocalNotifications.schedule({
notifications: [
{
@@ -162,7 +166,8 @@ export class HomePage implements OnInit {
sound: null,
attachments: null,
actionTypeId: "",
extra: null
extra: null,
foreground: true,
}
]
});
@@ -190,12 +195,11 @@ export class HomePage implements OnInit {
async viewPublicationDetail(processId: string, publicationId: string) {
async viewPublicationDetail(folderId) {
const modal = await this.modalController.create({
component: PublicationDetailPage,
componentProps: {
publicationId: publicationId,
folderId: processId,
folderId: folderId,
},
cssClass: 'publication-detail',
backdropDismiss: false
@@ -204,14 +208,15 @@ export class HomePage implements OnInit {
modal.onDidDismiss();
}
async viewPublications(folder) {
async viewPublications(folderId) {
const modal = await this.modalController.create({
component: ViewPublicationsPage,
/* enterAnimation,
leaveAnimation, */
componentProps: {
item: folder,
item: folderId,
},
cssClass: 'new-action',
backdropDismiss: false
@@ -26,7 +26,7 @@
<div class="item"
*ngFor="let viagem of publicationsTravelFolderList"
(click)="viewPublications(viagem)">
(click)="viewPublications(viagem.ProcessId)">
<div class="item-icon">
<ion-icon slot="end" src='assets/images/icons-plane-active.svg'></ion-icon>
</div>
@@ -112,7 +112,8 @@ export class PublicationsPage implements OnInit {
});
}
async viewPublications(folder: PublicationFolder) {
async viewPublications(folderId: string) {
console.log('FOLDER', folderId)
/* const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
@@ -145,7 +146,7 @@ export class PublicationsPage implements OnInit {
/* enterAnimation,
leaveAnimation, */
componentProps:{
item:folder,
folderId:folderId,
},
cssClass: 'new-action',
backdropDismiss: false
@@ -53,7 +53,7 @@ export class PublicationDetailPage implements OnInit {
this.showLoader = true;
console.log(this.publicationId);
console.log(this.folderId);
this.publications.GetPublicationById(this.folderId,this.publicationId).subscribe(res=>{
this.publications.GetPublicationById(this.publicationId).subscribe(res=>{
console.log(res);
/* this.publication = res; */
this.publication = {
@@ -18,6 +18,7 @@ export class ViewPublicationsPage implements OnInit {
publicationList: Publication[];
item: PublicationFolder;
folderId:string;
constructor(
private loadingController: LoadingService,
@@ -25,27 +26,38 @@ export class ViewPublicationsPage implements OnInit {
private publications: PublicationsService,
private navParams: NavParams,
) {
this.item = this.navParams.get('item');
this.item = new PublicationFolder();
this.folderId = this.navParams.get('folderId');
}
ngOnInit() {
this.getPublications()
console.log(this.folderId);
this.getPublications();
this.getPublicationDetail();
}
doRefresh(event) {
this.getPublications();
setTimeout(() => {
this.getPublications();
this.getPublicationDetail();
event.target.complete();
}, 3000);
}
close(){
this.modalController.dismiss();
}
getPublicationDetail(){
this.publications.GetPublicationFolderById(this.folderId).subscribe(res=>{
console.log(res);
this.item = res;
});
}
getPublications(){
this.showLoader = true;
this.publications.GetPublications(this.item.ProcessId).subscribe(res=>{
this.publications.GetPublications(this.folderId).subscribe(res=>{
this.publicationList = new Array();
console.log(res);
res.forEach(element => {
+4 -8
View File
@@ -29,14 +29,10 @@ export class PublicationsService {
}
GetPublicationFolderById(id:any){
const geturl = environment.apiURL + 'presidentialActions';
let params = new HttpParams();
params = params.set("id", id);
const geturl = environment.apiURL + 'presidentialActions/'+id;
let options = {
headers: this.headers,
params: params
};
return this.http.get<any>(`${geturl}`, options);
}
@@ -87,11 +83,10 @@ export class PublicationsService {
return this.http.get<any>(`${geturl}`, options);
}
GetPublicationById(folderId:any, publicationId:any){
const geturl = environment.apiURL + 'presidentialActions/'+ folderId +'/posts/'+ publicationId;
GetPublicationById( publicationId:any){
const geturl = environment.apiURL + 'presidentialActions/posts/'+ publicationId;
let params = new HttpParams();
params = params.set("folderId", folderId);
params = params.set("id", publicationId);
@@ -104,6 +99,7 @@ export class PublicationsService {
};
return this.http.get<any>(`${geturl}`, options);
}
CreatePublication(folderId:any,body:any){
const geturl = environment.apiURL + 'presidentialActions/'+folderId+'/posts';
let params = new HttpParams();