More useful prod & dev modes in dashboard
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
"@clr/ui": "^2.1.1",
|
||||
"@webcomponents/custom-elements": "^1.0.0",
|
||||
"frontblock": "latest",
|
||||
"frontblock-generic": "latest",
|
||||
"frontblock-generic": "^0.22.0",
|
||||
"key-file-storage": "^2.2.4",
|
||||
"rxjs": "~6.5.2",
|
||||
"systemjs": "^0.21.3",
|
||||
|
||||
+33
-3
@@ -1,11 +1,41 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { fbind } from 'q';
|
||||
import { FrontblockApiConf } from 'frontblock';
|
||||
import { SubscriptionResponse, parseResponse, SuccessResponse } from 'frontblock-generic/Types.js';
|
||||
import { environment } from "../../environments/environment"
|
||||
|
||||
let fb
|
||||
if(environment.production){
|
||||
fb = window["fb"]
|
||||
}else{
|
||||
fb = {
|
||||
ApiClient : {
|
||||
setConfig: async () => {
|
||||
await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('Promise A win!');
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
getConsumptions: async () => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve([new SubscriptionResponse("654", "321"), new SubscriptionResponse("456", "123")]);
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
getSubscriptions: async () => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve([new SubscriptionResponse("321"), new SubscriptionResponse("123")]);
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
unsubscribe: (uid) => new SuccessResponse(),
|
||||
quit: (uid) => new SuccessResponse()
|
||||
|
||||
declare const fb
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@Component({
|
||||
selector: 'consumptions',
|
||||
template: `
|
||||
+3
-4
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { SidebarEntry } from 'frontblock-generic/Plugin';
|
||||
declare const fb
|
||||
import { environment } from "../../environments/environment"
|
||||
|
||||
@Component({
|
||||
selector: 'apiclient', //!!!!
|
||||
template: `
|
||||
@@ -8,9 +9,7 @@ declare const fb
|
||||
<div class="clr-col-lg-auto">
|
||||
<settings></settings>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clr-row">
|
||||
<div class="clr-col">
|
||||
<div class="clr-col-12 clr-col-lg-12 clr-col-xl-12 clr-col-sm-12">
|
||||
<consumptions></consumptions>
|
||||
</div>
|
||||
</div>
|
||||
+16
-3
@@ -1,10 +1,23 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { fbind } from 'q';
|
||||
import { FrontblockApiConf } from 'frontblock';
|
||||
import { environment } from "../../environments/environment"
|
||||
|
||||
|
||||
declare const fb
|
||||
|
||||
let fb
|
||||
if(environment.production){
|
||||
fb = window["fb"]
|
||||
}else{
|
||||
fb = {
|
||||
ApiClient : {
|
||||
setConfig: async () => {
|
||||
await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('Promise A win!');
|
||||
}, 500)
|
||||
})}
|
||||
}
|
||||
}
|
||||
}
|
||||
@Component({
|
||||
selector: 'settings',
|
||||
template: `
|
||||
+33
-1
@@ -2,9 +2,41 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { fbind } from 'q';
|
||||
import { FrontblockApiConf } from 'frontblock';
|
||||
import { SubscriptionResponse, SuccessResponse, ErrorResponse, parseResponse } from 'frontblock-generic/Types.js';
|
||||
import { environment } from "../../environments/environment"
|
||||
|
||||
let fb
|
||||
if(environment.production){
|
||||
fb = window["fb"]
|
||||
}else{
|
||||
fb = {
|
||||
ApiClient : {
|
||||
setConfig: async () => {
|
||||
await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve('Promise A win!');
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
getConsumptions: async () => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve([new SubscriptionResponse("654", "321"), new SubscriptionResponse("456", "123")]);
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
getSubscriptions: async () => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve([new SubscriptionResponse("321"), new SubscriptionResponse("123")]);
|
||||
}, 500)
|
||||
})
|
||||
},
|
||||
unsubscribe: (uid) => new SuccessResponse(),
|
||||
quit: (uid) => new SuccessResponse()
|
||||
|
||||
declare const fb
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'subscriptions',
|
||||
@@ -0,0 +1,41 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { ApiclientDevComponent as ApiclientComponent } from './apiclient-dev.component';
|
||||
import { ApiclientFormComponent } from './apiclient-settings-form.component';
|
||||
import { ApiclientConsumptionComponent } from './apiclient-consumptions.component';
|
||||
import { ApiclientSubscriptionComponent } from './apiclient-subscriptions.component';
|
||||
|
||||
import { FrontendPlugin, SidebarEntry } from 'frontblock-generic/Plugin';
|
||||
import { ClarityModule } from '@clr/angular';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ClarityModule,
|
||||
|
||||
CommonModule,
|
||||
RouterModule.forChild([
|
||||
{path: "apiclient", component: ApiclientComponent},
|
||||
]),
|
||||
],
|
||||
exports: [RouterModule],
|
||||
declarations: [
|
||||
ApiclientComponent,
|
||||
ApiclientFormComponent,
|
||||
ApiclientConsumptionComponent,
|
||||
ApiclientSubscriptionComponent
|
||||
]
|
||||
})
|
||||
export class PluginModule implements FrontendPlugin{
|
||||
getSidebarEntry(): SidebarEntry {
|
||||
return {
|
||||
icon: "key",
|
||||
route: "apiclient",
|
||||
text: "Api client",
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
|
||||
import { SidebarEntry } from 'frontblock-generic/Plugin';
|
||||
declare const fb
|
||||
@Component({
|
||||
selector: 'pluginmanager', //!!!!
|
||||
selector: 'debug', //!!!!
|
||||
template: `
|
||||
<div class="clr-row">
|
||||
<div class="clr-col">
|
||||
@@ -30,7 +30,7 @@ declare const fb
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class PluginmanagerDevComponent implements OnInit {
|
||||
export class PluginmanagerDEBUG implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
||||
import { PluginmanagerDEBUG } from './debug.component';
|
||||
import { PluginsComponent } from './plugins.component';
|
||||
|
||||
import { FrontendPlugin, SidebarEntries } from 'frontblock-generic/Plugin';
|
||||
import { ClarityModule } from '@clr/angular';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
FormsModule,
|
||||
ClarityModule,
|
||||
|
||||
CommonModule,
|
||||
RouterModule.forChild([
|
||||
{path: "debug", component: PluginmanagerDEBUG},
|
||||
{path: "plugins", component: PluginsComponent}
|
||||
]),
|
||||
],
|
||||
exports: [RouterModule],
|
||||
declarations: [
|
||||
PluginmanagerDEBUG,
|
||||
PluginsComponent
|
||||
]
|
||||
})
|
||||
export class PluginModule implements FrontendPlugin{
|
||||
getSidebarEntry(): SidebarEntries {
|
||||
return {
|
||||
icon: "plugin",
|
||||
text: "Plugin manager",
|
||||
parentRoute: "pluginmanager",
|
||||
links: [{
|
||||
route: "debug",
|
||||
text: "DEBUG"
|
||||
},{
|
||||
route: "plugins",
|
||||
text: "Plugins"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { SidebarEntry } from 'frontblock-generic/Plugin';
|
||||
declare const fb
|
||||
@Component({
|
||||
selector: 'plugins', //!!!!
|
||||
template: `
|
||||
<div class="modal" *ngIf="!updatepending">
|
||||
<div class="modal-dialog fadeDown in" role="dialog" aria-hidden="true">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Confirm installation</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>{{updateCandidate}} But not much to say...</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-icon btn-success" (click)="download(updateCandidate)"><clr-icon shape="check"></clr-icon></button>
|
||||
<button class="btn btn-icon btn-danger" (click)="cancelModal()"><clr-icon shape="times"></clr-icon></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-backdrop fade in" aria-hidden="true" *ngIf="!updatepending"></div>
|
||||
|
||||
<div class="clr-row">
|
||||
<div class="clr-col">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Plugins
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-text">
|
||||
<clr-accordion>
|
||||
<clr-accordion-panel *ngFor="let entry of plugins">
|
||||
<clr-accordion-title>{{entry.name}}</clr-accordion-title>
|
||||
<clr-accordion-content *clrIfExpanded>
|
||||
<div class="btn-group btn-primary">
|
||||
<button *ngIf="entry.status === 'Stopped'" class="btn btn-icon btn-success-outline" (click)="start(entry.name)"><clr-icon shape="play"></clr-icon></button>
|
||||
<button *ngIf="entry.status === 'Running'" class="btn btn-icon btn-warning-outline" (click)="stop(entry.name)"><clr-icon shape="stop"></clr-icon></button>
|
||||
<button *ngIf="entry.status === 'Stopped'" class="btn btn-icon btn-danger-outline" (click)="delete(entry.name)"><clr-icon shape="trash"></clr-icon></button>
|
||||
<button *ngIf="entry.status === 'Available'" class="btn btn-icon btn-info-outline" (click)="showConfirmation(entry.name)"><clr-icon shape="download"></clr-icon></button>
|
||||
<button *ngIf="entry.available !== entry.installed && entry.status === 'Stopped'" class="btn btn-icon btn-outline " (click)="showConfirmation(entry.name)">
|
||||
<clr-icon shape="sync"></clr-icon>
|
||||
</button>
|
||||
</div>
|
||||
</clr-accordion-content>
|
||||
</clr-accordion-panel>
|
||||
</clr-accordion>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<!-- <button class="btn btn-success" onclick="setup()">HELLO</button> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class PluginsComponent implements OnInit {
|
||||
plugins = [{
|
||||
name: "test",
|
||||
available: "0.0.1",
|
||||
installed: "0.0.1",
|
||||
status: "Running"
|
||||
},{
|
||||
name: "test II: Return of test",
|
||||
available: "0.0.1",
|
||||
installed: "0.0.1",
|
||||
status: "Available"
|
||||
},{
|
||||
name: "test 3",
|
||||
available: "0.0.2",
|
||||
installed: "0.0.1",
|
||||
status: "Stopped"
|
||||
},]
|
||||
|
||||
updatepending = true
|
||||
updateCandidate = ""
|
||||
|
||||
constructor() { }
|
||||
|
||||
start(name){
|
||||
this.plugins.find((el) => el.name === name).status = "Running"
|
||||
}
|
||||
|
||||
stop(name){
|
||||
this.plugins.find((el) => el.name === name).status = "Stopped"
|
||||
}
|
||||
|
||||
delete(name){
|
||||
this.plugins.find((el) => el.name === name).status = "Available"
|
||||
}
|
||||
|
||||
showConfirmation(name){
|
||||
this.updateCandidate = name
|
||||
this.updatepending = !this.updatepending
|
||||
}
|
||||
|
||||
download(name){
|
||||
let plugin = this.plugins.find((el) => el.name === name)
|
||||
plugin.status = "Stopped"
|
||||
plugin.installed = plugin.available
|
||||
this.updatepending = !this.updatepending
|
||||
}
|
||||
|
||||
cancelModal(){
|
||||
this.updateCandidate = ""
|
||||
this.updatepending = !this.updatepending
|
||||
}
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
}
|
||||
|
||||
@@ -2,17 +2,9 @@ import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule, Route } from '@angular/router';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { ErrorDisplayComponent } from './error-display/error-display.component';
|
||||
import { PluginmanagerDevComponent } from './pluginmanager-dev/pluginmanager-dev.component';
|
||||
import { ApiclientDevComponent } from './apiclient-dev/apiclient-dev.component';
|
||||
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
const routes: Routes = [{
|
||||
path: "dev/pluginmanager",
|
||||
component: PluginmanagerDevComponent
|
||||
},{
|
||||
path: "dev/apiclient",
|
||||
component: ApiclientDevComponent
|
||||
},{
|
||||
path: "",
|
||||
component: HomeComponent
|
||||
},{
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<div class="main-container">
|
||||
<header-bar></header-bar>
|
||||
<app-dynamic-loader></app-dynamic-loader>
|
||||
</div>
|
||||
<header-bar></header-bar>
|
||||
<subnav></subnav>
|
||||
<div class="content-container">
|
||||
<sidebar></sidebar>
|
||||
<dynamic-loader></dynamic-loader>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,10 +1,30 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, ChangeDetectorRef, NgZone, ViewChild, OnInit, AfterContentInit } from '@angular/core';
|
||||
import { SidebarComponent } from './sidebar/sidebar.component';
|
||||
import { SidebarEntryService } from './sidebar-entry-service.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
export class AppComponent implements AfterContentInit {
|
||||
title = 'dashboard';
|
||||
|
||||
@ViewChild(SidebarComponent, {static: false})
|
||||
sidebar: SidebarComponent
|
||||
|
||||
constructor(private zone:NgZone, private sidebarService: SidebarEntryService){
|
||||
window["refresh"] = () => zone.run(()=>{ /*this triggers an angular reload*/})
|
||||
}
|
||||
|
||||
ngAfterContentInit(){
|
||||
const _this = this;
|
||||
(function awaitSidebar(){
|
||||
if(_this.sidebar != null){
|
||||
_this.sidebarService.setSidebar(_this.sidebar)
|
||||
return
|
||||
}
|
||||
setTimeout(awaitSidebar,25)
|
||||
})()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +1,51 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule, ANALYZE_FOR_ENTRY_COMPONENTS, ModuleWithProviders } from '@angular/core';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { AppRoutingModule, getRoutes } from './app-routing.module';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { AppRoutingModule } from './app-routing.module';
|
||||
|
||||
import { ClarityModule } from '@clr/angular';
|
||||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import { COMPILER_OPTIONS, CompilerFactory, Compiler } from '@angular/core';
|
||||
import { JitCompilerFactory } from '@angular/platform-browser-dynamic';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { SidebarComponent } from './sidebar/sidebar.component';
|
||||
import { MainComponent } from './main/main.component';
|
||||
import { MainComponent } from './content-area/main.component';
|
||||
import { DynamicLoaderComponent } from './dynamic-loader/dynamic-loader.component';
|
||||
import { HomeComponent } from './home/home.component';
|
||||
import { ErrorDisplayComponent } from './error-display/error-display.component';
|
||||
import { PluginmanagerDevComponent } from './pluginmanager-dev/pluginmanager-dev.component';
|
||||
import { HeaderBarComponent } from './header-bar/header-bar.component';
|
||||
import { ApiclientDevComponent } from './apiclient-dev/apiclient-dev.component';
|
||||
import { ApiclientFormComponent } from './apiclient-dev/apiclient-settings-form.component';
|
||||
import { ApiclientConsumptionComponent } from './apiclient-dev/apiclient-consumptions.component';
|
||||
import { ApiclientSubscriptionComponent } from './apiclient-dev/apiclient-subscriptions.component';
|
||||
import { SubnavComponent } from './subnav/subnav.component';
|
||||
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
export function createCompiler(fn: CompilerFactory): Compiler {
|
||||
return fn.createCompiler();
|
||||
}
|
||||
|
||||
const entryComps = []
|
||||
const declarations = [
|
||||
AppComponent,
|
||||
|
||||
SidebarComponent,
|
||||
MainComponent,
|
||||
DynamicLoaderComponent,
|
||||
HomeComponent,
|
||||
HeaderBarComponent,
|
||||
ErrorDisplayComponent,
|
||||
SubnavComponent,
|
||||
]
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
SidebarComponent,
|
||||
MainComponent,
|
||||
DynamicLoaderComponent,
|
||||
HomeComponent,
|
||||
ErrorDisplayComponent,
|
||||
PluginmanagerDevComponent,
|
||||
HeaderBarComponent,
|
||||
ApiclientDevComponent,
|
||||
ApiclientFormComponent,
|
||||
ApiclientConsumptionComponent,
|
||||
ApiclientSubscriptionComponent
|
||||
|
||||
],
|
||||
declarations: declarations,
|
||||
imports: [
|
||||
FormsModule,
|
||||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
ClarityModule,
|
||||
HttpClientModule,
|
||||
AppRoutingModule
|
||||
AppRoutingModule,
|
||||
],
|
||||
entryComponents: entryComps,
|
||||
entryComponents: [],
|
||||
providers: [
|
||||
{
|
||||
provide: COMPILER_OPTIONS,
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { Component, OnInit, ViewContainerRef, ViewChild } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main',
|
||||
selector: 'content-area',
|
||||
templateUrl: './main.component.html',
|
||||
styleUrls: ['./main.component.scss']
|
||||
})
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { SidebarEntry } from 'frontblock-generic/Plugin';
|
||||
declare const fb
|
||||
@Component({
|
||||
selector: 'apiclient', //!!!!
|
||||
template: `
|
||||
<div class="clr-row">
|
||||
<div class="clr-col">
|
||||
<settings></settings>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class ApiclientDevComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
}
|
||||
|
||||
export const sidebarEntry:SidebarEntry = {
|
||||
icon: "wrench",
|
||||
route: "dev/apiclient",
|
||||
text: "DEV ApiClient",
|
||||
}
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { fbind } from 'q';
|
||||
import { FrontblockApiConf } from 'frontblock';
|
||||
|
||||
|
||||
declare const fb
|
||||
|
||||
@Component({
|
||||
selector: 'settings',
|
||||
template: `
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Configuration
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
Settings
|
||||
</div>
|
||||
<div class="card-text">
|
||||
<form clrForm clrLayout="vertical">
|
||||
<clr-input-container>
|
||||
<label>testnet</label>
|
||||
<clr-control-error>We need your first name for legal compliance</clr-control-error>
|
||||
</clr-input-container>
|
||||
<input type="checkbox" [(ngModel)]="testnet" (change)="updateTestnet($event)" name="testnetToggle" clrToggle />
|
||||
|
||||
<clr-input-container *ngIf="!testnet">
|
||||
<label>API key</label>
|
||||
<input clrInput type="text" name="apiKey" required />
|
||||
<clr-control-error>We need your first name for legal compliance</clr-control-error>
|
||||
</clr-input-container>
|
||||
|
||||
<clr-input-container *ngIf="advanced">
|
||||
<label>API address</label>
|
||||
<input type="text" [(ngModel)]="data.apiHost" (change)="updatePort($event)" clrInput name="apiHost" required />
|
||||
<clr-control-error>This field is required!</clr-control-error>
|
||||
</clr-input-container>
|
||||
|
||||
<clr-checkbox-wrapper *ngIf="advanced" >
|
||||
<input [(ngModel)]="data.tls" type="checkbox" clrCheckbox value="tls" name="options" />
|
||||
<label>Use TLS</label>
|
||||
</clr-checkbox-wrapper>
|
||||
|
||||
<clr-input-container *ngIf="advanced">
|
||||
<label>Port</label>
|
||||
<input [(ngModel)]="data.apiPort" clrInput type="number" name="lastName" required />
|
||||
<clr-control-error>Valid range 1024 - 65536
|
||||
</clr-control-error>
|
||||
</clr-input-container>
|
||||
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button *ngIf="!saving" class="btn btn-success" (click)="save()">
|
||||
<span>Save</span>
|
||||
</button>
|
||||
|
||||
<button *ngIf="saving" class="btn btn-disabled" (click)="save()" disabled>
|
||||
<span class="spinner spinner-inline"></span>
|
||||
</button>
|
||||
<button *ngIf="!advanced" class="btn btn-sm btn-link" (click)="setAdvanced()">Advanced</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
export class ApiclientFormComponent implements OnInit {
|
||||
testnet:boolean = true
|
||||
saving:boolean = false
|
||||
advanced:boolean = false
|
||||
data:FrontblockApiConf = {
|
||||
apiHost: "api.testnet.frontblock.me",
|
||||
apiPort: 10001,
|
||||
tls: false,
|
||||
apiKey: ""
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() { }
|
||||
|
||||
setAdvanced(){ this.advanced = true }
|
||||
|
||||
checkData():boolean{
|
||||
return (
|
||||
typeof this.data.apiPort === "number" &&
|
||||
typeof this.data.apiHost === "string" &&
|
||||
typeof this.data.tls === "boolean" &&
|
||||
typeof this.data.apiKey === "string"
|
||||
)
|
||||
}
|
||||
|
||||
updateTestnet(){
|
||||
if(this.testnet){
|
||||
this.data.apiHost = "api.testnet.frontblock.me"
|
||||
this.data.apiPort = 10001
|
||||
}else{
|
||||
this.data.apiHost = "api.frontblock.me"
|
||||
this.data.apiPort = 10000
|
||||
}
|
||||
}
|
||||
|
||||
updatePort(obj){
|
||||
switch (this.data.apiHost) {
|
||||
case "api.testnet.frontblock.me":
|
||||
this.data.apiPort = 10001
|
||||
break;
|
||||
case "api.frontblock.me":
|
||||
this.data.apiPort = 10000
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn("A non-standard api host was chosen: "+this.data.apiPort)
|
||||
break;
|
||||
}
|
||||
console.log(this.data)
|
||||
}
|
||||
|
||||
async save(){
|
||||
this.saving = true;
|
||||
if(typeof this.data.apiPort === "string")
|
||||
this.data.apiPort = parseInt(this.data.apiPort)
|
||||
|
||||
if(this.checkData()){
|
||||
const conf = await fb.ApiClient.setConfig(this.data)
|
||||
console.log(conf)
|
||||
}else{
|
||||
//show error in gui
|
||||
console.error("bad data :(")
|
||||
}
|
||||
this.saving = false
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
<div class="content-container">
|
||||
<app-sidebar></app-sidebar>
|
||||
<app-main></app-main>
|
||||
<content-area></content-area>
|
||||
</div>
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
import { System } from 'systemjs';
|
||||
declare const SystemJS: System;
|
||||
declare const fb
|
||||
|
||||
import * as angularRouter from '@angular/router';
|
||||
import * as angularCore from '@angular/core';
|
||||
@@ -13,47 +12,76 @@ import * as angularCommon from '@angular/common';
|
||||
import * as angularCommonHttp from '@angular/common/http';
|
||||
import * as angularForms from '@angular/forms';
|
||||
import * as angularAnimations from '@angular/animations';
|
||||
//import * as angularAnimationsBrowser from '@angular/animations/browser'
|
||||
import * as angularPlatformBrowser from '@angular/platform-browser';
|
||||
import * as angularPlatformBrowserDynamic from '@angular/platform-browser-dynamic';
|
||||
import * as clarityModule from '@clr/angular';
|
||||
import * as frontblockGenericTypes from 'frontblock-generic/Types.js'
|
||||
//import * as browserAnimationsModule from "@angular/platform-browser/animations";
|
||||
|
||||
SystemJS.set('@clr/angular', SystemJS.newModule(clarityModule));
|
||||
SystemJS.set('@angular/router', SystemJS.newModule(angularRouter));
|
||||
SystemJS.set('@angular/core', SystemJS.newModule(angularCore));
|
||||
SystemJS.set('@angular/common', SystemJS.newModule(angularCommon));
|
||||
SystemJS.set('@angular/common/http', SystemJS.newModule(angularCommonHttp));
|
||||
SystemJS.set('@angular/forms', SystemJS.newModule(angularForms));
|
||||
SystemJS.set('@angular/animations', SystemJS.newModule(angularAnimations));
|
||||
//SystemJS.set('@angular/animations/browser', SystemJS.newModule(angularAnimationsBrowser));
|
||||
SystemJS.set('@angular/platform-browser', SystemJS.newModule(angularPlatformBrowser));
|
||||
//SystemJS.set('@angular/platform-browser/animations', SystemJS.newModule(browserAnimationsModule));
|
||||
SystemJS.set('@angular/platform-browser-dynamic', SystemJS.newModule(angularPlatformBrowserDynamic));
|
||||
SystemJS.set('frontblock-generic/Types', SystemJS.newModule(frontblockGenericTypes));
|
||||
|
||||
SystemJS.config({ meta: { '*': { authorization: true } } });
|
||||
/** --------- */
|
||||
|
||||
|
||||
import { AfterViewInit, Component, ViewContainerRef, ViewChild } from '@angular/core';
|
||||
import { AfterViewInit, Component, Input, ViewChild } from '@angular/core';
|
||||
import { SidebarComponent } from '../sidebar/sidebar.component';
|
||||
import { MainComponent } from '../main/main.component';
|
||||
import { Router } from '@angular/router';
|
||||
import { FrontendPlugin, SidebarEntries, SidebarEntry } from "frontblock-generic/Plugin"
|
||||
import { SidebarEntryService } from '../sidebar-entry-service.service';
|
||||
import { environment } from "../../environments/environment"
|
||||
|
||||
|
||||
let fb
|
||||
if(environment.production){
|
||||
fb = window["fb"]
|
||||
}else{
|
||||
|
||||
fb = {
|
||||
PluginManager : {
|
||||
getLoadedPluginNames: () => ["ApiClient", "PluginManager"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'app-dynamic-loader',
|
||||
selector: 'dynamic-loader',
|
||||
templateUrl: './dynamic-loader.component.html',
|
||||
styleUrls: ['./dynamic-loader.component.scss']
|
||||
})
|
||||
export class DynamicLoaderComponent implements AfterViewInit {
|
||||
|
||||
@ViewChild(SidebarComponent, {static: false})
|
||||
sidebar: SidebarComponent
|
||||
@ViewChild(MainComponent, {read: ViewContainerRef, static: false})
|
||||
maincontent: ViewContainerRef
|
||||
sidebar:SidebarComponent
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
) { }
|
||||
private sidebarService:SidebarEntryService
|
||||
) {
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.loadWidgets()
|
||||
const _this = this;
|
||||
(function awaitSidebar(){
|
||||
const sb = _this.sidebarService.getSidebar()
|
||||
if(sb != null){
|
||||
_this.sidebar = sb
|
||||
_this.loadWidgets()
|
||||
return
|
||||
}
|
||||
setTimeout(awaitSidebar,25)
|
||||
})()
|
||||
}
|
||||
|
||||
private async loadWidgets(){
|
||||
@@ -65,7 +93,12 @@ export class DynamicLoaderComponent implements AfterViewInit {
|
||||
}
|
||||
|
||||
private async installWidget(pluginName:string){
|
||||
const module: FrontendPlugin = await SystemJS.import("plugins/"+pluginName+".js");
|
||||
let module: FrontendPlugin
|
||||
if(environment.production)
|
||||
module = await SystemJS.import("plugins/"+pluginName+".js");
|
||||
else
|
||||
module = await import("../"+pluginName+"/module")
|
||||
|
||||
const plugin = new module['PluginModule']()
|
||||
const entry:SidebarEntries | SidebarEntry = plugin.getSidebarEntry()
|
||||
const rc = this.router.config
|
||||
@@ -94,8 +127,6 @@ export class DynamicLoaderComponent implements AfterViewInit {
|
||||
path: m.parentRoute,
|
||||
loadChildren: async () => module['PluginModule']
|
||||
})
|
||||
|
||||
console.log(this.sidebar.multientires)
|
||||
break;
|
||||
}
|
||||
this.router.resetConfig(rc)
|
||||
|
||||
@@ -10,10 +10,3 @@
|
||||
</a>
|
||||
</div>
|
||||
</header>
|
||||
<nav class="subnav">
|
||||
<ul class="nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#">Dashboard</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
@@ -1 +0,0 @@
|
||||
<p>pluginmanager-dev works!</p>
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { SidebarComponent } from './sidebar/sidebar.component';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class SidebarEntryService {
|
||||
|
||||
private sidebar:SidebarComponent
|
||||
|
||||
constructor() { }
|
||||
|
||||
setSidebar(sidebar){
|
||||
this.sidebar = sidebar
|
||||
}
|
||||
|
||||
getSidebar():SidebarComponent{
|
||||
return this.sidebar
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<clr-vertical-nav [clrVerticalNavCollapsible]="true">
|
||||
<clr-vertical-nav style="height: 100%" class="nav-trigger--bottom" [clrVerticalNavCollapsible]="true" [(clrVerticalNavCollapsed)]="collapsed">
|
||||
<clr-vertical-nav-group *ngFor="let e of multientires" routerLinkActive="active">
|
||||
<clr-icon [attr.shape]="e.icon" clrVerticalNavIcon></clr-icon>
|
||||
{{e.text}}
|
||||
@@ -17,7 +17,4 @@
|
||||
{{entry.text}}
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</clr-vertical-nav>
|
||||
@@ -1,30 +1,19 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { SidebarEntries, SidebarEntry } from 'frontblock-generic/Plugin';
|
||||
import { sidebarEntry as apiclient } from "../apiclient-dev/apiclient-dev.component"
|
||||
import { sidebarEntry as pluginmanager } from "../pluginmanager-dev/pluginmanager-dev.component"
|
||||
|
||||
import { environment } from 'src/environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar',
|
||||
selector: 'sidebar',
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrls: ['./sidebar.component.scss']
|
||||
})
|
||||
export class SidebarComponent implements OnInit {
|
||||
|
||||
entries:SidebarEntry[] = [
|
||||
pluginmanager,
|
||||
apiclient
|
||||
]
|
||||
|
||||
multientires:SidebarEntries[] = [{
|
||||
icon: "times",
|
||||
text: "HELP",
|
||||
parentRoute: "oops",
|
||||
links: [{
|
||||
route: "xd",
|
||||
text: "XD"
|
||||
}]
|
||||
}]
|
||||
multientires:SidebarEntries[] = [
|
||||
]
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<nav class="subnav">
|
||||
<ul class="nav">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" href="#">Dashboard</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
+6
-6
@@ -1,20 +1,20 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { PluginmanagerDevComponent } from './pluginmanager-dev.component';
|
||||
import { SubnavComponent } from './subnav.component';
|
||||
|
||||
describe('PluginmanagerDevComponent', () => {
|
||||
let component: PluginmanagerDevComponent;
|
||||
let fixture: ComponentFixture<PluginmanagerDevComponent>;
|
||||
describe('SubnavComponent', () => {
|
||||
let component: SubnavComponent;
|
||||
let fixture: ComponentFixture<SubnavComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ PluginmanagerDevComponent ]
|
||||
declarations: [ SubnavComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(PluginmanagerDevComponent);
|
||||
fixture = TestBed.createComponent(SubnavComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'subnav',
|
||||
templateUrl: './subnav.component.html',
|
||||
styleUrls: ['./subnav.component.scss']
|
||||
})
|
||||
export class SubnavComponent implements OnInit {
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
"src/**/*.ts"
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"src/test.ts",
|
||||
"src/**/*.spec.ts"
|
||||
]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import typescript from 'rollup-plugin-typescript2';
|
||||
import externals from 'rollup-plugin-node-externals'
|
||||
|
||||
export default {
|
||||
input: 'src/frontend/widget/main.ts',
|
||||
@@ -21,8 +20,6 @@ export default {
|
||||
})
|
||||
],
|
||||
external: [
|
||||
"frontblock",
|
||||
"frontblock-generic",
|
||||
'plugins-core',
|
||||
'@angular/core',
|
||||
'@angular/common',
|
||||
|
||||
Reference in New Issue
Block a user