mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve tinymce autosave and notification web click solved
This commit is contained in:
@@ -18,7 +18,6 @@ import { ActiveTabService } from 'src/app/services/active-tab.service';
|
||||
import { Device } from '@capacitor/device';
|
||||
import { RouteService } from 'src/app/services/route.service';
|
||||
import { NetworkServiceService, ConnectionStatus } from 'src/app/services/network-service.service';
|
||||
import { NativeNotificationService } from 'src/app/services/native-notification.service';
|
||||
import { UserSession } from '../models/user.model';
|
||||
import { PermissionList } from '../models/permission/permissionList';
|
||||
|
||||
@@ -85,7 +84,6 @@ export class HomePage implements OnInit {
|
||||
private eventservice: EventsService,
|
||||
private processservice: ProcessesService,
|
||||
public RouteService: RouteService,
|
||||
private NativeNotificationService: NativeNotificationService,
|
||||
private RochetChatConnectorService: RochetChatConnectorService,
|
||||
private NetworkServiceService: NetworkServiceService,
|
||||
public eventService: EventsService,
|
||||
@@ -96,9 +94,6 @@ export class HomePage implements OnInit {
|
||||
this.user = SessionStore.user;
|
||||
}
|
||||
|
||||
this.NativeNotificationService.askForPermission();
|
||||
this.NativeNotificationService.foregroundNotification();
|
||||
|
||||
this.router.events.subscribe((val) => {
|
||||
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
|
||||
document.querySelectorAll('popover-viewport').forEach((e: any) => e.remove())
|
||||
|
||||
@@ -713,7 +713,7 @@
|
||||
Pendentes<br>
|
||||
<span class="new-task-count" *ngIf="TaskService.pendentesstore.newList.length >=2">{{
|
||||
TaskService.pendentesstore.newList.length}} correspondências novas</span>
|
||||
<span class="new-task-count" *ngIf="TaskService.pendentesstore.newList.length >=1">{{
|
||||
<span class="new-task-count" *ngIf="TaskService.pendentesstore.newList.length ==1">{{
|
||||
TaskService.pendentesstore.newList.length}} correspondência nova</span>
|
||||
</p>
|
||||
<p *ngIf="p.userPermission([p.permissionList.Gabinete.pr_tasks])" class="text-center exp-card-title ">Meus
|
||||
|
||||
@@ -102,7 +102,7 @@ export class RoomService {
|
||||
private ViewedMessageService: ViewedMessageService,
|
||||
private notificationService: NotificationsService
|
||||
) {
|
||||
this.NativeNotificationService.askForPermission()
|
||||
/* this.NativeNotificationService.askForPermission() */
|
||||
|
||||
this.RochetChatConnectorService.getUserStatus((d) => {
|
||||
|
||||
@@ -337,10 +337,10 @@ export class RoomService {
|
||||
}
|
||||
|
||||
if(this.isSenderIsNotMe(ChatMessage)) {
|
||||
this.NativeNotificationService.sendNotificationChat({
|
||||
/* this.NativeNotificationService.sendNotificationChat({
|
||||
message: message.msg,
|
||||
title: this.name
|
||||
});
|
||||
}); */
|
||||
}
|
||||
|
||||
if(this.hasLoadHistory == true) {
|
||||
|
||||
@@ -15,26 +15,33 @@ export class NativeNotificationService {
|
||||
|
||||
askForPermission() {
|
||||
|
||||
LocalNotifications.requestPermissions()
|
||||
/* LocalNotifications.requestPermissions()
|
||||
|
||||
LocalNotifications.checkPermissions().then((data)=>{
|
||||
//
|
||||
}).catch((data)=>{
|
||||
//
|
||||
})
|
||||
}) */
|
||||
|
||||
}
|
||||
|
||||
foregroundNotification() {
|
||||
|
||||
LocalNotifications.addListener('localNotificationReceived', (notification) => {
|
||||
/* LocalNotifications.addListener('localNotificationReceived', (notification) => {
|
||||
|
||||
})
|
||||
}) */
|
||||
}
|
||||
|
||||
backgroundNotification() {
|
||||
/* LocalNotifications.addListener('localNotificationActionPerformed', (action) => {
|
||||
console.log('Local notification action performed (background):', action);
|
||||
// Implemente a lógica para lidar com a ação da notificação em segundo plano
|
||||
}); */
|
||||
}
|
||||
|
||||
sendNotificationChat({title = 'User', icon = '', message = 'hello'}) {
|
||||
|
||||
LocalNotifications.schedule({
|
||||
/* LocalNotifications.schedule({
|
||||
notifications:[
|
||||
{
|
||||
title : title,
|
||||
@@ -42,7 +49,7 @@ export class NativeNotificationService {
|
||||
id : new Date().getTime()
|
||||
}
|
||||
]
|
||||
});
|
||||
}); */
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -188,25 +188,44 @@ export class NotificationsService {
|
||||
}
|
||||
|
||||
onReciveBackground() {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
this.active = true
|
||||
console.log('NOtification Listener Backgroud', notification)
|
||||
/* this.DataArray.push(notification.notification)
|
||||
|
||||
this.storageService.store("Notifications", this.DataArray)
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
}) */
|
||||
this.notificatinsRoutes(notification)
|
||||
// this.runNotificationCallback(notification)
|
||||
if(this.platform.is('mobile')) {
|
||||
if (!this.isPushNotificationsAvailable) {
|
||||
return false
|
||||
}
|
||||
);
|
||||
|
||||
PushNotifications.addListener('pushNotificationActionPerformed',
|
||||
(notification: ActionPerformed) => {
|
||||
this.active = true
|
||||
console.log('NOtification Listener Backgroud', notification)
|
||||
/* this.DataArray.push(notification.notification)
|
||||
|
||||
this.storageService.store("Notifications", this.DataArray)
|
||||
this.eventtrigger.publishSomeData({
|
||||
notification: "recive"
|
||||
}) */
|
||||
this.notificatinsRoutes(notification)
|
||||
// this.runNotificationCallback(notification)
|
||||
}
|
||||
);
|
||||
} else {
|
||||
navigator.serviceWorker.onmessage = (event) => {
|
||||
console.log('Mensagem recebida do Service Worker:', event.data.data);
|
||||
let object = {
|
||||
notification: event.data
|
||||
}
|
||||
|
||||
this.notificatinsRoutes(object)
|
||||
// Implemente a lógica para lidar com a mensagem recebida do Service Worker
|
||||
if (event.data.notificationClicked) {
|
||||
console.log('Notificação push do Firebase clicada em segundo plano!');
|
||||
// Implemente ações adicionais conforme necessário
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ChatSendMessageNotification(userID, title, bodymsg, roomId) {
|
||||
const geturl = environment.apiURL + `notifications/sendbyUsername`;
|
||||
@@ -250,7 +269,7 @@ export class NotificationsService {
|
||||
|
||||
notificatinsRoutes = (notification) => {
|
||||
|
||||
|
||||
console.log('BACK BACK',notification)
|
||||
|
||||
if (notification.notification.data.Service === "agenda" && notification.notification.data.IdObject.length > 10) {
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
language: 'pt_PT',
|
||||
height: 600,
|
||||
menubar: false,
|
||||
autosave_interval:30,
|
||||
autosave_interval:'3s',
|
||||
plugins: [
|
||||
'advlist autolink autosave lists link image charmap print preview anchor',
|
||||
'searchreplace visualblocks code fullscreen',
|
||||
@@ -40,4 +40,5 @@
|
||||
initialValue='{{content}}'
|
||||
[(ngModel)]="content"
|
||||
(onSaveContent)="somefunction()"
|
||||
(ngModelChange)="onEditorContentChange()"
|
||||
></editor>
|
||||
@@ -19,7 +19,7 @@ export class TinyMCEPage implements OnDestroy {
|
||||
editorContent: "";
|
||||
value: "";
|
||||
private intervalId: any;
|
||||
private intervalTime: number = 30000;
|
||||
private intervalTime: number = 3000;
|
||||
|
||||
loadingTiny = true
|
||||
|
||||
@@ -37,7 +37,7 @@ export class TinyMCEPage implements OnDestroy {
|
||||
|
||||
|
||||
this.waitForTiny();
|
||||
this.saveDraft();
|
||||
/* this.saveDraft(); */
|
||||
}
|
||||
|
||||
waitForTiny() {
|
||||
@@ -59,37 +59,39 @@ export class TinyMCEPage implements OnDestroy {
|
||||
|
||||
ngOnDestroy() {
|
||||
// Certifique-se de limpar o intervalo quando o componente é destruído
|
||||
if (this.intervalId) {
|
||||
clearInterval(this.intervalId);
|
||||
}
|
||||
window['tinyupdate']()
|
||||
}
|
||||
|
||||
close() {
|
||||
this.modalController.dismiss()
|
||||
}
|
||||
|
||||
onEditorContentChange() {
|
||||
console.log('Autosave successful! Content saved to local storage1.');
|
||||
this.saveDraft()
|
||||
}
|
||||
|
||||
saveDraft() {
|
||||
this.intervalId = setInterval(() => {
|
||||
// Lógica que deseja executar em intervalos regulares
|
||||
console.log('Intervalo de 30 segundos...');
|
||||
console.log(document)
|
||||
let objectDraft = {
|
||||
"status": false,
|
||||
"description": this.Document.Assunto,
|
||||
"content": this.content,
|
||||
"path": this.Document.path,
|
||||
"ownerId": this.Document.ownerId
|
||||
}
|
||||
this.processService.SaveDraftByID(this.Document.DocId, objectDraft).subscribe((res) => {
|
||||
window['tinyupdate']()
|
||||
}, (error) => {
|
||||
this.erroHandler.httpStatusHandle(error)
|
||||
})
|
||||
}, this.intervalTime);
|
||||
// Lógica que deseja executar em intervalos regulares
|
||||
console.log('Intervalo de 3 segundos...');
|
||||
console.log(document)
|
||||
let objectDraft = {
|
||||
"status": false,
|
||||
"description": this.Document.Assunto,
|
||||
"content": this.content,
|
||||
"path": this.Document.path,
|
||||
"ownerId": this.Document.ownerId
|
||||
}
|
||||
this.processService.SaveDraftByID(this.Document.DocId, objectDraft).subscribe((res) => {
|
||||
console.log('Saved tinymce')
|
||||
|
||||
}, (error) => {
|
||||
this.erroHandler.httpStatusHandle(error)
|
||||
})
|
||||
}
|
||||
|
||||
somefunction() {
|
||||
|
||||
console.log('Saved tinymce')
|
||||
}
|
||||
|
||||
async openOptions() {
|
||||
|
||||
@@ -19,7 +19,7 @@ firebase.initializeApp(firebaseConfig);
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
messaging.onBackgroundMessage(function(payload) {
|
||||
console.log('Received background message ', payload);
|
||||
console.log('Received background message 22 ', payload);
|
||||
|
||||
const notificationTitle = payload.notification.title;
|
||||
const notificationOptions = {
|
||||
@@ -57,4 +57,16 @@ self.addEventListener('message', function(event){
|
||||
self.userID = data.uid;
|
||||
self.userToken = data.token;
|
||||
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', function(event) {
|
||||
console.log("Push Clicked ", event);
|
||||
// Enviar uma mensagem para o cliente (componente)
|
||||
self.clients.matchAll().then((clients) => {
|
||||
if (clients && clients.length) {
|
||||
clients.forEach((client) => {
|
||||
client.postMessage({ notificationClicked: true });
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
+10
@@ -31,6 +31,16 @@ if (environment.production) {
|
||||
SentrySibling.init
|
||||
); */
|
||||
|
||||
if ('serviceWorker' in navigator && environment.production) {
|
||||
navigator.serviceWorker.register('firebase-messaging-sw.js')
|
||||
.then(registration => {
|
||||
console.log('Service Worker registrado com sucesso:', registration);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erro ao registrar o Service Worker:', error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.log(err));
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export let versionData = {
|
||||
"shortSHA": "a05918788",
|
||||
"SHA": "a0591878852492c56134ff984c8ce56a75329b28",
|
||||
"shortSHA": "5cf48c1b2",
|
||||
"SHA": "5cf48c1b2f7e695ac200b429c2a107b7caab4eac",
|
||||
"branch": "developer",
|
||||
"lastCommitAuthor": "'Eudes Inácio'",
|
||||
"lastCommitTime": "'Thu Aug 3 13:04:58 2023 +0100'",
|
||||
"lastCommitMessage": "duplication of notification solved",
|
||||
"lastCommitNumber": "5134",
|
||||
"lastCommitTime": "'Fri Aug 4 10:13:06 2023 +0100'",
|
||||
"lastCommitMessage": "pull made",
|
||||
"lastCommitNumber": "5137",
|
||||
"change": "",
|
||||
"changeStatus": "On branch developer\nYour branch and 'origin/developer' have diverged,\nand have 9 and 2 different commits each, respectively.\n (use \"git pull\" to merge the remote branch into yours)\n\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.html\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\n\tmodified: src/app/pages/login/login.page.html\n\tmodified: src/app/pages/search/search.page.ts\n\tmodified: src/app/shared/gabinete-digital/despachos/despachos.page.html",
|
||||
"changeStatus": "On branch developer\nYour branch is up to date with 'origin/developer'.\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/home/home.page.ts\n\tmodified: src/app/pages/gabinete-digital/gabinete-digital.page.html\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/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",
|
||||
"changeAuthor": "eudes.inacio"
|
||||
}
|
||||
Reference in New Issue
Block a user