Ver código fonte

add filters for archive raids. add date/time on raid details

master
peter 5 anos atrás
pai
commit
f9110bd2df

+ 1
- 0
.gitignore Ver arquivo

8
 static
8
 static
9
 data
9
 data
10
 conf
10
 conf
11
+log.txt
11
 
12
 
12
 *.d.ts
13
 *.d.ts
13
 *.js
14
 *.js

+ 0
- 138
log.txt Ver arquivo

1
-[2020-04-12T02:46:02.286] [DEBUG] Admin#makeKnex - Making new knex: {
2
-  client: 'sqlite3',
3
-  connection: {
4
-    filename: '/home/cake/nitowa.xyz/frontcraft/admin/data/frontworkAdmin.sqlite'
5
-  },
6
-  migrations: {
7
-    directory: '/home/cake/nitowa.xyz/frontcraft/admin/migrations',
8
-    extension: 'ts'
9
-  },
10
-  useNullAsDefault: true
11
-}
12
-[2020-04-12T02:46:02.426] [DEBUG] Admin#startWebsocket - Websocket up on 20000
13
-[2020-04-12T02:46:02.427] [DEBUG] UserManager#initialize - setting up permissions
14
-skipping spec insertion
15
-[2020-04-12T02:46:02.613] [DEBUG] Admin#start - 6 components initialized
16
-[2020-04-12T02:46:03.296] [INFO] Admin#startWebserver - Frontend from /home/cake/nitowa.xyz/frontcraft/admin/dist/server.js loaded
17
-[2020-04-12T02:46:03.297] [INFO] Admin#startWebserver - Admin panel listening for HTTP on *8080
18
-[2020-04-12T02:46:42.194] [DEBUG] UserManager#checkConnection - {
19
-  celinda: {
20
-    connections: { '45536': [Socket] },
21
-    auth: { token: [Object], user: [Object], port: 20001 },
22
-    user: {
23
-      id: 3,
24
-      username: 'celinda',
25
-      rank: 'Officer',
26
-      MC: 1,
27
-      BWL: 0,
28
-      ZG: 1,
29
-      AQ20: 1,
30
-      AQ40: 1,
31
-      Naxx: 1
32
-    }
33
-  }
34
-} [ 'cfa202ff-5f2c-4e4e-9fa5-9a45233ab0e0' ]
35
-[2020-04-12T02:49:29.208] [DEBUG] UserManager#closeHandler - {
36
-  celinda: {
37
-    connections: {},
38
-    auth: { token: [Object], user: [Object], port: 20001 },
39
-    user: {
40
-      id: 3,
41
-      username: 'celinda',
42
-      rank: 'Officer',
43
-      MC: 1,
44
-      BWL: 0,
45
-      ZG: 1,
46
-      AQ20: 1,
47
-      AQ40: 1,
48
-      Naxx: 1
49
-    }
50
-  }
51
-} [ 'cfa202ff-5f2c-4e4e-9fa5-9a45233ab0e0' ]
52
-[2020-04-12T02:49:31.572] [DEBUG] UserManager#checkConnection - {
53
-  celinda: {
54
-    connections: { '46948': [Socket] },
55
-    auth: { token: [Object], user: [Object], port: 20001 },
56
-    user: {
57
-      id: 3,
58
-      username: 'celinda',
59
-      rank: 'Officer',
60
-      MC: 1,
61
-      BWL: 0,
62
-      ZG: 1,
63
-      AQ20: 1,
64
-      AQ40: 1,
65
-      Naxx: 1
66
-    }
67
-  }
68
-} [ 'cfa202ff-5f2c-4e4e-9fa5-9a45233ab0e0' ]
69
-[2020-04-12T02:49:37.031] [DEBUG] UserManager#closeHandler - {
70
-  celinda: {
71
-    connections: {},
72
-    auth: { token: [Object], user: [Object], port: 20001 },
73
-    user: {
74
-      id: 3,
75
-      username: 'celinda',
76
-      rank: 'Officer',
77
-      MC: 1,
78
-      BWL: 0,
79
-      ZG: 1,
80
-      AQ20: 1,
81
-      AQ40: 1,
82
-      Naxx: 1
83
-    }
84
-  }
85
-} [ 'cfa202ff-5f2c-4e4e-9fa5-9a45233ab0e0' ]
86
-[2020-04-12T02:49:38.886] [DEBUG] UserManager#checkConnection - {
87
-  celinda: {
88
-    connections: { '47044': [Socket] },
89
-    auth: { token: [Object], user: [Object], port: 20001 },
90
-    user: {
91
-      id: 3,
92
-      username: 'celinda',
93
-      rank: 'Officer',
94
-      MC: 1,
95
-      BWL: 0,
96
-      ZG: 1,
97
-      AQ20: 1,
98
-      AQ40: 1,
99
-      Naxx: 1
100
-    }
101
-  }
102
-} [ 'cfa202ff-5f2c-4e4e-9fa5-9a45233ab0e0' ]
103
-[2020-04-12T02:49:44.132] [DEBUG] UserManager#closeHandler - {} []
104
-[2020-04-12T02:52:10.916] [DEBUG] UserManager#checkConnection - {
105
-  celinda: {
106
-    connections: { '48390': [Socket] },
107
-    auth: { token: [Object], user: [Object], port: 20001 },
108
-    user: {
109
-      id: 3,
110
-      username: 'celinda',
111
-      rank: 'Officer',
112
-      MC: 1,
113
-      BWL: 0,
114
-      ZG: 0,
115
-      AQ20: 1,
116
-      AQ40: 1,
117
-      Naxx: 1
118
-    }
119
-  }
120
-} [ '7a8bbb51-412a-4bee-9e0e-9b7cbaef82d8' ]
121
-[2020-04-12T02:52:47.682] [INFO] process#SIGINT - Shutting down from SIGINT (Ctrl-C)
122
-[2020-04-12T02:52:47.684] [DEBUG] UserManager#closeHandler - {
123
-  celinda: {
124
-    connections: {},
125
-    auth: { token: [Object], user: [Object], port: 20001 },
126
-    user: {
127
-      id: 3,
128
-      username: 'celinda',
129
-      rank: 'Officer',
130
-      MC: 1,
131
-      BWL: 0,
132
-      ZG: 0,
133
-      AQ20: 1,
134
-      AQ40: 1,
135
-      Naxx: 1
136
-    }
137
-  }
138
-} [ '7a8bbb51-412a-4bee-9e0e-9b7cbaef82d8' ]

+ 2
- 1
package.json Ver arquivo

5
   "scripts": {
5
   "scripts": {
6
     "tsc": "tsc",
6
     "tsc": "tsc",
7
     "knex": "knex",
7
     "knex": "knex",
8
-    "launch": "node lib/src/backend/Launcher.js > log.txt",
8
+    "launch": "npm run debug > log.txt",
9
+    "debug": "node lib/src/backend/Launcher.js",
9
     "start": "npm run build && npm run launch",
10
     "start": "npm run build && npm run launch",
10
     "start-backend": "npm run build-backend && npm run launch",
11
     "start-backend": "npm run build-backend && npm run launch",
11
     "test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",
12
     "test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",

+ 14
- 5
src/backend/Admin/Admin.ts Ver arquivo

7
 import * as Knex from 'knex';
7
 import * as Knex from 'knex';
8
 import * as http from 'http';
8
 import * as http from 'http';
9
 import * as express from 'express';
9
 import * as express from 'express';
10
+import { existsSync } from "fs";
10
 import { GuildManager } from '../Components/Guild/GuildManager';
11
 import { GuildManager } from '../Components/Guild/GuildManager';
11
 import { ItemManager } from '../Components/Item/ItemManager';
12
 import { ItemManager } from '../Components/Item/ItemManager';
12
 import { RaidManager } from '../Components/Raid/RaidManager';
13
 import { RaidManager } from '../Components/Raid/RaidManager';
21
 import { Injector } from '../Injector/Injector';
22
 import { Injector } from '../Injector/Injector';
22
 import { PubSub } from '../Components/PubSub/PubSub';
23
 import { PubSub } from '../Components/PubSub/PubSub';
23
 
24
 
24
-getLogger().level = 'debug'
25
-
26
 @RootComponent({
25
 @RootComponent({
27
     injectable: IAdmin,
26
     injectable: IAdmin,
28
     injects: [
27
     injects: [
137
 
136
 
138
         this.express.get('*.*', (req, res) => {
137
         this.express.get('*.*', (req, res) => {
139
             //console.log('*.*', req.path);
138
             //console.log('*.*', req.path);
140
-            res.sendFile(Path.join(__dirname, distFolder, 'browser', decodeURIComponent(req.path)))
141
-            res.status(200)
139
+            try{
140
+                const filepath = Path.join(__dirname, distFolder, 'browser', decodeURIComponent(req.path))
141
+                if(!existsSync(filepath)){
142
+                    throw new Error("Bad file access: "+filepath)
143
+                }
144
+                res.sendFile(filepath)
145
+                res.status(200)
146
+            }catch(e){
147
+                getLogger('Admin#startWebserver#serveFile').error(String(e))
148
+                res.send("404 NOT FOUND")
149
+                res.status(404)
150
+            }
142
         })
151
         })
143
 
152
 
144
         try {
153
         try {
145
             const req = require(distFolder + "/server.js")
154
             const req = require(distFolder + "/server.js")
146
             await req.attachExpress(this.express, './dist', getLogger('angularSSR#'))
155
             await req.attachExpress(this.express, './dist', getLogger('angularSSR#'))
147
-            getLogger('Admin#startWebserver').info('Frontend from ' + ngExpressServer + " loaded")
156
+            getLogger('Admin#startWebserver').debug('Frontend from ' + ngExpressServer + " loaded")
148
         } catch (e) {
157
         } catch (e) {
149
             getLogger('Admin#startWebserver').error(e)
158
             getLogger('Admin#startWebserver').error(e)
150
             getLogger('Admin#startWebserver').warn("No angular SSR module was provided in " + ngExpressServer)
159
             getLogger('Admin#startWebserver').warn("No angular SSR module was provided in " + ngExpressServer)

+ 5
- 2
src/backend/Components/Character/CharacterManager.ts Ver arquivo

7
 import { IAdmin } from "../../Admin/Interface";
7
 import { IAdmin } from "../../Admin/Interface";
8
 import { IUserManager } from "../User/Interface";
8
 import { IUserManager } from "../User/Interface";
9
 import { ICharacterManager } from "./Interface";
9
 import { ICharacterManager } from "./Interface";
10
+import { getLogger } from "log4js";
10
 
11
 
11
 @Injectable(ICharacterManager)
12
 @Injectable(ICharacterManager)
12
 export class CharacterManager
13
 export class CharacterManager
61
     initialize = async () => {
62
     initialize = async () => {
62
         if(this.initialized) return
63
         if(this.initialized) return
63
         this.initialized = true
64
         this.initialized = true
64
-        await this.admin.knex('specs').insert(getSpecTableData()).catch(e => { console.log("skipping spec insertion") })
65
+        await this.admin.knex('specs').insert(getSpecTableData()).catch(e => { 
66
+            getLogger('CharacterManager#createCharacter').debug("skipping spec insertion") 
67
+        })
65
     }
68
     }
66
 
69
 
67
     createCharacter = async (userToken: string, character : Character) : Promise<Character> => {
70
     createCharacter = async (userToken: string, character : Character) : Promise<Character> => {
72
             const char : Character = await this.admin.knex.select('*').from('characters').where(character).first()
75
             const char : Character = await this.admin.knex.select('*').from('characters').where(character).first()
73
             return char
76
             return char
74
         }catch(e){
77
         }catch(e){
75
-            console.log(e);
78
+            getLogger('CharacterManager#createCharacter').error(e);
76
         }
79
         }
77
         throw new Error('Unable to create character')
80
         throw new Error('Unable to create character')
78
     }
81
     }

+ 0
- 2
src/backend/Components/User/UserManager.ts Ver arquivo

17
 import { IItemManager } from "../Item/Interface";
17
 import { IItemManager } from "../Item/Interface";
18
 import { IGuildManager } from "../Guild/Interface";
18
 import { IGuildManager } from "../Guild/Interface";
19
 
19
 
20
-getLogger().level = "debug"
21
-
22
 const uuid = require('uuid/v4')
20
 const uuid = require('uuid/v4')
23
 
21
 
24
 const salt = "6pIbc6yjSN"
22
 const salt = "6pIbc6yjSN"

+ 3
- 1
src/backend/Launcher.ts Ver arquivo

1
 import { Injector } from './Injector/Injector';
1
 import { Injector } from './Injector/Injector';
2
 import { IAdmin } from './Admin/Interface';
2
 import { IAdmin } from './Admin/Interface';
3
 import "./Admin/Admin"
3
 import "./Admin/Admin"
4
-require('events').EventEmitter.defaultMaxListeners = 0;
4
+import {getLogger} from 'log4js';
5
+getLogger().level = "debug"
5
 
6
 
7
+require('events').EventEmitter.defaultMaxListeners = 0;
6
 Injector.resolve<IAdmin>(IAdmin).start()
8
 Injector.resolve<IAdmin>(IAdmin).start()

+ 5
- 0
src/frontend/package-lock.json Ver arquivo

13523
       "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
13523
       "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
13524
       "dev": true
13524
       "dev": true
13525
     },
13525
     },
13526
+    "node-fetch": {
13527
+      "version": "2.6.0",
13528
+      "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
13529
+      "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA=="
13530
+    },
13526
     "node-fetch-npm": {
13531
     "node-fetch-npm": {
13527
       "version": "2.0.2",
13532
       "version": "2.0.2",
13528
       "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz",
13533
       "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz",

+ 1
- 0
src/frontend/package.json Ver arquivo

74
     "ng2-smart-table": "1.3.5",
74
     "ng2-smart-table": "1.3.5",
75
     "ngx-cookie-service": "^2.2.0",
75
     "ngx-cookie-service": "^2.2.0",
76
     "ngx-echarts": "^4.0.1",
76
     "ngx-echarts": "^4.0.1",
77
+    "node-fetch": "^2.6.0",
77
     "node-sass": "^4.13.1",
78
     "node-sass": "^4.13.1",
78
     "normalize.css": "6.0.0",
79
     "normalize.css": "6.0.0",
79
     "pace-js": "1.0.2",
80
     "pace-js": "1.0.2",

+ 9
- 1
src/frontend/server.ts Ver arquivo

7
 import { enableProdMode } from '@angular/core';
7
 import { enableProdMode } from '@angular/core';
8
 const domino = require('domino');
8
 const domino = require('domino');
9
 const win = domino.createWindow('');
9
 const win = domino.createWindow('');
10
+const fetch = require('node-fetch');
10
 
11
 
11
 global['window'] = win;
12
 global['window'] = win;
12
 global['document'] = win.document;
13
 global['document'] = win.document;
13
 global['alert'] = console.log
14
 global['alert'] = console.log
14
 global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
15
 global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
16
+global['fetch'] = fetch.default;
17
+
18
+
15
 
19
 
16
 export async function attachExpress(app, staticDir = "./dist", logger = console) {
20
 export async function attachExpress(app, staticDir = "./dist", logger = console) {
17
   const STATIC_FOLDER = resolve(process.cwd(), staticDir);
21
   const STATIC_FOLDER = resolve(process.cwd(), staticDir);
54
 
58
 
55
   app.get('*', (req, res) => {
59
   app.get('*', (req, res) => {
56
     //console.log('*', req.path);
60
     //console.log('*', req.path);
57
-    res.render(resolve(STATIC_FOLDER, 'browser/index'), { req, res })
61
+    try{
62
+      res.render(resolve(STATIC_FOLDER, 'browser/index'), { req, res })
63
+    }catch(e){
64
+      loggerService.error(e)
65
+    }
58
   });
66
   });
59
 }
67
 }

+ 3
- 0
src/frontend/src/app/frontcraft/pages/raid/raid.component.html Ver arquivo

15
                         <p style="white-space: pre-line;">
15
                         <p style="white-space: pre-line;">
16
                             {{raid.description}}
16
                             {{raid.description}}
17
                         </p>
17
                         </p>
18
+                        <p>
19
+                            {{raid.start | date : 'EEE MMM d'}} {{raid.start | date : 'HH:mm'}}
20
+                        </p>
18
                         <div *ngIf="canSignup">
21
                         <div *ngIf="canSignup">
19
                             <div *ngIf="isSignedup" style="width: 100%;">
22
                             <div *ngIf="isSignedup" style="width: 100%;">
20
                                 <p style="white-space: pre-line;">
23
                                 <p style="white-space: pre-line;">

+ 9
- 1
src/frontend/src/app/frontcraft/pages/raids/raids.component.html Ver arquivo

39
 </nb-card>
39
 </nb-card>
40
 
40
 
41
 <nb-card class="col-12 col-xl-9">
41
 <nb-card class="col-12 col-xl-9">
42
-  <nb-card-header>Previous raids</nb-card-header>
42
+  <nb-card-header>Previous raids (Limit <input nbInput style="width: 100px;" type="number" [(ngModel)]="archiveCount" (change)="refresh()" /> 
43
+    Showing only tier 
44
+    <nb-select [(selected)]="tier" placeholder="Tier" (selectedChange)="refresh()">
45
+      <nb-option *ngFor="let _tier of tiers" [value]="_tier">
46
+        {{_tier}}
47
+      </nb-option>
48
+    </nb-select>
49
+    )
50
+  </nb-card-header>
43
   <nb-list nbInfiniteList listenWindowScroll [threshold]="500">
51
   <nb-list nbInfiniteList listenWindowScroll [threshold]="500">
44
     <nb-list-item *ngFor="let raid of oldraids" [routerLink]="'/frontcraft/archive/'+raid.id">
52
     <nb-list-item *ngFor="let raid of oldraids" [routerLink]="'/frontcraft/archive/'+raid.id">
45
       <a [routerLink]="'/frontcraft/archive/'+raid.id">
53
       <a [routerLink]="'/frontcraft/archive/'+raid.id">

+ 10
- 2
src/frontend/src/app/frontcraft/pages/raids/raids.component.ts Ver arquivo

6
 import { UpdatingComponent } from '../../UpdatingComponent';
6
 import { UpdatingComponent } from '../../UpdatingComponent';
7
 import { LoggerService } from '../../services/LoggerService/logger.service';
7
 import { LoggerService } from '../../services/LoggerService/logger.service';
8
 import { FlashService } from '../../services/flash-service';
8
 import { FlashService } from '../../services/flash-service';
9
+import { Tiers, _Tiers } from '../../../../../../backend/Types/Items';
9
 
10
 
10
 @Component({
11
 @Component({
11
   selector: 'raids',
12
   selector: 'raids',
16
   extends UpdatingComponent
17
   extends UpdatingComponent
17
   implements OnInit {
18
   implements OnInit {
18
 
19
 
20
+  archiveCount = 50
21
+  tiers:string[] = ["any", ..._Tiers]
22
+  tier = "any"
19
 
23
 
20
   manageRaid
24
   manageRaid
21
   raids = []
25
   raids = []
22
   oldraids = []
26
   oldraids = []
23
-  pageSize = 10;
27
+  pageSize = 25;
24
 
28
 
25
   constructor(
29
   constructor(
26
     injector: Injector,
30
     injector: Injector,
47
   async refresh() {
51
   async refresh() {
48
     this.raids = await this.api.get('RaidManager').getRaids()
52
     this.raids = await this.api.get('RaidManager').getRaids()
49
     const raidManager = this.api.get('RaidManager')
53
     const raidManager = this.api.get('RaidManager')
50
-    this.oldraids = await raidManager.getPastRaids(10)
54
+    this.oldraids = await raidManager.getPastRaids(this.archiveCount)
55
+
56
+    if(this.tier !== "any"){
57
+      this.oldraids = this.oldraids.filter(raid => raid.tier === this.tier)
58
+    }
51
   }
59
   }
52
 
60
 
53
   create() {
61
   create() {

Carregando…
Cancelar
Salvar