[update]
This commit is contained in:
@@ -1,13 +1,10 @@
|
|||||||
import {Component, ViewChild} from '@angular/core';
|
import {Component, ViewChild} from '@angular/core';
|
||||||
import {MatPaginator} from '@angular/material/paginator';
|
import {MatPaginator} from '@angular/material/paginator';
|
||||||
import {MatSort} from '@angular/material/sort';
|
import {MatSort} from '@angular/material/sort';
|
||||||
|
|
||||||
import generateParamsValue from '../utils/GenerateParamsValue';
|
import generateParamsValue from '../utils/GenerateParamsValue';
|
||||||
|
|
||||||
import {MatTableDataSource} from '@angular/material/table';
|
import {MatTableDataSource} from '@angular/material/table';
|
||||||
import {IListPageDefault, IListResponse} from "../interface/ListResponse";
|
import {IListPageDefault, IListResponse} from "../interface/ListResponse";
|
||||||
import {CDialogConfig, IDialogConfig} from "../interface/Dialog";
|
import {CDialogConfig, IDialogConfig} from "../interface/Dialog";
|
||||||
import { STORAGE } from "../../@config/app";
|
|
||||||
|
|
||||||
@Component({template: ''})
|
@Component({template: ''})
|
||||||
export abstract class BaseListComponent {
|
export abstract class BaseListComponent {
|
||||||
@@ -22,7 +19,6 @@ export abstract class BaseListComponent {
|
|||||||
totalItem: any = 0;
|
totalItem: any = 0;
|
||||||
totalOfElement: number = 10;
|
totalOfElement: number = 10;
|
||||||
isTab: string = '';
|
isTab: string = '';
|
||||||
storage: any = STORAGE;
|
|
||||||
|
|
||||||
|
|
||||||
dialogConfig: IDialogConfig = CDialogConfig;
|
dialogConfig: IDialogConfig = CDialogConfig;
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute, Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { AppService } from '../../app.service';
|
import { AppService } from '../../app.service';
|
||||||
import { environment } from "../../../environments/environment";
|
import { environment } from "../../../environments/environment";
|
||||||
import { AuthService } from 'src/app/core/service/auth/auth.service';
|
import { AuthService } from 'src/app/core/service/auth/auth.service';
|
||||||
import { catchError, lastValueFrom, tap, throwError } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import { EAction, EText } from 'src/app/@config/app';
|
import { EAction, EText } from 'src/app/@config/app';
|
||||||
|
import { CathayAuthService } from 'src/app/core/service/auth/cathay-auth.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -13,15 +14,19 @@ import { EAction, EText } from 'src/app/@config/app';
|
|||||||
styles: []
|
styles: []
|
||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
// apiUrl: string = API.login;
|
|
||||||
dataForm: any = {};
|
dataForm: any = {};
|
||||||
|
cathayForm: any = {
|
||||||
|
mobileDeviceId : "1234",
|
||||||
|
userName: 'admin',
|
||||||
|
password: 'P@ssword1'
|
||||||
|
};
|
||||||
isLoading = false;
|
isLoading = false;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private appService: AppService,
|
private appService: AppService,
|
||||||
private route: ActivatedRoute,
|
private authService: AuthService,
|
||||||
private authService: AuthService
|
private cathayAuthService: CathayAuthService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,8 +43,11 @@ export class LoginComponent implements OnInit {
|
|||||||
async onSubmit(form: any) {
|
async onSubmit(form: any) {
|
||||||
if (!form.valid) return false;
|
if (!form.valid) return false;
|
||||||
try {
|
try {
|
||||||
const result = await lastValueFrom(this.authService.login(this.dataForm));
|
// const result = await lastValueFrom(this.authService.login(this.dataForm));
|
||||||
this.appService.setAuth(result);
|
const cathayResult = await lastValueFrom(this.cathayAuthService.login(this.cathayForm))
|
||||||
|
// this.cathayAuthService.login(this.cathayForm).subscribe(res => console.log(res))
|
||||||
|
console.log(cathayResult)
|
||||||
|
this.appService.setAuth(cathayResult);
|
||||||
return this.router.navigate(['/pages']);
|
return this.router.navigate(['/pages']);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.appService.message(EAction.ERROR, EText.NO_DATA);
|
return this.appService.message(EAction.ERROR, EText.NO_DATA);
|
||||||
|
|||||||
22
src/app/core/service/auth/cathay-auth.service.ts
Normal file
22
src/app/core/service/auth/cathay-auth.service.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { BaseService } from 'src/app/core/base/base-service';
|
||||||
|
import { environment } from 'src/environments/environment';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class CathayAuthService extends BaseService{
|
||||||
|
API_URL = environment.CATHAYAPIURL
|
||||||
|
constructor(
|
||||||
|
public http: HttpClient
|
||||||
|
) {
|
||||||
|
super('', http)
|
||||||
|
super.fullUrl = `${this.API_URL}/v1/User`
|
||||||
|
}
|
||||||
|
|
||||||
|
login(payload : {'mobileDeviceId': string , 'userName': string , 'password' : string}){
|
||||||
|
return this.http.post(`${this.fullUrl}/login`, payload)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
hideForm: false,
|
hideForm: false,
|
||||||
APIURL: 'https://cathaypay.71dev.com/cathaypay-api'
|
APIURL: 'https://cathaypay.71dev.com/cathaypay-api',
|
||||||
|
CATHAYAPIURL: 'https://sathorn.cathay-pay.com/api'
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export const environment = {
|
export const environment = {
|
||||||
production: false,
|
production: false,
|
||||||
hideForm: false,
|
hideForm: false,
|
||||||
APIURL: 'https://cathaypay.71dev.com/cathaypay-api'
|
APIURL: 'https://cathaypay.71dev.com/cathaypay-api',
|
||||||
|
CATHAYAPIURL: 'https://sathorn.cathay-pay.com/api'
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user