diff --git a/package.json b/package.json index d42f148ac8..cca649ed22 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "he": "1.2.0", "highcharts": "11.4.7", "highcharts-vue": "1.4.3", + "jsonata": "2.0.4", "leaflet.heat": "0.2.0", "localforage": "1.10.0", "lodash": "4.17.21", @@ -129,4 +130,4 @@ "author": "The LSSM-Team: Sanni, Jan (jxn_30), Ron31, Crazycake", "description": "LSSM V4 is a Script-Collection for Leitstellenspiel, Missionchief, Meldkamerspel and its other language versions." } -} \ No newline at end of file +} diff --git a/src/generated/libraries.json b/src/generated/libraries.json index ca78e3a435..470f7109e2 100644 --- a/src/generated/libraries.json +++ b/src/generated/libraries.json @@ -265,6 +265,10 @@ "js-yaml": { "version": "4.1.0" }, + "jsonata": { + "url": "http://jsonata.org/", + "version": "2.0.4" + }, "leaflet.heat": { "url": "https://github.com/Leaflet/Leaflet.heat", "version": "0.2.0" diff --git a/src/modules/lssmaql/assets/parser.ts b/src/modules/lssmaql/assets/parser.ts deleted file mode 100644 index cd78577587..0000000000 --- a/src/modules/lssmaql/assets/parser.ts +++ /dev/null @@ -1,75 +0,0 @@ -import type { - Condition, - FunctionTree, - ObjectTree, - QueryTree, - Token, -} from 'typings/modules/LSSMAQL'; - -const baseObjects = ['allianceinfo', 'buildings', 'vehicles', 'missions']; -const functions = ['len', 'sum', 'min', 'max']; -const comparisons = ['>', '<', '<=', '>=', '=', '!=', 'IN', 'NOT IN']; - -const parser = (tokens: Token[], base?: ObjectTree['base']): QueryTree => { - let tree = {} as QueryTree; - if (base) tokens.unshift({ type: 'identifier', value: 'base' }); - const token = tokens.shift(); - if (!token || token.type !== 'identifier') return tree; - if ((token && baseObjects.includes(token.value)) || base) { - tree = { - type: 'object', - base: base ?? (token?.value as ObjectTree['base']), - attributes: [], - filter: [], - }; - while ( - tokens.length && - ['getter_dot', 'getter_num'].includes(tokens[0].type) - ) { - if (tokens[0].type === 'getter_num') { - tree.attributes.push( - parseInt( - tokens.shift()?.value.replace(/^\[|\]$/gu, '') || '-1' - ) - ); - } else if (tokens.length >= 2 && tokens[1].type === 'identifier') { - tokens.shift(); - tree.attributes.push(tokens.shift()?.value || -1); - } else if (tokens.length >= 2 && tokens[1].type === 'getter_dot') { - tokens.shift(); - tree.attributes.push('..'); - } else { - break; - } - } - if (tokens.length >= 2 && tokens[0].type === 'where') { - tokens.shift(); - const left = [] as Token[]; - while (tokens.length && !comparisons.includes(tokens[0].value)) { - const token = tokens.shift(); - if (!token) break; - left.push(token); - } - const token = tokens.shift(); - if (!token) return tree; - const comparison = token.value as Condition['comparison']; - const right = [] as Token[]; - while (tokens.length && !['AND', 'OR'].includes(tokens[0].value)) { - const token = tokens.shift(); - if (!token) break; - right.push(token); - } - tree.filter.push({ left, comparison, right }); - } - } else if (token && functions.includes(token.value)) { - tree = { - type: 'function', - function: token.value as FunctionTree['function'], - base: base ?? '', - body: null, - }; - } - return tree; -}; - -export default parser; diff --git a/src/modules/lssmaql/assets/tokenizer.ts b/src/modules/lssmaql/assets/tokenizer.ts deleted file mode 100644 index 8f3b19bed1..0000000000 --- a/src/modules/lssmaql/assets/tokenizer.ts +++ /dev/null @@ -1,54 +0,0 @@ -import type { QueryTokens, Token, TokenRegexes } from 'typings/modules/LSSMAQL'; - -const regexes = { - getter_dot: /\./u, - getter_num: /\[\d+\]/u, - where: /WHERE/u, - not_in: /NOT IN/u, - in: /IN/u, - and: /AND/u, - or: /OR/u, - greater_equal: />=/u, - smaller_equal: /<=/u, - equals: /=/u, - unequal: /!=/u, - greater: />/u, - smaller: / { - let newQuery = query; - Object.entries(regexes).some(([token, regex]) => { - const startRegex = new RegExp( - `^(${regex.toString().replace(/^\/|\/[ADJUgimux]*$/gu, '')})` - ); - const match = query.match(startRegex); - if (match) { - newQuery = query.replace(startRegex, ''); - token_list.push({ - type: token as QueryTokens, - value: match[0].replace(/^["']|["']$/gu, ''), - }); - return true; - } - return false; - }); - return newQuery.trim(); -}; - -export default (query: string): Token[] => { - let newQuery = query.trim(); - const token_list = [] as Token[]; - while (newQuery.length) { - const queryBefore = newQuery; - newQuery = consume(newQuery, token_list); - if (queryBefore === newQuery) break; - } - return token_list; -}; diff --git a/src/modules/lssmaql/i18n/de_DE.json b/src/modules/lssmaql/i18n/de_DE.json new file mode 100644 index 0000000000..1a3235f3a4 --- /dev/null +++ b/src/modules/lssmaql/i18n/de_DE.json @@ -0,0 +1,6 @@ +{ + "console": "Konsole", + "execute": "Ausführen", + "query": "Deine LSSM-AQL Abfrage", + "result": "Ergebnis" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/en_AU.json b/src/modules/lssmaql/i18n/en_AU.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/en_AU.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/en_GB.json b/src/modules/lssmaql/i18n/en_GB.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/en_GB.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/en_US.json b/src/modules/lssmaql/i18n/en_US.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/en_US.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/es_ES.json b/src/modules/lssmaql/i18n/es_ES.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/es_ES.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/fi_FI.json b/src/modules/lssmaql/i18n/fi_FI.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/fi_FI.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/fr_FR.json b/src/modules/lssmaql/i18n/fr_FR.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/fr_FR.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/it_IT.json b/src/modules/lssmaql/i18n/it_IT.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/it_IT.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/nb_NO.json b/src/modules/lssmaql/i18n/nb_NO.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/nb_NO.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/nl_NL.json b/src/modules/lssmaql/i18n/nl_NL.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/nl_NL.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/pl_PL.json b/src/modules/lssmaql/i18n/pl_PL.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/pl_PL.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/i18n/sv_SE.json b/src/modules/lssmaql/i18n/sv_SE.json new file mode 100644 index 0000000000..9f3fa5d9fa --- /dev/null +++ b/src/modules/lssmaql/i18n/sv_SE.json @@ -0,0 +1,6 @@ +{ + "console": "console", + "execute": "execute", + "query": "query", + "result": "result" +} \ No newline at end of file diff --git a/src/modules/lssmaql/lssmaql.vue b/src/modules/lssmaql/lssmaql.vue index febe9d1900..88e8d5360e 100644 --- a/src/modules/lssmaql/lssmaql.vue +++ b/src/modules/lssmaql/lssmaql.vue @@ -1,236 +1,98 @@ + - diff --git a/src/modules/lssmaql/main.ts b/src/modules/lssmaql/main.ts index 077a7421e7..428a45c0ad 100644 --- a/src/modules/lssmaql/main.ts +++ b/src/modules/lssmaql/main.ts @@ -1,8 +1,8 @@ import type { ModuleMainFunction } from 'typings/Module'; -export default (({ LSSM }) => { +export default (({ LSSM, $m }) => { LSSM.$stores.root - .addMenuItem('LSSMAQL Console') + .addMenuItem(`LSSMAQL ${$m('console')}`) .addEventListener('click', () => LSSM.$modal.show( () => diff --git a/src/modules/lssmaql/register.json b/src/modules/lssmaql/register.json index 698fca3ff9..6eea28db56 100644 --- a/src/modules/lssmaql/register.json +++ b/src/modules/lssmaql/register.json @@ -1 +1 @@ -{ "dev": true, "github": 51, "location": "^/?$", "noapp": true } \ No newline at end of file +{ "dev": true, "github": 51, "location": "^/?$", "noapp": false } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 53acfa3499..bf64cfcf3a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7250,6 +7250,13 @@ __metadata: languageName: node linkType: hard +"jsonata@npm:2.0.4": + version: 2.0.4 + resolution: "jsonata@npm:2.0.4" + checksum: 10c0/0e5c3f9630dec7eb59d8c79b02aa6f6c4465af1a1638abae0b1d42df7a02f1911a3494038645d260cdc96b395f072498b5adf35927dea0918ad75a6401fb35ad + languageName: node + linkType: hard + "jsonfile@npm:^6.0.1": version: 6.1.0 resolution: "jsonfile@npm:6.1.0" @@ -7772,6 +7779,7 @@ __metadata: html-loader: "npm:5.1.0" husky: "npm:9.1.5" js-yaml: "npm:4.1.0" + jsonata: "npm:2.0.4" leaflet.heat: "npm:0.2.0" local-web-server: "npm:5.4.0" localforage: "npm:1.10.0"