From f2f8c516392eb668a1caf8570fc016f2eb077d7e Mon Sep 17 00:00:00 2001 From: Patrick Sun Date: Sun, 21 Mar 2021 17:21:36 +1100 Subject: [PATCH] remove hint-card, add broker-loan-list, add authgard to all urls --- src/app/app-routing.module.ts | 20 ++++----- src/app/app.module.ts | 2 - src/app/auth/auth.component.scss | 4 +- src/app/auth/auth.component.ts | 2 +- .../broker-loan-list.component.html | 35 ++++++++++++++- .../broker-loan-list.component.scss | 24 ++++++++++ .../broker-loan-list.component.ts | 26 ++++++++++- src/app/e403/e403.component.scss | 2 +- .../list-all-loans.component.html | 2 +- .../hint-card/hint-card.component.html | 44 ------------------- .../hint-card/hint-card.component.scss | 0 .../hint-card/hint-card.component.spec.ts | 25 ----------- .../hint-card/hint-card.component.ts | 29 ------------ src/app/main-menu-items.ts | 13 +----- src/app/models/api-v1-login-response.ts | 8 ++-- src/app/models/broker.model.ts | 5 +++ src/app/models/people.model.ts | 4 ++ src/app/service/auth.service.ts | 19 +++++++- src/app/top-bar/top-bar.component.html | 12 +++++ src/app/top-bar/top-bar.component.ts | 16 +++++-- 20 files changed, 155 insertions(+), 137 deletions(-) delete mode 100644 src/app/loan-edit/hint-card/hint-card.component.html delete mode 100644 src/app/loan-edit/hint-card/hint-card.component.scss delete mode 100644 src/app/loan-edit/hint-card/hint-card.component.spec.ts delete mode 100644 src/app/loan-edit/hint-card/hint-card.component.ts diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index ff6a63e..975a112 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -22,16 +22,16 @@ const routes: Routes = [ {path : 'login', component: AuthComponent}, {path : 'transaction', component: TransactionComponent, canActivate: [AuthGuard]}, {path : 'transaction-list', component: TransactionListComponent, canActivate: [AuthGuard]}, - {path : 'list-all-loans', component: ListAllLoansComponent, }, - {path : 'edit-loan/:id', component: LoanEditComponent, }, - {path : 'edit-loan', component: LoanEditComponent, }, - {path : 'uploads', component: LenderUploadsComponent, }, - {path : 'uploads/:id', component: LenderUploadsComponent, }, - {path : 'broker-loan-list', component: BrokerLoanListComponent, }, - {path : 'broker-reward', component: BrokerRewardComponent, }, - {path : 'broker-profile', component: BrokerProfileComponent, }, - {path : 'client-loan-list', component: ClientLoanListComponent, }, - {path : 'client-profile', component: ClientProfileComponent, }, + {path : 'list-all-loans', component: ListAllLoansComponent, canActivate: [AuthGuard]}, + {path : 'edit-loan/:id', component: LoanEditComponent, canActivate: [AuthGuard]}, + {path : 'edit-loan', component: LoanEditComponent, canActivate: [AuthGuard]}, + {path : 'uploads', component: LenderUploadsComponent, canActivate: [AuthGuard]}, + {path : 'uploads/:id', component: LenderUploadsComponent, canActivate: [AuthGuard]}, + {path : 'broker-loan-list', component: BrokerLoanListComponent, canActivate: [AuthGuard] }, + {path : 'broker-reward', component: BrokerRewardComponent, canActivate: [AuthGuard] }, + {path : 'broker-profile', component: BrokerProfileComponent, canActivate: [AuthGuard]}, + {path : 'client-loan-list', component: ClientLoanListComponent, canActivate: [AuthGuard] }, + {path : 'client-profile', component: ClientProfileComponent, canActivate: [AuthGuard] }, {path : 'e403', component: E403Component, }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 3dc352e..4db05bf 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -57,7 +57,6 @@ import { EditorModule } from '@progress/kendo-angular-editor'; import { BasicinfoComponent } from './loan-edit/basicinfo/basicinfo.component'; import { PeopleRewardComponent } from './loan-edit/people-reward/people-reward.component'; import { TrailIncomeComponent } from './loan-edit/trail-income/trail-income.component'; -import { HintCardComponent } from './loan-edit/hint-card/hint-card.component'; import { PeopleSelectComponent } from './people-select/people-select.component'; import { LoanDetailComponent } from './loan-detail/loan-detail.component'; import {LoanSingleService} from './service/loan.single.service'; @@ -100,7 +99,6 @@ import { E403Component } from './e403/e403.component'; BasicinfoComponent, PeopleRewardComponent, TrailIncomeComponent, - HintCardComponent, PeopleSelectComponent, LoanDetailComponent, RatingInputComponent, diff --git a/src/app/auth/auth.component.scss b/src/app/auth/auth.component.scss index 596fac1..c0e33d9 100644 --- a/src/app/auth/auth.component.scss +++ b/src/app/auth/auth.component.scss @@ -5,7 +5,7 @@ div.parent { width: 100%; height: 100vh; opacity: 0.95; - background: url('../../assets/img/body_bg.jpg') no-repeat center center fixed; + background: url('/assets/img/body_bg.jpg') no-repeat center center fixed; background-size: cover; } @@ -22,4 +22,4 @@ div.parent { padding-bottom: 20px; box-shadow: 0 0 6px black; border-radius: 5px; - } \ No newline at end of file + } diff --git a/src/app/auth/auth.component.ts b/src/app/auth/auth.component.ts index c5774c1..c18b103 100644 --- a/src/app/auth/auth.component.ts +++ b/src/app/auth/auth.component.ts @@ -38,7 +38,7 @@ export class AuthComponent implements OnInit, OnDestroy{ // tslint:disable-next-line:typedef submitForm() { - console.log(this.userForm); + // console.log(this.userForm); this.loading = true; this.authService.login(this.userForm.value.email, this.userForm.value.password); } diff --git a/src/app/broker-loan-list/broker-loan-list.component.html b/src/app/broker-loan-list/broker-loan-list.component.html index 3d301d1..4f23498 100644 --- a/src/app/broker-loan-list/broker-loan-list.component.html +++ b/src/app/broker-loan-list/broker-loan-list.component.html @@ -1 +1,34 @@ -

broker-loan-list works!

+ + + + + + + + {{ dataItem.Amount | currency }} + + + + + +
+ {{ dataItem.Settlement | date: 'yyyy-MM-dd' }} +
+
+
+ + + +
+
+
{{ p }}
+
+
+
+ +
diff --git a/src/app/broker-loan-list/broker-loan-list.component.scss b/src/app/broker-loan-list/broker-loan-list.component.scss index e69de29..d346340 100644 --- a/src/app/broker-loan-list/broker-loan-list.component.scss +++ b/src/app/broker-loan-list/broker-loan-list.component.scss @@ -0,0 +1,24 @@ +.fullheight_grid { + height: calc(100vh - 48px) !important; +} + +.customer-photo{ + display: inline-block; + width: 32px; + height: 32px; + border-radius: 50%; + background-size: 32px 35px; + background-position: center center; + vertical-align: middle; + line-height: 32px; + box-shadow: inset 0 0 1px #999, inset 0 0 10px rgba(0,0,0,.2); + margin-left: 5px; + margin-bottom: 10px; +} + +.customer-name { + display: inline-block; + vertical-align: middle; + line-height: 32px; + padding-left: 10px; +} diff --git a/src/app/broker-loan-list/broker-loan-list.component.ts b/src/app/broker-loan-list/broker-loan-list.component.ts index f7c4cc0..25d9b4a 100644 --- a/src/app/broker-loan-list/broker-loan-list.component.ts +++ b/src/app/broker-loan-list/broker-loan-list.component.ts @@ -1,4 +1,10 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, Input, OnInit} from '@angular/core'; +import {BrokerModel} from '../models/broker.model'; +import {LoanModel} from '../models/loan.model'; +import {LoanSummaryService} from '../service/loan_summary.service'; +import {CompositeFilterDescriptor, SortDescriptor} from '@progress/kendo-data-query'; +import {AuthService} from '../service/auth.service'; +import {PeopleModel} from '../models/people.model'; @Component({ selector: 'app-broker-loan-list', @@ -7,9 +13,25 @@ import { Component, OnInit } from '@angular/core'; }) export class BrokerLoanListComponent implements OnInit { - constructor() { } + @Input() public broker: PeopleModel = PeopleModel.EmptyNew(); + public brokerLoans: LoanSummaryService; + + constructor( private lss: LoanSummaryService, private auth: AuthService) { } ngOnInit(): void { + this.brokerLoans = this.lss; + this.broker = this.auth.loggedIn.user; + this.loadData(); + } + + private loadData(): void { + const sort: Array = [{dir: 'desc', field: 'Settlement'}]; + const filter: CompositeFilterDescriptor = {logic: 'and', filters: [] }; + this.lss.query({ skip: 0, take: 1000, sort, filter}); } + private photoURL(peopleId: any): string { + const url = this.auth.getUrl('avatar/') + peopleId; + return 'url("' + url + '")'; + } } diff --git a/src/app/e403/e403.component.scss b/src/app/e403/e403.component.scss index 20aa7a3..cf0f9b0 100644 --- a/src/app/e403/e403.component.scss +++ b/src/app/e403/e403.component.scss @@ -13,7 +13,7 @@ h1 { font-size: 50px; } -body { +div.body { font: 20px Helvetica, sans-serif; color: #333; } diff --git a/src/app/list-all-loans/list-all-loans.component.html b/src/app/list-all-loans/list-all-loans.component.html index ecc22e4..4c432c6 100644 --- a/src/app/list-all-loans/list-all-loans.component.html +++ b/src/app/list-all-loans/list-all-loans.component.html @@ -112,7 +112,7 @@
- {{ dataItem.Settlement | date: 'yyyy-MM-dd' }} {{dataItem.Index}} + {{ dataItem.Settlement | date: 'yyyy-MM-dd' }}
diff --git a/src/app/loan-edit/hint-card/hint-card.component.html b/src/app/loan-edit/hint-card/hint-card.component.html deleted file mode 100644 index 595fa8d..0000000 --- a/src/app/loan-edit/hint-card/hint-card.component.html +++ /dev/null @@ -1,44 +0,0 @@ - - - -
-

bg_tourism - {{currentStep}}

-

Bulgaria, Europe

-
-
- cover_img - -

Black Sea, Bulgaria

-
-

- The Black Sea is bordered by Ukraine, Romania, Bulgaria, - Turkey, Georgia, and Russia. It has a positive water - balance; that is, a net outflow of water 300 km3 per year - through the Bosphorus and the Dardanelles into the Aegean - Sea. -

-
- - -
- -
- -
- - Created By @alex - March 4, 2020 - -
diff --git a/src/app/loan-edit/hint-card/hint-card.component.scss b/src/app/loan-edit/hint-card/hint-card.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/loan-edit/hint-card/hint-card.component.spec.ts b/src/app/loan-edit/hint-card/hint-card.component.spec.ts deleted file mode 100644 index b22b951..0000000 --- a/src/app/loan-edit/hint-card/hint-card.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { HintCardComponent } from './hint-card.component'; - -describe('HintCardComponent', () => { - let component: HintCardComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ HintCardComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(HintCardComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/loan-edit/hint-card/hint-card.component.ts b/src/app/loan-edit/hint-card/hint-card.component.ts deleted file mode 100644 index 579ef3a..0000000 --- a/src/app/loan-edit/hint-card/hint-card.component.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {Component, Input, OnInit} from '@angular/core'; - -@Component({ - selector: 'app-loan-edit-hint-card', - templateUrl: './hint-card.component.html', - styleUrls: ['./hint-card.component.scss'] -}) -export class HintCardComponent implements OnInit { - - @Input() currentStep: string; - constructor() { } - - ngOnInit(): void { - } - // tslint:disable-next-line:max-line-length - public thumbnailSrc = 'https://www.telerik.com/kendo-angular-ui-develop/components/layout/card/assets/rila.jpg'; - // tslint:disable-next-line:max-line-length - public cover = 'https://www.telerik.com/kendo-angular-ui-develop/components/layout/card/assets/black_sea.jpg'; - - public liked = false; - - public toggleLike(): void { - this.liked = !this.liked; - } - - public heartIcon(): string { - return this.liked ? 'k-icon k-i-heart' : 'k-icon k-i-heart-outline'; - } -} diff --git a/src/app/main-menu-items.ts b/src/app/main-menu-items.ts index e6d7869..2b297f0 100644 --- a/src/app/main-menu-items.ts +++ b/src/app/main-menu-items.ts @@ -2,10 +2,6 @@ import { faChartArea, faIdCard, faIdCardAlt, faMoneyCheck, faUniversity, faUserCircle, faUserTie } from '@fortawesome/free-solid-svg-icons'; export const mainMenuItems: any[] = [ - { - text: '', - fa: faUniversity, - }, { text: 'SFM', icon: 'more-vertical', @@ -63,10 +59,7 @@ export const mainMenuItems: any[] = [ export const brokerMenuItems: any[] = [ - { - text: '|', - fa: faUserTie, - }, + { text: 'My Loans', icon: 'categorize', @@ -86,10 +79,6 @@ export const brokerMenuItems: any[] = [ ]; export const userMenuItems: any[] = [ - { - text: '|', - fa: faUserCircle, - }, { text: 'My Loans', icon: 'categorize', diff --git a/src/app/models/api-v1-login-response.ts b/src/app/models/api-v1-login-response.ts index c9314a7..c0b3bee 100644 --- a/src/app/models/api-v1-login-response.ts +++ b/src/app/models/api-v1-login-response.ts @@ -1,6 +1,8 @@ // tslint:disable-next-line:class-name +import {PeopleModel} from './people.model'; + export class apiV1LoginResponse { constructor( @@ -8,7 +10,8 @@ export class apiV1LoginResponse { public machineId: string, public session: string, public sessionExpire: number, // unix timestamp - public role: string + public role: string, + public user: PeopleModel ) { this.login = login; this.machineId = machineId; @@ -18,8 +21,7 @@ export class apiV1LoginResponse { public static EmptyNew(): apiV1LoginResponse{ return new apiV1LoginResponse( - false, '', '', 0, '' - ); + false, '', '', 0, '', PeopleModel.EmptyNew() ); } public hasValidSession(): boolean { diff --git a/src/app/models/broker.model.ts b/src/app/models/broker.model.ts index 97de3c0..f6232dd 100644 --- a/src/app/models/broker.model.ts +++ b/src/app/models/broker.model.ts @@ -20,4 +20,9 @@ export class BrokerModel{ public toPeopleModel(): PeopleModel{ return new PeopleModel( this.Id, this.First, this.Last, this.Middle, this.Title, this.Display, this.Nick ); } + + public static EmptyNew(): BrokerModel { + return new BrokerModel('', '', '', '', '', '', '', + '', false, '', '', '', ''); + } } diff --git a/src/app/models/people.model.ts b/src/app/models/people.model.ts index 5f871d6..3195fd7 100644 --- a/src/app/models/people.model.ts +++ b/src/app/models/people.model.ts @@ -19,6 +19,10 @@ export class PeopleModel{ return this.First + ' ' + this.Middle + ' ' + this.Last; } } + + public static EmptyNew(): PeopleModel { + return new PeopleModel('', '', '', '', '', '', '' ); + } } diff --git a/src/app/service/auth.service.ts b/src/app/service/auth.service.ts index c6cfc3c..46ed0c8 100644 --- a/src/app/service/auth.service.ts +++ b/src/app/service/auth.service.ts @@ -2,6 +2,7 @@ import {EventEmitter, Injectable, OnDestroy, OnInit} from '@angular/core'; import {HttpClient, HttpEvent, HttpHandler, HttpInterceptor, HttpParams, HttpRequest} from '@angular/common/http'; import {apiV1LoginResponse} from '../models/api-v1-login-response'; import {Router} from '@angular/router'; +import {PeopleModel} from '../models/people.model'; @Injectable() export class AuthService { @@ -29,7 +30,10 @@ export class AuthService { sfm.machineId, sfm.session, sfm.sessionExpire, - sfm.role + sfm.role, + new PeopleModel( + sfm.user.Id, sfm.user.First, sfm.user.Last, sfm.user.Middle, sfm.user.Title, sfm.user.Display, sfm.user.Nick + ) ); this.loginSuccess.emit(this.loggedIn); // console.log ( 'auto login emit events', this.loggedIn); @@ -58,6 +62,19 @@ export class AuthService { this.loggedIn.machineId = responseData['Biukop-Mid']; this.loggedIn.sessionExpire = responseData.sessionExpire; this.loggedIn.role = responseData.role; + if ( responseData.user !== undefined) { + this.loggedIn.user = new PeopleModel( + responseData.user.Id, + responseData.user.First, + responseData.user.Last, + responseData.user.Middle, + responseData.user.Title, + responseData.user.Display, + responseData.user.Nick + ); + }else{ + this.loggedIn.user = PeopleModel.EmptyNew(); + } this.saveSessionInfo(); this.loginSuccess.emit(responseData); }, diff --git a/src/app/top-bar/top-bar.component.html b/src/app/top-bar/top-bar.component.html index 2e97527..18500b0 100644 --- a/src/app/top-bar/top-bar.component.html +++ b/src/app/top-bar/top-bar.component.html @@ -1,4 +1,10 @@ + + + {{LoggedInUser.Display}} + + + @@ -8,6 +14,10 @@ + + + + @@ -19,6 +29,8 @@ + + diff --git a/src/app/top-bar/top-bar.component.ts b/src/app/top-bar/top-bar.component.ts index bf6d5c2..4c929aa 100644 --- a/src/app/top-bar/top-bar.component.ts +++ b/src/app/top-bar/top-bar.component.ts @@ -4,6 +4,7 @@ import {AuthService} from '../service/auth.service'; import {brokerMenuItems, mainMenuItems, peopleMenuItems, userMenuItems} from '../main-menu-items'; import {apiV1LoginResponse} from '../models/api-v1-login-response'; import {Subscription} from 'rxjs'; +import {PeopleModel} from '../models/people.model'; @Component({ @@ -13,11 +14,13 @@ import {Subscription} from 'rxjs'; }) export class TopBarComponent implements OnInit , OnDestroy { login = false; + public LoggedInUser: PeopleModel; + Avatar = './assets/img/logout.png'; public items: any[] = mainMenuItems; private loginSub: Subscription; - public showMenu = true; + public showMenu = true; public opened = false; constructor(private menuService: MenuService, @@ -30,11 +33,14 @@ export class TopBarComponent implements OnInit , OnDestroy { public initAndSubLogin(): void{ this.login = this.authService.loggedIn.login; + this.LoggedInUser = this.authService.loggedIn.user; + console.log(this); this.selectMenuShow(this.authService.loggedIn.role); // console.log('subscribe auto login', this.authService.loggedIn); this.loginSub = this.authService.loginSuccess.subscribe( (rsp: apiV1LoginResponse) => { this.login = rsp.login; + this.LoggedInUser = this.authService.loggedIn.user; this.selectMenuShow(rsp.role); console.log ('topbar received auth events', rsp); } @@ -82,8 +88,7 @@ export class TopBarComponent implements OnInit , OnDestroy { } } - // tslint:disable-next-line:typedef - ngOnDestroy() { + ngOnDestroy(): void { this.loginSub.unsubscribe(); } @@ -97,4 +102,9 @@ export class TopBarComponent implements OnInit , OnDestroy { this.authService.logout(); } } + + public loggedInUserAvatar(): string { + return this.authService.getUrl('avatar/') + this.authService.loggedIn.user.Id; + } + }