From e083d0c783c44e23ef8d1d821371724ad04c8384 Mon Sep 17 00:00:00 2001 From: Sultan Khan Date: Thu, 27 Jun 2019 12:25:44 +0300 Subject: [PATCH] dashboard changes --- Mohem/src/app/app.component.html | 4 +- Mohem/src/app/app.component.ts | 47 ++++++++++++++++--- .../authentication/authentication.service.ts | 2 + .../models/authenticated-user.ts | 2 + Mohem/src/app/home/home.page.html | 4 +- Mohem/src/app/home/home.page.ts | 9 ++-- 6 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Mohem/src/app/app.component.html b/Mohem/src/app/app.component.html index 03b58f52..6d62d18f 100644 --- a/Mohem/src/app/app.component.html +++ b/Mohem/src/app/app.component.html @@ -1,9 +1,9 @@ + - +
diff --git a/Mohem/src/app/app.component.ts b/Mohem/src/app/app.component.ts index 16423e38..5e38b6f6 100644 --- a/Mohem/src/app/app.component.ts +++ b/Mohem/src/app/app.component.ts @@ -7,6 +7,8 @@ import { AuthenticatedUser } from "./hmg-common/services/authentication/models/a import { TabsBarComponent } from "./hmg-common/ui/tabs-bar/tabs-bar.component"; import { KeyboardService } from "./hmg-common/services/keyboard/keyboard.service"; +import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; + import { LazyLoadingService } from "./hmg-common/services/lazy-loading/lazy-loading.service"; @Component({ @@ -20,7 +22,7 @@ export class AppComponent implements OnInit, AfterViewInit { start: any = false; menuList: any = []; User_name_Emp: string = ""; - user_image: string = "../assets/imgs/profile.png" + user_image: string = "../assets/imgs/profile.png"; menuSide: string = "left"; notBadge: number; companyUrl: string = "../assets/imgs/CS.png"; @@ -33,7 +35,8 @@ export class AppComponent implements OnInit, AfterViewInit { private platform: Platform, private events: Events, private keyboardService: KeyboardService, - private menu: MenuController + private menu: MenuController, + private authService: AuthenticationService ) {} ngOnInit() { this.initializeApp(); @@ -48,20 +51,45 @@ export class AppComponent implements OnInit, AfterViewInit { // this.statusBar.styleDefault(); this.start = true; this.watchLanguageChangeEvents(); - // this.checkIfUserLoggedInBefore(); + this.subscribeEvents(); this.keyboardService.watchKeyboard(); }); }); } + subscribeEvents() { + this.events.subscribe("setMenu", () => { + const user = this.authService + .loadAuthenticatedUser() + .subscribe((user: AuthenticatedUser) => { + if (user) { + this.companyUrl = user.CompanyImageURL + ? user.CompanyImageURL + : "../assets/imgs/CS.png"; + + this.companyDesc = user.CompanyImageDescription + ? user.CompanyImageDescription + : "Powered By Cloud Solutions"; + this.User_name_Emp = user.EMPLOYEE_DISPLAY_NAME; + this.user_image = user.EMPLOYEE_IMAGE + ? "data:image/png;base64," + user.EMPLOYEE_IMAGE + : "../assets/imgs/profile.png"; + console.log(user); + } else { + console.log(user); + } + }); + }); + this.events.subscribe("getNotCount", badge => { + this.notBadge = badge; + }); + } private initializeDirection() { this.direction = TranslatorService.getCurrentDirection(); } private watchUserLoginChangeEvents() { this.events.subscribe( AuthenticationService.LOGIN_EVENT, - (user: AuthenticatedUser, time: Date) => { - - } + (user: AuthenticatedUser, time: Date) => {} ); } private watchLanguageChangeEvents() { @@ -73,4 +101,11 @@ export class AppComponent implements OnInit, AfterViewInit { }, 100); }); } + logout() { + // let req:any={}; + // this.menuService.disableSession(req).subscribe((result: any) => { + // }); + this.cs.sharedService.clearAll(); + this.cs.openLogin(); + } } diff --git a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts index f3ddea32..210c3e6a 100644 --- a/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts +++ b/Mohem/src/app/hmg-common/services/authentication/authentication.service.ts @@ -304,6 +304,8 @@ export class AuthenticationService { user.P_SESSION_ID = result.P_SESSION_ID; user.MobileNumber = result.EMPLOYEE_MOBILE_NUMBER; user.TokenID = result.TokenID; + user.CompanyImageDescription=result.CompanyImageDescription; + user.CompanyImageURL=result.CompanyImageURL; user.LogInTokenID = this.cs.sharedService.getSharedData( "logindata" ).LogInTokenID; diff --git a/Mohem/src/app/hmg-common/services/authentication/models/authenticated-user.ts b/Mohem/src/app/hmg-common/services/authentication/models/authenticated-user.ts index 8a51c013..fd842744 100644 --- a/Mohem/src/app/hmg-common/services/authentication/models/authenticated-user.ts +++ b/Mohem/src/app/hmg-common/services/authentication/models/authenticated-user.ts @@ -75,4 +75,6 @@ USER_STATUS: string; P_SESSION_ID:number; MobileNumber:string; LogInTokenID:string; +CompanyImageDescription: string +CompanyImageURL: string } diff --git a/Mohem/src/app/home/home.page.html b/Mohem/src/app/home/home.page.html index c921be5d..e870a242 100644 --- a/Mohem/src/app/home/home.page.html +++ b/Mohem/src/app/home/home.page.html @@ -12,14 +12,14 @@ {{notBadge}}
-

{{ts.trPK('home','hello')}}, {{User_name_Emp}}, {{User_name_Emp}}

+

{{ts.trPK('home','hello')}}, {{userData.EMPLOYEE_DISPLAY_NAME}}

-

{{ts.trPK('home','dashboard')}}, {{User_name_Emp}}

+

{{ts.trPK('home','dashboard')}}, {{userData.EMPLOYEE_DISPLAY_NAME}}

diff --git a/Mohem/src/app/home/home.page.ts b/Mohem/src/app/home/home.page.ts index fcd61833..9c83887b 100644 --- a/Mohem/src/app/home/home.page.ts +++ b/Mohem/src/app/home/home.page.ts @@ -1,12 +1,12 @@ import { Component, OnInit } from "@angular/core"; import { TranslatorService } from "src/app/hmg-common/services/translator/translator.service"; -import { MenuController } from "@ionic/angular"; +import { MenuController,Events } from "@ionic/angular"; import { AuthenticationService } from "src/app/hmg-common/services/authentication/authentication.service"; -import { SMSCheckResponse } from "src/app/hmg-common/services/authentication/models/smscheck.response"; import { AuthenticatedUser } from "src/app/hmg-common/services/authentication/models/authenticated-user"; import { MenuService } from "src/app/hmg-common/services/menu/menuservice.service"; import { MenuResponse } from "src/app/hmg-common/services/menu/models/menu-response"; import { CommonService } from "src/app/hmg-common/services/common/common.service"; + @Component({ selector: "app-home", templateUrl: "./home.page.html", @@ -21,7 +21,8 @@ export class HomePage implements OnInit { public menu: MenuController, public authService: AuthenticationService, public menuService: MenuService, - public common: CommonService + public common: CommonService, + public events:Events ) {} ngOnInit() { @@ -37,7 +38,9 @@ export class HomePage implements OnInit { .loadAuthenticatedUser() .subscribe((user: AuthenticatedUser) => { if (user) { + this.events.publish('setMenu'); this.userData = user; + this.user_image=user.EMPLOYEE_IMAGE?user.EMPLOYEE_IMAGE: this.user_image; console.log(user); } else { console.log(user);