diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 02ea0c3..9b74490 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -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],
diff --git a/src/app/modules/admin/settings/domain/components/list.component.html b/src/app/modules/admin/settings/domain/components/list.component.html
index a5fbf40..4c842f0 100644
--- a/src/app/modules/admin/settings/domain/components/list.component.html
+++ b/src/app/modules/admin/settings/domain/components/list.component.html
@@ -26,7 +26,7 @@
- {{ info.idx }}
+ {{ info.getId() }}
|
@@ -42,7 +42,7 @@
- {{ info.domain }}
+ {{ info.getUrl() }}
|
diff --git a/src/app/modules/admin/settings/domain/components/list.component.ts b/src/app/modules/admin/settings/domain/components/list.component.ts
index b677369..536dd5e 100644
--- a/src/app/modules/admin/settings/domain/components/list.component.ts
+++ b/src/app/modules/admin/settings/domain/components/list.component.ts
@@ -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();
+ });
}
/**
diff --git a/src/app/modules/admin/settings/domain/domain.routing.ts b/src/app/modules/admin/settings/domain/domain.routing.ts
index 1243f44..4b6ecd0 100644
--- a/src/app/modules/admin/settings/domain/domain.routing.ts
+++ b/src/app/modules/admin/settings/domain/domain.routing.ts
@@ -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,
},
},
];
diff --git a/src/app/modules/admin/settings/domain/resolvers/domain.resolver.ts b/src/app/modules/admin/settings/domain/resolvers/site.resolver.ts
similarity index 60%
rename from src/app/modules/admin/settings/domain/resolvers/domain.resolver.ts
rename to src/app/modules/admin/settings/domain/resolvers/site.resolver.ts
index a0349cf..c01e508 100644
--- a/src/app/modules/admin/settings/domain/resolvers/domain.resolver.ts
+++ b/src/app/modules/admin/settings/domain/resolvers/site.resolver.ts
@@ -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 {
+export class SiteResolver implements Resolve {
/**
* Constructor
*/
- constructor(private _domainService: DomainService) {}
+ constructor(private __siteService: SiteService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
@@ -31,9 +31,10 @@ export class DomainResolver implements Resolve {
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
- ): Observable<{
- domainSetting: any;
- }> {
- return this._domainService.getDomainSetting();
+ ):
+ | Observable
+ | Promise
+ | ListSitesResponse.Result {
+ return this.__siteService.listSites();
}
}
diff --git a/src/app/modules/polyglot/domain/domain.module.ts b/src/app/modules/polyglot/domain/domain.module.ts
new file mode 100644
index 0000000..208755c
--- /dev/null
+++ b/src/app/modules/polyglot/domain/domain.module.ts
@@ -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 {
+ return {
+ ngModule: DomainRootModule,
+ providers: [...SERVICES],
+ };
+ }
+}
diff --git a/src/app/modules/polyglot/domain/services/index.ts b/src/app/modules/polyglot/domain/services/index.ts
new file mode 100644
index 0000000..2316ce7
--- /dev/null
+++ b/src/app/modules/polyglot/domain/services/index.ts
@@ -0,0 +1,5 @@
+import { Type } from '@angular/core';
+
+import { SiteService } from './site.service';
+
+export const SERVICES: Type[] = [SiteService];
diff --git a/src/app/modules/polyglot/domain/services/site.service.ts b/src/app/modules/polyglot/domain/services/site.service.ts
new file mode 100644
index 0000000..2c5fb98
--- /dev/null
+++ b/src/app/modules/polyglot/domain/services/site.service.ts
@@ -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 {
+ return new Promise((resolve, reject) => {
+ let req = new ListSitesRequest();
+
+ this.__natsService
+ .request(
+ 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 {
+ return new Promise((resolve, reject) => {
+ let req = new CreateSiteRequest();
+
+ this.__natsService
+ .request(
+ 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);
+ });
+ });
+ }
+}