Add "new-group" and "contacts" pages

- Style new group page
- Improve style in chat page
This commit is contained in:
tiago.kayaya
2020-12-21 16:37:44 +01:00
parent 4e3cd4ac73
commit 4c16f7bd83
31 changed files with 1223 additions and 233 deletions
+12 -3
View File
@@ -35,6 +35,7 @@ export class AuthService {
if (result)
{
this.ValidatedUser = user;
}
return result;
}
@@ -46,14 +47,22 @@ export class AuthService {
//Login to rocketChat server
loginChat(postData: any):Observable<any> {
return this.httpService.post('login', postData);
const res = this.httpService.post('login', postData);
const res2 = res.subscribe(res=>{
this.storageService.store(res);
});
return res;
}
//Get user data from RocketChat
getUserData(){
this.storageService.get(AuthConnstants.AUTH).then(res=>{
const res = this.storageService.get('user');
console.log(res);
/* this.storageService.get(AuthConnstants.AUTH).then(res=>{
this.userData$.next(res);
})
}) */
}
/* getProfile(){
+17 -3
View File
@@ -6,6 +6,7 @@ import { HttpService } from './http.service';
import { StorageService } from './storage.service';
import { HttpClient, HttpHeaderResponse } from '@angular/common/http';
import { environment } from 'src/environments/environment';
import { Storage } from '@ionic/storage';
@Injectable({
providedIn: 'root'
@@ -19,19 +20,32 @@ export class ChatService {
private http:HttpClient,
private httpService: HttpService,
private authService: AuthService,
private storage: Storage,
private storageService:StorageService,) {
this.headers = new HttpHeaders();
this.authService.userData$.subscribe((res:any)=>{
this.storage.get('user').then((val) => {
console.log(JSON.parse(unescape(atob(val))).data.userId);
let user = JSON.parse(unescape(atob(val))).data;
this.headers = this.headers.set('Access-Control-Allow-Origin', 'http://localhost:8100');
this.headers = this.headers.set('Access-Control-Allow-Credentials', 'true');
this.headers = this.headers.set('Access-Control-Allow-Headers', 'Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Headers, x-requested-with, Content-Type, X-Auth-Token, X-User-Id, origin, authorization, accept, client-security-token');
this.headers = this.headers.set('X-User-Id', user.userId);
this.headers = this.headers.set('X-Auth-Token', user.authToken);
});
/* 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);
});
}); */
this.options = {
headers: this.headers,
};
}
getAllUsers(){
/* console.log(this.headers); */
console.log(this.headers);
return this.http.get(environment.apiChatUrl+'users.list', this.options);
}
getAllConnectedUsers(){
+16 -10
View File
@@ -1,24 +1,30 @@
import { Injectable } from '@angular/core';
import { Storage } from '@ionic/storage';
import { AuthConnstants } from '../config/auth-constants';
@Injectable({
providedIn: 'root'
})
export class StorageService {
user: any = "Max";
storageKey = "user";
constructor(private storage: Storage) {}
// Store the value
async store(value: any) {
const encryptedValue = btoa(escape(JSON.stringify(value)));
await this.storage.set('user', encryptedValue);;
// set a key/value2
store(user:any){
const encryptedValue = btoa(escape(JSON.stringify(user)));
this.storage.set(AuthConnstants.AUTH, encryptedValue);
}
// Get the value
async get() {
const ret = await this.storage.get('user').then(res=>{
return JSON.parse(unescape(atob(ret.value)));
});
// Or to get a key/value pair
get(key:any){
let user = this.storage.get(key).then((val) => {
console.log(JSON.parse(unescape(atob(val))).data);
return JSON.parse(unescape(atob(val))).data;
});
return user;
}
/* async removeStorageItem(storageKey: string) {
await this.storage.remove({ key: storageKey });