zzz
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
import * as Logger from 'log4js'
|
||||
import { socketioRPC, ConfigLoader } from 'frontblock-generic/Plugin';
|
||||
import { ErrorResponse, SuccessResponse } from 'frontblock-generic/Types';
|
||||
import { default as PluginManagerPlugin } from './PluginManager/Plugin'
|
||||
import express = require('express');
|
||||
import http = require('http');
|
||||
import bsock = require('bsock');
|
||||
import { FrontblockCherryPicker } from "git-cherrypicker"
|
||||
import { basename } from "path"
|
||||
import { promises as fs } from "fs"
|
||||
|
||||
const kfs = require("key-file-storage").default('kfs')
|
||||
|
||||
@@ -67,11 +69,10 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
private httpServer
|
||||
private io = bsock.createServer()
|
||||
private wsServer = http.createServer()
|
||||
private pm: PluginManagerPlugin
|
||||
private pm
|
||||
|
||||
constructor(){
|
||||
super("FrontblockAdmin")
|
||||
this.pm = new PluginManagerPlugin()
|
||||
|
||||
this.initialize()
|
||||
}
|
||||
@@ -81,6 +82,13 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
}
|
||||
|
||||
private async initialize(){
|
||||
await fs.mkdir("plugins/PluginManager", {recursive: true})
|
||||
await (new FrontblockCherryPicker("fb-dist/pluginmanager", "master", "Plugin.js")).write("plugins/PluginManager/Plugin.js")
|
||||
await (new FrontblockCherryPicker("fb-dist/pluginmanager", "master", "FrontendPlugin.js")).write("plugins/PluginManager/FrontendPlugin.js")
|
||||
let str = "../plugins/PluginManager/Plugin"
|
||||
const PM = await import(str)
|
||||
this.pm = new PM.default()
|
||||
|
||||
this.startWebsocket()
|
||||
this.startWebserver()
|
||||
}
|
||||
@@ -104,11 +112,20 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
type:'call',
|
||||
fn: () => { return rpcInfos }
|
||||
}
|
||||
},{
|
||||
owner: 'Admin',
|
||||
name: 'installPluginManager',
|
||||
args: '',
|
||||
info: {
|
||||
type: 'call',
|
||||
fn: () => {}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
//translate RPCs to socket-bound function metadata
|
||||
|
||||
const loadedPlugins = this.pm.getLoadedPlugins()
|
||||
for(const name in loadedPlugins){
|
||||
loadedPlugins[name].backend.exportRPCs().forEach(rpc => {
|
||||
@@ -116,6 +133,7 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
rpcInfos.push(info)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//Hook up all the functions
|
||||
for(const api of rpcInfos){
|
||||
@@ -173,6 +191,10 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
private installPluginManager(){
|
||||
|
||||
}
|
||||
|
||||
private startWebserver(){
|
||||
if(this.httpServer != null || this.express != null){
|
||||
@@ -204,7 +226,7 @@ export class FrontblockAdmin extends ConfigLoader<AdminConf>{
|
||||
|
||||
/**
|
||||
* redirect all the other traffic to the single
|
||||
* side app to the main entry point from where
|
||||
* page app to the main entry point from where
|
||||
* a webpacked and rolled up index.html is serverd
|
||||
* and angular takes over routing
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { parseSubResponse, parseResponse } from "frontblock-generic/Types";
|
||||
import PluginManager from "./PluginManager/PluginManager";
|
||||
var bsock = require('bsock')
|
||||
|
||||
/**
|
||||
@@ -78,7 +77,7 @@ export class FrontblockConfigLib{
|
||||
|
||||
|
||||
window['fb'] = new FrontblockConfigLib()
|
||||
declare const fb:{PluginManager:PluginManager}
|
||||
declare const fb:{PluginManager:any}
|
||||
window['setup'] = async() => {
|
||||
await Promise.all([
|
||||
fb.PluginManager.installPlugin("ApiClient"),
|
||||
|
||||
Reference in New Issue
Block a user