From 2443d34bb5cdbc3ba9298d97b3c755c8cf666106 Mon Sep 17 00:00:00 2001 From: byung eun park Date: Sat, 27 Jul 2019 20:45:14 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9A=8C=EC=9B=90=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 15 ++ package-lock.json | 10 + package.json | 3 +- src/app/app-routing.module.ts | 2 +- src/app/app.module.ts | 3 +- src/app/navigation/navigation.ts | 2 +- src/app/pages/pages-routing.module.ts | 2 +- .../user/component/user-list.component.html | 202 +++++++++++------- .../user/component/user-list.component.ts | 30 ++- .../users/user/component/user-list.service.ts | 60 ++++++ .../pages/users/user/user-routing.module.ts | 12 +- src/app/pages/users/user/user.module.ts | 13 +- src/app/pages/users/users-routing.module.ts | 4 +- tsconfig.json | 4 +- tslint.json | 1 + 15 files changed, 261 insertions(+), 102 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 src/app/pages/users/user/component/user-list.service.ts diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..e04e3dc --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:4200", + "webRoot": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 72776ce..e6fe127 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@agm/core": { + "version": "1.0.0-beta.5", + "resolved": "https://registry.npmjs.org/@agm/core/-/core-1.0.0-beta.5.tgz", + "integrity": "sha512-LVENJqtBZEWpX+uJkGI0zgg+Xkm2KkktQm4ojZozArbeNvQkVL6pqVc04Mme6vvOzwJpD1cET5w4byC8Xaq1QQ==" + }, "@angular-devkit/architect": { "version": "0.801.2", "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.801.2.tgz", @@ -1753,6 +1758,11 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, + "angular-in-memory-web-api": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/angular-in-memory-web-api/-/angular-in-memory-web-api-0.8.0.tgz", + "integrity": "sha512-2n0YtCLFxZo4JePHvH6q8b7JmBmhZq44Ic8VaBPRSXE4vAmlKXHU+kI2quNa612EAETDRkZcvLOU8K8CkhIZgQ==" + }, "ansi-colors": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.4.tgz", diff --git a/package.json b/package.json index dbd6e37..57a77f4 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@ngrx/store": "^8.1.0", "@ngx-translate/core": "^11.0.1", "@swimlane/ngx-datatable": "^15.0.2", + "angular-in-memory-web-api": "0.8.0", "d3": "^5.9.7", "hammerjs": "^2.0.8", "lodash": "^4.17.15", @@ -71,4 +72,4 @@ "tslint": "~5.15.0", "typescript": "~3.4.3" } -} +} \ No newline at end of file diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 334be4f..00d9521 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -12,4 +12,4 @@ const routes: Routes = [ imports: [RouterModule.forRoot(routes)], exports: [RouterModule] }) -export class AppRoutingModule {} +export class AppRoutingModule { } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index d895103..7f9885e 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -21,6 +21,7 @@ import { appFuseConfig } from './app.fuse'; import { LayoutModule } from './layout/layout.module'; +import { from } from 'rxjs'; @NgModule({ imports: [ BrowserModule, @@ -51,4 +52,4 @@ import { LayoutModule } from './layout/layout.module'; providers: [], bootstrap: [AppComponent] }) -export class AppModule {} +export class AppModule { } diff --git a/src/app/navigation/navigation.ts b/src/app/navigation/navigation.ts index ea4cd46..9164129 100644 --- a/src/app/navigation/navigation.ts +++ b/src/app/navigation/navigation.ts @@ -21,7 +21,7 @@ export const navigation: FuseNavigation[] = [ translate: 'NAV.USER.TITLE', type: 'item', icon: 'email', - url: '/pages/users/users', + url: '/pages/users/user-list', badge: { title: '25', translate: 'NAV.USER.BADGE', diff --git a/src/app/pages/pages-routing.module.ts b/src/app/pages/pages-routing.module.ts index cdb88c8..d959c96 100644 --- a/src/app/pages/pages-routing.module.ts +++ b/src/app/pages/pages-routing.module.ts @@ -12,4 +12,4 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) -export class PagesRoutingModule {} +export class PagesRoutingModule { } diff --git a/src/app/pages/users/user/component/user-list.component.html b/src/app/pages/users/user/component/user-list.component.html index b295a96..e413a06 100644 --- a/src/app/pages/users/user/component/user-list.component.html +++ b/src/app/pages/users/user/component/user-list.component.html @@ -6,30 +6,14 @@
-
+
- -
+
\ No newline at end of file diff --git a/src/app/pages/users/user/component/user-list.component.ts b/src/app/pages/users/user/component/user-list.component.ts index 077821d..c46857f 100644 --- a/src/app/pages/users/user/component/user-list.component.ts +++ b/src/app/pages/users/user/component/user-list.component.ts @@ -16,6 +16,7 @@ import { fuseAnimations } from 'src/@fuse/animations'; import { FuseUtils } from 'src/@fuse/utils'; import { takeUntil } from 'rxjs/internal/operators'; +import { UserListService } from './user-list.service'; @Component({ selector: 'app-user-user-list', @@ -25,14 +26,24 @@ import { takeUntil } from 'rxjs/internal/operators'; encapsulation: ViewEncapsulation.None }) export class UserListComponent implements OnInit, OnDestroy { + displayedColumns = [ 'id', - 'reference', - 'customer', - 'total', - 'payment', + 'phone', 'status', - 'date' + 'totalPrice', + 'point', + 'level', + 'chargeMoney', + 'exchangeMoney', + 'revenueMoney', + 'numberOfBets', + 'referrals', + 'recommender', + 'couponStatus', + 'registerDate', + 'recentConnectDate', + 'recentConnectIp' ]; @ViewChild(MatPaginator, { static: true }) @@ -50,7 +61,10 @@ export class UserListComponent implements OnInit, OnDestroy { /** * Constructor */ - constructor() { + constructor( + private _userListService: UserListService + ) { + // Set the private defaults this._unsubscribeAll = new Subject(); } @@ -62,7 +76,9 @@ export class UserListComponent implements OnInit, OnDestroy { /** * On init */ - ngOnInit(): void {} + ngOnInit(): void { + + } /** * On destroy diff --git a/src/app/pages/users/user/component/user-list.service.ts b/src/app/pages/users/user/component/user-list.service.ts new file mode 100644 index 0000000..3aabf0a --- /dev/null +++ b/src/app/pages/users/user/component/user-list.service.ts @@ -0,0 +1,60 @@ +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router'; +import { BehaviorSubject, Observable } from 'rxjs'; + +@Injectable() +export class UserListService implements Resolve { + + userList: any[]; + onUserListChanged: BehaviorSubject; + + /** + * Constructor + * + * @param {HttpClient} _httpClient + */ + constructor( + private _httpClient: HttpClient + ) { + // Set the defaults + this.onUserListChanged = new BehaviorSubject({}); + } + + /** + * Resolver + * + * @param {ActivatedRouteSnapshot} route + * @param {RouterStateSnapshot} state + * @returns {Observable | Promise | any} + */ + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | any { + return new Promise((resolve, reject) => { + + Promise.all([ + this.getUserList() + ]).then( + () => { + resolve(); + }, + reject + ); + }); + } + + /** + * Get user list + * + * @returns {Promise} + */ + getUserList(): Promise { + return new Promise((resolve, reject) => { + this._httpClient.get('api/users-list') + .subscribe((response: any) => { + this.userList = response; + this.onUserListChanged.next(this.userList); + resolve(response); + }, reject); + }); + } +} diff --git a/src/app/pages/users/user/user-routing.module.ts b/src/app/pages/users/user/user-routing.module.ts index 4559bae..fd14cfd 100644 --- a/src/app/pages/users/user/user-routing.module.ts +++ b/src/app/pages/users/user/user-routing.module.ts @@ -1,12 +1,18 @@ import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; +import { UserDetailComponent } from './component/user-detail.component'; import { UserListComponent } from './component/user-list.component'; - +import { UserListService } from './component/user-list.service'; const routes: Routes = [ + { path: '', - component: UserListComponent + component: UserListComponent, + }, + { + path: 'user-list/:userId', + component: UserDetailComponent } ]; @@ -14,4 +20,4 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) -export class UserRoutingModule {} +export class UserRoutingModule { } diff --git a/src/app/pages/users/user/user.module.ts b/src/app/pages/users/user/user.module.ts index c768da1..f084480 100644 --- a/src/app/pages/users/user/user.module.ts +++ b/src/app/pages/users/user/user.module.ts @@ -13,10 +13,12 @@ import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table'; import { MatTabsModule } from '@angular/material/tabs'; +import { AgmCoreModule } from '@agm/core'; import { FuseSharedModule } from 'src/@fuse/shared.module'; import { UserRoutingModule } from './user-routing.module'; import { COMPONENTS } from './component'; +import { UserListService } from './component/user-list.service'; @NgModule({ imports: [ @@ -34,10 +36,17 @@ import { COMPONENTS } from './component'; MatTableModule, MatTabsModule, + AgmCoreModule.forRoot({ + apiKey: 'AIzaSyD81ecsCj4yYpcXSLFcYU97PvRsE_X8Bx8' + }), + FuseSharedModule, UserRoutingModule ], - declarations: [...COMPONENTS] + declarations: [...COMPONENTS], + providers: [ + UserListService + ] }) -export class UserModule {} +export class UserModule { } diff --git a/src/app/pages/users/users-routing.module.ts b/src/app/pages/users/users-routing.module.ts index a16c34b..5b436fd 100644 --- a/src/app/pages/users/users-routing.module.ts +++ b/src/app/pages/users/users-routing.module.ts @@ -3,7 +3,7 @@ import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { - path: 'users', + path: 'user-list', loadChildren: './user/user.module#UserModule' } ]; @@ -12,4 +12,4 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) -export class UsersRoutingModule {} +export class UsersRoutingModule { } diff --git a/tsconfig.json b/tsconfig.json index 30956ae..a6444f0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,6 @@ }, "angularCompilerOptions": { "fullTemplateTypeCheck": true, - "strictInjectionParameters": true + "strictInjectionParameters": true, } -} +} \ No newline at end of file diff --git a/tslint.json b/tslint.json index f0adae9..f4ae1d1 100644 --- a/tslint.json +++ b/tslint.json @@ -6,6 +6,7 @@ "deprecation": { "severity": "warning" }, + "completed-docs": false, "component-class-suffix": true, "contextual-lifecycle": true, "directive-class-suffix": true,