mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
- Add cordova storage plugin
- Add plugin configuration - Add storage set and get methods
This commit is contained in:
+2
-1
@@ -101,7 +101,8 @@
|
|||||||
"cordova-plugin-inappbrowser": {},
|
"cordova-plugin-inappbrowser": {},
|
||||||
"cordova-plugin-camera": {
|
"cordova-plugin-camera": {
|
||||||
"ANDROID_SUPPORT_V4_VERSION": "27.+"
|
"ANDROID_SUPPORT_V4_VERSION": "27.+"
|
||||||
}
|
},
|
||||||
|
"cordova-sqlite-storage": {}
|
||||||
},
|
},
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"ios",
|
"ios",
|
||||||
|
|||||||
@@ -26,10 +26,10 @@
|
|||||||
<ion-icon name="search"></ion-icon>
|
<ion-icon name="search"></ion-icon>
|
||||||
<ion-label>Pesquisa</ion-label>
|
<ion-label>Pesquisa</ion-label>
|
||||||
</ion-tab-button> -->
|
</ion-tab-button> -->
|
||||||
<!-- <ion-tab-button tab="chat">
|
<ion-tab-button tab="chat">
|
||||||
<ion-icon class="nav-icon" src="assets/images/icons-nav-chat-inactive.svg"></ion-icon>
|
<ion-icon class="nav-icon" src="assets/images/icons-nav-chat-inactive.svg"></ion-icon>
|
||||||
<ion-label>Chat</ion-label>
|
<ion-label>Chat</ion-label>
|
||||||
</ion-tab-button> -->
|
</ion-tab-button>
|
||||||
</ion-tab-bar>
|
</ion-tab-bar>
|
||||||
|
|
||||||
</ion-tabs>
|
</ion-tabs>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class ChatPage implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async starConversation(selectedUser) {
|
async startConversation(selectedUser) {
|
||||||
const modal = await this.modalController.create({
|
const modal = await this.modalController.create({
|
||||||
component: ConversationPage,
|
component: ConversationPage,
|
||||||
cssClass: 'conversation',
|
cssClass: 'conversation',
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ export class LoginPage implements OnInit {
|
|||||||
|
|
||||||
loginRocketChat(){
|
loginRocketChat(){
|
||||||
this.authService.loginChat(this.postData).subscribe((res: any) =>{
|
this.authService.loginChat(this.postData).subscribe((res: any) =>{
|
||||||
|
this.storageService.store(res);
|
||||||
console.log('Login to Rocket chat OK');
|
console.log('Login to Rocket chat OK');
|
||||||
},(error:any) =>{
|
},(error:any) =>{
|
||||||
console.log('Network error');
|
console.log('Network error');
|
||||||
|
|||||||
@@ -50,11 +50,11 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get user data from RocketChat
|
//Get user data from RocketChat
|
||||||
/* getUserData(){
|
getUserData(){
|
||||||
this.storageService.get(AuthConnstants.AUTH).then(res=>{
|
this.storageService.get(AuthConnstants.AUTH).then(res=>{
|
||||||
this.userData$.next(res);
|
this.userData$.next(res);
|
||||||
})
|
})
|
||||||
} */
|
}
|
||||||
|
|
||||||
/* getProfile(){
|
/* getProfile(){
|
||||||
this.storageService.get(AuthConnstants.PROFILE).then(res=>{
|
this.storageService.get(AuthConnstants.PROFILE).then(res=>{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export class ChatService {
|
|||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private storageService:StorageService,) {
|
private storageService:StorageService,) {
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
|
this.storageService.get()
|
||||||
this.authService.userData$.subscribe((res:any)=>{
|
this.authService.userData$.subscribe((res:any)=>{
|
||||||
this.headers = this.headers.set('X-User-Id', res.userId);
|
this.headers = this.headers.set('X-User-Id', res.userId);
|
||||||
this.headers = this.headers.set('X-Auth-Token', res.authToken);
|
this.headers = this.headers.set('X-Auth-Token', res.authToken);
|
||||||
|
|||||||
@@ -1,33 +1,31 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
/* import { Plugins } from '@capacitor/core';
|
import { Storage } from '@ionic/storage';
|
||||||
const { Storage } = Plugins; */
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class StorageService {
|
export class StorageService {
|
||||||
constructor() {}
|
constructor(private storage: Storage) {}
|
||||||
|
|
||||||
/* // Store the value
|
// Store the value
|
||||||
async store(storageKey: string, value: any) {
|
async store(value: any) {
|
||||||
const encryptedValue = btoa(escape(JSON.stringify(value)));
|
const encryptedValue = btoa(escape(JSON.stringify(value)));
|
||||||
await Storage.set({
|
await this.storage.set('user', encryptedValue);;
|
||||||
key: storageKey,
|
|
||||||
value: encryptedValue
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the value
|
// Get the value
|
||||||
async get(storageKey: string) {
|
async get(user: any) {
|
||||||
const ret = await Storage.get({ key: storageKey });
|
const ret = await this.storage.get('user').then(res=>{
|
||||||
return JSON.parse(unescape(atob(ret.value)));
|
return JSON.parse(unescape(atob(ret.value)));
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeStorageItem(storageKey: string) {
|
/* async removeStorageItem(storageKey: string) {
|
||||||
await Storage.remove({ key: storageKey });
|
await this.storage.remove({ key: storageKey });
|
||||||
}
|
} */
|
||||||
|
|
||||||
// Clear storage
|
// Clear storage
|
||||||
async clear() {
|
async clear() {
|
||||||
await Storage.clear();
|
await this.storage.clear();
|
||||||
} */
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user