add show total users in rocket chat server

This commit is contained in:
Tiago Kayaya
2020-10-30 15:22:35 +01:00
parent 4a7df21759
commit 21eb3d3cf1
63 changed files with 970 additions and 139 deletions
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { HomeGuard } from './home.guard';
describe('HomeGuard', () => {
let guard: HomeGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(HomeGuard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});
+32
View File
@@ -0,0 +1,32 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { StorageService } from '../services/storage.service';
@Injectable({
providedIn: 'root'
})
export class HomeGuard implements CanActivate {
constructor(
public storageService:StorageService,
private router:Router
){}
canActivate(): Promise<boolean>{
return new Promise(resolve => {
this.storageService.get(AuthConnstants.AUTH).then(res => {
if(res){
resolve(true);
}
else{
this.router.navigate(['']);
resolve(false);
}
}).catch(err =>{
resolve(false);
})
});
}
}
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { IndexGuard } from './index.guard';
describe('IndexGuard', () => {
let guard: IndexGuard;
beforeEach(() => {
TestBed.configureTestingModule({});
guard = TestBed.inject(IndexGuard);
});
it('should be created', () => {
expect(guard).toBeTruthy();
});
});
+31
View File
@@ -0,0 +1,31 @@
import { Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
import { StorageService } from '../services/storage.service';
@Injectable({
providedIn: 'root'
})
export class IndexGuard implements CanActivate {
constructor(
public storageService:StorageService,
private router:Router
){}
canActivate(): Promise<boolean>{
return new Promise(resolve => {
this.storageService.get(AuthConnstants.AUTH).then(res => {
if(res){
this.router.navigate(['home']);
resolve(false);
}
else{
resolve(true);
}
}).catch(err =>{
resolve(false);
})
});
}
}
+6
View File
@@ -1,5 +1,7 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeGuard } from '../guards/home.guard';
import { UserDataResolver } from '../resolvers/userData.resolver';
import { HomePage } from './home.page';
@@ -7,6 +9,10 @@ const routes: Routes = [
{
path: 'home',
component: HomePage,
/* canActivate: [HomeGuard], */
resolve: {
userData: UserDataResolver
},
children: [
{
path: 'events',
+2
View File
@@ -1,11 +1,13 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { IndexGuard } from '../guards/index.guard';
import { IndexPage } from './index.page';
const routes: Routes = [
{
path: '',
component: IndexPage,
/* canActivate: [IndexGuard], */
children: [
/*{
path: '',
+22 -14
View File
@@ -1,17 +1,25 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ChatPage } from './chat.page';
const routes: Routes = [
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ChatPage } from './chat.page';
const routes: Routes = [
{
path: '',
component: ChatPage
},
{
path: 'conversation',
loadChildren: () => import('./conversation/conversation.module').then( m => m.ConversationPageModule)
},
path: '',
component: ChatPage
{
path: 'newchat',
loadChildren: () => import('./newchat/newchat.module').then( m => m.NewchatPageModule)
];
}
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ChatPageRoutingModule {}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
+43 -31
View File
@@ -1,39 +1,51 @@
<ion-header>
<ion-toolbar>
<ion-title>chat</ion-title>
<ion-title>Chat</ion-title>
<ion-icon slot="end" src="assets/images/icons-chat-new-group.svg" class="iconschatnew-group"></ion-icon>
<ion-icon slot="end" src="assets/images/icons-chat-new-conversation.svg" class="iconschatnew-conversation" [routerLink]="['/home/chat/newchat']"></ion-icon>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-row *ngFor="let message of messages" class="chat-container">
<ion-col size="9" *ngIf="message.user !== currentUser" class="message other-message">
<p><b>{{message.user}}</b></p>
<span>{{message.msg}}</span>
<div class="message-date">{{message.createdAt | date: 'HH:mm'}}</div>
</ion-col>
<ion-col offset="3" size="9" *ngIf="message.user === currentUser" class="message my-message">
<ion-label>
<p><b>{{message.user}}</b></p>
<span>{{message.msg}}</span>
<div class="message-date">{{message.createdAt | date: 'HH:mm'}}</div>
</ion-label>
</ion-col>
</ion-row>
<ion-toolbar >
<ion-segment [(ngModel)]="segment" (ionChange)="onSegmentChange()">
<ion-segment-button value="Contactos">
Contactos
</ion-segment-button>
<ion-segment-button value="Grupos">
Grupos
</ion-segment-button>
</ion-segment>
</ion-toolbar>
<div [ngSwitch]="segment">
<ion-list *ngSwitchCase="'Contactos'" >
<ion-item-group>
<ion-item-sliding>
<ion-item>
<ion-icon slot="start" src="assets/images/icons-chat-chat-40.svg" class="iconschatchat-40"></ion-icon>
<div>
<h3>Secretario Assuntos Sociais</h3>
<p>Podemos marcar reunião para amanha</p>
</div>
</ion-item>
</ion-item-sliding>
</ion-item-group>
</ion-list>
<ion-list *ngSwitchCase="'Grupos'" >
<ion-item-group>
<ion-item-sliding>
<ion-item>
<ion-icon slot="start" src="assets/images/icons-chat-group-chat-40.svg" class="iconschatgroup-chat-40"></ion-icon>
<div>
<h3>Viagem a Maputo</h3>
<p>Grande momento.</p>
</div>
</ion-item>
</ion-item-sliding>
</ion-item-group>
</ion-list>
</div>
</ion-content>
<ion-footer class="ion-no-border">
<ion-toolbar>
<ion-row align-items-center>
<ion-col size="10">
<ion-textarea auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
</ion-col>
<ion-col size="2">
<ion-button expand="block" fill="clear" color="primary" [disabled]="message === ''" class="msg-btn"
(click)="sendMessage()">
<ion-icon name="send" slot="icon-only"></ion-icon>
</ion-button>
</ion-col>
</ion-row>
</ion-toolbar>
</ion-footer>
+20 -47
View File
@@ -1,50 +1,23 @@
ion-content{
background-color:#fefefe;
.iconschatnew-group{
width: 30px;
height: 30px;
object-fit: contain;
margin: 0 5px 0 5px;
}
.chat-container{
margin: 10px 10px 0 10px;
.iconschatgroup-chat-40 {
width: 40px;
height: 40px;
object-fit: contain;
}
.message {
padding: 5px 5px 5px 10px;
border-radius: 10px;
margin-bottom: 10px;
white-space: pre-wrap;
}
.my-message {
background: var(--ion-color-primary);
color: #fff;
}
.my-message p{
margin: 0;
padding: 0;
color: #9ab8e9;
}
.message-date{
font-size: 10px;
text-align: right;
margin-right: 5px;
}
.other-message {
background: #f2f3f7;
color: #333;
}
.other-message p{
margin: 0;
padding: 0;
color:#959ba7;
}
.message-input {
margin-top: 0px;
border: 1px solid var(--ion-color-medium);
border-radius: 20px;
background: #fff;
padding: 0;
margin: 0;
}
.iconschatnew-conversation{
width: 30px;
height: 30px;
object-fit: contain;
margin: 0 5px 0 5px;
}
.iconschatchat-40 {
width: 40px;
height: 40px;
object-fit: contain;
}
+25 -38
View File
@@ -1,8 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Socket } from 'ngx-socket-io';
import { ToastController } from '@ionic/angular';
import { WebsocketService } from 'src/app/services/websocket.service';
import { fromEvent } from 'rxjs';
import { AuthService } from 'src/app/services/auth.service';
import { ChatService } from 'src/app/services/chat.service';
@Component({
selector: 'app-chat',
@@ -10,43 +8,32 @@ import { fromEvent } from 'rxjs';
styleUrls: ['./chat.page.scss'],
})
export class ChatPage implements OnInit {
loggedUser: any;
/* Set segment variable */
segment:string;
groupList: any[];
result:any;
message = '';
messages = [];
currentUser = '';
constructor(private websocket:WebsocketService, private socket: Socket) { }
constructor(
private chatService: ChatService,
private authService: AuthService) { }
ngOnInit() {
console.log("ON");
this.socket.connect();
/* Set current user */
let name = `User-${new Date().getTime()}`;
this.currentUser=name;
this.socket.emit('set-name', name);
/* Reat from event calling "fromEvent" */
this.socket.fromEvent('users-changed').subscribe(data =>{
console.log('gOT data:', data);
this.segment = "Contactos";
this.authService.userData$.subscribe((res:any)=>{
this.loggedUser=res;
});
/* Add message to the array of messages */
this.socket.fromEvent('message').subscribe(message =>{
console.log('New:', message);
this.messages.push(message);
/* this.getGroups(); */
}
onSegmentChange(){
this.RefreshEvents();
}
RefreshEvents(){}
/* getGroups(){
this.result = this.chatService.getPrivateGroups().subscribe((res:any)=>{
this.groupList = res.users;
console.log(this.groupList);
});
}
sendMessage(){
this.socket.emit('send-message', {text: this.message});
this.message="";
}
ionViewWillLeave(){
this.socket.disconnect();
}
} */
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ConversationPage } from './conversation.page';
const routes: Routes = [
{
path: '',
component: ConversationPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class ConversationPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { ConversationPageRoutingModule } from './conversation-routing.module';
import { ConversationPage } from './conversation.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
ConversationPageRoutingModule
],
declarations: [ConversationPage]
})
export class ConversationPageModule {}
@@ -0,0 +1,49 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button (click)="close()" defaultHref="/home/chat" icon="chevron-back"></ion-back-button>
</ion-buttons>
<ion-title>{{chatUser.name}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-row *ngFor="let message of messages" class="chat-container">
<ion-col size="9" *ngIf="message.user !== currentUser" class="message other-message">
<p><b>{{message.user}}</b></p>
<span>{{message.msg}}</span>
<div class="message-date">{{message.createdAt | date: 'HH:mm'}}</div>
</ion-col>
<ion-col offset="3" size="9" *ngIf="message.user === currentUser" class="message my-message">
<ion-label>
<p><b>{{message.user}}</b></p>
<span>{{message.msg}}</span>
<div class="message-date">{{message.createdAt | date: 'HH:mm'}}</div>
</ion-label>
</ion-col>
</ion-row>
</ion-content>
<ion-footer class="ion-no-border">
<ion-toolbar>
<ion-row align-items-center>
<ion-col>
<ion-item button lines="none">
<img src="assets/images/icons-arrow-arrow-down-25.svg">
</ion-item>
</ion-col>
<ion-col>
<ion-item lines="none" class="div-message">
<ion-textarea placeholder="Escrever uma mensagem" auto-grow class="message-input" rows="1" [(ngModel)]="message"></ion-textarea>
<ion-icon slot="end" name="mic-outline"></ion-icon>
</ion-item>
</ion-col>
<ion-col>
<ion-item button lines="none" [disabled]="message === ''">
<img src="assets/images/icons-chat-send.svg">
</ion-item>
</ion-col>
</ion-row>
</ion-toolbar>
</ion-footer>
@@ -0,0 +1,55 @@
ion-content{
background-color:#fefefe;
}
.chat-container{
margin: 10px 10px 0 10px;
}
.message {
padding: 5px 5px 5px 10px;
border-radius: 10px;
margin-bottom: 10px;
white-space: pre-wrap;
}
.my-message {
background: var(--ion-color-primary);
color: #fff;
}
.my-message p{
margin: 0;
padding: 0;
color: #9ab8e9;
}
.message-date{
font-size: 10px;
text-align: right;
margin-right: 5px;
}
.other-message {
background: #f2f3f7;
color: #333;
}
.other-message p{
margin: 0;
padding: 0;
color:#959ba7;
}
.message-input {
margin-top: 0px;
background: #fff;
padding: 0;
margin: 0;
}
.div-message{
border: 1px solid var(--ion-color-medium);
border-radius: 20px;
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { ConversationPage } from './conversation.page';
describe('ConversationPage', () => {
let component: ConversationPage;
let fixture: ComponentFixture<ConversationPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ConversationPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(ConversationPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,73 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ModalController, NavParams } from '@ionic/angular';
import { AuthService } from 'src/app/services/auth.service';
@Component({
selector: 'app-conversation',
templateUrl: './conversation.page.html',
styleUrls: ['./conversation.page.scss'],
})
export class ConversationPage implements OnInit {
message = '';
messages = [];
currentUser = '';
constructor(
private authService: AuthService,
private router:Router,
private modalController: ModalController,
private navParams: NavParams) { }
loggedUser: any;
chatUser: any;
ngOnInit() {
this.authService.userData$.subscribe((res:any)=>{
this.loggedUser=res;
})
this.chatUser = this.navParams.get('user');
console.log(this.navParams.get('user'));
console.log(this.chatUser.name);
/* console.log("ON");
this.socket.connect();
//Set current user
let name = `User-${new Date().getTime()}`;
this.currentUser=name;
this.socket.emit('set-name', name);
//Reat from event calling "fromEvent"
this.socket.fromEvent('users-changed').subscribe(data =>{
console.log('gOT data:', data);
});
//Add message to the array of messages
this.socket.fromEvent('message').subscribe(message =>{
console.log('New:', message);
this.messages.push(message);
}); */
}
close(){
this.router.navigate(['/home/chat']);
this.modalController.dismiss(null);
}
sendMessage(){
}
/* sendMessage(){
this.socket.emit('send-message', {text: this.message});
this.message="";
}
ionViewWillLeave(){
this.socket.disconnect();
} */
}
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { NewchatPage } from './newchat.page';
const routes: Routes = [
{
path: '',
component: NewchatPage
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class NewchatPageRoutingModule {}
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { NewchatPageRoutingModule } from './newchat-routing.module';
import { NewchatPage } from './newchat.page';
@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
NewchatPageRoutingModule
],
declarations: [NewchatPage]
})
export class NewchatPageModule {}
@@ -0,0 +1,20 @@
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button icon="chevron-back"></ion-back-button>
</ion-buttons>
<ion-title>Nova Conversa</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-toolbar>
<ion-searchbar round (ionChange)="onChange($event)" placeholder="Pesquisar por cantacto" ></ion-searchbar>
</ion-toolbar>
<ion-list>
<ion-item *ngFor="let user of searchedItem" (click)="starConversation(user)">
{{user.name}}
</ion-item>
</ion-list>
</ion-content>
@@ -0,0 +1,3 @@
ion-searchbar{
--border-radius: 20px;
}
@@ -0,0 +1,24 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { IonicModule } from '@ionic/angular';
import { NewchatPage } from './newchat.page';
describe('NewchatPage', () => {
let component: NewchatPage;
let fixture: ComponentFixture<NewchatPage>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NewchatPage ],
imports: [IonicModule.forRoot()]
}).compileComponents();
fixture = TestBed.createComponent(NewchatPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,65 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ModalController } from '@ionic/angular';
import { Observable } from 'rxjs';
import { ChatService } from 'src/app/services/chat.service';
import { ConversationPage } from '../conversation/conversation.page';
@Component({
selector: 'app-newchat',
templateUrl: './newchat.page.html',
styleUrls: ['./newchat.page.scss'],
})
export class NewchatPage implements OnInit {
userList: any[];
constructor(
private chatService: ChatService,
private modalController: ModalController,
private router:Router) { }
result:any;
searchCountryString:any;
searchedItem:any;
ngOnInit() {
this.getUsers();
}
getUsers(){
this.result = this.chatService.getAllUsers().subscribe((res:any)=>{
this.userList = res.users;
this.searchedItem = this.userList;
});
}
userSelected(id){
console.log(id);
this.router.navigate(['/home/chat/conversation']);
}
onChange(event){
const val = event.detail.value;
this.searchedItem = this.userList;
if(val && val.trim() != ''){
this.searchedItem = this.searchedItem.filter((item:any) =>{
return (item.name.toLowerCase().indexOf(val.toLowerCase()) > -1);
});
}
}
async starConversation(selectedUser) {
const modal = await this.modalController.create({
component: ConversationPage,
cssClass: 'conversation',
backdropDismiss: false,
componentProps: {
user: selectedUser,
}
});
await modal.present();
modal.onDidDismiss();
}
}
+31 -1
View File
@@ -5,6 +5,8 @@ import { User } from 'src/app/models/user.model';
import { ToastService } from 'src/app/services/toast.service';
import { environment } from 'src/environments/environment';
import { AlertController } from '@ionic/angular';
import { StorageService } from 'src/app/services/storage.service';
import { AuthConnstants } from 'src/app/config/auth-constants';
@Component({
@@ -19,9 +21,13 @@ export class LoginPage implements OnInit {
password: string = environment.defaultuserpwd;
userattempt: User;
public body = {"user": this.username,"password": this.password};
public postData = {"user": "admin","password": this.password};
constructor(
private router: Router,
private authService: AuthService,
private storageService: StorageService,
private toastService: ToastService,
public alertController: AlertController) { }
@@ -47,6 +53,29 @@ export class LoginPage implements OnInit {
await alert.present();
}
loginAction(){
if(this.validateInput()){
this.authService.loginChat2(this.postData).subscribe((res: any) =>{
if(res.data){
this.storageService.store(AuthConnstants.AUTH, res.data);
console.log('Log RockectChat OK');
console.log(res.data);
}
else{
console.log("Invalid username or password!");
}
},
(error:any) =>{
console.log('Network error');
})
}
else{
this.presentAlert('Por favor, insira o seu nome de utilizador e palavra-passe.');
}
}
async Login(){
try {
//Go to our home in home/feed.
@@ -57,9 +86,10 @@ export class LoginPage implements OnInit {
domainName: environment.domain,
BasicAuthKey: ""
}
if (await this.authService.login(this.userattempt))
{
this.loginAction();
console.log('Log Gabinete Digital OK');
this.router.navigate(['/home/events']);
}
else
+13
View File
@@ -0,0 +1,13 @@
import { Injectable } from '@angular/core';
import { AuthService } from '../services/auth.service';
@Injectable({
providedIn: 'root'
})
export class UserDataResolver{
constructor(private authService: AuthService){}
resolve(){
return this.authService.getUserData();
}
}
+39 -7
View File
@@ -1,19 +1,23 @@
import { Injectable } from '@angular/core';
import { StorageService } from './storage.service';
import { Router } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { User } from '../models/user.model';
import { environment } from 'src/environments/environment';
import { HttpService } from './http.service';
import { BehaviorSubject, Observable } from 'rxjs';
import { AuthConnstants } from '../config/auth-constants';
@Injectable({
providedIn: 'root'
})
export class AuthService {
userData$ = new BehaviorSubject<any>('');
constructor(
private http: HttpClient
private http: HttpClient,
private httpService: HttpService,
private storageService:StorageService,
private router:Router
) { }
public ValidatedUser:User;
@@ -31,12 +35,40 @@ export class AuthService {
if (result)
{
this.ValidatedUser = user;
}
}
return result;
}
logout(){
this.ValidatedUser = null;
}
loginChat(){
const body = {"user": "admin","password": "tabteste@006"};
const url = "http://192.168.100.111:3000/api/v1/login";
return this.http.post(url, body);
}
//Login to rocketChat server
loginChat2(postData: any):Observable<any> {
return this.httpService.post('login', postData);
}
//Get user data from RocketChat
getUserData(){
this.storageService.get(AuthConnstants.AUTH).then(res=>{
this.userData$.next(res);
})
}
logoutChat(){
//this.storageService.clear();
this.storageService.removeStorageItem(AuthConnstants.AUTH).then(res =>{
this.userData$.next('');
this.router.navigate(['']);
})
}
}
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { ChatService } from './chat.service';
describe('ChatService', () => {
let service: ChatService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(ChatService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+41
View File
@@ -0,0 +1,41 @@
import { HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from "rxjs"
import { AuthService } from './auth.service';
import { HttpService } from './http.service';
import { StorageService } from './storage.service';
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class ChatService {
headers: HttpHeaders;
options:any;
constructor(
private http:HttpClient,
private httpService: HttpService,
private authService: AuthService,
private storageService:StorageService,) {
this.headers = new HttpHeaders();
this.authService.userData$.subscribe((res:any)=>{
this.headers = this.headers.set('X-User-Id', res.userId);
this.headers = this.headers.set('X-Auth-Token', res.authToken);
});
}
getAllUsers(){
this.options = {
headers: this.headers,
};
console.log(this.headers);
return this.http.get(environment.apiChatUrl+'users.list', this.options);
}
getPrivateGroups(){
this.http.get(environment.apiChatUrl+'groups.list', this.options);
}
}
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { FcmService } from './fcm.service';
describe('FcmService', () => {
let service: FcmService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(FcmService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+64
View File
@@ -0,0 +1,64 @@
import { Injectable } from '@angular/core';
import {
Plugins,
PushNotification,
PushNotificationToken,
PushNotificationActionPerformed,
Capacitor
} from '@capacitor/core';
import { Router } from '@angular/router';
const { PushNotifications } = Plugins;
@Injectable({
providedIn: 'root'
})
export class FcmService {
constructor(private router: Router) { }
initPush() {
if (Capacitor.platform !== 'web') {
this.registerPush();
}
}
private registerPush() {
PushNotifications.requestPermission().then((permission) => {
if (permission.granted) {
// Register with Apple / Google to receive push via APNS/FCM
PushNotifications.register();
} else {
// No permission for push granted
}
});
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
console.log('My token: ' + JSON.stringify(token));
}
);
PushNotifications.addListener('registrationError', (error: any) => {
console.log('Error: ' + JSON.stringify(error));
});
PushNotifications.addListener(
'pushNotificationReceived',
async (notification: PushNotification) => {
console.log('Push received: ' + JSON.stringify(notification));
}
);
PushNotifications.addListener(
'pushNotificationActionPerformed',
async (notification: PushNotificationActionPerformed) => {
const data = notification.notification.data;
console.log('Action performed: ' + JSON.stringify(notification.notification));
if (data.detailsId) {
this.router.navigateByUrl(`/home/notifications/notification-detail${data.detaisId}`);
}
}
);
}
}
+16
View File
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { HttpService } from './http.service';
describe('HttpService', () => {
let service: HttpService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(HttpService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
+26
View File
@@ -0,0 +1,26 @@
import { HttpClient, HttpHeaderResponse, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class HttpService {
constructor(private http:HttpClient) { }
post(serviceName:string, data:any){
const headers = new HttpHeaders();
const options = {header: headers, withCredentials: false};
const url = environment.apiChatUrl+serviceName;
const body = {"user": "admin","password": "tabteste@006"};
return this.http.post(url, /* JSON.stringify( */data/* ), options */)
}
get(serviceName:string, options:any){
const url = environment.apiChatUrl+serviceName;
return this.http.get(url, options);
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

@@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 25 25">
<g fill="none" fill-rule="evenodd">
<g stroke="#42B9FE" stroke-width="2">
<g>
<g>
<g>
<g transform="translate(-20 -696) translate(0 84) translate(0 592) translate(20 10) translate(0 10)">
<rect width="17" height="14" x="4" y="7" rx="2"/>
<path stroke-linecap="round" stroke-linejoin="round" d="M9 6.684C9 4.228 10.071 3 12.214 3s3.215 1.228 3.215 3.684V13.387C15.476 14.462 15 15 14 15s-1.476-.538-1.429-1.613h0V9.535h0"/>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 768 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

+15
View File
@@ -0,0 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<g fill="none" fill-rule="evenodd" stroke-linejoin="round">
<g stroke="#061B52" stroke-width="2">
<g>
<g>
<g>
<g>
<path d="M8.571 0c2.74 0 4.96 2.22 4.96 4.959v.095c0 1.563-.724 2.957-1.853 3.866 3.198 1.255 5.465 4.393 5.465 8.067 0 4.78-17.143 4.78-17.143 0 0-3.674 2.267-6.812 5.465-8.068-1.13-.908-1.853-2.302-1.853-3.865V4.96C3.612 2.22 5.832 0 8.572 0z" transform="translate(-15 -232) translate(0 84) translate(0 130) translate(15 18) translate(11 10)"/>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 778 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40">
<g fill="none" fill-rule="evenodd" stroke-linejoin="round">
<g stroke="#061B52" stroke-width="2">
<g>
<g>
<g>
<g>
<path d="M15.55 5c2.688 0 4.868 2.18 4.868 4.868 0 1.54-.716 2.914-1.834 3.806 3.17 1.22 5.416 4.27 5.416 7.841 0 4.647-17 4.647-17 0 0-3.57 2.246-6.62 5.416-7.843-1.118-.89-1.834-2.264-1.834-3.804C10.582 7.179 12.762 5 15.45 5h.1z" transform="translate(-15 -232) translate(0 84) translate(0 130) translate(15 18) translate(8 7) matrix(-1 0 0 1 31 0)"/>
<path stroke-linecap="round" d="M0 2.332C.823.932 2.285 0 3.951 0c2.572 0 4.657 2.22 4.657 4.957v.095c0 1.584-.698 2.994-1.784 3.901M8.483 20c2.05-.571 3.517-1.578 3.517-3.02 0-3.585-2.476-6.529-5.366-7.841" transform="translate(-15 -232) translate(0 84) translate(0 130) translate(15 18) translate(8 7) matrix(-1 0 0 1 12 0)"/>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@@ -0,0 +1,16 @@
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" viewBox="0 0 35 35">
<g fill="none" fill-rule="evenodd">
<g>
<g>
<g>
<g transform="translate(-345 -109) translate(0 84) translate(20 25) translate(325)">
<circle cx="17.5" cy="17.5" r="17.5" fill="#42B9FE"/>
<path stroke="#FFF" stroke-linejoin="round" stroke-width="2" d="M14.5 9c2.396 0 4.34 1.943 4.34 4.34v.083c0 1.367-.633 2.586-1.622 3.382C20.016 17.903 22 20.649 22 23.863c0 4.183-15 4.183-15 0 0-3.214 1.984-5.96 4.783-7.06-.99-.794-1.622-2.013-1.622-3.38v-.084C10.16 10.943 12.104 9 14.5 9z"/>
<rect width="2" height="8" x="25" y="6" fill="#FFF" rx="1"/>
<rect width="8" height="2" x="22" y="9" fill="#FFF" rx="1"/>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@@ -0,0 +1,19 @@
<svg xmlns="http://www.w3.org/2000/svg" width="35" height="35" viewBox="0 0 35 35">
<g fill="none" fill-rule="evenodd">
<g>
<g>
<g>
<g transform="translate(-290 -109) translate(0 84) translate(20 25) translate(270)">
<circle cx="17.5" cy="17.5" r="17.5" fill="#42B9FE"/>
<rect width="2" height="8" x="25" y="6" fill="#FFF" rx="1"/>
<rect width="8" height="2" x="22" y="9" fill="#FFF" rx="1"/>
<g stroke="#FFF" stroke-linejoin="round" stroke-width="2">
<path d="M7.5 5c2.396 0 4.34 1.943 4.34 4.34v.083c0 1.367-.633 2.586-1.622 3.382C13.016 13.903 15 16.649 15 19.863c0 4.183-15 4.183-15 0 0-3.214 1.984-5.96 4.783-7.06-.99-.794-1.622-2.013-1.622-3.38v-.084C3.16 6.943 5.104 5 7.5 5z" transform="matrix(-1 0 0 1 25 7)"/>
<path stroke-linecap="round" d="M9.818 1.983C10.573.792 11.913 0 13.44 0c2.358 0 4.269 1.886 4.269 4.213v.081c0 1.346-.64 2.545-1.636 3.316M17.594 17c1.879-.486 3.224-1.342 3.224-2.568 0-3.046-2.27-5.548-4.918-6.664" transform="matrix(-1 0 0 1 25 7)"/>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

+23
View File
@@ -0,0 +1,23 @@
<svg xmlns="http://www.w3.org/2000/svg" width="45" height="45" viewBox="0 0 45 45">
<g fill="none" fill-rule="evenodd">
<g>
<g>
<g>
<g>
<g>
<g transform="translate(-335 -686) translate(0 84) translate(0 592) translate(20 10) translate(315)">
<path fill="#FFF" d="M9 9H23V10H9z"/>
<circle cx="14" cy="10" r="2" fill="#FFF"/>
<g fill="#42B9FE">
<circle cx="22.5" cy="22.5" r="22.5"/>
</g>
</g>
<path stroke="#FFF" stroke-linejoin="round" stroke-width="2" d="M23 11L31 33 23 29 15 33z" transform="translate(-335 -686) translate(0 84) translate(0 592) translate(20 10) translate(315) rotate(90 23 22)"/>
<path fill="#FFF" d="M16 21L33 21 33 23 16 23z" transform="translate(-335 -686) translate(0 84) translate(0 592) translate(20 10) translate(315)"/>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

+1
View File
@@ -1,6 +1,7 @@
export const environment = {
production: true,
apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/v1/api/',
apiChatUrl: 'http://192.168.100.111:3000/api/v1/',
domain: 'gabinetedigital.local',
defaultuser: '',
defaultuserpwd: ''
+2 -1
View File
@@ -5,8 +5,9 @@
export const environment = {
production: false,
apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/v2/api/',
apiChatUrl: 'http://192.168.100.111:3000/api/v1/',
domain: 'gabinetedigital.local',
defaultuser: 'tiago.kayaya',
defaultuser: 'paulo.pinto',
defaultuserpwd: 'tabteste@006'
};