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:
commit
d8fa7066ad
|
@ -21,6 +21,7 @@ import { WebStorageModule } from 'app/core/web-storage/web-storage.module';
|
||||||
|
|
||||||
import { environment } from 'environments/environment';
|
import { environment } from 'environments/environment';
|
||||||
|
|
||||||
|
import { DomainModule } from 'app/modules/polyglot/domain/domain.module';
|
||||||
import { MemberModule } from 'app/modules/polyglot/member/member.module';
|
import { MemberModule } from 'app/modules/polyglot/member/member.module';
|
||||||
|
|
||||||
const routerConfig: ExtraOptions = {
|
const routerConfig: ExtraOptions = {
|
||||||
|
@ -53,6 +54,7 @@ const routerConfig: ExtraOptions = {
|
||||||
NatsModule.forRoot(environment.nats),
|
NatsModule.forRoot(environment.nats),
|
||||||
WebStorageModule.forRoot({}),
|
WebStorageModule.forRoot({}),
|
||||||
|
|
||||||
|
DomainModule.forRoot(),
|
||||||
MemberModule.forRoot(),
|
MemberModule.forRoot(),
|
||||||
],
|
],
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
</th>
|
</th>
|
||||||
<td mat-cell *matCellDef="let info" style="text-align: center">
|
<td mat-cell *matCellDef="let info" style="text-align: center">
|
||||||
<span class="font-medium text-right">
|
<span class="font-medium text-right">
|
||||||
{{ info.idx }}
|
{{ info.getId() }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
</th>
|
</th>
|
||||||
<td mat-cell *matCellDef="let info" style="text-align: center">
|
<td mat-cell *matCellDef="let info" style="text-align: center">
|
||||||
<span class="font-medium text-right">
|
<span class="font-medium text-right">
|
||||||
{{ info.domain }}
|
{{ info.getUrl() }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
|
@ -31,6 +31,9 @@ import { fuseAnimations } from '@fuse/animations';
|
||||||
import { FuseConfirmationService } from '@fuse/services/confirmation';
|
import { FuseConfirmationService } from '@fuse/services/confirmation';
|
||||||
import { DomainService } from '../services/domain.service';
|
import { DomainService } from '../services/domain.service';
|
||||||
import { MatSelectChange } from '@angular/material/select';
|
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({
|
@Component({
|
||||||
selector: 'settings-domain-list',
|
selector: 'settings-domain-list',
|
||||||
|
@ -93,10 +96,11 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
constructor(
|
constructor(
|
||||||
|
private _activatedRoute: ActivatedRoute,
|
||||||
private _changeDetectorRef: ChangeDetectorRef,
|
private _changeDetectorRef: ChangeDetectorRef,
|
||||||
private _fuseConfirmationService: FuseConfirmationService,
|
private _fuseConfirmationService: FuseConfirmationService,
|
||||||
private _formBuilder: FormBuilder,
|
private _formBuilder: FormBuilder,
|
||||||
private _domainService: DomainService
|
private __siteService: SiteService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
|
@ -108,14 +112,24 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// Get the products
|
// Get the products
|
||||||
this._domainService.domainSetting$
|
/* this._domainService.domainSetting$
|
||||||
.pipe(takeUntil(this._unsubscribeAll))
|
.pipe(takeUntil(this._unsubscribeAll))
|
||||||
.subscribe((domainSetting: any | undefined) => {
|
.subscribe((domainSetting: any | undefined) => {
|
||||||
this.domainSettingDataSource = domainSetting.domain;
|
this.domainSettingDataSource = domainSetting.domain;
|
||||||
this.domainRegistrationDataSource = domainSetting.bota;
|
this.domainRegistrationDataSource = domainSetting.bota;
|
||||||
// Mark for check
|
// Mark for check
|
||||||
this._changeDetectorRef.markForCheck();
|
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();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,14 +2,14 @@ import { Route } from '@angular/router';
|
||||||
|
|
||||||
import { ListComponent } from './components/list.component';
|
import { ListComponent } from './components/list.component';
|
||||||
|
|
||||||
import { DomainResolver } from './resolvers/domain.resolver';
|
import { SiteResolver } from './resolvers/site.resolver';
|
||||||
|
|
||||||
export const domainRoutes: Route[] = [
|
export const domainRoutes: Route[] = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
component: ListComponent,
|
component: ListComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
domain: DomainResolver,
|
listSites: SiteResolver,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -5,18 +5,18 @@ import {
|
||||||
Router,
|
Router,
|
||||||
RouterStateSnapshot,
|
RouterStateSnapshot,
|
||||||
} from '@angular/router';
|
} 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 { catchError, Observable, throwError } from 'rxjs';
|
||||||
|
|
||||||
import { DomainService } from '../services/domain.service';
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class DomainResolver implements Resolve<any> {
|
export class SiteResolver implements Resolve<any> {
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
constructor(private _domainService: DomainService) {}
|
constructor(private __siteService: SiteService) {}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------------------------------
|
||||||
// @ Public methods
|
// @ Public methods
|
||||||
|
@ -31,9 +31,10 @@ export class DomainResolver implements Resolve<any> {
|
||||||
resolve(
|
resolve(
|
||||||
route: ActivatedRouteSnapshot,
|
route: ActivatedRouteSnapshot,
|
||||||
state: RouterStateSnapshot
|
state: RouterStateSnapshot
|
||||||
): Observable<{
|
):
|
||||||
domainSetting: any;
|
| Observable<ListSitesResponse.Result>
|
||||||
}> {
|
| Promise<ListSitesResponse.Result>
|
||||||
return this._domainService.getDomainSetting();
|
| ListSitesResponse.Result {
|
||||||
|
return this.__siteService.listSites();
|
||||||
}
|
}
|
||||||
}
|
}
|
16
src/app/modules/polyglot/domain/domain.module.ts
Normal file
16
src/app/modules/polyglot/domain/domain.module.ts
Normal 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],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
5
src/app/modules/polyglot/domain/services/index.ts
Normal file
5
src/app/modules/polyglot/domain/services/index.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import { Type } from '@angular/core';
|
||||||
|
|
||||||
|
import { SiteService } from './site.service';
|
||||||
|
|
||||||
|
export const SERVICES: Type<any>[] = [SiteService];
|
81
src/app/modules/polyglot/domain/services/site.service.ts
Normal file
81
src/app/modules/polyglot/domain/services/site.service.ts
Normal 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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user