diff --git a/server.js b/server.js index 8132c6b..1ba5158 100644 --- a/server.js +++ b/server.js @@ -543,7 +543,7 @@ function main() { if (err) console.log("error", err)//serverError(res, err); else if (dbResC != null) { - if (dbResC.player_count == '' || dbResC.player_count < parseInt(dbResC.player_limit)) { + if (dbResC.player_limit == '' || dbResC.player_count < parseInt(dbResC.player_limit) || req.userSession.access_level <= 5) { let insWlPlayer = { id_clan: dbResC._id, username: parm.username, diff --git a/src/App.vue b/src/App.vue index 734b68a..e4bd646 100644 --- a/src/App.vue +++ b/src/App.vue @@ -255,7 +255,7 @@ - + @@ -312,7 +312,10 @@ tabData.Whitelist.add_data = $event; " @confirm="removeWhitelistPlayer" - @import_whitelist="popups.importWhitelist = true" + @import_whitelist=" + popups.importWhitelist = true; + tabData.Whitelist.add_data = $event; + " /> diff --git a/src/assets/base.css b/src/assets/base.css index 364744e..232b933 100644 --- a/src/assets/base.css +++ b/src/assets/base.css @@ -278,6 +278,14 @@ label { .overflow { overflow: auto; } +.overflow.y { + overflow: hidden; + overflow-y: auto; +} +.overflow.x { + overflow: hidden; + overflow-x: auto; +} .hoverMenu { position: absolute; diff --git a/src/components/importWhitelist.vue b/src/components/importWhitelist.vue index 4d992db..8be27f8 100644 --- a/src/components/importWhitelist.vue +++ b/src/components/importWhitelist.vue @@ -18,32 +18,69 @@ confBtnText: 'Next', }, { - title: 'Import', + title: 'Player Names', confBtnText: 'Import', }, ], currentStep: 0, + importFoundGroups: [] as Array, + parListImport: [] as Array, + game_groups: [] as Array, + conv_gameGroups: {} as any, + player_name_conv: {} as any, }; }, + props: { + add_data: { + required: true, + type: Object, + }, + }, methods: { - confirmBtnClick(dt: any) { - if (this.currentStep < this.importSteps.length - 1) { - this.currentStep++; + confirmBtnClick: function (dt: any) { + if (this.currentStep == 0) { + const listImport = this.$el + .querySelector('textarea') + .value.split('\n') + .filter((a: any) => a != '' && a.startsWith('Admin')); + const reg = /^Admin=(?\d{17}):(?.[a-zA-Z_]{1,})((\s\/{2}\s?)(?.{1,}))?/gm; + + listImport.forEach((elm: any, key: any) => { + const r = elm; + const regRes = this.regexExec(r, reg) as any; + const regResGr = regRes.groups; + this.parListImport.push(regResGr); + if (!this.importFoundGroups.includes(regResGr.group)) this.importFoundGroups.push(regResGr.group); + }); + this.parListImport = this.parListImport.filter((a: any) => a != null); + console.log('List Import', this.parListImport); + // console.log('Found Groups', this.importFoundGroups); + } else if (this.currentStep == 1) { + for (let fg of this.importFoundGroups) { + this.conv_gameGroups[fg] = dt['sel-' + fg]; + } + console.log(this.conv_gameGroups); + } else if (this.currentStep == 2) { + console.log(dt); + this.player_name_conv = dt; + } - if (this.currentStep == 1) { - const listImport = this.$el - .querySelector('textarea') - .value.split('\n') - .filter((a: any) => a != '' && a.startsWith('Admin')); - let parListImport = [] as Array; - const reg = /^Admin=(?\d{17}):(?.[a-zA-Z_]{1,})((\s\/{2}\s?)(?.{1,}))?/gm; + if (this.currentStep + 1 < this.importSteps.length) this.currentStep++; + else { + const delay = 50; + let c = 0; + for (let p of this.parListImport) { + const player = { + username: this.player_name_conv[p.steamid], + steamid64: p.steamid, + group: this.conv_gameGroups[p.group], + sel_clan_id: this.add_data.sel_clan, + }; + console.log('Importing whitelist', player); - listImport.forEach((elm: any, key: any) => { - const r = elm; - const regRes = reg.exec(r); - parListImport.push(regRes?.groups); - }); - console.log('List Import', listImport, parListImport); + setTimeout(() => { + this.requestAddToWhitelist(player); + }, delay * c++); } } // console.log(dt); @@ -65,6 +102,49 @@ // }, // }); }, + requestAddToWhitelist: function (dt: any) { + $.ajax({ + url: '/api/whitelist/write/addPlayer', + type: 'post', + data: JSON.stringify(dt), + dataType: 'json', + contentType: 'application/json', + timeout: 60000, + success: (dt) => { + if (dt.status == 'inserted_new_player') { + const plDt = { ...dt.player, group_full_data: this.game_groups.filter((g) => g._id == dt.player.id_group) }; + console.log(plDt); + this.add_data.callback(plDt); + this.$emit('cancelBtnClick'); + } else { + console.error(dt); + this.$emit('cancelBtnClick'); + } + }, + error: (err) => { + console.error(err); + this.$emit('cancelBtnClick'); + }, + }); + }, + regexExec: function (str: string, regex: RegExp) { + if (str.match(regex)) { + const r = regex.exec(str); + if (r == null) this.regexExec(str, regex); + else return r; + } else return null; + }, + getGameGroups: function () { + fetch('/api/gameGroups/read/getAllGroups') + .then((res) => res.json()) + .then((dt) => { + console.log('Game Groups', dt); + this.game_groups = dt; + }); + }, + }, + created() { + this.getGameGroups(); }, components: { popup }, }; @@ -74,6 +154,20 @@

{{ importSteps[currentStep].title }}

+
+
+ {{ g }} + +
+
+
+
+ {{ game_groups.filter((g) => g._id == conv_gameGroups[p.group])[0].group_name }}{{ p.steamid }} +
+
@@ -93,4 +187,11 @@ flex-grow: 1; white-space: nowrap; } + .grTranslation { + display: flex; + flex-wrap: nowrap; + flex-direction: row; + align-items: center; + justify-content: center; + } diff --git a/src/components/whitelistTab.vue b/src/components/whitelistTab.vue index 4cdeb38..2d804c6 100644 --- a/src/components/whitelistTab.vue +++ b/src/components/whitelistTab.vue @@ -78,7 +78,7 @@ - + {{ sel_clan_obj.player_count }}/ {{ sel_clan_obj.player_limit && sel_clan_obj.player_limit != '' ? sel_clan_obj.player_limit : '∞' }}