Parcourir la source

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

master
peter il y a 5 ans
Parent
révision
f9110bd2df

+ 1
- 0
.gitignore Voir le fichier

@@ -8,6 +8,7 @@ plugins
8 8
 static
9 9
 data
10 10
 conf
11
+log.txt
11 12
 
12 13
 *.d.ts
13 14
 *.js

+ 0
- 138
log.txt Voir le fichier

@@ -1,138 +0,0 @@
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 Voir le fichier

@@ -5,7 +5,8 @@
5 5
   "scripts": {
6 6
     "tsc": "tsc",
7 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 10
     "start": "npm run build && npm run launch",
10 11
     "start-backend": "npm run build-backend && npm run launch",
11 12
     "test": "rm -rf data && npm run build-backend && mocha lib/test/backendTest.js",

+ 14
- 5
src/backend/Admin/Admin.ts Voir le fichier

@@ -7,6 +7,7 @@ import * as Path from 'path'
7 7
 import * as Knex from 'knex';
8 8
 import * as http from 'http';
9 9
 import * as express from 'express';
10
+import { existsSync } from "fs";
10 11
 import { GuildManager } from '../Components/Guild/GuildManager';
11 12
 import { ItemManager } from '../Components/Item/ItemManager';
12 13
 import { RaidManager } from '../Components/Raid/RaidManager';
@@ -21,8 +22,6 @@ import { IAdmin } from './Interface';
21 22
 import { Injector } from '../Injector/Injector';
22 23
 import { PubSub } from '../Components/PubSub/PubSub';
23 24
 
24
-getLogger().level = 'debug'
25
-
26 25
 @RootComponent({
27 26
     injectable: IAdmin,
28 27
     injects: [
@@ -137,14 +136,24 @@ export class FrontworkAdmin
137 136
 
138 137
         this.express.get('*.*', (req, res) => {
139 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 153
         try {
145 154
             const req = require(distFolder + "/server.js")
146 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 157
         } catch (e) {
149 158
             getLogger('Admin#startWebserver').error(e)
150 159
             getLogger('Admin#startWebserver').warn("No angular SSR module was provided in " + ngExpressServer)

+ 5
- 2
src/backend/Components/Character/CharacterManager.ts Voir le fichier

@@ -7,6 +7,7 @@ import { getSpecTableData, SpecT } from "../../Types/PlayerSpecs";
7 7
 import { IAdmin } from "../../Admin/Interface";
8 8
 import { IUserManager } from "../User/Interface";
9 9
 import { ICharacterManager } from "./Interface";
10
+import { getLogger } from "log4js";
10 11
 
11 12
 @Injectable(ICharacterManager)
12 13
 export class CharacterManager
@@ -61,7 +62,9 @@ implements FrontworkComponent<CharacterManagerIfc, RPCInterface>, ICharacterMana
61 62
     initialize = async () => {
62 63
         if(this.initialized) return
63 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 70
     createCharacter = async (userToken: string, character : Character) : Promise<Character> => {
@@ -72,7 +75,7 @@ implements FrontworkComponent<CharacterManagerIfc, RPCInterface>, ICharacterMana
72 75
             const char : Character = await this.admin.knex.select('*').from('characters').where(character).first()
73 76
             return char
74 77
         }catch(e){
75
-            console.log(e);
78
+            getLogger('CharacterManager#createCharacter').error(e);
76 79
         }
77 80
         throw new Error('Unable to create character')
78 81
     }

+ 0
- 2
src/backend/Components/User/UserManager.ts Voir le fichier

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

+ 3
- 1
src/backend/Launcher.ts Voir le fichier

@@ -1,6 +1,8 @@
1 1
 import { Injector } from './Injector/Injector';
2 2
 import { IAdmin } from './Admin/Interface';
3 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 8
 Injector.resolve<IAdmin>(IAdmin).start()

+ 5
- 0
src/frontend/package-lock.json Voir le fichier

@@ -13523,6 +13523,11 @@
13523 13523
       "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
13524 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 13531
     "node-fetch-npm": {
13527 13532
       "version": "2.0.2",
13528 13533
       "resolved": "https://registry.npmjs.org/node-fetch-npm/-/node-fetch-npm-2.0.2.tgz",

+ 1
- 0
src/frontend/package.json Voir le fichier

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

+ 9
- 1
src/frontend/server.ts Voir le fichier

@@ -7,11 +7,15 @@ import { resolve } from 'path';
7 7
 import { enableProdMode } from '@angular/core';
8 8
 const domino = require('domino');
9 9
 const win = domino.createWindow('');
10
+const fetch = require('node-fetch');
10 11
 
11 12
 global['window'] = win;
12 13
 global['document'] = win.document;
13 14
 global['alert'] = console.log
14 15
 global['XMLHttpRequest'] = require('xmlhttprequest').XMLHttpRequest;
16
+global['fetch'] = fetch.default;
17
+
18
+
15 19
 
16 20
 export async function attachExpress(app, staticDir = "./dist", logger = console) {
17 21
   const STATIC_FOLDER = resolve(process.cwd(), staticDir);
@@ -54,6 +58,10 @@ export async function attachExpress(app, staticDir = "./dist", logger = console)
54 58
 
55 59
   app.get('*', (req, res) => {
56 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 Voir le fichier

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

+ 9
- 1
src/frontend/src/app/frontcraft/pages/raids/raids.component.html Voir le fichier

@@ -39,7 +39,15 @@
39 39
 </nb-card>
40 40
 
41 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 51
   <nb-list nbInfiniteList listenWindowScroll [threshold]="500">
44 52
     <nb-list-item *ngFor="let raid of oldraids" [routerLink]="'/frontcraft/archive/'+raid.id">
45 53
       <a [routerLink]="'/frontcraft/archive/'+raid.id">

+ 10
- 2
src/frontend/src/app/frontcraft/pages/raids/raids.component.ts Voir le fichier

@@ -6,6 +6,7 @@ import { IApiService } from '../../services/ApiService/ApiService';
6 6
 import { UpdatingComponent } from '../../UpdatingComponent';
7 7
 import { LoggerService } from '../../services/LoggerService/logger.service';
8 8
 import { FlashService } from '../../services/flash-service';
9
+import { Tiers, _Tiers } from '../../../../../../backend/Types/Items';
9 10
 
10 11
 @Component({
11 12
   selector: 'raids',
@@ -16,11 +17,14 @@ export class FrontcraftRaidsComponent
16 17
   extends UpdatingComponent
17 18
   implements OnInit {
18 19
 
20
+  archiveCount = 50
21
+  tiers:string[] = ["any", ..._Tiers]
22
+  tier = "any"
19 23
 
20 24
   manageRaid
21 25
   raids = []
22 26
   oldraids = []
23
-  pageSize = 10;
27
+  pageSize = 25;
24 28
 
25 29
   constructor(
26 30
     injector: Injector,
@@ -47,7 +51,11 @@ export class FrontcraftRaidsComponent
47 51
   async refresh() {
48 52
     this.raids = await this.api.get('RaidManager').getRaids()
49 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 61
   create() {

Chargement…
Annuler
Enregistrer