SPA
This commit is contained in:
+1
-1
@@ -15,7 +15,7 @@
|
||||
"options": {
|
||||
"outputPath": "dist/server",
|
||||
"main": "src/backend/Launcher.ts",
|
||||
"tsConfig": "tsconfig.server.json"
|
||||
"tsConfig": "tsconfig.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+387
-5648
File diff suppressed because it is too large
Load Diff
+2
-13
@@ -4,12 +4,12 @@
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"tsc": "tsc",
|
||||
"launch": "node lib/src/backend/Launcher.js",
|
||||
"launch": "node dist/server/main.js",
|
||||
"start": "npm run build && npm run launch",
|
||||
"start-backend": "npm run build-backend && npm run launch",
|
||||
"test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",
|
||||
"build": "npm run build-backend && npm run build-frontend",
|
||||
"build-backend": "npm run clean-backend && ng v && ng run frontcraft:server",
|
||||
"build-backend": "npm run clean-backend && tsc",
|
||||
"build-frontend": "npm run clean-frontend && (mkdir static || rm -rf static/*) && npm run build-dashboard",
|
||||
"build-dashboard": "cd src/frontend && npm i && npm run build && cp -r dist/* ../../static",
|
||||
"clean": "rm -rf data && npm run clean-backend && npm run clean-frontend",
|
||||
@@ -25,14 +25,7 @@
|
||||
"author": "frontblock.me",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@angular-devkit/build-angular": "^0.900.5",
|
||||
"@angular/compiler": "^9.0.5",
|
||||
"@angular/compiler-cli": "^9.0.5",
|
||||
"@angular/platform-server": "^9.0.5",
|
||||
"@nguniversal/express-engine": "^9.0.1",
|
||||
"@nguniversal/module-map-ngfactory-loader": "^8.2.6",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"angular": "^1.7.9",
|
||||
"bsert": "0.0.10",
|
||||
"bsock": "^0.1.9",
|
||||
"child-process-promise": "^2.2.1",
|
||||
@@ -64,10 +57,6 @@
|
||||
"xml2js": "^0.4.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular/cli": "^9.0.5",
|
||||
"@types/express": "^4.17.0",
|
||||
"@types/node": "^11.13.19",
|
||||
"@types/semver": "^6.0.1",
|
||||
"madge": "^3.6.0",
|
||||
"mocha": "^7.0.0",
|
||||
"terser-webpack-plugin": "^1.4.1",
|
||||
|
||||
+22
-17
@@ -22,9 +22,9 @@ import { Injector } from '../Injector/Injector';
|
||||
import { Shoutbox } from '../Components/Shoutbox/Shoutbox';
|
||||
import { PubSub } from '../Components/PubSub/PubSub';
|
||||
|
||||
import { ngExpressEngine } from '@nguniversal/express-engine';
|
||||
import { APP_BASE_HREF } from '@angular/common';
|
||||
import { AppServerModule } from './app.server.module';
|
||||
//import { ngExpressEngine } from '../../frontend/node_modules/@nguniversal/express-engine';
|
||||
//import { APP_BASE_HREF } from '../../frontend/';
|
||||
//import { AppServerModule } from './app.server.module';
|
||||
|
||||
|
||||
const logger = getLogger("admin", 'debug')
|
||||
@@ -134,13 +134,12 @@ implements TableDefinitionExporter, IAdmin {
|
||||
|
||||
let port:number = this.config.getConfig().httpPort
|
||||
this.express = express()
|
||||
this.express.use('/', express.static('static'))
|
||||
|
||||
|
||||
/*
|
||||
this.express.engine('html', ngExpressEngine({
|
||||
bootstrap: AppServerModule,
|
||||
}));
|
||||
|
||||
|
||||
this.express.set('view engine', 'html');
|
||||
this.express.set('views', 'static');
|
||||
|
||||
@@ -148,15 +147,23 @@ implements TableDefinitionExporter, IAdmin {
|
||||
this.express.get('*.*', express.static('static', {
|
||||
maxAge: '1y'
|
||||
}));
|
||||
|
||||
|
||||
this.express.get("/", (request, response) => {
|
||||
response.status(200)
|
||||
response.sendFile('index.html');
|
||||
})
|
||||
|
||||
// All regular routes use the Universal engine
|
||||
this.express.get('*', (req, res) => {
|
||||
res.render('index', { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
|
||||
res.status(301)
|
||||
res.redirect('/')
|
||||
//res.render('index', { req, providers: [{ provide: APP_BASE_HREF, useValue: req.baseUrl }] });
|
||||
});
|
||||
*/
|
||||
/* */
|
||||
// get the compiled FrontendPlugins.js
|
||||
this.express.use('/', express.static('static'))
|
||||
|
||||
/**
|
||||
* get the compiled FrontendPlugins.js
|
||||
*/
|
||||
this.express.get('/plugins/:id'+".js", async (request, response) => {
|
||||
const pth = Path.resolve("plugins/"+request.params.id, "FrontendPlugin.js");
|
||||
const file = await fs.readFile(pth)
|
||||
@@ -167,17 +174,13 @@ implements TableDefinitionExporter, IAdmin {
|
||||
response.send(frontend)
|
||||
})
|
||||
|
||||
/**
|
||||
* serve the index.html from the static folder
|
||||
*/
|
||||
// serve the index.html from the static folder
|
||||
this.express.get("/", (request, response) => {
|
||||
response.status(200)
|
||||
response.sendFile('index.html');
|
||||
})
|
||||
|
||||
/**
|
||||
* redirect all the other traffic to the single page app
|
||||
*/
|
||||
// redirect all the other traffic to the single page app
|
||||
this.express.get("*", (request, response) => {
|
||||
response.status(301)
|
||||
response.redirect('/')
|
||||
@@ -187,6 +190,8 @@ implements TableDefinitionExporter, IAdmin {
|
||||
this.httpServer.listen(port, () => {
|
||||
logger.info('Admin panel listening for HTTP on *'+port)
|
||||
})
|
||||
|
||||
/* */
|
||||
}
|
||||
|
||||
private stopWebserver(){
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { ServerModule } from '@angular/platform-server';
|
||||
import { ModuleMapLoaderModule } from '@nguniversal/module-map-ngfactory-loader';
|
||||
/*
|
||||
import { NgModule } from '../../frontend/node_modules/@angular/core';
|
||||
import { ServerModule } from '../../frontend/node_modules/@angular/platform-server';
|
||||
import { ModuleMapLoaderModule } from '../../frontend/node_modules/@nguniversal/module-map-ngfactory-loader';
|
||||
|
||||
import { AppModule } from '../../frontend/src/app/app.module';
|
||||
import { AppComponent } from '../../frontend/src/app/app.component';
|
||||
@@ -17,3 +18,4 @@ import { AppComponent } from '../../frontend/src/app/app.component';
|
||||
bootstrap: [ AppComponent ],
|
||||
})
|
||||
export class AppServerModule {}
|
||||
*/
|
||||
@@ -1,6 +1,5 @@
|
||||
import { RPCServer, Socket, RPCInterface } from "rpclibrary";
|
||||
import { Inject, Injectable } from "../../Injector/ServiceDecorator";
|
||||
import { FrontworkAdmin } from "../../Admin/Admin";
|
||||
import { GuildManager } from "../Guild/GuildManager";
|
||||
import { ItemManager } from "../Item/ItemManager";
|
||||
import { RaidManager } from "../Raid/RaidManager";
|
||||
@@ -35,7 +34,7 @@ implements FrontworkComponent<UserManagerIfc, UserManagerFeatureIfc>, IUserManag
|
||||
name = "UserManager" as "UserManager"
|
||||
|
||||
@Inject(IAdmin)
|
||||
private admin: FrontworkAdmin
|
||||
private admin: IAdmin
|
||||
|
||||
@Inject(IGuildManager)
|
||||
private guild : GuildManager
|
||||
@@ -50,7 +49,7 @@ implements FrontworkComponent<UserManagerIfc, UserManagerFeatureIfc>, IUserManag
|
||||
private character : CharacterManager
|
||||
|
||||
exporters :any[] = []
|
||||
rankServer : Serverstate<{}, FrontcraftFeatureIfc>
|
||||
rankServer : Serverstate<{}, FrontcraftFeatureIfc>
|
||||
userLogins : {[username in string] : UserRecord} = {}
|
||||
allowed: string[] = []
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { RPCExporter } from "rpclibrary";
|
||||
* @returns {GenericClassDecorator<Type<any>>}
|
||||
* @constructor
|
||||
*/
|
||||
export const Injectable = (_interface?: Type<any>) : GenericClassDecorator<Type<any>> => {
|
||||
export function Injectable (_interface?: Type<any>) : GenericClassDecorator<Type<any>> {
|
||||
return (target: Type<any>) => {
|
||||
Injector.modules.push({
|
||||
implements: _interface,
|
||||
@@ -20,10 +20,10 @@ export const Injectable = (_interface?: Type<any>) : GenericClassDecorator<Type<
|
||||
* @returns {GenericClassDecorator<Type<any>>}
|
||||
* @constructor
|
||||
*/
|
||||
export const RootComponent = (config : {
|
||||
export function RootComponent(config : {
|
||||
injectable : Type<any>
|
||||
injects : Type<RPCExporter>[]
|
||||
}) : GenericClassDecorator<Type<any>> => {
|
||||
}) : GenericClassDecorator<Type<any>>{
|
||||
return (target: Type<any>) => {
|
||||
Injector.rootModules = config.injects
|
||||
Injector.rootInterface = config.injectable
|
||||
@@ -31,7 +31,7 @@ export const RootComponent = (config : {
|
||||
}
|
||||
}
|
||||
|
||||
export const Inject = (type: any) => {
|
||||
export function Inject(type: any) {
|
||||
return function (_this, key) {
|
||||
Injector.injectionQueue.push({what: type, target: _this, where:key})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
//import { enableProdMode } from '../frontend/node_modules/@angular/core';
|
||||
//enableProdMode();
|
||||
Generated
+4554
-8042
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
||||
"ng": "ng",
|
||||
"conventional-changelog": "conventional-changelog",
|
||||
"start": "ng serve",
|
||||
"build": "ng build --aot",
|
||||
"build": "ng build",
|
||||
"build:prod": "npm run build -- --prod --aot",
|
||||
"test": "ng test",
|
||||
"test:coverage": "rimraf coverage && npm run test -- --code-coverage",
|
||||
@@ -44,7 +44,7 @@
|
||||
"@nebular/auth": "4.4.0",
|
||||
"@nebular/eva-icons": "4.4.0",
|
||||
"@nebular/security": "4.4.0",
|
||||
"@nebular/theme": "4.4.0",
|
||||
"@nebular/theme": "^4.4.0",
|
||||
"@swimlane/ngx-charts": "^10.0.0",
|
||||
"angular-tree-component": "7.2.0",
|
||||
"angular2-chartjs": "0.4.1",
|
||||
@@ -109,6 +109,6 @@
|
||||
"ts-node": "3.2.2",
|
||||
"tslint": "^5.7.0",
|
||||
"tslint-language-service": "^0.9.9",
|
||||
"typescript": "3.4.5"
|
||||
"typescript": "^3.5.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
* Copyright Akveo. All Rights Reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*/
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, Inject, PLATFORM_ID, APP_ID } from '@angular/core';
|
||||
import { ApiService } from './frontcraft/services/login-api';
|
||||
import { isPlatformBrowser } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-app',
|
||||
@@ -12,11 +13,17 @@ import { ApiService } from './frontcraft/services/login-api';
|
||||
})
|
||||
export class AppComponent implements OnInit {
|
||||
|
||||
constructor(private loginSvc: ApiService) {
|
||||
|
||||
constructor(
|
||||
private loginSvc: ApiService,
|
||||
@Inject(PLATFORM_ID) private platformId: Object,
|
||||
@Inject(APP_ID) private appId: string
|
||||
) {
|
||||
if(!isPlatformBrowser(platformId)){
|
||||
global['window'] = {}
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
window['s'] = this.loginSvc
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class FrontcraftRaidComponent implements OnInit, OnDestroy{
|
||||
tokens:{},
|
||||
tier: 'null'
|
||||
}
|
||||
tokens = {}
|
||||
tokens: {[itemname in string]: (Character & SRToken & Item)[]} = {}
|
||||
displayedtokens = {}
|
||||
search = ""
|
||||
uuid
|
||||
@@ -51,7 +51,6 @@ export class FrontcraftRaidComponent implements OnInit, OnDestroy{
|
||||
private dialogService : NbDialogService,
|
||||
private toast: NbToastrService
|
||||
){
|
||||
window['r'] = this
|
||||
router.events.subscribe(event => {
|
||||
if (event instanceof NavigationStart) {
|
||||
this.ngOnDestroy()
|
||||
@@ -163,7 +162,6 @@ export class FrontcraftRaidComponent implements OnInit, OnDestroy{
|
||||
const raiddata = await raidManager.getRaidData(<any>{
|
||||
id: param
|
||||
})
|
||||
console.log(raiddata);
|
||||
|
||||
this.display(raiddata)
|
||||
|
||||
|
||||
+16
-2
@@ -2,13 +2,27 @@
|
||||
"compilerOptions": {
|
||||
"strictPropertyInitialization": false,
|
||||
"noImplicitAny": false,
|
||||
"target": "ESnext",
|
||||
"target": "esNext",
|
||||
"declaration": true,
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true
|
||||
"emitDecoratorMetadata": true,
|
||||
|
||||
"outDir": "./lib",
|
||||
//"types": ["node"],
|
||||
"strictNullChecks": false
|
||||
},
|
||||
"include": ["src/backend/**/*"],
|
||||
"exclude": [
|
||||
"./src/frontend/**/*",
|
||||
"./node_modules/**/*",
|
||||
"./src/frontend/node_modules/**/*",
|
||||
"./test",
|
||||
],
|
||||
"angularCompilerOptions": {
|
||||
"enableIvy": false,
|
||||
"entryModule": "./src/backend/Admin/app.server.module#AppServerModule"
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src/backend/**/*", "test/**/*"],
|
||||
"exclude": ["node_modules", "**/__tests__/*"],
|
||||
|
||||
"angularCompilerOptions": {
|
||||
"entryModule": "./src/app/app.server.module#AppServerModule"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user