From 45b019725db2008c7a78cc7c95d63fe8bb6dcea0 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Thu, 21 Mar 2024 13:15:56 +0100 Subject: [PATCH] fix: add missing Setting handle to git --- src/packages/Setting/VersionsHandle.ts | 80 ++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/packages/Setting/VersionsHandle.ts diff --git a/src/packages/Setting/VersionsHandle.ts b/src/packages/Setting/VersionsHandle.ts new file mode 100644 index 0000000..a236ebf --- /dev/null +++ b/src/packages/Setting/VersionsHandle.ts @@ -0,0 +1,80 @@ +/* + * decaffeinate suggestions: + * DS102: Remove unnecessary code created because of implicit returns + * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md + */ +// Copyright 2017-2018 Xuan Sang LE + +// AnTOS Web desktop is is licensed under the GNU General Public +// License v3.0, see the LICENCE file for more information + +// This program is free software: you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. + +// You should have received a copy of the GNU General Public License +//along with this program. If not, see https://www.gnu.org/licenses/. + +namespace OS { + const App = OS.application.Setting; + + /** + * + * + * @class VFSHandle + * @extends {App.SettingHandle} + */ + class VersionsHandle extends App.SettingHandle { + private grid: GUI.tag.GridViewTag; + + /** + *Creates an instance of VFSHandle. + * @param {HTMLElement} scheme + * @param {OS.application.Setting} parent + * @memberof VFSHandle + */ + constructor(scheme: HTMLElement, parent: OS.application.Setting) { + super(scheme, parent); + this.grid = this.find("grid-version") as GUI.tag.GridViewTag; + this.grid.resizable = true; + this.grid.header = [{ text: __("Component")}, { text: __("Version")}]; + this.display_versions(); + } + + /** + * Display versions of all system components + */ + private async display_versions() : Promise + { + try { + let result = await API.handle.versions(); + if(result.error) + { + throw API.throwe(__("Unable to fetch system version information")); + } + let data = result.result as GenericObject; + let records = [[{text:"AntOS"}, {text: `${OS.VERSION.version_string}`}]]; + for (const key in data) { + const element = data[key]; + records.push([ + { text: key }, + { text: `${element["version"]}-${element["ref"]}` } + ]) + } + this.grid.rows = records; + } + catch(e) + { + this.parent.error(e.toString()); + } + } + } + + App.VersionsHandle = VersionsHandle; +}