This commit is contained in:
Eudes Inácio
2022-01-30 10:45:27 +01:00
22 changed files with 440 additions and 115 deletions
+8 -3
View File
@@ -2213,15 +2213,20 @@
"resolved": "https://registry.npmjs.org/@capacitor/keyboard/-/keyboard-1.1.3.tgz", "resolved": "https://registry.npmjs.org/@capacitor/keyboard/-/keyboard-1.1.3.tgz",
"integrity": "sha512-WpD1f/3HH6IpADiRaFTDGdhrqYhZDikybXXhUdGAEEwHbErHt9zS5RQgbeROjGmkXcurVvQsalQ59YuKU0VzwA==" "integrity": "sha512-WpD1f/3HH6IpADiRaFTDGdhrqYhZDikybXXhUdGAEEwHbErHt9zS5RQgbeROjGmkXcurVvQsalQ59YuKU0VzwA=="
}, },
"@capacitor/local-notifications": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@capacitor/local-notifications/-/local-notifications-1.1.0.tgz",
"integrity": "sha512-l6S9rBylxGPq/U+xpJzZcOL4l2s8I2Igq7uDTidR4imIxxX3bLRz9nDSQREWsbQkFx7ALFm/5Y8PJGz2C6qKPw=="
},
"@capacitor/network": { "@capacitor/network": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/@capacitor/network/-/network-1.0.6.tgz", "resolved": "https://registry.npmjs.org/@capacitor/network/-/network-1.0.6.tgz",
"integrity": "sha512-xkkmRLlFcg1dM0WfblxKwcKFjcfBQ04yWYX0ubD/n5QfQjLCCb8GbAHlorqIyt2j4PUvSAb0ERLyL89hpKlh2w==" "integrity": "sha512-xkkmRLlFcg1dM0WfblxKwcKFjcfBQ04yWYX0ubD/n5QfQjLCCb8GbAHlorqIyt2j4PUvSAb0ERLyL89hpKlh2w=="
}, },
"@capacitor/push-notifications": { "@capacitor/push-notifications": {
"version": "1.0.7", "version": "1.0.9",
"resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-1.0.7.tgz", "resolved": "https://registry.npmjs.org/@capacitor/push-notifications/-/push-notifications-1.0.9.tgz",
"integrity": "sha512-vbvAptFq5cI6xKYYWMb7tsWvA88/PTG4v6ptxN0Ygtc1fQ4l/AzONQiYqdtFpbBhF2fML2kXQ/5eSAfn8HY9aw==" "integrity": "sha512-NaH+drTYjOGgFMHl/2Jn1/+2rlgomtwP2NfK20E0i7+QoRze1ArcSThJ4vSF0m7VkYBsH3MgbXkWfNSSPaYrtw=="
}, },
"@capacitor/share": { "@capacitor/share": {
"version": "1.0.7", "version": "1.0.7",
+2 -1
View File
@@ -43,8 +43,9 @@
"@capacitor/haptics": "^1.1.2", "@capacitor/haptics": "^1.1.2",
"@capacitor/ios": "3.3.0", "@capacitor/ios": "3.3.0",
"@capacitor/keyboard": "^1.1.2", "@capacitor/keyboard": "^1.1.2",
"@capacitor/local-notifications": "^1.1.0",
"@capacitor/network": "^1.0.6", "@capacitor/network": "^1.0.6",
"@capacitor/push-notifications": "^1.0.7", "@capacitor/push-notifications": "^1.0.9",
"@capacitor/share": "^1.0.7", "@capacitor/share": "^1.0.7",
"@capacitor/storage": "^1.2.3", "@capacitor/storage": "^1.2.3",
"@fortawesome/angular-fontawesome": "^0.9.0", "@fortawesome/angular-fontawesome": "^0.9.0",
+5 -1
View File
@@ -29,6 +29,7 @@ import { RouteService } from 'src/app/services/route.service';
import { WsChatService } from 'src/app/services/chat/ws-chat.service'; import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { v4 as uuidv4 } from 'uuid' import { v4 as uuidv4 } from 'uuid'
import { NativeNotificationService } from 'src/app/services/native-notification.service';
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
@@ -100,10 +101,13 @@ export class HomePage implements OnInit {
private screenOrientation: ScreenOrientation, private screenOrientation: ScreenOrientation,
private sqliteservice: SqliteService, private sqliteservice: SqliteService,
private RouteService: RouteService, private RouteService: RouteService,
private WsChatService: WsChatService) { private WsChatService: WsChatService,
private NativeNotificationService: NativeNotificationService) {
/* this.webNotificationPopupService.askNotificationPermission() */ /* this.webNotificationPopupService.askNotificationPermission() */
this.NativeNotificationService.askForPermission()
this.router.events.subscribe((val) => { this.router.events.subscribe((val) => {
document.querySelectorAll('ion-modal').forEach((e: any) => e.remove()) document.querySelectorAll('ion-modal').forEach((e: any) => e.remove())
document.querySelectorAll('popover-viewport').forEach((e: any) => e.remove()) document.querySelectorAll('popover-viewport').forEach((e: any) => e.remove())
+44 -36
View File
@@ -42,42 +42,48 @@
<ion-list *ngSwitchCase="'Contactos'"> <ion-list *ngSwitchCase="'Contactos'">
<ion-item-sliding> <ion-item-sliding>
<div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin" <div class="item item-hover width-100 d-flex ion-no-padding ion-no-margin"
*ngFor="let room of wsChatMethodsService.dm | keyvalue" *ngFor="let room of wsChatMethodsService._dm"
[class.item-active]="room.value.id == idSelected"> [class.item-active]="room.id == idSelected">
<div class="item-icon"> <div class="item-icon">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon" slot="start" src="assets/images/icons-chat-chat-40.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon" slot="start" src="assets/images/icons-chat-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.value.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.value.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40-hover.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' && room.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-chat-40-hover.svg"></ion-icon>
</div> </div>
<div [class.highlight]="room.value.id =='cjFv5XfreKz5j3fWW'" <div [class.highlight]="room.id =='cjFv5XfreKz5j3fWW'"
(click)="openMessagesPage(room.value.id)" (click)="openMessagesPage(room.id)"
class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" --> class="item-content flex-grow-1 cursor-pointer"><!-- (click)="openMessages(dm)" -->
<div class="item-title-time"> <div class="item-title-time">
<div class="item-title" [class.item-title-active]="room.value.id == idSelected"> <div class="item-title" [class.item-title-active]="room.id == idSelected">
<ion-label > <ion-label >
<span > <span >
<div > <div >
<div > <div >
{{room.value.name}} {{room.name}}
</div> </div>
</div> </div>
</span> </span>
</ion-label> </ion-label>
</div> </div>
<div class="item-date" [class.item-date-active]="room.value.id == idSelected">{{room.value.duration}}</div> <div class="item-date" [class.item-date-active]="room.id == idSelected">{{room.duration}}</div>
</div> </div>
<div *ngIf="room.value.lastMessage" class="item-description" [class.item-description-active]="room.value.id == idSelected"> <div *ngIf="room.lastMessage" class="item-description" [class.item-description-active]="room.id == idSelected">
<ion-label *ngIf="room.value.lastMessage">{{room.value.lastMessage.msg}}</ion-label>
<div *ngIf="room.value.lastMessage.file"> <ion-label *ngIf="room.lastMessage && room.otherUserType == false">{{room.lastMessage.msg}}</ion-label>
<fa-icon *ngIf="room.value.lastMessage.file.type != 'application/meeting' && room.value.lastMessage.file.type != 'application/img'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon> <ion-label *ngIf="room.otherUserType == true">A escrever ...</ion-label>
<fa-icon *ngIf="room.value.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon> <ion-label *ngIf="room.lastMessage.file">
<span> {{room.value.lastMessage.file.name || room.value.lastMessage.file.subject }}</span> <fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
</ion-label>
<div *ngIf="room.lastMessage.file">
<fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting' && room.lastMessage.file.type != 'application/img'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<fa-icon *ngIf="room.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<span> {{room.lastMessage.file.name || room.lastMessage.file.subject }}</span>
</div> </div>
<ion-label *ngIf="room.value.lastMessage.attachments"> <ion-label *ngIf="room.lastMessage.attachments">
<div *ngIf="room.value.lastMessage.attachments[0].image_url"> <div *ngIf="room.lastMessage.attachments[0].image_url">
<fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="room.value.id == idSelected"></fa-icon> <fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
<span> Fotografia</span> <span> Fotografia</span>
</div> </div>
</ion-label> </ion-label>
@@ -104,35 +110,37 @@
</ion-list> </ion-list>
<ion-list *ngSwitchCase="'Grupos'"> <ion-list *ngSwitchCase="'Grupos'">
<ion-item-sliding *ngIf="!wsChatMethodsService.loadingWholeList"> <ion-item-sliding *ngIf="!wsChatMethodsService.loadingWholeList">
<div *ngFor="let group of wsChatMethodsService.group | keyvalue" <div *ngFor="let group of wsChatMethodsService._group"
[class.item-active]="group.value.id ==idSelected" [class.item-active]="group.id ==idSelected"
class="item item-hover d-flex"> class="item item-hover d-flex">
<div class="item-icon"> <div class="item-icon">
<!-- <ion-icon class="icon" slot="start" src="assets/images/icons-chat-group-chat-40.svg"></ion-icon> --> <!-- <ion-icon class="icon" slot="start" src="assets/images/icons-chat-group-chat-40.svg"></ion-icon> -->
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon" slot="start" src="assets/images/icons-chat-group-chat-40.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon" slot="start" src="assets/images/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && group.value.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' && group.id != idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' && group.value.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40-hover.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' && group.id == idSelected " class="icon" slot="start" src="assets/images/theme/gov/icons-chat-group-chat-40-hover.svg"></ion-icon>
</div> </div>
<div <div
(click)="openGroupMessagesPage(group.value.id)" class="item-content flex-grow-1 cursor-pointer"> (click)="openGroupMessagesPage(group.id)" class="item-content flex-grow-1 cursor-pointer">
<div class="item-title-time"> <div class="item-title-time">
<div class="item-title" [class.item-title-active]="group.value.id ==idSelected"> <div class="item-title" [class.item-title-active]="group.id ==idSelected">
<ion-label>{{group.value.name.split('-').join(' ')}}</ion-label> <ion-label>{{group.name.split('-').join(' ')}}</ion-label>
</div> </div>
<div class="item-date" [class.item-date-active]="group.value.id ==idSelected" *ngIf="group.value.lastMessage && !group.value.customFields.countDownDate">{{group.value.duration}}</div> <div class="item-date" [class.item-date-active]="group.id ==idSelected" *ngIf="group.lastMessage && !group.customFields.countDownDate">{{group.duration}}</div>
<div class="item-date" [class.item-date-active]="group.value.id ==idSelected" *ngIf="group.value.customFields.countDownDate">{{countDownDate(group.value.customFields.countDownDate, group.value.id)}}</div> <div class="item-date" [class.item-date-active]="group.id ==idSelected" *ngIf="group.customFields.countDownDate">{{countDownDate(group.customFields.countDownDate, group.id)}}</div>
</div> </div>
<div *ngIf="group.value.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.value.id ==idSelected"> <div *ngIf="group.lastMessage" class="item-description d-flex align-items-center" [class.item-description-active]="group.id ==idSelected">
<div *ngIf="group.value.lastMessage.u.name" class="item-message">{{group.value.lastMessage.u.name}}: {{group.value.lastMessage.msg}} </div> <div class="item-message" *ngIf="group.otherUserType == false">{{group.lastMessage.u.name}}: {{group.lastMessage.msg}} </div>
<div class="item-files add-ellipsis" *ngIf="group.value.file"> <div *ngIf="group.otherUserType == true">{{group.userThatIsTyping}} A escrever ...</div>
<fa-icon *ngIf="group.value.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon>
<fa-icon *ngIf="group.value.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon> <div class="item-files add-ellipsis" *ngIf="group.file">
<span class="item-files-title"> {{group.value.lastMessage.file.name || group.value.file.subject}}</span> <fa-icon *ngIf="group.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<fa-icon *ngIf="group.lastMessage.file.type == 'application/meeting'" icon="calendar-alt" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<span class="item-files-title"> {{group.lastMessage.file.name || group.file.subject}}</span>
</div> </div>
<div class="item-files" *ngIf="group.value.attachments"> <div class="item-files" *ngIf="group.attachments">
<div *ngIf="group.value.value.lastMessage.attachments[0].image_url"> <div *ngIf="group.value.lastMessage.attachments[0].image_url">
<fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="group.value.id == idSelected"></fa-icon> <fa-icon icon="image" class="file-icon" [class.set-active-item-font-to-white]="group.id == idSelected"></fa-icon>
<span> Fotografia</span> <span> Fotografia</span>
</div> </div>
</div> </div>
@@ -56,7 +56,7 @@
<ion-label>Esta conversa passou a grupo</ion-label><br /> <ion-label>Esta conversa passou a grupo</ion-label><br />
<ion-label>A conversa original mantêm-se como chat individual</ion-label> <ion-label>A conversa original mantêm-se como chat individual</ion-label>
</div> </div>
<div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).massages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId"> <div class="messages-list-item-wrapper container-width-100" *ngFor="let msg of wsChatMethodsService.getGroupRoom(roomId).messages; let last = last" [class.messages-list-item-wrapper-active]="msg._id == selectedMsgId">
<div class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)"> <div class='message-container incoming-{{msg.u.username!=loggedUser.me.username}}' *ngIf="msg.t != 'r' && msg.t != 'ul' && msg.t != 'au' && msg.t != 'ru' && msg.msg !=''" (press)="handlePress(msg._id)">
<div class="title"> <div class="title">
<ion-label>{{msg.u.name ?? ""}}</ion-label> <ion-label>{{msg.u.name ?? ""}}</ion-label>
@@ -196,18 +196,18 @@
</div> </div>
<div class="message-box width-80"> <div class="message-box width-80">
<ion-item class="ion-no-padding type-message" lines="none"> <ion-item class="ion-no-padding type-message" lines="none">
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea> <ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getGroupRoom(roomId).message" (ionChange)="changeInput()"></ion-textarea>
<button hidden class="btn-no-color"> <button hidden class="btn-no-color">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button> </button>
</ion-item> </ion-item>
</div> </div>
<div> <div>
<button *ngIf="message" class="btn-no-color" (click)="sendMessage()"> <button *ngIf="wsChatMethodsService.getGroupRoom(roomId).message" class="btn-no-color" (click)="sendMessage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
<button *ngIf="!message" class="btn-no-color"> <button *ngIf="!wsChatMethodsService.getGroupRoom(roomId).message" class="btn-no-color">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
@@ -39,7 +39,6 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
showLoader: boolean; showLoader: boolean;
isGroupCreated:boolean; isGroupCreated:boolean;
loggedUser: any; loggedUser: any;
message:any;
messages:any; messages:any;
room:any; room:any;
@@ -184,6 +183,11 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.currentPosition = scroll; this.currentPosition = scroll;
} }
changeInput() {
this.wsChatMethodsService.getDmRoom(this.roomId).typing()
}
async goToEvent(eventId: any) { async goToEvent(eventId: any) {
let classs; let classs;
if (window.innerWidth < 701) { if (window.innerWidth < 701) {
@@ -323,8 +327,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
sendMessage() { sendMessage() {
this.wsChatMethodsService.getGroupRoom(this.roomId).send(this.message) this.wsChatMethodsService.getGroupRoom(this.roomId).send()
this.message = "";
} }
async openOptions() { async openOptions() {
@@ -186,7 +186,7 @@
</div> </div>
<div class="width-70"> <div class="width-70">
<ion-item class="ion-no-padding ion-no-margin type-message" lines="none"> <ion-item class="ion-no-padding ion-no-margin type-message" lines="none">
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" *ngIf="!recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea> <ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" *ngIf="!recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getDmRoom(roomId).message" (ionChange)="changeInput()"></ion-textarea>
<ion-textarea autocomplete="on" spellcheck="true" *ngIf="recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="durationDisplay"></ion-textarea> <ion-textarea autocomplete="on" spellcheck="true" *ngIf="recording" clearOnEdit="true" placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="durationDisplay"></ion-textarea>
<button hidden #recordbtn class="btn-no-color" (click)="notImplemented()"> <button hidden #recordbtn class="btn-no-color" (click)="notImplemented()">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
@@ -194,11 +194,11 @@
</ion-item> </ion-item>
</div> </div>
<div> <div>
<button *ngIf="message" class="btn-no-color" (click)="sendMessage()"> <button *ngIf="wsChatMethodsService.getDmRoom(roomId).message" class="btn-no-color" (click)="sendMessage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
<button *ngIf="!message" class="btn-no-color"> <button *ngIf="!wsChatMethodsService.getDmRoom(roomId).message" class="btn-no-color">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
+5 -1
View File
@@ -117,7 +117,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
setTimeout(()=>{ setTimeout(()=>{
this.scrollToBottomClicked() this.scrollToBottomClicked()
}, 50) }, 150)
} }
@@ -343,6 +343,10 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
window.removeEventListener('scroll', this.scrollChangeCallback, true); window.removeEventListener('scroll', this.scrollChangeCallback, true);
} }
changeInput() {
this.wsChatMethodsService.getDmRoom(this.roomId).typing()
}
sendMessage() { sendMessage() {
let body = { let body = {
"message": "message":
@@ -39,12 +39,14 @@
(click)="goToPublicationDetail(publication.DocumentId)" (click)="goToPublicationDetail(publication.DocumentId)"
> >
<div *ngIf="publication.FileBase64 != null"> <div *ngIf="publication.FileBase64 != null">
<div *ngIf="publication.FileBase64.length > 30" class="post-img"> <div *ngIf="publication.FileBase64.length < 30; else imageLoaded" class="post-img">
<img src="{{'data:image/jpeg;base64,' + publication.FileBase64}}" alt="image"> <img src="/assets/icon/icon-no-image.svg">
</div>
<div *ngIf="publication.FileBase64.length < 30" class="post-img">
<img src="/assets/icon/icon-no-image.svg" alt="image">
</div> </div>
<ng-template #imageLoaded>
<div *ngIf="publication.FileBase64.length > 30" class="post-img">
<img src="{{publication.FileBase64}}">
</div>
</ng-template>
</div> </div>
<div class="post-content px-20"> <div class="post-content px-20">
<div class="post-title-time"> <div class="post-title-time">
@@ -70,9 +70,10 @@ export class ViewPublicationsPage implements OnInit {
} }
//this.testForkJoin() //this.testForkJoin()
this.getPublicationDetail(); this.getPublicationDetail();
setTimeout(() => { this.getPublicationsIds();
/* setTimeout(() => {
this.getPublicationsIds(); this.getPublicationsIds();
}, 1000); }, 1000); */
this.backgroundservice.registerBackService('Online', () => { this.backgroundservice.registerBackService('Online', () => {
this.getPublicationDetail(); this.getPublicationDetail();
@@ -92,7 +93,7 @@ export class ViewPublicationsPage implements OnInit {
// this.id = this.id['ProcessId'] // this.id = this.id['ProcessId']
// } // }
//this.testForkJoin() //this.testForkJoin()
this.getPublicationDetail(); //this.getPublicationDetail();
// this.getPublicationsIds(); // this.getPublicationsIds();
} }
@@ -119,6 +120,7 @@ export class ViewPublicationsPage implements OnInit {
this.publications.GetPresidentialAction(this.folderId).subscribe(res => { this.publications.GetPresidentialAction(this.folderId).subscribe(res => {
console.log(res); console.log(res);
this.item = res; this.item = res;
this.sqliteservice.updatePublicationsDetails(this.folderId, JSON.stringify(res));
}); });
} }
@@ -144,16 +146,16 @@ export class ViewPublicationsPage implements OnInit {
console.log('publications ids', res) console.log('publications ids', res)
this.publicationList = new Array(); this.publicationList = new Array();
/* for(let i of res) { for(let i = 0; i < res.length; i++) {
this.publications.GetPublicationById(i).subscribe(ress => { this.publications.GetPublicationById(res[i]).subscribe(ress => {
console.log('publications by ids', ress) console.log('publications by ids', ress)
let item: Publication = this.publicationPipe.itemList(ress) let item: Publication = this.publicationPipe.itemList(ress)
console.log('publications by ids 2', item) console.log('publications by ids 2', item)
this.publicationList.push(item); this.publicationList.push(item);
}) })
} */ }
res.forEach(element => { /* res.forEach(element => {
console.log('publications elements', element) console.log('publications elements', element)
this.publications.GetPublicationById(element).subscribe(ress => { this.publications.GetPublicationById(element).subscribe(ress => {
console.log('publications by ids', ress) console.log('publications by ids', ress)
@@ -162,9 +164,10 @@ export class ViewPublicationsPage implements OnInit {
this.publicationList.push(ress); this.publicationList.push(ress);
}) })
}); }); */
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList)); this.sqliteservice.updateactions(this.folderId, JSON.stringify(this.publicationList));
console.log('PUBLICATIONS IMAGEs',this.publicationList)
this.publicationListStorage.add(folderId, this.publicationList) this.publicationListStorage.add(folderId, this.publicationList)
this.getpublication = this.publicationList; this.getpublication = this.publicationList;
@@ -237,7 +240,7 @@ export class ViewPublicationsPage implements OnInit {
this.sqliteservice.getActionById(this.folderId).then((publications) => { this.sqliteservice.getActionById(this.folderId).then((publications) => {
console.log('publications', publications) console.log('publications', publications)
let item = { /* let item = {
ActionType: publications[0].ActionType, ActionType: publications[0].ActionType,
DateBegin: publications[0].DateBegin, DateBegin: publications[0].DateBegin,
DateEnd: publications[0].DateEnd, DateEnd: publications[0].DateEnd,
@@ -245,7 +248,8 @@ export class ViewPublicationsPage implements OnInit {
Detail: publications[0].Detail, Detail: publications[0].Detail,
ProcessId: publications[0].ProcessId ProcessId: publications[0].ProcessId
} }
this.publicationDitails = item; this.publicationDitails = item; */
this.item = JSON.parse(publications[0].publicationsDetails);
let publicationArray = []; let publicationArray = [];
JSON.parse(publications[0].publications).forEach(element => { JSON.parse(publications[0].publications).forEach(element => {
@@ -263,7 +267,7 @@ export class ViewPublicationsPage implements OnInit {
publicationArray.push(publicationlis); publicationArray.push(publicationlis);
}); });
this.getpublication = publicationArray; this.getpublication = publicationArray;
}) })
} }
+101 -16
View File
@@ -1,13 +1,16 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core';
import { WsChatService } from 'src/app/services/chat/ws-chat.service'; import { WsChatService } from 'src/app/services/chat/ws-chat.service';
import { MessageService } from 'src/app/services/chat/message.service' import { MessageService } from 'src/app/services/chat/message.service';
import { ChatUserService } from 'src/app/services/chat/chat-user.service' import { ChatUserService } from 'src/app/services/chat/chat-user.service';
import { showDateDuration } from 'src/plugin/showDateDuration' import { showDateDuration } from 'src/plugin/showDateDuration';
import { ToastsService } from '../toast.service'; import { ToastsService } from '../toast.service';
import { chatHistory, ChatMessage } from 'src/app/models/chatMethod' import { chatHistory, ChatMessage } from 'src/app/models/chatMethod';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { NativeNotificationService } from 'src/app/services/native-notification.service';
import { SessionStore } from 'src/app/store/session.service';
import { capitalizeTxt } from 'src/plugin/text'
import { SortService } from '../functions/sort.service'; import { SortService } from '../functions/sort.service';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@@ -26,6 +29,12 @@ export class RoomService {
_updatedAt = {} _updatedAt = {}
private hasLoadHistory = false private hasLoadHistory = false
duration = '' duration = ''
isTyping = false
otherUserType = false
lastTimeType = null
message = ''
lastMessageTxt = ''
userThatIsTyping = ''
private ToastService = ToastsService private ToastService = ToastsService
mgsArray = []; mgsArray = [];
@@ -38,8 +47,11 @@ export class RoomService {
private storage: Storage, private storage: Storage,
private platform: Platform, private platform: Platform,
private sqlservice: SqliteService, private sqlservice: SqliteService,
private NativeNotificationService: NativeNotificationService,
private sortService: SortService, private sortService: SortService,
) { } ) {
this.NativeNotificationService.askForPermission()
}
setData({ customFields, id, name, t, lastMessage = new MessageService(this.storage), _updatedAt }) { setData({ customFields, id, name, t, lastMessage = new MessageService(this.storage), _updatedAt }) {
this.customFields = customFields this.customFields = customFields
@@ -54,7 +66,7 @@ export class RoomService {
receiveMessage() { receiveMessage() {
this.WsChatService.upateRoomEvents( this.WsChatService.updateRoomEventss(
this.id, this.id,
"stream-room-messages", "stream-room-messages",
(ChatMessage) => { (ChatMessage) => {
@@ -77,6 +89,13 @@ export class RoomService {
//this.sortService.sortDate(this.messages, '') //this.sortService.sortDate(this.messages, '')
if(SessionStore.user.RochetChatUser != ChatMessage.u.username) {
this.NativeNotificationService.sendNotificationChat({
message: message.msg,
title: this.name
});
}
// save to ionic storage // save to ionic storage
this.storage.get('chatmsg' + this.id).then((messages: any) => { this.storage.get('chatmsg' + this.id).then((messages: any) => {
const newListMessages = messages.push(ChatMessage) const newListMessages = messages.push(ChatMessage)
@@ -89,12 +108,25 @@ export class RoomService {
} }
) )
this.WsChatService.receiveStreamNotifyRoom((message) => {
if(message.fields.eventName == this.id+'/'+'typing') {
this.userThatIsTyping = this.usernameToDisplayName(message.fields.args[0])
this.isTyping = message.fields.args[1]
this.otherUserType = message.fields.args[1]
} else if (message.fields.eventName == this.id+'/'+'deleteMessage') {}
})
this.WsChatService.registerCallback this.WsChatService.registerCallback
} }
async receiveMessageDelete() { async receiveMessageDelete() {
this.WsChatService.upateRoomEvents( this.WsChatService.updateRoomEventss(
this.id, this.id,
"stream-notify-room", "stream-notify-room",
async (ChatMessage) => { async (ChatMessage) => {
@@ -121,8 +153,49 @@ export class RoomService {
this.WsChatService.registerCallback this.WsChatService.registerCallback
} }
send(msg) { send() {
this.WsChatService.send(this.id, msg) this.WsChatService.send(this.id, this.message)
this.message= ''
}
typing(text:string = this.message) {
if(this.lastMessageTxt == text) { return false }
this.lastTimeType = new Date().getTime()
const lastIsTyping = this.isTyping
if(text.length >= 1) {
this.isTyping = true
} else {
this.isTyping = false
}
if(lastIsTyping != this.isTyping) {
this.WsChatService.sendStreamNotifyRoom(this.id, SessionStore.user.RochetChatUser, 'typing', this.isTyping)
}
this.lastMessageTxt = this.message
this.typingWatch()
}
private typingWatch() {
setTimeout(()=>{
const now = new Date().getTime()
if((now - this.lastTimeType) >= 2888) {
if(this.isTyping == true) {
this.isTyping = false
this.WsChatService.sendStreamNotifyRoom(this.id, SessionStore.user.RochetChatUser, 'typing', this.isTyping)
}
} else {
//console.log(now - this.lastTimeType)
}
}, 3000)
} }
leave(rid?) { leave(rid?) {
@@ -206,20 +279,25 @@ export class RoomService {
if (this.hasLoadHistory) { return false } if (this.hasLoadHistory) { return false }
this.storage.get('chatmsg' + this.id).then((messages = [])=>{ this.storage.get('chatmsg' + this.id).then((messages = []) => {
let localMessages = []
messages.forEach(message => { messages.forEach(message => {
message = this.fix_updatedAt(message) message = this.fix_updatedAt(message)
const wewMessage = new MessageService(this.storage) const wewMessage = new MessageService(this.storage)
wewMessage.setData(message) wewMessage.setData(message)
this.messages.push(wewMessage) localMessages.push(wewMessage)
}); });
this.messages = localMessages
}) })
this.WsChatService.loadHistory(this.id, limit).then((chatHistory:chatHistory) => { this.WsChatService.loadHistory(this.id, limit).then((chatHistory:chatHistory) => {
console.log('loadHistory', chatHistory) console.log('loadHistory', chatHistory)
let localMessages = [] let localMessages = []
//const sortedRoomList = this.sortService.sortDate(chatHistory.result.messages, "_updatedAt.$date")
chatHistory.result.messages.reverse().forEach(message => { chatHistory.result.messages.reverse().forEach(message => {
message = this.fix_updatedAt(message) message = this.fix_updatedAt(message)
@@ -230,9 +308,11 @@ export class RoomService {
this.messages = localMessages this.messages = localMessages
this.storage.set('chatmsg' + this.id, chatHistory.result.messages.reverse()) console.log(chatHistory.result.messages);
this.storage.set('chatmsg' + this.id, chatHistory.result.messages.reverse())
}) })
/* this.WsChatService.loadHistory(this.id, limit).then(async (chatHistory: chatHistory) => { /* this.WsChatService.loadHistory(this.id, limit).then(async (chatHistory: chatHistory) => {
@@ -348,6 +428,7 @@ export class RoomService {
private calDateDuration(date = null) { private calDateDuration(date = null) {
this.duration = showDateDuration(date || this._updatedAt); this.duration = showDateDuration(date || this._updatedAt);
this._updatedAt = date || this._updatedAt
} }
@@ -363,7 +444,11 @@ export class RoomService {
} }
// to add usernameToDisplayName(username) {
countDownDate() { }
const firstName = capitalizeTxt(username.split('.')[0])
const lastName = capitalizeTxt(username.split('.')[1])
return firstName + ' ' + lastName
}
} }
@@ -8,6 +8,7 @@ import { Rooms, Update as room } from 'src/app/models/chatMethod';
import { Storage } from '@ionic/storage'; import { Storage } from '@ionic/storage';
import { Platform } from '@ionic/angular'; import { Platform } from '@ionic/angular';
import { SqliteService } from 'src/app/services/sqlite.service'; import { SqliteService } from 'src/app/services/sqlite.service';
import { NativeNotificationService } from 'src/app/services/native-notification.service';
import { SortService } from '../functions/sort.service'; import { SortService } from '../functions/sort.service';
@Injectable({ @Injectable({
@@ -15,11 +16,13 @@ import { SortService } from '../functions/sort.service';
}) })
export class WsChatMethodsService { export class WsChatMethodsService {
dm: {[key: string]: RoomService} = {} dm: {[key: string]: RoomService} = {}
group: {[key: string]: RoomService} = {} group: {[key: string]: RoomService} = {}
_dm = []
_group = []
loadingWholeList = false loadingWholeList = false
dmCount = 0; dmCount = 0;
@@ -30,6 +33,7 @@ export class WsChatMethodsService {
private storage: Storage, private storage: Storage,
private platform: Platform, private platform: Platform,
private sqlservice: SqliteService, private sqlservice: SqliteService,
private NativeNotificationService: NativeNotificationService,
private sortService: SortService private sortService: SortService
) { ) {
(async()=>{ (async()=>{
@@ -56,20 +60,56 @@ export class WsChatMethodsService {
this.storage.set('Rooms', rooms); this.storage.set('Rooms', rooms);
// console.log("ROOMS" + JSON.stringify(rooms)) // console.log("ROOMS" + JSON.stringify(rooms))
this.WsChatService.registerCallback({
type:'Onmessage',
funx:(message)=>{
rooms.result.update.forEach((roomData: room) => { if(message.msg =='changed' && message.collection == "stream-room-messages") {
this.prepareRoom(roomData); if(message.fields.args[0].rid) {
setTimeout(()=>{
console.log('sort this._dm', this._dm)
this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
}, 100)
}
}
if(message.msg =='changed' && message.collection == "stream-notify-room") {
if(message.fields.eventName.includes('deleteMessage')){
setTimeout(()=>{
console.log('sort this._dm', this._dm)
this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
}, 100)
}
}
}
})
await rooms.result.update.forEach( async (roomData: room) => {
await this.prepareRoom(roomData);
}); });
this._dm = this.sortService.sortDate(this._dm,'_updatedAt').reverse()
this._group = this.sortService.sortDate(this._group,'_updatedAt').reverse()
this.loadingWholeList = false this.loadingWholeList = false
} }
subscribeToRoom() { subscribeToRoom() {
for (const id in this.dm) { for (const id in this.dm) {
this.WsChatService.streamRoomMessages(id).then((subscription)=>{ this.WsChatService.streamRoomMessages(id).then((subscription)=>{
console.log('streamRoomMessages', subscription) console.log('streamRoomMessages', subscription)
}) })
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{ this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
console.log('streamNotifyRoomDeleteMessage', subscription); console.log('streamNotifyRoomDeleteMessage', subscription);
}) })
@@ -79,6 +119,8 @@ export class WsChatMethodsService {
this.WsChatService.streamRoomMessages(id).then((subscription)=>{ this.WsChatService.streamRoomMessages(id).then((subscription)=>{
console.log('streamRoomMessages', subscription) console.log('streamRoomMessages', subscription)
}) })
this.WsChatService.subStreamNotifyRoom(id, 'typing', false)
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{ this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
console.log('streamNotifyRoomDeleteMessage', subscription); console.log('streamNotifyRoomDeleteMessage', subscription);
}) })
@@ -90,13 +132,13 @@ export class WsChatMethodsService {
subscribeToRoomUpdate(id, roomData) { subscribeToRoomUpdate(id, roomData) {
this.WsChatService.streamRoomMessages(id).then((subscription)=>{ this.WsChatService.streamRoomMessages(id).then((subscription)=> {
console.log('streamRoomMessages', subscription) console.log('streamRoomMessages', subscription)
}) })
this.WsChatService.streamRoomMessages(id).then((subscription)=>{ this.WsChatService.streamRoomMessages(id).then((subscription) => {
console.log('streamRoomMessages', subscription) console.log('streamRoomMessages', subscription)
}) })
this.WsChatService.streamNotifyLogged().then((subscription=>{ this.WsChatService.streamNotifyLogged().then((subscription=> {
console.log('streamRoomMessages', subscription) console.log('streamRoomMessages', subscription)
})) }))
this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{ this.WsChatService.streamNotifyRoomDeleteMessage(id).then((subscription)=>{
@@ -109,10 +151,11 @@ export class WsChatMethodsService {
} }
prepareRoom(roomData){ prepareRoom(roomData) {
let room:RoomService; let room:RoomService;
room = new RoomService(this.WsChatService, new MessageService(this.storage), this.storage, this.platform, this.sqlservice, this.sortService) room = new RoomService(this.WsChatService, new MessageService(this.storage), this.storage, this.platform, this.sqlservice, this.NativeNotificationService, this.sortService)
room.setData({ room.setData({
customFields: roomData.customFields, customFields: roomData.customFields,
id: this.getRoomId(roomData), id: this.getRoomId(roomData),
@@ -128,12 +171,12 @@ export class WsChatMethodsService {
let roomId = this.getRoomId(roomData) let roomId = this.getRoomId(roomData)
if(this.isIndividual(roomData)) { if(this.isIndividual(roomData)) {
console.log(room);
this.dm[roomId] = room this.dm[roomId] = room
this._dm.push(room)
this.dmCount++ this.dmCount++
} else { } else {
this.group[roomId] = room this.group[roomId] = room
this._group.push(room)
this.groupCount++ this.groupCount++
} }
} }
+68 -2
View File
@@ -282,7 +282,73 @@ export class WsChatService {
}); });
} }
sendStreamNotifyRoom(roomId : string, username, event: 'typing', param: any) {
const requestId = uuidv4()
let message = {
msg: "method",
method: "stream-notify-room",
id: requestId,
params: [
`${roomId}/${event}`,
username,
param
]
};
this.ws.send({message, requestId})
return new Promise((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
resolve(message)
return true
}
}})
});
}
subStreamNotifyRoom(roomId : string , event: 'typing' | 'deleteMessage', param: any) {
const requestId = uuidv4()
let message = {
msg: "sub",
id: requestId,
name: "stream-notify-room",
params:[
`${roomId}/${event}`,
param
]
}
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)
return true
}
}})
});
}
receiveStreamNotifyRoom(funx: Function) {
this.ws.registerCallback({
type:'Onmessage',
funx:(message)=> {
if(message.collection == "stream-notify-room" && message.msg == 'changed') {
funx(message)
}
}})
}
loadHistory(roomId, limit: number = 50) { loadHistory(roomId, limit: number = 50) {
@@ -359,7 +425,7 @@ export class WsChatService {
} }
upateRoomEvents(roomId, collection:string, funx: Function, ) { updateRoomEventss(roomId, collection:string, funx: Function, ) {
this.ws.registerCallback({ this.ws.registerCallback({
type:'Onmessage', type:'Onmessage',
@@ -451,7 +517,7 @@ upateRoomEvents(roomId, collection:string, funx: Function, ) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.ws.registerCallback({type:'Onmessage', funx:(message)=>{ this.ws.registerCallback({type:'Onmessage', funx:(message)=>{
if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send if(message.id == requestId || deepFind(message,'result.id') == requestId) { // same request send
resolve('') resolve(message)
return true return true
} }
}}) }})
+2 -2
View File
@@ -8,11 +8,11 @@ export class ObjectService {
constructor() { } constructor() { }
deepFind(obj, path) { deepFind(obj, path):any {
var paths = path.split('.') var paths = path.split('.')
, current = obj , current = obj
, i; , i;
for (i = 0; i < paths.length; ++i) { for (i = 0; i < paths.length; ++i) {
if (current[paths[i]] == undefined) { if (current[paths[i]] == undefined) {
return undefined; return undefined;
+11 -1
View File
@@ -26,8 +26,18 @@ export class SortService {
} }
sortDate(array = [], path: string) { sortDate(array = [], path: string) {
return array.sort( (a,b)=> { return array.sort( (a,b)=> {
return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime()
/* console.log("AAA"+new Date(this.ObjectService.deepFind(a, path)));
console.log("BB"+new Date(this.ObjectService.deepFind(b, path))); */
return (new Date(this.ObjectService.deepFind(a, path)) < new Date(this.ObjectService.deepFind(b, path))) ? -1 : ((new Date(this.ObjectService.deepFind(a, path)) > new Date(this.ObjectService.deepFind(b, path))) ? 1 : 0);
//return new Date(this.ObjectService.deepFind(b, path)).getTime() - new Date(this.ObjectService.deepFind(a, path)).getTime();
}) })
} }
} }
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { NativeNotificationService } from './native-notification.service';
describe('NativeNotificationService', () => {
let service: NativeNotificationService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(NativeNotificationService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,51 @@
import { Injectable } from '@angular/core';
import { Platform } from '@ionic/angular';
import { CapacitorConfig } from '@capacitor/cli';
import { LocalNotifications } from '@capacitor/local-notifications';
@Injectable({
providedIn: 'root'
})
export class NativeNotificationService {
constructor(private platform: Platform,) {
this.askForPermission()
}
askForPermission() {
LocalNotifications.requestPermissions()
LocalNotifications.checkPermissions().then((data)=>{
console.log('success', data)
}).catch((data)=>{
console.log('error', data)
})
}
sendNotificationChat({title = 'User', icon = '', message = 'hello'}) {
LocalNotifications.schedule({
notifications:[
{
title : title,
body : message,
id : new Date().getTime()
}
]
});
}
isDesktop() {
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
return true
} else {
return false
}
}
}
+20 -3
View File
@@ -127,7 +127,8 @@ export class SqliteService {
DateEnd varchar(255), DateEnd varchar(255),
Detail varchar(255), Detail varchar(255),
Description varchar(255), Description varchar(255),
publications Text publications Text,
publicationsDetails Text
)`, []) )`, [])
.then((res) => { .then((res) => {
console.log("Sucess action Table created: ", res) console.log("Sucess action Table created: ", res)
@@ -195,8 +196,8 @@ export class SqliteService {
public addactions(data) { public addactions(data) {
console.log('Action insert', data) console.log('Action insert', data)
this.dbInstance.executeSql(` this.dbInstance.executeSql(`
INSERT OR IGNORE INTO ${this.actions} (ActionType,DateBegin,DateEnd,Description,Detail,ProcessId,publications) INSERT OR IGNORE INTO ${this.actions} (ActionType,DateBegin,DateEnd,Description,Detail,ProcessId,publications,publicationsDetails)
VALUES ('${data.ActionType}','${data.DateBegin}', '${data.DateEnd}','${data.Description}','${data.Detail}','${data.ProcessId}','${data.publications}')`, []) VALUES ('${data.ActionType}','${data.DateBegin}', '${data.DateEnd}','${data.Description}','${data.Detail}','${data.ProcessId}','${data.publications}','${data.publicationsDetails}')`, [])
.then(() => { .then(() => {
console.log("action add with Success"); console.log("action add with Success");
@@ -319,6 +320,22 @@ export class SqliteService {
} }
//updatePublicationsDetails
public updatePublicationsDetails(id, data) {
try {
console.log("update action data", data)
this.dbInstance.executeSql(`
UPDATE ${this.actions} SET publicationsDetails = ? WHERE ProcessId = ${id}`, [data])
.then(() => {
console.log("action update with Success");
}, (e) => {
console.log(JSON.stringify(e.err));
});
} catch(error) {}
}
//updateChatMsg //updateChatMsg
public updateChatMsg(id, data) { public updateChatMsg(id, data) {
let jsonId = JSON.stringify(id) let jsonId = JSON.stringify(id)
@@ -234,18 +234,18 @@
<div class="width-100"> <div class="width-100">
<ion-item class="ion-no-padding type-message" lines="none"> <ion-item class="ion-no-padding type-message" lines="none">
<ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" (keyup.enter)="sendMessage()" clearOnEdit="true" placeholder="Escrever uma mensagem" class="message-input" rows="1" [(ngModel)]="message"></ion-textarea> <ion-textarea autocomplete="on" autocorrect="on" spellcheck="true" (keyup.enter)="sendMessage()" clearOnEdit="true" placeholder="Escrever uma mensagem" class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getGroupRoom(roomId).message" (ionChange)="changeInput()"></ion-textarea>
<button hidden class="btn-no-color"> <button hidden class="btn-no-color">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button> </button>
</ion-item> </ion-item>
</div> </div>
<div class="btn-send"> <div class="btn-send">
<button *ngIf="message" class="btn-no-color" (click)="sendMessage()"> <button *ngIf="wsChatMethodsService.getGroupRoom(roomId).message" class="btn-no-color" (click)="sendMessage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
<button title="Enviar Mensagem" *ngIf="!message" class="btn-no-color"> <button title="Enviar Mensagem" *ngIf="!wsChatMethodsService.getGroupRoom(roomId).message" class="btn-no-color">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
@@ -220,6 +220,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
window.removeEventListener('scroll', this.scrollChangeCallback, true); window.removeEventListener('scroll', this.scrollChangeCallback, true);
} }
changeInput() {
this.wsChatMethodsService.getDmRoom(this.roomId).typing()
}
async getChatMembers() { async getChatMembers() {
//return await this.chatService.getMembers(roomId).toPromise(); //return await this.chatService.getMembers(roomId).toPromise();
this.chatService.getAllUsers().subscribe(res => { this.chatService.getAllUsers().subscribe(res => {
@@ -302,8 +307,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
} }
sendMessage() { sendMessage() {
this.wsChatMethodsService.getGroupRoom(this.roomId).send(this.message) this.wsChatMethodsService.getGroupRoom(this.roomId).send()
this.message = "";
} }
deleteMessage(msgId: string, room:any) { deleteMessage(msgId: string, room:any) {
@@ -215,20 +215,20 @@
<div class="width-100"> <div class="width-100">
<ion-item class="ion-no-padding type-message" lines="none"> <ion-item class="ion-no-padding type-message" lines="none">
<ion-textarea (keyup.enter)="sendMessage()" clearOnEdit="true" placeholder="Escrever uma mensagem" <ion-textarea (keyup.enter)="sendMessage()" clearOnEdit="true" placeholder="Escrever uma mensagem"
class="message-input" rows="1" [(ngModel)]="message"></ion-textarea> class="message-input" rows="1" [(ngModel)]="wsChatMethodsService.getDmRoom(roomId).message" (ionChange)="changeInput()"></ion-textarea>
<button hidden class="btn-no-color" (click)="notImplemented()"> <button hidden class="btn-no-color" (click)="notImplemented()">
<ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon> <ion-icon slot="end" src="assets/icon/icons-chat-mic.svg"></ion-icon>
</button> </button>
</ion-item> </ion-item>
</div> </div>
<div> <div>
<button *ngIf="message" class="btn-no-color" (click)="sendMessage()"> <button *ngIf="wsChatMethodsService.getDmRoom(roomId).message" class="btn-no-color" (click)="sendMessage()">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send"
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send"
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
</button> </button>
<button *ngIf="!message" class="btn-no-color"> <button *ngIf="!wsChatMethodsService.getDmRoom(roomId).message" class="btn-no-color">
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send" <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="chat-icon-send"
src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon> src="assets/icon/theme/gov/icons-chat-send.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send" <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="chat-icon-send"
@@ -42,7 +42,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
loggedUser: any; loggedUser: any;
message = '';
messages: any; messages: any;
dm: any; dm: any;
userPresence = ''; userPresence = '';
@@ -250,8 +249,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} }
sendMessage() { sendMessage() {
this.wsChatMethodsService.getDmRoom(this.roomId).send(this.message) this.wsChatMethodsService.getDmRoom(this.roomId).send()
this.message = "";
} }
deleteMessage(msgId: string, room:any) { deleteMessage(msgId: string, room:any) {
@@ -282,6 +280,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
} }
changeInput() {
this.wsChatMethodsService.getDmRoom(this.roomId).typing()
}
async openViewDocumentModal(file: any) { async openViewDocumentModal(file: any) {
let task = { let task = {
serialNumber: '', serialNumber: '',