From 787bf13f3c938a50ccd60b010c340266eeffb4b1 Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Wed, 20 Dec 2023 12:33:46 +0100 Subject: [PATCH] Completed manager and moved client to common folder --- client/app.js | 82 +- client/bin/www | 24 +- client/client.js | 6 +- client/client.vbs | 2 +- client/copy.bat | 8 +- client/package-lock.json | 16 +- client/package.json | 4 +- client/public/stylesheets/leaflet/leaflet.css | 661 + client/routes/api/databases.js | 98 +- client/server.bat | 1 - client/server.vbs | 1 + client/src/olympusapp.ts | 1 - installer/olympus.iss | 17 +- manager/ejs/instanceDiv.ejs | 48 +- manager/ejs/popup.ejs | 10 + manager/icons/window-maximize-regular.svg | 1 + manager/icons/window-minimize-regular.svg | 1 + manager/icons/window-restore-regular.svg | 1 + manager/icons/xmark-solid.svg | 1 + manager/index.html | 89 +- manager/javascripts/preload.js | 187 +- manager/manager.js | 67 +- manager/package.json | 1 + manager/stylesheets/style.css | 132 +- moc_dcs/Config/olympus.json | 19 + .../Olympus/databases/airbases/caucasus.json | 466 + .../Olympus/databases/airbases/falklands.json | 838 + .../Olympus/databases/airbases/marianas.json | 466 + .../Olympus/databases/airbases/nevada.json | 558 + .../Olympus/databases/airbases/normandy.json | 2633 ++ .../databases/airbases/persiangulf.json | 769 + .../Olympus/databases/airbases/sinaimap.json | 1374 + .../Olympus/databases/airbases/syria.json | 1366 + .../databases/airbases/thechannel.json | 525 + .../databases/units/aircraftdatabase.json | 33295 ++++++++++++++++ .../units/default/aircraftdatabase.json | 33295 ++++++++++++++++ .../units/default/groundunitdatabase.json | 10359 +++++ .../units/default/helicopterdatabase.json | 4482 +++ .../units/default/navyunitdatabase.json | 1748 + .../databases/units/groundunitdatabase.json | 10359 +++++ .../databases/units/helicopterdatabase.json | 4482 +++ .../databases/units/navyunitdatabase.json | 1748 + .../databases/units/old/aircraftdatabase.json | 33295 ++++++++++++++++ .../units/old/groundUnitDatabase.json | 10359 +++++ .../units/old/helicopterDatabase.json | 4482 +++ .../databases/units/old/navyUnitDatabase.json | 1748 + src/shared/include/defines.h | 10 +- 47 files changed, 159936 insertions(+), 199 deletions(-) create mode 100644 client/public/stylesheets/leaflet/leaflet.css delete mode 100644 client/server.bat create mode 100644 client/server.vbs create mode 100644 manager/ejs/popup.ejs create mode 100644 manager/icons/window-maximize-regular.svg create mode 100644 manager/icons/window-minimize-regular.svg create mode 100644 manager/icons/window-restore-regular.svg create mode 100644 manager/icons/xmark-solid.svg create mode 100644 moc_dcs/Config/olympus.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/caucasus.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/falklands.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/marianas.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/nevada.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/normandy.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/persiangulf.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/sinaimap.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/syria.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/airbases/thechannel.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/aircraftdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/default/aircraftdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/default/groundunitdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/default/helicopterdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/default/navyunitdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/groundunitdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/helicopterdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/navyunitdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/old/aircraftdatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/old/groundUnitDatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/old/helicopterDatabase.json create mode 100644 moc_dcs/Mods/Services/Olympus/databases/units/old/navyUnitDatabase.json diff --git a/client/app.js b/client/app.js index 42c1367f..b42a8b8f 100644 --- a/client/app.js +++ b/client/app.js @@ -1,50 +1,50 @@ -/* Requires */ -var express = require('express'); -var path = require('path'); -var logger = require('morgan'); -var fs = require('fs'); -var bodyParser = require('body-parser'); -const { createProxyMiddleware } = require('http-proxy-middleware'); +module.exports = function (configLocation) { + /* Requires */ + var express = require('express'); + var path = require('path'); + var logger = require('morgan'); + var fs = require('fs'); + var bodyParser = require('body-parser'); + const { createProxyMiddleware } = require('http-proxy-middleware'); -/* Default routers */ -var atcRouter = require('./routes/api/atc'); -var airbasesRouter = require('./routes/api/airbases'); -var elevationRouter = require('./routes/api/elevation'); -var databasesRouter = require('./routes/api/databases'); -var indexRouter = require('./routes/index'); -var uikitRouter = require('./routes/uikit'); -var usersRouter = require('./routes/users'); -var resourcesRouter = require('./routes/resources'); -var pluginsRouter = require('./routes/plugins'); + /* Default routers */ + var atcRouter = require('./routes/api/atc'); + var airbasesRouter = require('./routes/api/airbases'); + var elevationRouter = require('./routes/api/elevation'); + var databasesRouter = require('./routes/api/databases')(path.join(path.dirname(configLocation), "..", "Mods", "Services", "Olympus", "databases")); + var indexRouter = require('./routes/index'); + var uikitRouter = require('./routes/uikit'); + var usersRouter = require('./routes/users'); + var resourcesRouter = require('./routes/resources'); + var pluginsRouter = require('./routes/plugins'); -/* Load the config and create the express app */ -let rawdata = fs.readFileSync('../olympus.json'); -let config = JSON.parse(rawdata); -var app = express(); + /* Load the config and create the express app */ + let rawdata = fs.readFileSync(configLocation); + let config = JSON.parse(rawdata); + var app = express(); -/* Define middleware */ -app.use(logger('dev')); -app.use('/olympus', createProxyMiddleware({target: `http://${config["server"]["address"]}:${config["server"]["port"]}`, changeOrigin: true })); -app.use(bodyParser.json({limit: '50mb'})); -app.use(bodyParser.urlencoded({limit: '50mb', extended: true})); -app.use(express.static(path.join(__dirname, 'public'))); + /* Define middleware */ + app.use(logger('dev')); + app.use('/olympus', createProxyMiddleware({ target: `http://${config["server"]["address"]}:${config["server"]["port"]}`, changeOrigin: true })); + app.use(bodyParser.json({ limit: '50mb' })); + app.use(bodyParser.urlencoded({ limit: '50mb', extended: true })); + app.use(express.static(path.join(__dirname, 'public'))); -/* Apply routers */ -app.use('/', indexRouter); -app.use('/api/atc', atcRouter); -app.use('/api/airbases', airbasesRouter); -app.use('/api/elevation', elevationRouter); -app.use('/api/databases', databasesRouter); -app.use('/plugins', pluginsRouter) -app.use('/users', usersRouter); -app.use('/uikit', uikitRouter); -app.use('/resources', resourcesRouter); - -app.set('view engine', 'ejs'); - -module.exports = app; + /* Apply routers */ + app.use('/', indexRouter); + app.use('/api/atc', atcRouter); + app.use('/api/airbases', airbasesRouter); + app.use('/api/elevation', elevationRouter); + app.use('/api/databases', databasesRouter); + app.use('/plugins', pluginsRouter) + app.use('/users', usersRouter); + app.use('/uikit', uikitRouter); + app.use('/resources', resourcesRouter); + app.set('view engine', 'ejs'); + return app; +} diff --git a/client/bin/www b/client/bin/www index 88de1786..64e16058 100644 --- a/client/bin/www +++ b/client/bin/www @@ -1,5 +1,10 @@ #!/usr/bin/env node +const yargs = require('yargs'); + +yargs.alias('c', 'config').describe('c', 'olympus.json config location').string('rp'); +args = yargs.argv; + console.log('\x1b[36m%s\x1b[0m', "*********************************************************************"); console.log('\x1b[36m%s\x1b[0m', "* _____ _____ _____ ____ _ *"); console.log('\x1b[36m%s\x1b[0m', "* | __ \\ / ____|/ ____| / __ \\| | *"); @@ -12,16 +17,23 @@ console.log('\x1b[36m%s\x1b[0m', "* |___/ console.log('\x1b[36m%s\x1b[0m', "*********************************************************************"); console.log('\x1b[36m%s\x1b[0m', ""); console.log("Please wait while DCS Olympus Server starts up..."); +console.log(`Config location: ${args["config"]}`) var fs = require('fs'); -let rawdata = fs.readFileSync('../olympus.json'); -let config = JSON.parse(rawdata); + +var clientPort = 3000; +if (fs.existsSync(args["config"])) { + var json = JSON.parse(fs.readFileSync(args["config"], 'utf-8')); + clientPort = json["client"]["port"]; +} else { + console.log("Failed to read config, trying default port"); +} /** * Module dependencies. */ -var app = require('../app'); +var app = require('../app')(args["config"]); var debug = require('debug')('client:server'); var http = require('http'); @@ -29,12 +41,8 @@ var http = require('http'); * Get port from environment and store in Express. */ -var configPort = null; -if (config["client"] != undefined && config["client"]["port"] != undefined) { - configPort = config["client"]["port"]; -} -var port = normalizePort(configPort || '3000'); +var port = normalizePort(clientPort || '3000'); app.set('port', port); console.log("Express server listening on port: " + port) diff --git a/client/client.js b/client/client.js index 59bb0455..45abe24e 100644 --- a/client/client.js +++ b/client/client.js @@ -27,10 +27,10 @@ function createWindow() { } app.whenReady().then(() => { - const server = spawn('node', [path.join('.', 'bin', 'www')]); + const server = spawn('node', [path.join('.', 'bin', 'www'), "--config", args["config"]]); server.stdout.on('data', (data) => { - console.log(`stdout: ${data}`); + console.log(`${data}`); }); server.stderr.on('data', (data) => { @@ -38,7 +38,7 @@ app.whenReady().then(() => { }); server.on('close', (code) => { - console.log(`child process exited with code ${code}`); + console.log(`Child process exited with code ${code}`); }); createWindow() diff --git a/client/client.vbs b/client/client.vbs index 53d57aaf..c2fe93ae 100644 --- a/client/client.vbs +++ b/client/client.vbs @@ -1 +1 @@ -CreateObject("Wscript.Shell").Run "npm run client -- --config """&WScript.Arguments(0)&"""", 1 \ No newline at end of file +CreateObject("Wscript.Shell").Run "npm run client -- --config """&WScript.Arguments(0)&"""", 0 \ No newline at end of file diff --git a/client/copy.bat b/client/copy.bat index 2bb46e0c..967d62b1 100644 --- a/client/copy.bat +++ b/client/copy.bat @@ -1,4 +1,4 @@ -copy .\\node_modules\\leaflet\\dist\\leaflet.css .\\public\\stylesheets\\leaflet\\leaflet.css -copy .\\node_modules\\leaflet-gesture-handling\\dist\\leaflet-gesture-handling.css .\\public\\stylesheets\\leaflet\\leaflet-gesture-handling.css -copy .\\node_modules\\leaflet.nauticscale\\dist\\leaflet.nauticscale.js .\\public\\javascripts\\leaflet.nauticscale.js -copy .\\node_modules\\leaflet-path-drag\\dist\\L.Path.Drag.js .\\public\\javascripts\\L.Path.Drag.js +xcopy /S /Q /Y /F .\\node_modules\\leaflet\\dist\\leaflet.css .\\public\\stylesheets\\leaflet\\leaflet.css +xcopy /S /Q /Y /F .\\node_modules\\leaflet-gesture-handling\\dist\\leaflet-gesture-handling.css .\\public\\stylesheets\\leaflet\\leaflet-gesture-handling.css +xcopy /S /Q /Y /F .\\node_modules\\leaflet.nauticscale\\dist\\leaflet.nauticscale.js .\\public\\javascripts\\leaflet.nauticscale.js +xcopy /S /Q /Y /F .\\node_modules\\leaflet-path-drag\\dist\\L.Path.Drag.js .\\public\\javascripts\\L.Path.Drag.js diff --git a/client/package-lock.json b/client/package-lock.json index d6b1b0c0..2daccc2a 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,14 +1,15 @@ { "name": "DCSOlympus", - "version": "v1.0.4", + "version": "v{{OLYMPUS_VERSION_NUMBER}}", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "DCSOlympus", - "version": "v1.0.4", + "version": "v{{OLYMPUS_VERSION_NUMBER}}", "dependencies": { "appjs": "^0.0.20", + "appjs-win32": "^0.0.19", "body-parser": "^1.20.2", "debug": "~2.6.9", "ejs": "^3.1.8", @@ -3782,6 +3783,17 @@ "node": ">=0.8" } }, + "node_modules/appjs-win32": { + "version": "0.0.19", + "resolved": "https://registry.npmjs.org/appjs-win32/-/appjs-win32-0.0.19.tgz", + "integrity": "sha512-ide+/pVBbT043Zxx5CQd2R8j2UIhOs4xV17rEf335ooujHtdvWphiyC3R81UWib9vKHEOY7dNlv91J9R/a7pVw==", + "os": [ + "win32" + ], + "engines": { + "node": ">=0.8" + } + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", diff --git a/client/package.json b/client/package.json index f9808931..389fb8ca 100644 --- a/client/package.json +++ b/client/package.json @@ -2,7 +2,7 @@ "name": "DCSOlympus", "node-main": "./bin/www", "main": "client.js", - "version": "v1.0.4", + "version": "v{{OLYMPUS_VERSION_NUMBER}}", "private": true, "scripts": { "build": "browserify .\\src\\index.ts --debug -o .\\public\\javascripts\\bundle.js -t [ babelify --global true --presets [ @babel/preset-env ] --extensions '.js'] -p [ tsify --noImplicitAny ] && copy.bat", @@ -10,7 +10,7 @@ "emit-declarations": "tsc --project tsconfig.json --declaration --emitDeclarationOnly --outfile ./@types/olympus/index.d.ts", "copy": "copy.bat", "start": "node ./bin/www", - "debug": "npm run copy & concurrently --kill-others \"npm run watch\" \"nodemon --ignore ./public/databases/ ./bin/www\"", + "debug": "npm run copy & concurrently --kill-others \"npm run watch\" \"nodemon --ignore ./public/databases/ ./bin/www -- --config ../moc_dcs/Config/olympus.json\"", "watch": "watchify .\\src\\index.ts --debug -o .\\public\\javascripts\\bundle.js -t [ babelify --global true --presets [ @babel/preset-env ] --extensions '.js'] -p [ tsify --noImplicitAny ]", "client": "electron ." }, diff --git a/client/public/stylesheets/leaflet/leaflet.css b/client/public/stylesheets/leaflet/leaflet.css new file mode 100644 index 00000000..9ade8dc4 --- /dev/null +++ b/client/public/stylesheets/leaflet/leaflet.css @@ -0,0 +1,661 @@ +/* required styles */ + +.leaflet-pane, +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-tile-container, +.leaflet-pane > svg, +.leaflet-pane > canvas, +.leaflet-zoom-box, +.leaflet-image-layer, +.leaflet-layer { + position: absolute; + left: 0; + top: 0; + } +.leaflet-container { + overflow: hidden; + } +.leaflet-tile, +.leaflet-marker-icon, +.leaflet-marker-shadow { + -webkit-user-select: none; + -moz-user-select: none; + user-select: none; + -webkit-user-drag: none; + } +/* Prevents IE11 from highlighting tiles in blue */ +.leaflet-tile::selection { + background: transparent; +} +/* Safari renders non-retina tile on retina better with this, but Chrome is worse */ +.leaflet-safari .leaflet-tile { + image-rendering: -webkit-optimize-contrast; + } +/* hack that prevents hw layers "stretching" when loading new tiles */ +.leaflet-safari .leaflet-tile-container { + width: 1600px; + height: 1600px; + -webkit-transform-origin: 0 0; + } +.leaflet-marker-icon, +.leaflet-marker-shadow { + display: block; + } +/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ +/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ +.leaflet-container .leaflet-overlay-pane svg { + max-width: none !important; + max-height: none !important; + } +.leaflet-container .leaflet-marker-pane img, +.leaflet-container .leaflet-shadow-pane img, +.leaflet-container .leaflet-tile-pane img, +.leaflet-container img.leaflet-image-layer, +.leaflet-container .leaflet-tile { + max-width: none !important; + max-height: none !important; + width: auto; + padding: 0; + } + +.leaflet-container img.leaflet-tile { + /* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */ + mix-blend-mode: plus-lighter; +} + +.leaflet-container.leaflet-touch-zoom { + -ms-touch-action: pan-x pan-y; + touch-action: pan-x pan-y; + } +.leaflet-container.leaflet-touch-drag { + -ms-touch-action: pinch-zoom; + /* Fallback for FF which doesn't support pinch-zoom */ + touch-action: none; + touch-action: pinch-zoom; +} +.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { + -ms-touch-action: none; + touch-action: none; +} +.leaflet-container { + -webkit-tap-highlight-color: transparent; +} +.leaflet-container a { + -webkit-tap-highlight-color: rgba(51, 181, 229, 0.4); +} +.leaflet-tile { + filter: inherit; + visibility: hidden; + } +.leaflet-tile-loaded { + visibility: inherit; + } +.leaflet-zoom-box { + width: 0; + height: 0; + -moz-box-sizing: border-box; + box-sizing: border-box; + z-index: 800; + } +/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ +.leaflet-overlay-pane svg { + -moz-user-select: none; + } + +.leaflet-pane { z-index: 400; } + +.leaflet-tile-pane { z-index: 200; } +.leaflet-overlay-pane { z-index: 400; } +.leaflet-shadow-pane { z-index: 500; } +.leaflet-marker-pane { z-index: 600; } +.leaflet-tooltip-pane { z-index: 650; } +.leaflet-popup-pane { z-index: 700; } + +.leaflet-map-pane canvas { z-index: 100; } +.leaflet-map-pane svg { z-index: 200; } + +.leaflet-vml-shape { + width: 1px; + height: 1px; + } +.lvml { + behavior: url(#default#VML); + display: inline-block; + position: absolute; + } + + +/* control positioning */ + +.leaflet-control { + position: relative; + z-index: 800; + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } +.leaflet-top, +.leaflet-bottom { + position: absolute; + z-index: 1000; + pointer-events: none; + } +.leaflet-top { + top: 0; + } +.leaflet-right { + right: 0; + } +.leaflet-bottom { + bottom: 0; + } +.leaflet-left { + left: 0; + } +.leaflet-control { + float: left; + clear: both; + } +.leaflet-right .leaflet-control { + float: right; + } +.leaflet-top .leaflet-control { + margin-top: 10px; + } +.leaflet-bottom .leaflet-control { + margin-bottom: 10px; + } +.leaflet-left .leaflet-control { + margin-left: 10px; + } +.leaflet-right .leaflet-control { + margin-right: 10px; + } + + +/* zoom and fade animations */ + +.leaflet-fade-anim .leaflet-popup { + opacity: 0; + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + transition: opacity 0.2s linear; + } +.leaflet-fade-anim .leaflet-map-pane .leaflet-popup { + opacity: 1; + } +.leaflet-zoom-animated { + -webkit-transform-origin: 0 0; + -ms-transform-origin: 0 0; + transform-origin: 0 0; + } +svg.leaflet-zoom-animated { + will-change: transform; +} + +.leaflet-zoom-anim .leaflet-zoom-animated { + -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1); + -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); + transition: transform 0.25s cubic-bezier(0,0,0.25,1); + } +.leaflet-zoom-anim .leaflet-tile, +.leaflet-pan-anim .leaflet-tile { + -webkit-transition: none; + -moz-transition: none; + transition: none; + } + +.leaflet-zoom-anim .leaflet-zoom-hide { + visibility: hidden; + } + + +/* cursors */ + +.leaflet-interactive { + cursor: pointer; + } +.leaflet-grab { + cursor: -webkit-grab; + cursor: -moz-grab; + cursor: grab; + } +.leaflet-crosshair, +.leaflet-crosshair .leaflet-interactive { + cursor: crosshair; + } +.leaflet-popup-pane, +.leaflet-control { + cursor: auto; + } +.leaflet-dragging .leaflet-grab, +.leaflet-dragging .leaflet-grab .leaflet-interactive, +.leaflet-dragging .leaflet-marker-draggable { + cursor: move; + cursor: -webkit-grabbing; + cursor: -moz-grabbing; + cursor: grabbing; + } + +/* marker & overlays interactivity */ +.leaflet-marker-icon, +.leaflet-marker-shadow, +.leaflet-image-layer, +.leaflet-pane > svg path, +.leaflet-tile-container { + pointer-events: none; + } + +.leaflet-marker-icon.leaflet-interactive, +.leaflet-image-layer.leaflet-interactive, +.leaflet-pane > svg path.leaflet-interactive, +svg.leaflet-image-layer.leaflet-interactive path { + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } + +/* visual tweaks */ + +.leaflet-container { + background: #ddd; + outline-offset: 1px; + } +.leaflet-container a { + color: #0078A8; + } +.leaflet-zoom-box { + border: 2px dotted #38f; + background: rgba(255,255,255,0.5); + } + + +/* general typography */ +.leaflet-container { + font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; + font-size: 12px; + font-size: 0.75rem; + line-height: 1.5; + } + + +/* general toolbar styles */ + +.leaflet-bar { + box-shadow: 0 1px 5px rgba(0,0,0,0.65); + border-radius: 4px; + } +.leaflet-bar a { + background-color: #fff; + border-bottom: 1px solid #ccc; + width: 26px; + height: 26px; + line-height: 26px; + display: block; + text-align: center; + text-decoration: none; + color: black; + } +.leaflet-bar a, +.leaflet-control-layers-toggle { + background-position: 50% 50%; + background-repeat: no-repeat; + display: block; + } +.leaflet-bar a:hover, +.leaflet-bar a:focus { + background-color: #f4f4f4; + } +.leaflet-bar a:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + } +.leaflet-bar a:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + border-bottom: none; + } +.leaflet-bar a.leaflet-disabled { + cursor: default; + background-color: #f4f4f4; + color: #bbb; + } + +.leaflet-touch .leaflet-bar a { + width: 30px; + height: 30px; + line-height: 30px; + } +.leaflet-touch .leaflet-bar a:first-child { + border-top-left-radius: 2px; + border-top-right-radius: 2px; + } +.leaflet-touch .leaflet-bar a:last-child { + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + } + +/* zoom control */ + +.leaflet-control-zoom-in, +.leaflet-control-zoom-out { + font: bold 18px 'Lucida Console', Monaco, monospace; + text-indent: 1px; + } + +.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { + font-size: 22px; + } + + +/* layers control */ + +.leaflet-control-layers { + box-shadow: 0 1px 5px rgba(0,0,0,0.4); + background: #fff; + border-radius: 5px; + } +.leaflet-control-layers-toggle { + background-image: url(images/layers.png); + width: 36px; + height: 36px; + } +.leaflet-retina .leaflet-control-layers-toggle { + background-image: url(images/layers-2x.png); + background-size: 26px 26px; + } +.leaflet-touch .leaflet-control-layers-toggle { + width: 44px; + height: 44px; + } +.leaflet-control-layers .leaflet-control-layers-list, +.leaflet-control-layers-expanded .leaflet-control-layers-toggle { + display: none; + } +.leaflet-control-layers-expanded .leaflet-control-layers-list { + display: block; + position: relative; + } +.leaflet-control-layers-expanded { + padding: 6px 10px 6px 6px; + color: #333; + background: #fff; + } +.leaflet-control-layers-scrollbar { + overflow-y: scroll; + overflow-x: hidden; + padding-right: 5px; + } +.leaflet-control-layers-selector { + margin-top: 2px; + position: relative; + top: 1px; + } +.leaflet-control-layers label { + display: block; + font-size: 13px; + font-size: 1.08333em; + } +.leaflet-control-layers-separator { + height: 0; + border-top: 1px solid #ddd; + margin: 5px -10px 5px -6px; + } + +/* Default icon URLs */ +.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */ + background-image: url(images/marker-icon.png); + } + + +/* attribution and scale controls */ + +.leaflet-container .leaflet-control-attribution { + background: #fff; + background: rgba(255, 255, 255, 0.8); + margin: 0; + } +.leaflet-control-attribution, +.leaflet-control-scale-line { + padding: 0 5px; + color: #333; + line-height: 1.4; + } +.leaflet-control-attribution a { + text-decoration: none; + } +.leaflet-control-attribution a:hover, +.leaflet-control-attribution a:focus { + text-decoration: underline; + } +.leaflet-attribution-flag { + display: inline !important; + vertical-align: baseline !important; + width: 1em; + height: 0.6669em; + } +.leaflet-left .leaflet-control-scale { + margin-left: 5px; + } +.leaflet-bottom .leaflet-control-scale { + margin-bottom: 5px; + } +.leaflet-control-scale-line { + border: 2px solid #777; + border-top: none; + line-height: 1.1; + padding: 2px 5px 1px; + white-space: nowrap; + -moz-box-sizing: border-box; + box-sizing: border-box; + background: rgba(255, 255, 255, 0.8); + text-shadow: 1px 1px #fff; + } +.leaflet-control-scale-line:not(:first-child) { + border-top: 2px solid #777; + border-bottom: none; + margin-top: -2px; + } +.leaflet-control-scale-line:not(:first-child):not(:last-child) { + border-bottom: 2px solid #777; + } + +.leaflet-touch .leaflet-control-attribution, +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + box-shadow: none; + } +.leaflet-touch .leaflet-control-layers, +.leaflet-touch .leaflet-bar { + border: 2px solid rgba(0,0,0,0.2); + background-clip: padding-box; + } + + +/* popup */ + +.leaflet-popup { + position: absolute; + text-align: center; + margin-bottom: 20px; + } +.leaflet-popup-content-wrapper { + padding: 1px; + text-align: left; + border-radius: 12px; + } +.leaflet-popup-content { + margin: 13px 24px 13px 20px; + line-height: 1.3; + font-size: 13px; + font-size: 1.08333em; + min-height: 1px; + } +.leaflet-popup-content p { + margin: 17px 0; + margin: 1.3em 0; + } +.leaflet-popup-tip-container { + width: 40px; + height: 20px; + position: absolute; + left: 50%; + margin-top: -1px; + margin-left: -20px; + overflow: hidden; + pointer-events: none; + } +.leaflet-popup-tip { + width: 17px; + height: 17px; + padding: 1px; + + margin: -10px auto 0; + pointer-events: auto; + + -webkit-transform: rotate(45deg); + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + transform: rotate(45deg); + } +.leaflet-popup-content-wrapper, +.leaflet-popup-tip { + background: white; + color: #333; + box-shadow: 0 3px 14px rgba(0,0,0,0.4); + } +.leaflet-container a.leaflet-popup-close-button { + position: absolute; + top: 0; + right: 0; + border: none; + text-align: center; + width: 24px; + height: 24px; + font: 16px/24px Tahoma, Verdana, sans-serif; + color: #757575; + text-decoration: none; + background: transparent; + } +.leaflet-container a.leaflet-popup-close-button:hover, +.leaflet-container a.leaflet-popup-close-button:focus { + color: #585858; + } +.leaflet-popup-scrolled { + overflow: auto; + } + +.leaflet-oldie .leaflet-popup-content-wrapper { + -ms-zoom: 1; + } +.leaflet-oldie .leaflet-popup-tip { + width: 24px; + margin: 0 auto; + + -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)"; + filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678); + } + +.leaflet-oldie .leaflet-control-zoom, +.leaflet-oldie .leaflet-control-layers, +.leaflet-oldie .leaflet-popup-content-wrapper, +.leaflet-oldie .leaflet-popup-tip { + border: 1px solid #999; + } + + +/* div icon */ + +.leaflet-div-icon { + background: #fff; + border: 1px solid #666; + } + + +/* Tooltip */ +/* Base styles for the element that has a tooltip */ +.leaflet-tooltip { + position: absolute; + padding: 6px; + background-color: #fff; + border: 1px solid #fff; + border-radius: 3px; + color: #222; + white-space: nowrap; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + pointer-events: none; + box-shadow: 0 1px 3px rgba(0,0,0,0.4); + } +.leaflet-tooltip.leaflet-interactive { + cursor: pointer; + pointer-events: auto; + } +.leaflet-tooltip-top:before, +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + position: absolute; + pointer-events: none; + border: 6px solid transparent; + background: transparent; + content: ""; + } + +/* Directions */ + +.leaflet-tooltip-bottom { + margin-top: 6px; +} +.leaflet-tooltip-top { + margin-top: -6px; +} +.leaflet-tooltip-bottom:before, +.leaflet-tooltip-top:before { + left: 50%; + margin-left: -6px; + } +.leaflet-tooltip-top:before { + bottom: 0; + margin-bottom: -12px; + border-top-color: #fff; + } +.leaflet-tooltip-bottom:before { + top: 0; + margin-top: -12px; + margin-left: -6px; + border-bottom-color: #fff; + } +.leaflet-tooltip-left { + margin-left: -6px; +} +.leaflet-tooltip-right { + margin-left: 6px; +} +.leaflet-tooltip-left:before, +.leaflet-tooltip-right:before { + top: 50%; + margin-top: -6px; + } +.leaflet-tooltip-left:before { + right: 0; + margin-right: -12px; + border-left-color: #fff; + } +.leaflet-tooltip-right:before { + left: 0; + margin-left: -12px; + border-right-color: #fff; + } + +/* Printing */ + +@media print { + /* Prevent printers from removing background-images of controls. */ + .leaflet-control { + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + } diff --git a/client/routes/api/databases.js b/client/routes/api/databases.js index 7cd4a341..eea9667e 100644 --- a/client/routes/api/databases.js +++ b/client/routes/api/databases.js @@ -1,58 +1,60 @@ -const express = require('express'); -const router = express.Router(); -const fs = require("fs"); -const path = require("path"); +module.exports = function (databasesLocation) { + const express = require('express'); + const router = express.Router(); + const fs = require("fs"); + const path = require("path"); -router.get('/:type/:name', function (req, res) { - console.log(req.params.database) -}); + router.get('/:type/:name', function (req, res) { + console.log(req.params.database) + }); -router.put('/save/:type/:name', function (req, res) { - var dir = path.join("./public/databases", req.params.type, "old"); - if (!fs.existsSync(dir)){ - fs.mkdirSync(dir); - } + router.put('/save/:type/:name', function (req, res) { + var dir = path.join(databasesLocation, req.params.type, "old"); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir); + } - var filepath = path.join("./public/databases", req.params.type, req.params.name + ".json"); - if (fs.existsSync(filepath)) { - var newFilepath = path.join("./public/databases/", req.params.type, "old", req.params.name + ".json"); - fs.copyFileSync(filepath, newFilepath); - if (fs.existsSync(newFilepath)) { - try { - var json = JSON.stringify(req.body.blueprints, null, "\t" ); - fs.writeFileSync(filepath, json, 'utf8'); - res.send("OK"); - } catch { + var filepath = path.join(databasesLocation, req.params.type, req.params.name + ".json"); + if (fs.existsSync(filepath)) { + var newFilepath = path.join(databasesLocation, req.params.type, "old", req.params.name + ".json"); + fs.copyFileSync(filepath, newFilepath); + if (fs.existsSync(newFilepath)) { + try { + var json = JSON.stringify(req.body.blueprints, null, "\t"); + fs.writeFileSync(filepath, json, 'utf8'); + res.send("OK"); + } catch { + res.status(422).send("Error"); + } + } else { res.status(422).send("Error"); } } else { - res.status(422).send("Error"); + res.status(404).send('Not found'); } - } else { - res.status(404).send('Not found'); - } -}); + }); -router.put('/reset/:type/:name', function (req, res) { - var filepath = path.join("./public/databases", req.params.type, "default", req.params.name + ".json"); - if (fs.existsSync(filepath)) { - var newFilepath = path.join("./public/databases", req.params.type, req.params.name + ".json"); - fs.copyFileSync(filepath, newFilepath); - res.send("OK"); - } else { - res.status(404).send('Not found'); - } -}); + router.put('/reset/:type/:name', function (req, res) { + var filepath = path.join(databasesLocation, req.params.type, "default", req.params.name + ".json"); + if (fs.existsSync(filepath)) { + var newFilepath = path.join(databasesLocation, req.params.type, req.params.name + ".json"); + fs.copyFileSync(filepath, newFilepath); + res.send("OK"); + } else { + res.status(404).send('Not found'); + } + }); -router.put('/restore/:type/:name', function (req, res) { - var filepath = path.join("./public/databases", req.params.type, "old", req.params.name + ".json"); - if (fs.existsSync(filepath)) { - var newFilepath = path.join("./public/databases", req.params.type, req.params.name + ".json"); - fs.copyFileSync(filepath, newFilepath); - res.send("OK"); - } else { - res.status(404).send('Not found'); - } -}); + router.put('/restore/:type/:name', function (req, res) { + var filepath = path.join(databasesLocation, req.params.type, "old", req.params.name + ".json"); + if (fs.existsSync(filepath)) { + var newFilepath = path.join(databasesLocation, req.params.type, req.params.name + ".json"); + fs.copyFileSync(filepath, newFilepath); + res.send("OK"); + } else { + res.status(404).send('Not found'); + } + }); -module.exports = router; + return router; +} diff --git a/client/server.bat b/client/server.bat deleted file mode 100644 index 78386a02..00000000 --- a/client/server.bat +++ /dev/null @@ -1 +0,0 @@ -node .\\bin\\www \ No newline at end of file diff --git a/client/server.vbs b/client/server.vbs new file mode 100644 index 00000000..397a7ac7 --- /dev/null +++ b/client/server.vbs @@ -0,0 +1 @@ +CreateObject("Wscript.Shell").Run "npm run start -- --config """&WScript.Arguments(0)&"""", 1 \ No newline at end of file diff --git a/client/src/olympusapp.ts b/client/src/olympusapp.ts index 676cacf0..aa1d9d7e 100644 --- a/client/src/olympusapp.ts +++ b/client/src/olympusapp.ts @@ -29,7 +29,6 @@ import { ContextManager } from "./context/contextmanager"; import { Context } from "./context/context"; var VERSION = "{{OLYMPUS_VERSION_NUMBER}}"; -var DEBUG = false; export class OlympusApp { /* Global data */ diff --git a/installer/olympus.iss b/installer/olympus.iss index 898bc0c4..da9adb03 100644 --- a/installer/olympus.iss +++ b/installer/olympus.iss @@ -34,8 +34,8 @@ Source: "..\scripts\mist.lua"; DestDir: "{app}\Scripts"; Flags: ignoreversion Source: "..\scripts\mods.lua"; DestDir: "{app}\Scripts"; Flags: ignoreversion Source: "..\mod\*"; DestDir: "{app}\mod"; Flags: ignoreversion recursesubdirs; - -Source: "..\bin\*.dll"; DestDir: "{app}\bin"; Flags: ignoreversion; +Source: "..\bin\*.dll"; DestDir: "{app}\mod\bin"; Flags: ignoreversion; +Source: "..\client\public\databases\*"; DestDir: "{app}\mod\databases"; Flags: ignoreversion recursesubdirs; Source: "..\client\bin\*"; DestDir: "{app}\client\bin"; Flags: ignoreversion; Source: "..\client\public\*"; DestDir: "{app}\client\public"; Flags: ignoreversion recursesubdirs; @@ -43,11 +43,16 @@ Source: "..\client\routes\*"; DestDir: "{app}\client\routes"; Flags: ignoreversi Source: "..\client\views\*"; DestDir: "{app}\client\views"; Flags: ignoreversion recursesubdirs; Source: "..\client\app.js"; DestDir: "{app}\client"; Flags: ignoreversion; Source: "..\client\demo.js"; DestDir: "{app}\client"; Flags: ignoreversion; +Source: "..\client\client.js"; DestDir: "{app}\client"; Flags: ignoreversion; Source: "..\client\package.json"; DestDir: "{app}\client"; Flags: ignoreversion; Source: "..\client\configurator.js"; DestDir: "{app}\client"; Flags: ignoreversion; Source: "..\client\install.bat"; DestDir: "{app}\client"; Flags: ignoreversion; +Source: "..\client\*.vbs"; DestDir: "{app}\client"; Flags: ignoreversion; Source: "..\manager\icons\*"; DestDir: "{app}\manager\icons"; Flags: ignoreversion; +Source: "..\manager\ejs\*"; DestDir: "{app}\manager\ejs"; Flags: ignoreversion; +Source: "..\manager\javascripts\*"; DestDir: "{app}\manager\javascripts"; Flags: ignoreversion; +Source: "..\manager\stylesheets\*"; DestDir: "{app}\manager\stylesheets"; Flags: ignoreversion; Source: "..\manager\*"; DestDir: "{app}\manager"; Flags: ignoreversion; Source: "..\img\olympus.ico"; DestDir: "{app}\img"; Flags: ignoreversion; @@ -61,13 +66,11 @@ Source: "..\LEGAL.txt"; DestDir: "{app}"; Flags: ignoreversion; [Run] Filename: "{app}\client\install.bat"; Description: "Installing node.js modules, this may take some time..."; Tasks: installmodules; Filename: "{app}\manager\install.bat"; Description: "Installing node.js modules, this may take some time..."; Tasks: installmodules; -Filename: "{app}\manager\run.vbs"; WorkingDir: "{app}\manager"; Description: "Launch the Olympus manager"; Flags: postinstall shellexec; +Filename: "{app}\manager\manager.vbs"; WorkingDir: "{app}\manager"; Description: "Launch the Olympus manager"; Flags: postinstall shellexec; [Icons] -Name: "{userdesktop}\DCS Olympus Manager"; Filename: "{app}\manager\run.vbs"; Tasks: desktopicon; IconFilename: "{app}\img\olympus.ico"; -Name: "{app}\DCS Olympus Manager"; Filename: "{app}\manager\run.vbs"; IconFilename: "{app}\img\olympus_configurator.ico"; -Name: "{app}\DCS Olympus Server"; Filename: "{app}\manager\server.bat"; IconFilename: "{app}\img\olympus_server.ico"; -Name: "{app}\DCS Olympus"; Filename: "{app}\manager\local.bat"; IconFilename: "{app}\img\olympus.ico"; +Name: "{userdesktop}\DCS Olympus Manager"; Filename: "{app}\manager\manager.vbs"; Tasks: desktopicon; IconFilename: "{app}\img\olympus_configurator.ico"; +Name: "{app}\DCS Olympus Manager"; Filename: "{app}\manager\manager.vbs"; IconFilename: "{app}\img\olympus_configurator.ico"; [UninstallDelete] Type: filesandordirs; Name: "{app}" diff --git a/manager/ejs/instanceDiv.ejs b/manager/ejs/instanceDiv.ejs index a0e7f588..e9883d9f 100644 --- a/manager/ejs/instanceDiv.ejs +++ b/manager/ejs/instanceDiv.ejs @@ -7,38 +7,50 @@
-
Client port
- " min="1023" max="65535" <%= !installed? "disabled": "" %> tabindex="<%= index %>"> - +
+
Client port
+ " min="1023" max="65535" <%= !installed? "disabled": "" %> tabindex="<%= index %>"> + +
-
Game Master password
- tabindex="<%= index + 3 %>"> - +
+
Game Master password
+ tabindex="<%= index + 3 %>"> + +
-
Backend port
- " min="1023" max="65535" <%= !installed? "disabled": "" %> tabindex="<%= index + 1 %>"> - +
+
Backend port
+ " min="1023" max="65535" <%= !installed? "disabled": "" %> tabindex="<%= index + 1 %>"> + +
-
Blue Commander password
- tabindex="<%= index + 4 %>"> - +
+
Blue Commander password
+ tabindex="<%= index + 4 %>"> + +
-
Backend address
- " min="1023" max="65535" <%= !installed? "disabled": "" %> tabindex="<%= index + 2 %>"> - +
+
Backend address
+ " min="1023" max="65535" <%= !installed? "disabled": "" %> tabindex="<%= index + 2 %>"> + +
-
Red Commander password
- tabindex="<%= index + 5 %>"> - +
+
Red Commander password
+ tabindex="<%= index + 5 %>"> + +
diff --git a/manager/ejs/popup.ejs b/manager/ejs/popup.ejs new file mode 100644 index 00000000..37258fa9 --- /dev/null +++ b/manager/ejs/popup.ejs @@ -0,0 +1,10 @@ + + + \ No newline at end of file diff --git a/manager/icons/window-maximize-regular.svg b/manager/icons/window-maximize-regular.svg new file mode 100644 index 00000000..847be364 --- /dev/null +++ b/manager/icons/window-maximize-regular.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/manager/icons/window-minimize-regular.svg b/manager/icons/window-minimize-regular.svg new file mode 100644 index 00000000..6704b4a4 --- /dev/null +++ b/manager/icons/window-minimize-regular.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/manager/icons/window-restore-regular.svg b/manager/icons/window-restore-regular.svg new file mode 100644 index 00000000..ab9c47b6 --- /dev/null +++ b/manager/icons/window-restore-regular.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/manager/icons/xmark-solid.svg b/manager/icons/xmark-solid.svg new file mode 100644 index 00000000..71a14b91 --- /dev/null +++ b/manager/icons/xmark-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/manager/index.html b/manager/index.html index a6775d55..35a452c5 100644 --- a/manager/index.html +++ b/manager/index.html @@ -1,27 +1,72 @@ - - - - - - - - DCS Olympus Manager v{{OLYMPUS_VERSION_NUMBER}} - - -