diff --git a/projects/explorer/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js b/projects/explorer/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js index 3bd94ea73..ad9eb62e9 100644 --- a/projects/explorer/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js +++ b/projects/explorer/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js @@ -103,6 +103,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: true, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/explorer/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js b/projects/explorer/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js index 55add7b9e..b1bc34e4f 100644 --- a/projects/explorer/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js +++ b/projects/explorer/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js @@ -103,6 +103,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: false, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/explorer/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js b/projects/explorer/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js index dca5d7eee..1e6708819 100644 --- a/projects/explorer/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js +++ b/projects/explorer/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js @@ -102,6 +102,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: true, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/explorer/src/app/models/config.service.ts b/projects/explorer/src/app/models/config.service.ts index d7243f951..bfe152478 100644 --- a/projects/explorer/src/app/models/config.service.ts +++ b/projects/explorer/src/app/models/config.service.ts @@ -30,10 +30,14 @@ export type Config = { monitor?: { monitorURL: string; }; - nftMint: { + nftMint?: { enabled: boolean; nftClasses: string[]; }; + developer?: { + enabled: boolean; + developerURL: string; + }; navigations: { name: string; link: string; diff --git a/projects/explorer/src/assets/config.js b/projects/explorer/src/assets/config.js index bf1e18275..ff2a68882 100644 --- a/projects/explorer/src/assets/config.js +++ b/projects/explorer/src/assets/config.js @@ -104,6 +104,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: true, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/portal/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js b/projects/portal/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js index 3bd94ea73..ad9eb62e9 100644 --- a/projects/portal/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js +++ b/projects/portal/editions/ununifi/launch/ununifi-alpha-test/firebase-hosting/config.js @@ -103,6 +103,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: true, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/portal/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js b/projects/portal/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js index 55add7b9e..b1bc34e4f 100644 --- a/projects/portal/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js +++ b/projects/portal/editions/ununifi/launch/ununifi-beta-test/firebase-hosting/config.js @@ -103,6 +103,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: false, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/portal/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js b/projects/portal/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js index dca5d7eee..1e6708819 100644 --- a/projects/portal/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js +++ b/projects/portal/editions/ununifi/launch/ununifi-stable/firebase-hosting/config.js @@ -102,6 +102,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: true, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, }, diff --git a/projects/portal/src/app/app-routing.module.ts b/projects/portal/src/app/app-routing.module.ts index d477f1557..b44f7a641 100644 --- a/projects/portal/src/app/app-routing.module.ts +++ b/projects/portal/src/app/app-routing.module.ts @@ -77,6 +77,11 @@ const routes: Routes = [ loadChildren: () => import('./pages/derivatives/derivatives.module').then((m) => m.AppDerivativesModule), }, + { + path: 'developers', + loadChildren: () => + import('./pages/developers/developers.module').then((m) => m.AppDevelopersModule), + }, ]; @NgModule({ diff --git a/projects/portal/src/app/app.component.ts b/projects/portal/src/app/app.component.ts index 534fd6572..1e3b7fd1d 100644 --- a/projects/portal/src/app/app.component.ts +++ b/projects/portal/src/app/app.component.ts @@ -49,6 +49,20 @@ export class AppComponent implements OnInit { this.currentStoredWallet$ = this.walletService.currentStoredWallet$; this.navigations$ = this.config$.pipe( map((config) => { + if (config?.extension?.developer?.enabled) { + config?.extension?.navigations.unshift({ + name: 'Developers', + link: '/portal/developers', + icon: 'build', + }); + } + if (config?.extension?.nftMint?.enabled) { + config.extension.navigations.unshift({ + name: 'NFT Mint', + link: '/portal/nfts/mint', + icon: 'add_photo_alternate', + }); + } if (config?.extension?.faucet?.filter((faucet) => faucet.hasFaucet == true).length) { config.extension.navigations.unshift({ name: 'Faucet', @@ -63,13 +77,6 @@ export class AppComponent implements OnInit { icon: 'monitor', }); } - if (config?.extension?.nftMint.enabled) { - config.extension.navigations.unshift({ - name: 'NFT Mint', - link: '/portal/nfts/mint', - icon: 'add_photo_alternate', - }); - } return config?.extension?.navigations; }), ); diff --git a/projects/portal/src/app/models/config.service.ts b/projects/portal/src/app/models/config.service.ts index d7243f951..bfe152478 100644 --- a/projects/portal/src/app/models/config.service.ts +++ b/projects/portal/src/app/models/config.service.ts @@ -30,10 +30,14 @@ export type Config = { monitor?: { monitorURL: string; }; - nftMint: { + nftMint?: { enabled: boolean; nftClasses: string[]; }; + developer?: { + enabled: boolean; + developerURL: string; + }; navigations: { name: string; link: string; diff --git a/projects/portal/src/app/models/wallets/wallet-developer.guard.ts b/projects/portal/src/app/models/wallets/wallet-developer.guard.ts new file mode 100644 index 000000000..117c3b3eb --- /dev/null +++ b/projects/portal/src/app/models/wallets/wallet-developer.guard.ts @@ -0,0 +1,44 @@ +import { WalletApplicationService } from './wallet.application.service'; +import { StoredWallet } from './wallet.model'; +import { WalletService } from './wallet.service'; +import { Injectable } from '@angular/core'; +import { + CanActivate, + ActivatedRouteSnapshot, + RouterStateSnapshot, + UrlTree, + Router, +} from '@angular/router'; + +@Injectable({ + providedIn: 'root', +}) +export class WalletDeveloperGuard implements CanActivate { + constructor( + private readonly router: Router, + private readonly walletService: WalletService, + private readonly walletApplicationService: WalletApplicationService, + ) {} + + async canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise { + const devAddress = [ + 'ununifi155u042u8wk3al32h3vzxu989jj76k4zcu44v6w', + 'ununifi1v0h8j7x7kfys29kj4uwdudcc9y0nx6twwxahla', + 'ununifi1y3t7sp0nfe2nfda7r9gf628g6ym6e7d44evfv6', + 'ununifi1pp2ruuhs0k7ayaxjupwj4k5qmgh0d72wrdyjyu', + 'ununifi1gnfsfp340h33glkccjet38faxwkspwpz3r4raj', + ]; + const currentStoredWallet: StoredWallet | undefined = + await this.walletService.getCurrentStoredWallet(); + if ( + currentStoredWallet && + devAddress.find((address) => address == currentStoredWallet.address) + ) { + return true; + } else { + alert('Please login with developer account.'); + this.router.navigate(['']); + return true; + } + } +} diff --git a/projects/portal/src/app/pages/developers/developers-routing.module.ts b/projects/portal/src/app/pages/developers/developers-routing.module.ts new file mode 100644 index 000000000..7823e787a --- /dev/null +++ b/projects/portal/src/app/pages/developers/developers-routing.module.ts @@ -0,0 +1,18 @@ +import { WalletDeveloperGuard } from '../../models/wallets/wallet-developer.guard'; +import { DevelopersComponent } from './developers.component'; +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +const routes: Routes = [ + { + path: '', + component: DevelopersComponent, + canActivate: [WalletDeveloperGuard], + }, +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class DevelopersRoutingModule {} diff --git a/projects/portal/src/app/pages/developers/developers.component.css b/projects/portal/src/app/pages/developers/developers.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/projects/portal/src/app/pages/developers/developers.component.html b/projects/portal/src/app/pages/developers/developers.component.html new file mode 100644 index 000000000..93d29d955 --- /dev/null +++ b/projects/portal/src/app/pages/developers/developers.component.html @@ -0,0 +1,6 @@ + diff --git a/projects/portal/src/app/pages/developers/developers.component.ts b/projects/portal/src/app/pages/developers/developers.component.ts new file mode 100644 index 000000000..6ca164234 --- /dev/null +++ b/projects/portal/src/app/pages/developers/developers.component.ts @@ -0,0 +1,49 @@ +import { Config, ConfigService } from '../../models/config.service'; +import { HttpClient } from '@angular/common/http'; +import { Component, OnInit } from '@angular/core'; +import { Observable, of } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; + +@Component({ + selector: 'app-developers', + templateUrl: './developers.component.html', + styleUrls: ['./developers.component.css'], +}) +export class DevelopersComponent implements OnInit { + config$: Observable; + version$: Observable; + + constructor(private configService: ConfigService, private http: HttpClient) { + this.config$ = this.configService.config$; + this.version$ = this.config$.pipe( + mergeMap((conf) => { + if (conf && conf.extension && conf.extension.developer) { + return this.http.get(conf.extension.developer.developerURL + '/version', { + responseType: 'text', + }); + } else { + return of(undefined); + } + }), + ); + } + + ngOnInit(): void {} + + async onRebuild($event: Config) { + await this.http + .get($event?.extension?.developer?.developerURL + '/execute', { + responseType: 'text', + }) + .toPromise(); + alert('Successfully Sent Rebuild Request'); + } + async onRestart($event: Config) { + await this.http + .get($event?.extension?.developer?.developerURL + '/reset', { + responseType: 'text', + }) + .toPromise(); + alert('Successfully Sent Rebuild Request'); + } +} diff --git a/projects/portal/src/app/pages/developers/developers.module.ts b/projects/portal/src/app/pages/developers/developers.module.ts new file mode 100644 index 000000000..e3d7c888c --- /dev/null +++ b/projects/portal/src/app/pages/developers/developers.module.ts @@ -0,0 +1,11 @@ +import { DevelopersModule } from '../../views/developers/developers.module'; +import { DevelopersRoutingModule } from './developers-routing.module'; +import { DevelopersComponent } from './developers.component'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; + +@NgModule({ + declarations: [DevelopersComponent], + imports: [CommonModule, DevelopersRoutingModule, DevelopersModule], +}) +export class AppDevelopersModule {} diff --git a/projects/portal/src/app/pages/nfts/mint/mint.component.ts b/projects/portal/src/app/pages/nfts/mint/mint.component.ts index 483d6ba98..9d9068f92 100644 --- a/projects/portal/src/app/pages/nfts/mint/mint.component.ts +++ b/projects/portal/src/app/pages/nfts/mint/mint.component.ts @@ -27,7 +27,7 @@ export class MintComponent implements OnInit { map((wallet) => wallet.address), ); const config$ = this.configService.config$; - this.classes$ = config$.pipe(map((config) => config?.extension?.nftMint.nftClasses)); + this.classes$ = config$.pipe(map((config) => config?.extension?.nftMint?.nftClasses)); this.selectedClass$ = this.classes$.pipe(map((classes) => (classes ? classes[0] : ''))); } diff --git a/projects/portal/src/app/views/developers/developers.component.css b/projects/portal/src/app/views/developers/developers.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/projects/portal/src/app/views/developers/developers.component.html b/projects/portal/src/app/views/developers/developers.component.html new file mode 100644 index 000000000..4dfc89d1e --- /dev/null +++ b/projects/portal/src/app/views/developers/developers.component.html @@ -0,0 +1,41 @@ +
+
+

Developers (Only Stable & Alpha)

+
+ +
+
+
+

Node Operations

+ +
+ + + + + + + +
Version{{ version }}
+
+
+
+
+
diff --git a/projects/portal/src/app/views/developers/developers.component.ts b/projects/portal/src/app/views/developers/developers.component.ts new file mode 100644 index 000000000..7dee1fab8 --- /dev/null +++ b/projects/portal/src/app/views/developers/developers.component.ts @@ -0,0 +1,39 @@ +import { Config } from '../../models/config.service'; +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; + +@Component({ + selector: 'view-developers', + templateUrl: './developers.component.html', + styleUrls: ['./developers.component.css'], +}) +export class DevelopersComponent implements OnInit { + @Input() + config?: Config | null; + @Input() + version?: string | null; + + @Output() + rebuild = new EventEmitter(); + @Output() + restart = new EventEmitter(); + + constructor() {} + + ngOnInit(): void {} + + onRebuild() { + if (!this.config) { + alert('Invalid Config'); + return; + } + this.rebuild.emit(this.config); + } + + onRestart() { + if (!this.config) { + alert('Invalid Config'); + return; + } + this.restart.emit(this.config); + } +} diff --git a/projects/portal/src/app/views/developers/developers.module.ts b/projects/portal/src/app/views/developers/developers.module.ts new file mode 100644 index 000000000..2970f76cd --- /dev/null +++ b/projects/portal/src/app/views/developers/developers.module.ts @@ -0,0 +1,11 @@ +import { DevelopersComponent } from './developers.component'; +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { MaterialModule } from '../material.module'; + +@NgModule({ + declarations: [DevelopersComponent], + imports: [CommonModule,MaterialModule], + exports: [DevelopersComponent], +}) +export class DevelopersModule {} diff --git a/projects/portal/src/assets/config.js b/projects/portal/src/assets/config.js index bf1e18275..ff2a68882 100644 --- a/projects/portal/src/assets/config.js +++ b/projects/portal/src/assets/config.js @@ -104,6 +104,10 @@ const configs = [ enabled: true, nftClasses: ['ununifi-1AFC3C85B52311F13161F724B284EF900458E3B3'], }, + developer: { + enabled: true, + developerURL: `http://${domainCauchyEA}:3030`, + }, navigations: [], messageModules, },