전체파트너 page 추가

This commit is contained in:
이담 정 2022-07-12 06:05:24 +00:00
parent 39abd3aa29
commit be39026b6a
17 changed files with 1195 additions and 3 deletions

View File

@ -171,6 +171,13 @@ export const appRoutes: Route[] = [
'app/modules/admin/member/current-user/current-user.module' 'app/modules/admin/member/current-user/current-user.module'
).then((m: any) => m.CurrentUserModule), ).then((m: any) => m.CurrentUserModule),
}, },
{
path: 'partner',
loadChildren: () =>
import('app/modules/admin/member/partner/partner.module').then(
(m: any) => m.PartnerModule
),
},
], ],
}, },
{ {

View File

@ -0,0 +1,217 @@
import { Injectable } from '@angular/core';
import { assign, cloneDeep } from 'lodash-es';
import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api';
import { partners as partnersData } from './partner-data';
@Injectable({
providedIn: 'root',
})
export class MemberPartnerMockApi {
private _partners: any[] = partnersData;
/**
* Constructor
*/
constructor(private _fuseMockApiService: FuseMockApiService) {
// Register Mock API handlers
this.registerHandlers();
}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Register Mock API handlers
*/
registerHandlers(): void {
// -----------------------------------------------------------------------------------------------------
// @ Partners - GET
// -----------------------------------------------------------------------------------------------------
this._fuseMockApiService
.onGet('api/apps/member/partner/partners', 300)
.reply(({ request }) => {
// Get available queries
const search = request.params.get('search');
const sort = request.params.get('sort') || 'name';
const order = request.params.get('order') || 'asc';
const page = parseInt(request.params.get('page') ?? '1', 10);
const size = parseInt(request.params.get('size') ?? '10', 10);
// Clone the partners
let partners: any[] | null = cloneDeep(this._partners);
// Sort the partners
if (sort === 'sku' || sort === 'name' || sort === 'active') {
partners.sort((a, b) => {
const fieldA = a[sort].toString().toUpperCase();
const fieldB = b[sort].toString().toUpperCase();
return order === 'asc'
? fieldA.localeCompare(fieldB)
: fieldB.localeCompare(fieldA);
});
} else {
partners.sort((a, b) =>
order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort]
);
}
// If search exists...
if (search) {
// Filter the partners
partners = partners.filter(
(contact: any) =>
contact.name &&
contact.name.toLowerCase().includes(search.toLowerCase())
);
}
// Paginate - Start
const partnersLength = partners.length;
// Calculate pagination details
const begin = page * size;
const end = Math.min(size * (page + 1), partnersLength);
const lastPage = Math.max(Math.ceil(partnersLength / size), 1);
// Prepare the pagination object
let pagination = {};
// If the requested page number is bigger than
// the last possible page number, return null for
// partners but also send the last possible page so
// the app can navigate to there
if (page > lastPage) {
partners = null;
pagination = {
lastPage,
};
} else {
// Paginate the results by size
partners = partners.slice(begin, end);
// Prepare the pagination mock-api
pagination = {
length: partnersLength,
size: size,
page: page,
lastPage: lastPage,
startIndex: begin,
endIndex: end - 1,
};
}
// Return the response
return [
200,
{
partners,
pagination,
},
];
});
// -----------------------------------------------------------------------------------------------------
// @ Partner - GET
// -----------------------------------------------------------------------------------------------------
this._fuseMockApiService
.onGet('api/apps/member/partner/partner')
.reply(({ request }) => {
// Get the id from the params
const id = request.params.get('id');
// Clone the partners
const partners = cloneDeep(this._partners);
// Find the partner
const partner = partners.find((item: any) => item.id === id);
// Return the response
return [200, partner];
});
// -----------------------------------------------------------------------------------------------------
// @ Partner - POST
// -----------------------------------------------------------------------------------------------------
this._fuseMockApiService
.onPost('api/apps/member/partner/partner')
.reply(() => {
// Generate a new partner
const newPartner = {
id: FuseMockApiUtils.guid(),
category: '',
name: 'A New User',
description: '',
tags: [],
sku: '',
barcode: '',
brand: '',
vendor: '',
stock: '',
reserved: '',
cost: '',
basePrice: '',
taxPercent: '',
price: '',
weight: '',
thumbnail: '',
images: [],
active: false,
};
// Unshift the new partner
this._partners.unshift(newPartner);
// Return the response
return [200, newPartner];
});
// -----------------------------------------------------------------------------------------------------
// @ Partner - PATCH
// -----------------------------------------------------------------------------------------------------
this._fuseMockApiService
.onPatch('api/apps/member/partner/partner')
.reply(({ request }) => {
// Get the id and partner
const id = request.body.id;
const partner = cloneDeep(request.body.partner);
// Prepare the updated partner
let updatedPartner = null;
// Find the partner and update it
this._partners.forEach((item, index, partners) => {
if (item.id === id) {
// Update the partner
partners[index] = assign({}, partners[index], partner);
// Store the updated partner
updatedPartner = partners[index];
}
});
// Return the response
return [200, updatedPartner];
});
// -----------------------------------------------------------------------------------------------------
// @ Partner - DELETE
// -----------------------------------------------------------------------------------------------------
this._fuseMockApiService
.onDelete('api/apps/member/partner/partner')
.reply(({ request }) => {
// Get the id
const id = request.params.get('id');
// Find the partner and delete it
this._partners.forEach((item, index) => {
if (item.id === id) {
this._partners.splice(index, 1);
}
});
// Return the response
return [200, true];
});
}
}

View File

@ -0,0 +1,30 @@
/* eslint-disable */
export const partners = [
{
id: 'kgon1',
nickname: '본사',
rank: '본사',
branchCount: 2,
divisionCount: 2,
officeCount: 1,
storeCount: 1,
memberCount: 5,
level: '1',
calculateType: '롤링',
holdingMoney: 253675,
accountHolder: '본사',
phoneNumber: '010-0000-0000',
comp: 100737,
coupon: 1900000,
ownCharge: 460000,
bottomCharge: 54020000,
ownExchange: 100000,
bottomExchange: 19970000,
ownRevenue: 360000,
bottomRevenue: 34050000,
accession: '2021-10-14 10:53',
state: '정상',
note: '대본등록',
},
];

View File

@ -67,6 +67,13 @@ export const defaultNavigation: FuseNavigationItem[] = [
icon: 'heroicons_outline:academic-cap', icon: 'heroicons_outline:academic-cap',
link: '/member/current-user', link: '/member/current-user',
}, },
{
id: 'member.partner',
title: 'All Partner',
type: 'basic',
icon: 'heroicons_outline:academic-cap',
link: '/member/partner',
},
], ],
}, },
{ {

View File

@ -15,6 +15,7 @@ import { MemberUserMockApi } from 'app/mock-api/apps/member/user/api';
import { MemberCasinomoneyMockApi } from './apps/member/casinomoney/api'; import { MemberCasinomoneyMockApi } from './apps/member/casinomoney/api';
import { MemberUnconnectedMockApi } from './apps/member/unconnected/api'; import { MemberUnconnectedMockApi } from './apps/member/unconnected/api';
import { MemberCurrentUserMockApi } from './apps/member/current-user/api'; import { MemberCurrentUserMockApi } from './apps/member/current-user/api';
import { MemberPartnerMockApi } from './apps/member/partner/partner-api';
import { MessagesMockApi } from 'app/mock-api/common/messages/api'; import { MessagesMockApi } from 'app/mock-api/common/messages/api';
import { NavigationMockApi } from 'app/mock-api/common/navigation/api'; import { NavigationMockApi } from 'app/mock-api/common/navigation/api';
import { NotesMockApi } from 'app/mock-api/apps/notes/api'; import { NotesMockApi } from 'app/mock-api/apps/notes/api';
@ -50,6 +51,7 @@ export const mockApiServices = [
MemberCasinomoneyMockApi, MemberCasinomoneyMockApi,
MemberUnconnectedMockApi, MemberUnconnectedMockApi,
MemberCurrentUserMockApi, MemberCurrentUserMockApi,
MemberPartnerMockApi,
MessagesMockApi, MessagesMockApi,
NavigationMockApi, NavigationMockApi,
NotesMockApi, NotesMockApi,

View File

@ -11,7 +11,7 @@ export const casinomoneyRoutes: Route[] = [
path: '', path: '',
component: ListComponent, component: ListComponent,
resolve: { resolve: {
casinomoneyrs: CasinomoneysResolver, casinomoneys: CasinomoneysResolver,
}, },
}, },
{ {

View File

@ -0,0 +1,3 @@
import { ListComponent } from './list.component';
export const COMPONENTS = [ListComponent];

View File

@ -0,0 +1,374 @@
<div
class="sm:absolute sm:inset-0 flex flex-col flex-auto min-w-0 sm:overflow-hidden bg-card dark:bg-transparent"
>
<!-- Header -->
<div
class="relative flex flex-col sm:flex-row flex-0 sm:items-center sm:justify-between py-8 px-6 md:px-8 border-b"
>
<!-- Loader -->
<div class="absolute inset-x-0 bottom-0" *ngIf="isLoading">
<mat-progress-bar [mode]="'indeterminate'"></mat-progress-bar>
</div>
<!-- Title -->
<div class="text-4xl font-extrabold tracking-tight">전체목록</div>
<!-- Actions -->
<div class="flex shrink-0 items-center mt-6 sm:mt-0 sm:ml-4">
<!-- Memo -->
<!-- <mat-form-field>
<ng-container *ngIf="partners$ | async as partners">
<ng-container
*ngFor="let partner of partners; trackBy: __trackByFn"
>
<div
class="inventory-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b"
>
<fieldset>
총 회원수:{{ partenr.totalMemberCount }}
총 보유머니:{{ partner.totalHoldingMoney }}
총 콤프:{{ partner.totalComp }}
총 합계:{{ partner.total }}
</fieldset>
</div>
</ng-container>
</ng-container>
</mat-form-field> -->
<!-- Search -->
<mat-form-field
class="fuse-mat-dense fuse-mat-no-subscript fuse-mat-rounded min-w-64"
>
<mat-icon
class="icon-size-5"
matPrefix
[svgIcon]="'heroicons_solid:search'"
></mat-icon>
<input
matInput
[formControl]="searchInputControl"
[autocomplete]="'off'"
[placeholder]="'Search user'"
/>
</mat-form-field>
<!-- Add user button -->
<button
class="ml-4"
mat-flat-button
[color]="'primary'"
(click)="__createProduct()"
>
<mat-icon [svgIcon]="'heroicons_outline:plus'"></mat-icon>
<span class="ml-2 mr-1">Add</span>
</button>
</div>
</div>
<!-- Main -->
<div class="flex flex-auto overflow-hidden">
<!-- Products list -->
<div
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
>
<ng-container *ngIf="partners$ | async as partners">
<ng-container *ngIf="partners.length > 0; else noPartner">
<div class="grid">
<!-- Header -->
<div
class="inventory-grid z-10 sticky top-0 grid gap-4 py-4 px-6 md:px-8 shadow text-md font-semibold text-secondary bg-gray-50 dark:bg-black dark:bg-opacity-5"
matSort
matSortDisableClear
>
<div></div>
<div class="hidden sm:block" [mat-sort-header]="''">아이디</div>
<div class="hidden sm:block" [mat-sort-header]="''">매장수</div>
<div class="hidden sm:block" [mat-sort-header]="''">관리</div>
<div class="hidden sm:block" [mat-sort-header]="''">요율</div>
<div class="hidden sm:block" [mat-sort-header]="''">예금주</div>
<div class="hidden sm:block" [mat-sort-header]="''">연락처</div>
<div class="hidden sm:block" [mat-sort-header]="''">등급</div>
<div class="hidden sm:block" [mat-sort-header]="''">정산</div>
<div class="hidden sm:block" [mat-sort-header]="''">보유금</div>
<div class="hidden sm:block" [mat-sort-header]="''">로그</div>
<div class="hidden sm:block" [mat-sort-header]="''">콤프</div>
<div class="hidden sm:block" [mat-sort-header]="''">쿠폰</div>
<div class="hidden sm:block" [mat-sort-header]="''">충전금</div>
<div class="hidden sm:block" [mat-sort-header]="''">환전금</div>
<div class="hidden sm:block" [mat-sort-header]="''">수익금</div>
<div class="hidden sm:block" [mat-sort-header]="''">가입날짜</div>
<div class="hidden sm:block" [mat-sort-header]="''">상태</div>
<div class="hidden sm:block" [mat-sort-header]="''">비고</div>
<!-- <div class="hidden md:block" [mat-sort-header]="'sku'">SKU</div>
<div [mat-sort-header]="'name'">Name</div>
<div class="hidden sm:block" [mat-sort-header]="'price'">
Price
</div>
<div class="hidden lg:block" [mat-sort-header]="'stock'">
Stock
</div>
<div class="hidden lg:block" [mat-sort-header]="'active'">
Active
</div>
<div class="hidden sm:block">Details</div> -->
</div>
<!-- Rows -->
<ng-container *ngIf="partners$ | async as partners">
<ng-container
*ngFor="let partner of partners; trackBy: __trackByFn"
>
<div
class="inventory-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b"
>
<!-- id -->
<ng-container *ngIf="users$ | async as users">
<ng-container
*ngFor="let user of users; trackBy: __trackByFn"
>
<!-- rank -->
{{ partner.rank }}
<div
class="hidden sm:block truncate"
(click)="viewUserDetail(user.id!)"
>
{{ partner.id }}
</div>
<!-- nickname -->
{{ partner.nickname }}
</ng-container>
</ng-container>
<!-- 매장수 -->
<div class="hidden sm:block truncate">
{{ partner.branchCount }}
{{ partner.divisionCount }}
{{ partner.officeCount }}
{{ partner.storeCount }}
{{ partner.memberCount }}
</div>
<!-- management -->
<div class="hidden sm:block truncate">
<button mat-flat-button [color]="'primary'">
<mat-form-field>
<mat-select placeholder="관리">
<mat-option value="">보유금지급/회수</mat-option>
<mat-option value="">수수료설정</mat-option>
<mat-option value="">콤프지급/회수</mat-option>
<mat-option value="">쿠폰머니지급/회수</mat-option>
<mat-option value="">쪽지보내기</mat-option>
<mat-option value="">베팅리스트</mat-option>
<mat-option value="">강제로그아웃</mat-option>
</mat-select>
</mat-form-field>
</button>
</div>
<!-- rate -->
<div class="hidden sm:block truncate">
<button
mat-button
color="primary"
matTooltip="요율확인
카지노-바카라: 0%
카지노-룰렛: 0%
카지노-드레곤타이거: 0%
카지노-그외: 0%
슬롯: 0%
카지노루징: 0%
슬롯루징: 0%"
>
요율
</button>
<!-- accountHolder -->
<div class="hidden sm:block truncate">
{{ partner.accountHolder }}
</div>
<!-- contact -->
<div class="hidden sm:block truncate">
{{ partner.phoneNumber }}
</div>
<!-- level -->
<div class="hidden sm:block truncate">
LV.{{ partner.level }}
</div>
</div>
<!-- calculateType -->
<div class="hidden sm:block truncate">
{{ partner.calculateType }}
</div>
<!-- reserve -->
<div class="hidden sm:block truncate">
콤프{{ partner.comp }} 쿠폰{{ partner.coupon }}
</div>
<!-- holdingMoney -->
<div class="hidden sm:block truncate">
{{ partner.holdingMoney }}
</div>
<!-- comp -->
<div class="hidden sm:block truncate">
{{ partner.comp }}P
</div>
<!-- coupon -->
<div class="hidden sm:block truncate">
{{ partner.coupon }}
</div>
<!-- charge -->
<div class="hidden sm:block truncate">
본인 {{ partner.ownCharge }} 하부
{{ partner.bottomCharge }}
</div>
<!-- exchange -->
<div class="hidden sm:block truncate">
본인 {{ partner.ownExchange }} 하부
{{ partner.bottomExchange }}
</div>
<!-- revenue -->
<div class="hidden sm:block truncate">
본인 {{ partner.ownRevenue }} 하부
{{ partner.bottomRevenue }}
</div>
<!-- accession -->
<div class="hidden sm:block truncate">
가입날짜{{ partner.accession }}
</div>
<!-- state -->
<div class="hidden sm:block truncate">
{{ partner.state }}
</div>
<!-- note -->
<div class="hidden sm:block truncate">
<button mat-flat-button [color]="'primary'">
{{ partner.note }}
</button>
</div>
<!-- Image -->
<!-- <div class="flex items-center">
<div
class="relative flex flex-0 items-center justify-center w-12 h-12 mr-6 rounded overflow-hidden border"
>
<img
class="w-8"
*ngIf="user.thumbnail"
[alt]="'Product thumbnail image'"
[src]="user.thumbnail"
/>
<div
class="flex items-center justify-center w-full h-full text-xs font-semibold leading-none text-center uppercase"
*ngIf="!user.thumbnail"
>
NO THUMB
</div>
</div>
</div> -->
<!-- SKU -->
<!-- <div class="hidden md:block truncate">
{{ user.sku }}
</div> -->
<!-- Name -->
<!-- <div class="truncate">
{{ user.name }}
</div> -->
<!-- Price -->
<!-- <div class="hidden sm:block">
{{ user.price | currency: "USD":"symbol":"1.2-2" }}
</div> -->
<!-- Stock -->
<!-- <div class="hidden lg:flex items-center">
<div class="min-w-4">{{ user.stock }}</div> -->
<!-- Low stock -->
<!-- <div
class="flex items-end ml-2 w-1 h-4 bg-red-200 rounded overflow-hidden"
*ngIf="user.stock < 20"
>
<div class="flex w-full h-1/3 bg-red-600"></div>
</div> -->
<!-- Medium stock -->
<!-- <div
class="flex items-end ml-2 w-1 h-4 bg-orange-200 rounded overflow-hidden"
*ngIf="user.stock >= 20 && user.stock < 30"
>
<div class="flex w-full h-2/4 bg-orange-400"></div>
</div> -->
<!-- High stock -->
<!-- <div
class="flex items-end ml-2 w-1 h-4 bg-green-100 rounded overflow-hidden"
*ngIf="user.stock >= 30"
>
<div class="flex w-full h-full bg-green-400"></div>
</div>
</div> -->
<!-- Active -->
<!-- <div class="hidden lg:block">
<ng-container *ngIf="user.active">
<mat-icon
class="text-green-400 icon-size-5"
[svgIcon]="'heroicons_solid:check'"
></mat-icon>
</ng-container>
<ng-container *ngIf="!user.active">
<mat-icon
class="text-gray-400 icon-size-5"
[svgIcon]="'heroicons_solid:x'"
></mat-icon>
</ng-container>
</div> -->
<!-- Details button -->
<!-- <div>
<button
class="min-w-10 min-h-7 h-7 px-2 leading-6"
mat-stroked-button
(click)="__toggleDetails(user.id)"
>
<mat-icon
class="icon-size-5"
[svgIcon]="
selectedUser?.id === user.id
? 'heroicons_solid:chevron-up'
: 'heroicons_solid:chevron-down'
"
></mat-icon>
</button>
</div> -->
</div>
</ng-container>
</ng-container>
</div>
<mat-paginator
class="sm:absolute sm:inset-x-0 sm:bottom-0 border-b sm:border-t sm:border-b-0 z-10 bg-gray-50 dark:bg-transparent"
[ngClass]="{ 'pointer-events-none': isLoading }"
[length]="pagination?.length"
[pageIndex]="pagination?.page"
[pageSize]="pagination?.size"
[pageSizeOptions]="[5, 10, 25, 100]"
[showFirstLastButtons]="true"
></mat-paginator>
</ng-container>
</ng-container>
<ng-template #noPartner>
<div
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
>
There are no partners!
</div>
</ng-template>
</div>
</div>
</div>

View File

@ -0,0 +1,198 @@
import {
AfterViewInit,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
OnDestroy,
OnInit,
ViewChild,
ViewEncapsulation,
} from '@angular/core';
import {
FormBuilder,
FormControl,
FormGroup,
Validators,
} from '@angular/forms';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import {
debounceTime,
map,
merge,
Observable,
Subject,
switchMap,
takeUntil,
} from 'rxjs';
import { fuseAnimations } from '@fuse/animations';
import { FuseConfirmationService } from '@fuse/services/confirmation';
import { User } from '../../user/models/user';
import { Partner } from '../models/partner';
import { PartnerPagination } from '../models/partner-pagination';
import { PartnerService } from '../services/partner.service';
import { Router } from '@angular/router';
@Component({
selector: 'list',
templateUrl: './list.component.html',
styles: [
/* language=SCSS */
`
.inventory-grid {
grid-template-columns: 60px auto 40px;
@screen sm {
grid-template-columns: 60px auto 60px 72px;
}
@screen md {
grid-template-columns: 60px 60px auto 112px 72px;
}
@screen lg {
grid-template-columns: 60px 60px auto 112px 96px 96px 72px;
}
}
`,
],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
animations: fuseAnimations,
})
export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild(MatPaginator) private _paginator!: MatPaginator;
@ViewChild(MatSort) private _sort!: MatSort;
partners$!: Observable<Partner[] | undefined>;
users$!: Observable<User[] | undefined>;
isLoading = false;
searchInputControl = new FormControl();
selectedPartner?: Partner;
pagination?: PartnerPagination;
private _unsubscribeAll: Subject<any> = new Subject<any>();
/**
* Constructor
*/
constructor(
private _changeDetectorRef: ChangeDetectorRef,
private _fuseConfirmationService: FuseConfirmationService,
private _formBuilder: FormBuilder,
private _partnerService: PartnerService,
private router: Router
) {}
// -----------------------------------------------------------------------------------------------------
// @ Lifecycle hooks
// -----------------------------------------------------------------------------------------------------
/**
* On init
*/
ngOnInit(): void {
// Get the pagination
this._partnerService.pagination$
.pipe(takeUntil(this._unsubscribeAll))
.subscribe((pagination: PartnerPagination | undefined) => {
// Update the pagination
this.pagination = pagination;
// Mark for check
this._changeDetectorRef.markForCheck();
});
// Get the products
this.partners$ = this._partnerService.partners$;
}
/**
* After view init
*/
ngAfterViewInit(): void {
if (this._sort && this._paginator) {
// Set the initial sort
this._sort.sort({
id: 'name',
start: 'asc',
disableClear: true,
});
// Mark for check
this._changeDetectorRef.markForCheck();
// If the partner changes the sort order...
this._sort.sortChange
.pipe(takeUntil(this._unsubscribeAll))
.subscribe(() => {
// Reset back to the first page
this._paginator.pageIndex = 0;
});
// Get products if sort or page changes
merge(this._sort.sortChange, this._paginator.page)
.pipe(
switchMap(() => {
this.isLoading = true;
return this._partnerService.getPartners(
this._paginator.pageIndex,
this._paginator.pageSize,
this._sort.active,
this._sort.direction
);
}),
map(() => {
this.isLoading = false;
})
)
.subscribe();
}
}
/**
* On destroy
*/
ngOnDestroy(): void {
// Unsubscribe from all subscriptions
this._unsubscribeAll.next(null);
this._unsubscribeAll.complete();
}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
viewUserDetail(id: string): void {
let url: string = 'member/user/' + id;
this.router.navigateByUrl(url);
}
// -----------------------------------------------------------------------------------------------------
// @ Private methods
// -----------------------------------------------------------------------------------------------------
/**
* Create product
*/
__createProduct(): void {}
/**
* Toggle product details
*
* @param productId
*/
__toggleDetails(productId: string): void {}
/**
* Track by function for ngFor loops
*
* @param index
* @param item
*/
__trackByFn(index: number, item: any): any {
return item.id || index;
}
}

View File

@ -0,0 +1,8 @@
export interface PartnerPagination {
length: number;
size: number;
page: number;
lastPage: number;
startIndex: number;
endIndex: number;
}

View File

@ -0,0 +1,31 @@
import { NumberValueAccessor } from '@angular/forms';
export interface Partner {
id?: string;
totalMemberCount?: number;
totalHoldingMoney?: number;
totalComp?: number;
nickname?: string;
rank?: string;
branchCount?: number;
divisionCount?: number;
officeCount?: number;
storeCount?: number;
memberCount?: number;
level?: string;
calculateType?: string;
holdingMoney?: number;
accountHolder?: string;
phoneNumber?: string;
comp?: number;
coupon?: number;
ownCharge?: number;
bottomCharge?: number;
ownExchange?: number;
bottomExchange?: number;
ownRevenue?: number;
bottomRevenue?: number;
accession?: string;
state?: string;
note?: string;
}

View File

@ -0,0 +1,48 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { MatButtonModule } from '@angular/material/button';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatPaginatorModule } from '@angular/material/paginator';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatRippleModule } from '@angular/material/core';
import { MatSortModule } from '@angular/material/sort';
import { MatSelectModule } from '@angular/material/select';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatSlideToggleModule } from '@angular/material/slide-toggle';
import { MatRadioModule } from '@angular/material/radio';
import { TranslocoModule } from '@ngneat/transloco';
import { SharedModule } from 'app/shared/shared.module';
import { COMPONENTS } from './components';
import { partnerRoutes } from './partner.routing';
@NgModule({
declarations: [COMPONENTS],
imports: [
TranslocoModule,
SharedModule,
RouterModule.forChild(partnerRoutes),
MatButtonModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
MatPaginatorModule,
MatProgressBarModule,
MatRippleModule,
MatSortModule,
MatSelectModule,
MatTooltipModule,
MatGridListModule,
MatSlideToggleModule,
MatRadioModule,
],
})
export class PartnerModule {}

View File

@ -0,0 +1,24 @@
import { Route } from '@angular/router';
import { ListComponent } from './components/list.component';
import { ViewComponent } from '../user/components/view.component';
import { PartnersResolver } from './resolvers/partner.resolver';
import { UserResolver } from '../user/resolvers/user.resolver';
export const partnerRoutes: Route[] = [
{
path: '',
component: ListComponent,
resolve: {
Partners: PartnersResolver,
},
},
{
path: ':id',
component: ViewComponent,
resolve: {
users: UserResolver,
},
},
];

View File

@ -0,0 +1,89 @@
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot,
Resolve,
Router,
RouterStateSnapshot,
} from '@angular/router';
import { catchError, Observable, throwError } from 'rxjs';
import { Partner } from '../models/partner';
import { PartnerPagination } from '../models/partner-pagination';
import { PartnerService } from '../services/partner.service';
@Injectable({
providedIn: 'root',
})
export class PartnerResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(
private _partnerServiceService: PartnerService,
private _router: Router
) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<Partner | undefined> {
return this._partnerServiceService
.getPartnerById(route.paramMap.get('id'))
.pipe(
// Error here means the requested product is not available
catchError((error) => {
// Log the error
console.error(error);
// Get the parent url
const parentUrl = state.url.split('/').slice(0, -1).join('/');
// Navigate to there
this._router.navigateByUrl(parentUrl);
// Throw an error
return throwError(error);
})
);
}
}
@Injectable({
providedIn: 'root',
})
export class PartnersResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _partnerService: PartnerService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<{
pagination: PartnerPagination;
partners: Partner[];
}> {
return this._partnerService.getPartners();
}
}

View File

@ -0,0 +1,153 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {
BehaviorSubject,
filter,
map,
Observable,
of,
switchMap,
take,
tap,
throwError,
} from 'rxjs';
import { Partner } from '../models/partner';
import { PartnerPagination } from '../models/partner-pagination';
@Injectable({
providedIn: 'root',
})
export class PartnerService {
// Private
private __pagination = new BehaviorSubject<PartnerPagination | undefined>(
undefined
);
private __partner = new BehaviorSubject<Partner | undefined>(undefined);
private __partners = new BehaviorSubject<Partner[] | undefined>(undefined);
/**
* Constructor
*/
constructor(private _httpClient: HttpClient) {}
// -----------------------------------------------------------------------------------------------------
// @ Accessors
// -----------------------------------------------------------------------------------------------------
/**
* Getter for pagination
*/
get pagination$(): Observable<PartnerPagination | undefined> {
return this.__pagination.asObservable();
}
/**
* Getter for partner
*/
get partner$(): Observable<Partner | undefined> {
return this.__partner.asObservable();
}
/**
* Getter for partners
*/
get partners$(): Observable<Partner[] | undefined> {
return this.__partners.asObservable();
}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Get partners
*
*
* @param page
* @param size
* @param sort
* @param order
* @param search
*/
getPartners(
page: number = 0,
size: number = 10,
sort: string = 'name',
order: 'asc' | 'desc' | '' = 'asc',
search: string = ''
): Observable<{
pagination: PartnerPagination;
partners: Partner[];
}> {
return this._httpClient
.get<{ pagination: PartnerPagination; partners: Partner[] }>(
'api/apps/member/partner/partners',
{
params: {
page: '' + page,
size: '' + size,
sort,
order,
search,
},
}
)
.pipe(
tap((response) => {
this.__pagination.next(response.pagination);
this.__partners.next(response.partners);
})
);
}
/**
* Get product by id
*/
getPartnerById(id: string | null): Observable<Partner> {
return this.__partners.pipe(
take(1),
map((partners) => {
// Find the product
const partner = partners?.find((item) => item.id === id) || undefined;
// Update the product
this.__partner.next(partner);
// Return the product
return partner;
}),
switchMap((product) => {
if (!product) {
return throwError('Could not found product with id of ' + id + '!');
}
return of(product);
})
);
}
/**
* Create product
*/
createPartner(): Observable<Partner> {
return this.partners$.pipe(
take(1),
switchMap((partners) =>
this._httpClient
.post<Partner>('api/apps/member/partner/product', {})
.pipe(
map((newPartner) => {
// Update the partners with the new product
if (!!partners) {
this.__partners.next([newPartner, ...partners]);
}
// Return the new product
return newPartner;
})
)
)
);
}
}

View File

@ -6,7 +6,8 @@
"Casinomoney": "Casinomoney", "Casinomoney": "Casinomoney",
"Unconnected": "Unconnected", "Unconnected": "Unconnected",
"Project": "Project", "Project": "Project",
"Partner": "Partner", "All Partner": "All Partner",
"Mainoffice": "Mainoffice",
"Analytics": "Analytics", "Analytics": "Analytics",
"Deposit": "Deposit", "Deposit": "Deposit",
"Withdraw": "Withdraw", "Withdraw": "Withdraw",

View File

@ -6,7 +6,7 @@
"Casinomoney": "CASINO 머니파악", "Casinomoney": "CASINO 머니파악",
"Unconnected": "장기미접속회원", "Unconnected": "장기미접속회원",
"Project": "프로젝트", "Project": "프로젝트",
"Partner": "파트너", "All Partner": "전체파트너",
"Analytics": "Analytics", "Analytics": "Analytics",
"Deposit": "입금관리", "Deposit": "입금관리",
"Withdraw": "출금관리", "Withdraw": "출금관리",