Merge branch 'feature/BETERAN-BACKEND-APP-BROWSER-init' of https://gitlab.loafle.net/bet/beteran-backend-app-browser into feature/BETERAN-BACKEND-APP-BROWSER-init

This commit is contained in:
Park Byung Eun 2022-08-09 10:15:41 +00:00
commit d8fa7066ad
8 changed files with 134 additions and 15 deletions

View File

@ -21,6 +21,7 @@ import { WebStorageModule } from 'app/core/web-storage/web-storage.module';
import { environment } from 'environments/environment';
import { DomainModule } from 'app/modules/polyglot/domain/domain.module';
import { MemberModule } from 'app/modules/polyglot/member/member.module';
const routerConfig: ExtraOptions = {
@ -53,6 +54,7 @@ const routerConfig: ExtraOptions = {
NatsModule.forRoot(environment.nats),
WebStorageModule.forRoot({}),
DomainModule.forRoot(),
MemberModule.forRoot(),
],
bootstrap: [AppComponent],

View File

@ -26,7 +26,7 @@
</th>
<td mat-cell *matCellDef="let info" style="text-align: center">
<span class="font-medium text-right">
{{ info.idx }}
{{ info.getId() }}
</span>
</td>
</ng-container>
@ -42,7 +42,7 @@
</th>
<td mat-cell *matCellDef="let info" style="text-align: center">
<span class="font-medium text-right">
{{ info.domain }}
{{ info.getUrl() }}
</span>
</td>
</ng-container>

View File

@ -31,6 +31,9 @@ import { fuseAnimations } from '@fuse/animations';
import { FuseConfirmationService } from '@fuse/services/confirmation';
import { DomainService } from '../services/domain.service';
import { MatSelectChange } from '@angular/material/select';
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
import { ActivatedRoute } from '@angular/router';
import { ListSitesResponse } from 'app/modules/protobuf/c2se/backend/site_pb';
@Component({
selector: 'settings-domain-list',
@ -93,10 +96,11 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
* Constructor
*/
constructor(
private _activatedRoute: ActivatedRoute,
private _changeDetectorRef: ChangeDetectorRef,
private _fuseConfirmationService: FuseConfirmationService,
private _formBuilder: FormBuilder,
private _domainService: DomainService
private __siteService: SiteService
) {}
// -----------------------------------------------------------------------------------------------------
@ -108,14 +112,24 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
*/
ngOnInit(): void {
// Get the products
this._domainService.domainSetting$
/* this._domainService.domainSetting$
.pipe(takeUntil(this._unsubscribeAll))
.subscribe((domainSetting: any | undefined) => {
this.domainSettingDataSource = domainSetting.domain;
this.domainRegistrationDataSource = domainSetting.bota;
// Mark for check
this._changeDetectorRef.markForCheck();
});
}); */
this._activatedRoute.data.subscribe((data) => {
let listSitesResult: ListSitesResponse.Result = data['listSites'];
this.domainSettingDataSource.data = listSitesResult.getSitesList();
console.log('dddd', listSitesResult.getSitesList());
// Mark for check
this._changeDetectorRef.markForCheck();
});
}
/**

View File

@ -2,14 +2,14 @@ import { Route } from '@angular/router';
import { ListComponent } from './components/list.component';
import { DomainResolver } from './resolvers/domain.resolver';
import { SiteResolver } from './resolvers/site.resolver';
export const domainRoutes: Route[] = [
{
path: '',
component: ListComponent,
resolve: {
domain: DomainResolver,
listSites: SiteResolver,
},
},
];

View File

@ -5,18 +5,18 @@ import {
Router,
RouterStateSnapshot,
} from '@angular/router';
import { SiteService } from 'app/modules/polyglot/domain/services/site.service';
import { ListSitesResponse } from 'app/modules/protobuf/c2se/backend/site_pb';
import { catchError, Observable, throwError } from 'rxjs';
import { DomainService } from '../services/domain.service';
@Injectable({
providedIn: 'root',
})
export class DomainResolver implements Resolve<any> {
export class SiteResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _domainService: DomainService) {}
constructor(private __siteService: SiteService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
@ -31,9 +31,10 @@ export class DomainResolver implements Resolve<any> {
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<{
domainSetting: any;
}> {
return this._domainService.getDomainSetting();
):
| Observable<ListSitesResponse.Result>
| Promise<ListSitesResponse.Result>
| ListSitesResponse.Result {
return this.__siteService.listSites();
}
}

View File

@ -0,0 +1,16 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { SERVICES } from './services';
@NgModule({})
export class DomainRootModule {}
@NgModule({})
export class DomainModule {
public static forRoot(): ModuleWithProviders<DomainRootModule> {
return {
ngModule: DomainRootModule,
providers: [...SERVICES],
};
}
}

View File

@ -0,0 +1,5 @@
import { Type } from '@angular/core';
import { SiteService } from './site.service';
export const SERVICES: Type<any>[] = [SiteService];

View File

@ -0,0 +1,81 @@
import { Injectable } from '@angular/core';
import { NatsService } from 'app/core/nats/services/nats.service';
import * as nats from 'nats.ws';
import { Error } from 'app/modules/protobuf/protobuf/rpc/error_pb';
import {
ListSitesRequest,
ListSitesResponse,
CreateSiteRequest,
CreateSiteResponse,
UpdateSiteRequest,
UpdateSiteResponse,
DeleteSiteRequest,
DeleteSiteResponse,
SUBJECT_LIST_SITES,
SUBJECT_CREATE_SITE,
SUBJECT_UPDATE_SITE,
SUBJECT_DELETE_SITE,
} from 'app/modules/protobuf/c2se/backend/site_pb';
import { Site } from 'app/modules/protobuf/models/domain/site_pb';
@Injectable({
providedIn: 'root',
})
export class SiteService {
/**
* Constructor
*/
constructor(private __natsService: NatsService) {}
// -----------------------------------------------------------------------------------------------------
// @ Accessors
// -----------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
listSites(): Promise<ListSitesResponse.Result> {
return new Promise<ListSitesResponse.Result>((resolve, reject) => {
let req = new ListSitesRequest();
this.__natsService
.request<ListSitesResponse.Result>(
SUBJECT_LIST_SITES,
req.serializeBinary(),
ListSitesResponse.deserializeBinary
)
.then((result) => {
console.log('success', result, result.getSitesList());
return resolve(result);
})
.catch((e: Error) => {
console.log('failed', e);
reject(e);
});
});
}
createSite(): Promise<CreateSiteResponse.Result> {
return new Promise<CreateSiteResponse.Result>((resolve, reject) => {
let req = new CreateSiteRequest();
this.__natsService
.request<CreateSiteResponse.Result>(
SUBJECT_CREATE_SITE,
req.serializeBinary(),
CreateSiteResponse.deserializeBinary
)
.then((result) => {
console.log('success', result, result.getSite());
return resolve(result);
})
.catch((e: Error) => {
console.log('failed', e);
return reject(e);
});
});
}
}