checkpoint
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { FrontworkAdmin } from "../../Admin/Admin";
|
||||
import { FrontworkComponent } from "../../Types/FrontworkComponent";
|
||||
import { _Rank } from "../../Types/Types";
|
||||
|
||||
export class GuildManager
|
||||
implements FrontworkComponent<any>{
|
||||
|
||||
name = "GuildManager";
|
||||
admin: FrontworkAdmin
|
||||
|
||||
exportRPCs = () => [{
|
||||
name: 'getGuildInfo',
|
||||
call: async () => {
|
||||
|
||||
return await Promise.all(
|
||||
['ADMIN', ..._Rank].map(async r => {
|
||||
const res = await this.admin.knex
|
||||
.select('*')
|
||||
.from('users')
|
||||
.where('rank', '=', r)
|
||||
.first()
|
||||
.count()
|
||||
|
||||
return {
|
||||
rank: r,
|
||||
count: res['count(*)']
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}]
|
||||
|
||||
exportRPCFeatures = () => []
|
||||
|
||||
getTableDefinitions = () => []
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ export type Item = {
|
||||
}
|
||||
|
||||
export class ItemManager
|
||||
implements FrontworkComponent<ItemManagerFeatureIfc>, TableDefinitionExporter{
|
||||
implements FrontworkComponent<any, any, ItemManagerFeatureIfc>, TableDefinitionExporter{
|
||||
|
||||
admin:FrontworkAdmin
|
||||
name = "ItemManager";
|
||||
|
||||
@@ -4,7 +4,7 @@ import { FrontworkComponent } from "../../Types/FrontworkComponent";
|
||||
|
||||
|
||||
export class RaidManager
|
||||
implements FrontworkComponent<RaidManagerFeatureIfc>{
|
||||
implements FrontworkComponent<any, any, RaidManagerFeatureIfc>{
|
||||
name = "RaidManager";
|
||||
admin: FrontworkAdmin
|
||||
|
||||
|
||||
+22
-4
@@ -1,13 +1,19 @@
|
||||
import { RPCServer } from "rpclibrary";
|
||||
import { TableDefiniton, AnyRPCExporter, User, RPCPermission, _Rank, Token, Auth, FrontcraftFeatureIfc, Rank } from "../../Types/Types";
|
||||
import { TableDefiniton, AnyRPCExporter, User, RPCPermission, _Rank, Token, Auth, FrontcraftFeatureIfc, Rank, LoginManagerFeatureIfc } from "../../Types/Types";
|
||||
import { FrontworkAdmin } from "../../Admin/Admin";
|
||||
import { PrivilegedRPCExporter } from "../../Types/PrivilegedRPCExporter";
|
||||
import { FrontworkComponent } from "../../Types/FrontworkComponent";
|
||||
import { getSpecTableData } from "../../Types/PlayerSpecs"
|
||||
const uuid = require('uuid/v4')
|
||||
|
||||
export type LoginManagerIfc = {
|
||||
Authenticator: {
|
||||
login: (username:string, pwHash:string) => Promise<Token>
|
||||
}
|
||||
}
|
||||
|
||||
export class LoginManager
|
||||
implements FrontworkComponent{
|
||||
implements FrontworkComponent<LoginManagerFeatureIfc>{
|
||||
name = "Authenticator" as "Authenticator";
|
||||
admin:FrontworkAdmin
|
||||
|
||||
@@ -59,7 +65,8 @@ implements FrontworkComponent{
|
||||
table.string("name").notNullable().unique()
|
||||
table.string("pwhash").notNullable()
|
||||
table.string("rank").notNullable()
|
||||
table.string("class").notNullable()
|
||||
table.integer("specid").notNullable()
|
||||
table.foreign('specid').references('specs.id')
|
||||
table.string("email").nullable().unique()
|
||||
}
|
||||
},{
|
||||
@@ -77,6 +84,13 @@ implements FrontworkComponent{
|
||||
table.foreign('user_id').references('users')
|
||||
table.dateTime('created').defaultTo(this.admin.knex.fn.now())
|
||||
}
|
||||
},{
|
||||
name: 'specs',
|
||||
tableBuilder: (table) => {
|
||||
table.increments('id').primary()
|
||||
table.string('class')
|
||||
table.string('name')
|
||||
}
|
||||
}
|
||||
,...this.exporters.flatMap(exp => exp['getTableDefinitions']?exp['getTableDefinitions']():undefined)]
|
||||
}
|
||||
@@ -90,6 +104,10 @@ implements FrontworkComponent{
|
||||
})))
|
||||
|
||||
await Promise.all(this.exporters.map(ex => ex['initialize']?ex['initialize']():undefined))
|
||||
|
||||
console.log(getSpecTableData())
|
||||
|
||||
await this.admin.knex('specs').insert(getSpecTableData()).catch(console.log)
|
||||
}
|
||||
|
||||
async setPermission(permission: RPCPermission){
|
||||
@@ -147,7 +165,7 @@ implements FrontworkComponent{
|
||||
if(typeof tokenValue !== 'string') tokenValue = tokenValue.value
|
||||
|
||||
const res : User[] = await this.admin.knex
|
||||
.select('users.id', 'name', 'class', 'rank', 'email')
|
||||
.select('users.id', 'name', 'specid', 'rank', 'email')
|
||||
.from('tokens')
|
||||
.join('users', function(){
|
||||
this.on('users.id', '=', 'tokens.user_id')
|
||||
@@ -1,19 +1,21 @@
|
||||
import { FrontworkAdmin } from './Admin/Admin'
|
||||
import { RaidManager } from "./Components/Raid/RaidManager";
|
||||
import { ItemManager } from "./Components/Item/ItemManager";
|
||||
import { LoginManager } from "./Components/Login/LoginManager";
|
||||
import { LoginManager } from "./Components/User/UserManager";
|
||||
import { Debugger } from './Components/Debugger/Debugger';
|
||||
import { FrontworkComponent } from './Types/FrontworkComponent';
|
||||
import { GuildManager } from './Components/Guild/GuildManager';
|
||||
require('events').EventEmitter.defaultMaxListeners = 0;
|
||||
|
||||
let raidManager = new RaidManager()
|
||||
let itemManager = new ItemManager()
|
||||
let loginManager = new LoginManager([
|
||||
let guildManager = new GuildManager()
|
||||
let userManager = new LoginManager([
|
||||
raidManager,
|
||||
itemManager
|
||||
])
|
||||
|
||||
let components:FrontworkComponent[] = [ raidManager, itemManager, loginManager ]
|
||||
let components:FrontworkComponent[] = [ guildManager, raidManager, itemManager, userManager ]
|
||||
let dbg = new Debugger(components)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { Class, _Class, Spec } from "./Types";
|
||||
|
||||
const specs : { [classname in Class] : string[] } = {
|
||||
Warrior : [
|
||||
'Arms',
|
||||
'Fury',
|
||||
'Protection'
|
||||
],
|
||||
|
||||
Rogue: [
|
||||
'Subetly',
|
||||
'Combat',
|
||||
'Assassination'
|
||||
],
|
||||
|
||||
Hunter: [
|
||||
'Beast Mastery',
|
||||
'Marksmanship',
|
||||
'Survival'
|
||||
],
|
||||
|
||||
Paladin: [
|
||||
'Holy',
|
||||
'Protection',
|
||||
'Retribution'
|
||||
],
|
||||
|
||||
Priest: [
|
||||
'Discipline',
|
||||
'Holy',
|
||||
'Shadow'
|
||||
],
|
||||
|
||||
Druid: [
|
||||
'Feral (Tank)',
|
||||
'Feral (DPS)',
|
||||
'Restoration',
|
||||
'Balance'
|
||||
],
|
||||
|
||||
Mage: [
|
||||
'Frost',
|
||||
'Arcane',
|
||||
'Fire'
|
||||
],
|
||||
|
||||
Warlock: [
|
||||
'Demonology',
|
||||
'Destruction',
|
||||
'Affliction'
|
||||
],
|
||||
|
||||
Shaman: [
|
||||
'Restoration',
|
||||
'Enhancement',
|
||||
'Elemental'
|
||||
],
|
||||
}
|
||||
|
||||
export function getSpecTableData() : Spec[]{
|
||||
return _Class.flatMap((_class) => {
|
||||
const specNames : string[] = specs[_class]
|
||||
return specNames.map(specName => {
|
||||
return {
|
||||
name: specName,
|
||||
class: _class
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export type User = {
|
||||
id?: number
|
||||
name: string
|
||||
pwhash: string
|
||||
class: Class
|
||||
specid: number
|
||||
rank: Rank
|
||||
email?: string
|
||||
}
|
||||
@@ -90,6 +90,12 @@ export type RaidManagerFeatureIfc = {
|
||||
}
|
||||
}
|
||||
|
||||
export type Spec = {
|
||||
id?: number,
|
||||
class: Class,
|
||||
name: string
|
||||
}
|
||||
|
||||
export type SomeOf<T> = {
|
||||
[K in keyof T]? : T[K]
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
PlayerService,
|
||||
StateService,
|
||||
} from './utils';
|
||||
import { LoginApiService, initializeLoginSvc } from '../frontcraft/login-api';
|
||||
import { LoginApiService, initializeLoginSvc } from '../frontcraft/services/login-api';
|
||||
|
||||
const DATA_SERVICES = [
|
||||
{provide: LoginApiService, useClass: LoginApiService},
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Component } from '@angular/core';
|
||||
selector: 'ngx-footer',
|
||||
styleUrls: ['./footer.component.scss'],
|
||||
template: `
|
||||
<span class="created-by">Created with ♥ by <b><a href="https://akveo.com" target="_blank">Akveo</a></b> 2019</span>
|
||||
<span class="created-by">Created with <i class="fa fa-gamepad"></i> by <b><a href="https://frontcraft.me" target="_blank">FrontCraft</a></b></span>
|
||||
<div class="socials">
|
||||
<a href="http://www.versioncontrol.me/" target="_blank" class="ion ion-social-github"></a>
|
||||
</div>
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
</nb-action>
|
||||
<nb-action class="control-item" icon="email-outline"></nb-action>
|
||||
<nb-action class="control-item" icon="bell-outline"></nb-action>
|
||||
|
||||
<nb-action class="user-action">
|
||||
<nb-user [nbContextMenu]="userMenu"
|
||||
[onlyPicture]="userPictureOnly"
|
||||
[onlyPicture]="false"
|
||||
[name]="user?.name"
|
||||
[picture]="user?.picture">
|
||||
</nb-user>
|
||||
</nb-action>
|
||||
|
||||
</nb-actions>
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeService } from '@nebular/theme';
|
||||
|
||||
import { UserData } from '../../../@core/data/users';
|
||||
import { LayoutService } from '../../../@core/utils';
|
||||
import { map, takeUntil } from 'rxjs/operators';
|
||||
import { Subject } from 'rxjs';
|
||||
import { LoginApiService } from '../../../frontcraft/services/login-api';
|
||||
import { User } from '../../../../../../backend/Types/Types';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-header',
|
||||
@@ -15,7 +16,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||
|
||||
private destroy$: Subject<void> = new Subject<void>();
|
||||
userPictureOnly: boolean = false;
|
||||
user: any;
|
||||
user: User;
|
||||
|
||||
themes = [
|
||||
{
|
||||
@@ -44,12 +45,15 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
||||
private menuService: NbMenuService,
|
||||
private themeService: NbThemeService,
|
||||
private layoutService: LayoutService,
|
||||
private breakpointService: NbMediaBreakpointsService) {
|
||||
}
|
||||
private breakpointService: NbMediaBreakpointsService,
|
||||
private loginService: LoginApiService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.currentTheme = this.themeService.currentTheme;
|
||||
|
||||
this.user = this.loginService.getCurrentUser()
|
||||
|
||||
/*
|
||||
this.userService.getUsers()
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
|
||||
import { NgModule } from '@angular/core';
|
||||
import {
|
||||
NbLoginComponent,
|
||||
NbLogoutComponent,
|
||||
NbRegisterComponent,
|
||||
NbRequestPasswordComponent,
|
||||
NbResetPasswordComponent,
|
||||
} from '@nebular/auth';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'pages',
|
||||
loadChildren: () => import('./pages/pages.module')
|
||||
loadChildren: () => import('./demo_pages/pages.module')
|
||||
.then(m => m.PagesModule),
|
||||
},
|
||||
{
|
||||
path: 'auth',
|
||||
loadChildren: () => import('./frontcraft/auth/auth.module')
|
||||
.then(m => m.MyAuthModule),
|
||||
},
|
||||
{
|
||||
path: 'frontcraft',
|
||||
loadChildren: () => import('./frontcraft/pages/pages.module')
|
||||
.then(m => m.FrontcraftPagesModule),
|
||||
},
|
||||
|
||||
{ path: '', redirectTo: 'pages', pathMatch: 'full' },
|
||||
{ path: '**', redirectTo: 'pages' },
|
||||
{ path: '', redirectTo: 'frontcraft', pathMatch: 'full' },
|
||||
{ path: '**', redirectTo: 'frontcraft' },
|
||||
];
|
||||
|
||||
const config: ExtraOptions = {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { AnalyticsService } from './@core/utils/analytics.service';
|
||||
import { LoginApiService } from './frontcraft/login-api';
|
||||
import { LoginApiService } from './frontcraft/services/login-api';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-app',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user