mirror of
https://github.com/lxsang/antos-frontend.git
synced 2025-07-17 06:19:51 +02:00
Allow to set version number and build ID to the current Antos build
This commit is contained in:
@ -424,13 +424,14 @@ namespace OS {
|
||||
* AntOS version number is in the following format:
|
||||
*
|
||||
* ```
|
||||
* [major_number].[minor_number].[patch]-[branch]
|
||||
* [major_number].[minor_number].[patch]-[branch]-[build ID])
|
||||
*
|
||||
* e.g.: 1.2.3-r means that:
|
||||
* e.g.: 1.2.3-r-b means that:
|
||||
* - version major number is 1
|
||||
* - version minor number is 2
|
||||
* - patch version is 3
|
||||
* - the current branch is release `r`
|
||||
* - build ID (optional)
|
||||
* ```
|
||||
*
|
||||
* @export
|
||||
@ -440,10 +441,11 @@ namespace OS {
|
||||
/**
|
||||
* The version string
|
||||
*
|
||||
* @private
|
||||
* @type {string}
|
||||
* @memberof Version
|
||||
*/
|
||||
string: string;
|
||||
private string: string;
|
||||
|
||||
/**
|
||||
* The current branch
|
||||
@ -481,13 +483,40 @@ namespace OS {
|
||||
*/
|
||||
patch: number;
|
||||
|
||||
/**
|
||||
* Version build ID (optional): usually the current git commit hash
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof Version
|
||||
*/
|
||||
build_id: string;
|
||||
|
||||
/**
|
||||
*Creates an instance of Version.
|
||||
*
|
||||
* @param {string} string string represents the version
|
||||
* @memberof Version
|
||||
*/
|
||||
constructor(string: string) {
|
||||
this.string = string;
|
||||
this.version_string = string;
|
||||
}
|
||||
/**
|
||||
* Setter/getter to set the version string to the object
|
||||
*
|
||||
* @memberof Version
|
||||
*/
|
||||
set version_string(v: string)
|
||||
{
|
||||
if(!v)
|
||||
{
|
||||
this.string = undefined;
|
||||
this.major = undefined;
|
||||
this.minor = undefined;
|
||||
this.patch = undefined;
|
||||
this.build_id = undefined;
|
||||
return;
|
||||
}
|
||||
this.string = v;
|
||||
const arr = this.string.split("-");
|
||||
const br = {
|
||||
r: 3,
|
||||
@ -495,9 +524,14 @@ namespace OS {
|
||||
a: 1,
|
||||
};
|
||||
this.branch = 3;
|
||||
if (arr.length === 2 && br[arr[1]]) {
|
||||
if (arr.length >= 2 && br[arr[1]]) {
|
||||
this.branch = br[arr[1]];
|
||||
if(arr[2])
|
||||
{
|
||||
this.build_id = arr[2];
|
||||
}
|
||||
}
|
||||
|
||||
const mt = arr[0].match(/\d+/g);
|
||||
if (!mt) {
|
||||
API.throwe(
|
||||
@ -517,6 +551,10 @@ namespace OS {
|
||||
this.patch = Number(mt[2]);
|
||||
}
|
||||
}
|
||||
get version_string(): string
|
||||
{
|
||||
return this.string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the current version with another version.
|
||||
@ -761,7 +799,14 @@ namespace OS {
|
||||
* Variable represents the current AntOS version, it
|
||||
* is an instance of [[Version]]
|
||||
*/
|
||||
export const VERSION: Version = "1.2.1-b".__v();
|
||||
export const VERSION: Version = new Version(undefined);
|
||||
|
||||
/**
|
||||
* Variable represents the current AntOS source code repository
|
||||
* is an instance of [[string]]
|
||||
*/
|
||||
export const REPOSITORY: string = "https://github.com/lxsang/antos";
|
||||
|
||||
/**
|
||||
* Register a model prototype to the system namespace.
|
||||
* There are two types of model to be registered, if the model
|
||||
|
@ -926,7 +926,11 @@ namespace OS {
|
||||
* @export
|
||||
*/
|
||||
export function login(): void {
|
||||
const scheme = $.parseHTML(schemes.login);
|
||||
const scheme = $.parseHTML(
|
||||
schemes.login
|
||||
.replace("[ANTOS_BUILD_ID]", OS.VERSION.build_id)
|
||||
.replace("[ANTOS_VERSION]", OS.VERSION.version_string)
|
||||
);
|
||||
$("#wrapper").append(scheme);
|
||||
$("#btlogin").on("click", async function () {
|
||||
const data: API.UserLoginType = {
|
||||
@ -1060,12 +1064,13 @@ namespace OS {
|
||||
|
||||
schemes.login = `\
|
||||
<div id = "login_form">
|
||||
<p>Welcome to AntOS v${OS.VERSION.toString()}, please login</p>
|
||||
<p>Welcome to AntOS, please login</p>
|
||||
<input id = "txtuser" type = "text" value = "demo" ></input>
|
||||
<input id = "txtpass" type = "password" value = "demo" ></input>
|
||||
<button id = "btlogin">Login</button>
|
||||
<div id = "login_error"></div>
|
||||
</div>\
|
||||
</div>
|
||||
<div id = "antos_build_id"><a href="${OS.REPOSITORY}/tree/[ANTOS_BUILD_ID]">AntOS v[ANTOS_VERSION]</div>\
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user