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
|
export class ItemManager
|
||||||
implements FrontworkComponent<ItemManagerFeatureIfc>, TableDefinitionExporter{
|
implements FrontworkComponent<any, any, ItemManagerFeatureIfc>, TableDefinitionExporter{
|
||||||
|
|
||||||
admin:FrontworkAdmin
|
admin:FrontworkAdmin
|
||||||
name = "ItemManager";
|
name = "ItemManager";
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { FrontworkComponent } from "../../Types/FrontworkComponent";
|
|||||||
|
|
||||||
|
|
||||||
export class RaidManager
|
export class RaidManager
|
||||||
implements FrontworkComponent<RaidManagerFeatureIfc>{
|
implements FrontworkComponent<any, any, RaidManagerFeatureIfc>{
|
||||||
name = "RaidManager";
|
name = "RaidManager";
|
||||||
admin: FrontworkAdmin
|
admin: FrontworkAdmin
|
||||||
|
|
||||||
|
|||||||
+22
-4
@@ -1,13 +1,19 @@
|
|||||||
import { RPCServer } from "rpclibrary";
|
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 { FrontworkAdmin } from "../../Admin/Admin";
|
||||||
import { PrivilegedRPCExporter } from "../../Types/PrivilegedRPCExporter";
|
import { PrivilegedRPCExporter } from "../../Types/PrivilegedRPCExporter";
|
||||||
import { FrontworkComponent } from "../../Types/FrontworkComponent";
|
import { FrontworkComponent } from "../../Types/FrontworkComponent";
|
||||||
|
import { getSpecTableData } from "../../Types/PlayerSpecs"
|
||||||
const uuid = require('uuid/v4')
|
const uuid = require('uuid/v4')
|
||||||
|
|
||||||
|
export type LoginManagerIfc = {
|
||||||
|
Authenticator: {
|
||||||
|
login: (username:string, pwHash:string) => Promise<Token>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class LoginManager
|
export class LoginManager
|
||||||
implements FrontworkComponent{
|
implements FrontworkComponent<LoginManagerFeatureIfc>{
|
||||||
name = "Authenticator" as "Authenticator";
|
name = "Authenticator" as "Authenticator";
|
||||||
admin:FrontworkAdmin
|
admin:FrontworkAdmin
|
||||||
|
|
||||||
@@ -59,7 +65,8 @@ implements FrontworkComponent{
|
|||||||
table.string("name").notNullable().unique()
|
table.string("name").notNullable().unique()
|
||||||
table.string("pwhash").notNullable()
|
table.string("pwhash").notNullable()
|
||||||
table.string("rank").notNullable()
|
table.string("rank").notNullable()
|
||||||
table.string("class").notNullable()
|
table.integer("specid").notNullable()
|
||||||
|
table.foreign('specid').references('specs.id')
|
||||||
table.string("email").nullable().unique()
|
table.string("email").nullable().unique()
|
||||||
}
|
}
|
||||||
},{
|
},{
|
||||||
@@ -77,6 +84,13 @@ implements FrontworkComponent{
|
|||||||
table.foreign('user_id').references('users')
|
table.foreign('user_id').references('users')
|
||||||
table.dateTime('created').defaultTo(this.admin.knex.fn.now())
|
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)]
|
,...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))
|
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){
|
async setPermission(permission: RPCPermission){
|
||||||
@@ -147,7 +165,7 @@ implements FrontworkComponent{
|
|||||||
if(typeof tokenValue !== 'string') tokenValue = tokenValue.value
|
if(typeof tokenValue !== 'string') tokenValue = tokenValue.value
|
||||||
|
|
||||||
const res : User[] = await this.admin.knex
|
const res : User[] = await this.admin.knex
|
||||||
.select('users.id', 'name', 'class', 'rank', 'email')
|
.select('users.id', 'name', 'specid', 'rank', 'email')
|
||||||
.from('tokens')
|
.from('tokens')
|
||||||
.join('users', function(){
|
.join('users', function(){
|
||||||
this.on('users.id', '=', 'tokens.user_id')
|
this.on('users.id', '=', 'tokens.user_id')
|
||||||
@@ -1,19 +1,21 @@
|
|||||||
import { FrontworkAdmin } from './Admin/Admin'
|
import { FrontworkAdmin } from './Admin/Admin'
|
||||||
import { RaidManager } from "./Components/Raid/RaidManager";
|
import { RaidManager } from "./Components/Raid/RaidManager";
|
||||||
import { ItemManager } from "./Components/Item/ItemManager";
|
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 { Debugger } from './Components/Debugger/Debugger';
|
||||||
import { FrontworkComponent } from './Types/FrontworkComponent';
|
import { FrontworkComponent } from './Types/FrontworkComponent';
|
||||||
|
import { GuildManager } from './Components/Guild/GuildManager';
|
||||||
require('events').EventEmitter.defaultMaxListeners = 0;
|
require('events').EventEmitter.defaultMaxListeners = 0;
|
||||||
|
|
||||||
let raidManager = new RaidManager()
|
let raidManager = new RaidManager()
|
||||||
let itemManager = new ItemManager()
|
let itemManager = new ItemManager()
|
||||||
let loginManager = new LoginManager([
|
let guildManager = new GuildManager()
|
||||||
|
let userManager = new LoginManager([
|
||||||
raidManager,
|
raidManager,
|
||||||
itemManager
|
itemManager
|
||||||
])
|
])
|
||||||
|
|
||||||
let components:FrontworkComponent[] = [ raidManager, itemManager, loginManager ]
|
let components:FrontworkComponent[] = [ guildManager, raidManager, itemManager, userManager ]
|
||||||
let dbg = new Debugger(components)
|
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
|
id?: number
|
||||||
name: string
|
name: string
|
||||||
pwhash: string
|
pwhash: string
|
||||||
class: Class
|
specid: number
|
||||||
rank: Rank
|
rank: Rank
|
||||||
email?: string
|
email?: string
|
||||||
}
|
}
|
||||||
@@ -90,6 +90,12 @@ export type RaidManagerFeatureIfc = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Spec = {
|
||||||
|
id?: number,
|
||||||
|
class: Class,
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
export type SomeOf<T> = {
|
export type SomeOf<T> = {
|
||||||
[K in keyof T]? : T[K]
|
[K in keyof T]? : T[K]
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
PlayerService,
|
PlayerService,
|
||||||
StateService,
|
StateService,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
import { LoginApiService, initializeLoginSvc } from '../frontcraft/login-api';
|
import { LoginApiService, initializeLoginSvc } from '../frontcraft/services/login-api';
|
||||||
|
|
||||||
const DATA_SERVICES = [
|
const DATA_SERVICES = [
|
||||||
{provide: LoginApiService, useClass: LoginApiService},
|
{provide: LoginApiService, useClass: LoginApiService},
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Component } from '@angular/core';
|
|||||||
selector: 'ngx-footer',
|
selector: 'ngx-footer',
|
||||||
styleUrls: ['./footer.component.scss'],
|
styleUrls: ['./footer.component.scss'],
|
||||||
template: `
|
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">
|
<div class="socials">
|
||||||
<a href="http://www.versioncontrol.me/" target="_blank" class="ion ion-social-github"></a>
|
<a href="http://www.versioncontrol.me/" target="_blank" class="ion ion-social-github"></a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
</nb-action>
|
</nb-action>
|
||||||
<nb-action class="control-item" icon="email-outline"></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="control-item" icon="bell-outline"></nb-action>
|
||||||
|
|
||||||
<nb-action class="user-action">
|
<nb-action class="user-action">
|
||||||
<nb-user [nbContextMenu]="userMenu"
|
<nb-user [nbContextMenu]="userMenu"
|
||||||
[onlyPicture]="userPictureOnly"
|
[onlyPicture]="false"
|
||||||
[name]="user?.name"
|
[name]="user?.name"
|
||||||
[picture]="user?.picture">
|
[picture]="user?.picture">
|
||||||
</nb-user>
|
</nb-user>
|
||||||
</nb-action>
|
</nb-action>
|
||||||
|
|
||||||
</nb-actions>
|
</nb-actions>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeService } from '@nebular/theme';
|
import { NbMediaBreakpointsService, NbMenuService, NbSidebarService, NbThemeService } from '@nebular/theme';
|
||||||
|
|
||||||
import { UserData } from '../../../@core/data/users';
|
|
||||||
import { LayoutService } from '../../../@core/utils';
|
import { LayoutService } from '../../../@core/utils';
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
import { LoginApiService } from '../../../frontcraft/services/login-api';
|
||||||
|
import { User } from '../../../../../../backend/Types/Types';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-header',
|
selector: 'ngx-header',
|
||||||
@@ -15,7 +16,7 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private destroy$: Subject<void> = new Subject<void>();
|
private destroy$: Subject<void> = new Subject<void>();
|
||||||
userPictureOnly: boolean = false;
|
userPictureOnly: boolean = false;
|
||||||
user: any;
|
user: User;
|
||||||
|
|
||||||
themes = [
|
themes = [
|
||||||
{
|
{
|
||||||
@@ -44,12 +45,15 @@ export class HeaderComponent implements OnInit, OnDestroy {
|
|||||||
private menuService: NbMenuService,
|
private menuService: NbMenuService,
|
||||||
private themeService: NbThemeService,
|
private themeService: NbThemeService,
|
||||||
private layoutService: LayoutService,
|
private layoutService: LayoutService,
|
||||||
private breakpointService: NbMediaBreakpointsService) {
|
private breakpointService: NbMediaBreakpointsService,
|
||||||
}
|
private loginService: LoginApiService
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.currentTheme = this.themeService.currentTheme;
|
this.currentTheme = this.themeService.currentTheme;
|
||||||
|
|
||||||
|
this.user = this.loginService.getCurrentUser()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
this.userService.getUsers()
|
this.userService.getUsers()
|
||||||
.pipe(takeUntil(this.destroy$))
|
.pipe(takeUntil(this.destroy$))
|
||||||
|
|||||||
@@ -1,22 +1,25 @@
|
|||||||
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
|
import { ExtraOptions, RouterModule, Routes } from '@angular/router';
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import {
|
|
||||||
NbLoginComponent,
|
|
||||||
NbLogoutComponent,
|
|
||||||
NbRegisterComponent,
|
|
||||||
NbRequestPasswordComponent,
|
|
||||||
NbResetPasswordComponent,
|
|
||||||
} from '@nebular/auth';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: 'pages',
|
path: 'pages',
|
||||||
loadChildren: () => import('./pages/pages.module')
|
loadChildren: () => import('./demo_pages/pages.module')
|
||||||
.then(m => m.PagesModule),
|
.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: 'frontcraft', pathMatch: 'full' },
|
||||||
{ path: '**', redirectTo: 'pages' },
|
{ path: '**', redirectTo: 'frontcraft' },
|
||||||
];
|
];
|
||||||
|
|
||||||
const config: ExtraOptions = {
|
const config: ExtraOptions = {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { AnalyticsService } from './@core/utils/analytics.service';
|
import { AnalyticsService } from './@core/utils/analytics.service';
|
||||||
import { LoginApiService } from './frontcraft/login-api';
|
import { LoginApiService } from './frontcraft/services/login-api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ngx-app',
|
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