diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 0cf07bf..0000000 --- a/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -** -!files \ No newline at end of file diff --git a/web/root/index.css b/web/root/index.css index a609272..dbee6cb 100644 --- a/web/root/index.css +++ b/web/root/index.css @@ -1,5 +1,5 @@ body { - padding-top: 50px; + padding-top: 10px; background-color: black; } .green { @@ -20,6 +20,10 @@ body { background-color: aliceblue; } +.result { + padding: 5px; +} + .selected { background-color: cyan; } diff --git a/web/root/index.js b/web/root/index.js index 1f3cff3..d81ff72 100644 --- a/web/root/index.js +++ b/web/root/index.js @@ -4,10 +4,10 @@ const template = `

DayZ Docker Server

-
-
- -
+
+
+ +
@@ -53,9 +53,29 @@ const template = `
-
- {{ result.publishedfileid }} - {{ result.title }} -
+ + + + + + + + + + + + + + + +
Steam LinkTitleSizeLast UpdatedSubscriptions
+ + + + {{ result.title }}{{ result.file_size }}{{ new Date(result.time_updated * 1000) }}{{ result.lifetime_subscriptions }}
@@ -90,7 +110,6 @@ const template = `
- ` export default { @@ -142,8 +161,20 @@ export default { .then(response => response.json()) .then(response => { this.modInfo = "" - this.searchResults = response this.XMLInfo = "" + // const sortField = "time_updated" + const sortField = "lifetime_subscriptions" + response.response.publishedfiledetails.sort((a, b) => + a[sortField] < b[sortField] ? 1 : -1 + ) + this.searchResults = response.response.publishedfiledetails + }) + .then(() => { + // Enable all tooltips + const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) + tooltipTriggerList.map(function (tooltipTriggerEl) { + return new bootstrap.Tooltip(tooltipTriggerEl) + }) }) .catch((error) => { console.error(error) @@ -169,3 +200,9 @@ export default { }) } } + +/* + +{ "result": 1, "publishedfileid": "2489240546", "creator": "76561199068873691", "creator_appid": 221100, "consumer_appid": 221100, "consumer_shortcutid": 0, "filename": "", "file_size": "276817803", "preview_file_size": "27678", "preview_url": "https://steamuserimages-a.akamaihd.net/ugc/2011465736408144669/A7137390FBB9F4F94E0BFE5389932F6DE7AB7B87/", "url": "", "hcontent_file": "4050838808220661564", "hcontent_preview": "2011465736408144669", "title": "LastDayZ_Helis", "short_description": "The author of the helicopter mod https://sibnic.info on the site you can download the latest version of free helicopters, If you need help with installation, go to discord https://sibnic.info/discord", "time_created": 1621186063, "time_updated": 1684985831, "visibility": 0, "flags": 5632, "workshop_file": false, "workshop_accepted": false, "show_subscribe_all": false, "num_comments_public": 0, "banned": false, "ban_reason": "", "banner": "76561197960265728", "can_be_deleted": true, "app_name": "DayZ", "file_type": 0, "can_subscribe": true, "subscriptions": 7935, "favorited": 3, "followers": 0, "lifetime_subscriptions": 22759, "lifetime_favorited": 5, "lifetime_followers": 0, "lifetime_playtime": "0", "lifetime_playtime_sessions": "0", "views": 535, "num_children": 0, "num_reports": 0, "tags": [ { "tag": "Animation", "display_name": "Animation" }, { "tag": "Environment", "display_name": "Environment" }, { "tag": "Sound", "display_name": "Sound" }, { "tag": "Vehicle", "display_name": "Vehicle" }, { "tag": "Mod", "display_name": "Mod" } ], "language": 0, "maybe_inappropriate_sex": false, "maybe_inappropriate_violence": false, "revision_change_number": "14", "revision": 1, "ban_text_check_result": 5 } + + */ diff --git a/web/start.sh b/web/start.sh index a99d21b..02c9ab9 100755 --- a/web/start.sh +++ b/web/start.sh @@ -13,4 +13,4 @@ fi cd /web npm i export DEBUG='express:*' -npx nodemon index.js +npx nodemon web.js diff --git a/web/index.js b/web/web.js similarity index 80% rename from web/index.js rename to web/web.js index 3a7e704..bb888f3 100644 --- a/web/index.js +++ b/web/web.js @@ -30,6 +30,9 @@ const client_appid = "221100" const modDir = "/mods" const serverFiles = "/serverfiles" +/* + File path delimiter + */ const d = '/' /* @@ -95,35 +98,29 @@ const getMods = () => { app.use(express.static('root')) -app.route('/mod/:modId') - .get((req, res) => { - // Get mod metadata by ID - const modId = req.params["modId"] - const modDir = config.modDir + d + modId - const customXML = getCustomXML(modId) - const ret = { - id: modId, - name: getModNameById(modId), - size: getDirSize(modDir), - customXML: customXML - } - res.send(ret) - }) - .post((req, res) => { - // Add a mod by ID - }) - .put((req, res) => { - // Update a mod by ID - }) +// Get mod metadata by ID +app.get('/mod/:modId', (req, res) => { + const modId = req.params["modId"] + const modDir = config.modDir + d + modId + const customXML = getCustomXML(modId) + const ret = { + id: modId, + name: getModNameById(modId), + size: getDirSize(modDir), + customXML: customXML + } + res.send(ret) +}) -app.route('/mod/:modId/:file') - .get((req, res) => { - const modId = req.params["modId"] - const file = req.params["file"] - const contents = fs.readFileSync(config.modDir + d + modId + d + file) - res.send(contents) - }) +// Get a mod's XML file +app.get('/mod/:modId/:file', (req, res) => { + const modId = req.params["modId"] + const file = req.params["file"] + const contents = fs.readFileSync(config.modDir + d + modId + d + file) + res.send(contents) +}) +// Search for a mod app.get(('/search/:searchString'), (req, res) => { const searchString = req.params["searchString"] const url = "https://api.steampowered.com/IPublishedFileService/QueryFiles/v1/?numperpage=1000&appid=221100&return_short_description=true&strip_description_bbcode=true&key=" + config.steamAPIKey + "&search_text=" + searchString @@ -140,8 +137,12 @@ app.get(('/search/:searchString'), (req, res) => { }) }) +/* + Get the status of things: + If the base files are installed, the version of the server, a list of mods, etc. + */ app.get('/status', (req, res) => { - // FIXME! Group these into a Promise.All() + // FIXME Async/await this stuff... const installed = fs.existsSync(config.installFile) const mods = getMods() const ret = {