mirror of
https://github.com/lxsang/antos-frontend.git
synced 2024-11-08 05:58:22 +01:00
Allow to set version number and build ID to the current Antos build
This commit is contained in:
parent
699c697344
commit
da5bbdab60
3
Makefile
3
Makefile
@ -8,7 +8,7 @@ TSC=./node_modules/typescript/bin/tsc
|
||||
UGLIFYJS=./node_modules/terser/bin/terser
|
||||
UGLIFYCSS=./node_modules/uglifycss/uglifycss
|
||||
|
||||
VERSION=$(shell grep -e "export const VERSION" src/core/core.ts | cut -d '"' -f 2 | cut -d "-" -f 1)
|
||||
VERSION=1.2.1-b-$(shell git rev-parse --short HEAD)
|
||||
|
||||
GSED=sed
|
||||
UNAME_S := $(shell uname -s)
|
||||
@ -117,6 +117,7 @@ build_javascripts: ts
|
||||
(cat "$${f}"; echo) >> dist/antos.js;\
|
||||
rm "$${f}";\
|
||||
done
|
||||
echo 'OS.VERSION.version_string = "$(VERSION)";' >> dist/antos.js
|
||||
cp dist/antos.js $(BUILDDIR)/scripts/
|
||||
echo "if(exports){ exports.__esModule = true;exports.OS = OS; }" >> dist/antos.js
|
||||
rm -r dist/core
|
||||
|
25
d.ts/antos.d.ts
vendored
25
d.ts/antos.d.ts
vendored
@ -1559,13 +1559,14 @@ declare 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
|
||||
@ -1575,10 +1576,11 @@ declare namespace OS {
|
||||
/**
|
||||
* The version string
|
||||
*
|
||||
* @private
|
||||
* @type {string}
|
||||
* @memberof Version
|
||||
*/
|
||||
string: string;
|
||||
private string;
|
||||
/**
|
||||
* The current branch
|
||||
* - 1: `a` - alpha branch
|
||||
@ -1611,12 +1613,24 @@ declare namespace OS {
|
||||
* @memberof Version
|
||||
*/
|
||||
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);
|
||||
/**
|
||||
* Setter getter to set the version string to the object
|
||||
*/
|
||||
set version_string(v: string);
|
||||
get version_string(): string;
|
||||
/**
|
||||
* Compare the current version with another version.
|
||||
*
|
||||
@ -1670,6 +1684,11 @@ declare namespace OS {
|
||||
* is an instance of [[Version]]
|
||||
*/
|
||||
const VERSION: Version;
|
||||
/**
|
||||
* Variable represents the current AntOS source code repository
|
||||
* is an instance of [[string]]
|
||||
*/
|
||||
const REPOSITORY: string;
|
||||
/**
|
||||
* Register a model prototype to the system namespace.
|
||||
* There are two types of model to be registered, if the model
|
||||
|
@ -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>\
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ body
|
||||
|
||||
#login_form{
|
||||
width:300px;
|
||||
height: 200px;
|
||||
height: 180px;
|
||||
display: block;
|
||||
border:1px solid #262626;
|
||||
border-radius: 6px;
|
||||
@ -130,7 +130,23 @@ body
|
||||
height: 1px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#antos_build_id {
|
||||
position: absolute;
|
||||
display: block;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
padding: 2px;
|
||||
background-color: #d6d4d4;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
font-size: 12px;
|
||||
}
|
||||
#antos_build_id a:link,
|
||||
#antos_build_id a:visited,
|
||||
#antos_build_id a:hover
|
||||
{
|
||||
color:#df3154;
|
||||
text-decoration: none;
|
||||
}
|
||||
afx-desktop > .list-container > ul > afx-list-item afx-label span {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user