mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +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() {
|
||||
|
||||
Reference in New Issue
Block a user