From 338d925bcc93c3959809b4389548cc39a21d2ff0 Mon Sep 17 00:00:00 2001 From: Eric Lighthall <55029902+Eric-Lighthall@users.noreply.github.com> Date: Sat, 20 Apr 2024 02:24:33 -0700 Subject: [PATCH] Fetch server info from versionservice.js module Instead of directly fetching for the version info in UITabAbout.js, the module is now used for it --- src/UI/Settings/UITabAbout.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/src/UI/Settings/UITabAbout.js b/src/UI/Settings/UITabAbout.js index 8a6631b67..f53a587b9 100644 --- a/src/UI/Settings/UITabAbout.js +++ b/src/UI/Settings/UITabAbout.js @@ -17,6 +17,8 @@ * along with this program. If not, see . */ +import { fetchServerInfo } from '../../services/VersionService.js'; + // About export default { id: 'about', @@ -92,24 +94,15 @@ export default { `; }, init: ($el_window) => { - // version - $.ajax({ - url: api_origin + "/version", - type: 'GET', - async: true, - contentType: "application/json", - headers: { - "Authorization": "Bearer " + auth_token - }, - statusCode: { - 401: function () { - logout(); - }, - }, - success: function (res) { - var d = new Date(0); - $el_window.find('.version').html('Version: ' + res.version + ' • ' + 'Server: ' + res.location + ' • ' + 'Deployed: ' + new Date(res.deploy_timestamp)); - } + // server and version infomration + fetchServerInfo(api_origin, auth_token) + .then(res => { + const deployed_date = new Date(res.deployTimestamp).toLocaleString(); + $el_window.find('.version').html(`Version: ${res.version} • Server: ${res.location} • Deployed: ${deployed_date}`); + }) + .catch(error => { + console.error("Failed to fetch server info:", error); + $el_window.find('.version').html("Failed to load version information."); }); $el_window.find('.credits').on('click', function (e) {