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);
})
});
}
}