mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-12-24 11:18:21 +01:00
libantosdk: linux worker is renamed to backend, linux-exec job renamed to cmd-exec, add lua-exec job for backend lua script execution
This commit is contained in:
parent
402f0edb49
commit
79ddff1cbd
@ -19,8 +19,10 @@
|
|||||||
],
|
],
|
||||||
"jobs": [
|
"jobs": [
|
||||||
{
|
{
|
||||||
"name": "ts-import",
|
"name": "ts-antos-sdk",
|
||||||
"data": ["sdk://core/ts/core.d.ts", "sdk://core/ts/jquery.d.ts","sdk://core/ts/antos.d.ts"]
|
"data": {
|
||||||
|
"version": "2.0.x"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ts-compile",
|
"name": "ts-compile",
|
||||||
|
Binary file not shown.
@ -2,6 +2,7 @@
|
|||||||
AntOSDK: development API for AntOS based applications/projects
|
AntOSDK: development API for AntOS based applications/projects
|
||||||
|
|
||||||
## Change logs
|
## Change logs
|
||||||
|
- 0.1.1: linux worker is renamed to backend, linux-exec job re to cmd-exec, add lua-exec job for backend lua script execution
|
||||||
- 0.1.0: antOS SDK is no longer delivered in this package, it will be fetched directly from AntOS release site
|
- 0.1.0: antOS SDK is no longer delivered in this package, it will be fetched directly from AntOS release site
|
||||||
- 0.0.18: Add some public API on grid view
|
- 0.0.18: Add some public API on grid view
|
||||||
- 0.0.17: Use lastest AntOS d.ts file
|
- 0.0.17: Use lastest AntOS d.ts file
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
AntOSDK: development API for AntOS based applications/projects
|
AntOSDK: development API for AntOS based applications/projects
|
||||||
|
|
||||||
## Change logs
|
## Change logs
|
||||||
|
- 0.1.1: linux worker is renamed to backend, linux-exec job re to cmd-exec, add lua-exec job for backend lua script execution
|
||||||
- 0.1.0: antOS SDK is no longer delivered in this package, it will be fetched directly from AntOS release site
|
- 0.1.0: antOS SDK is no longer delivered in this package, it will be fetched directly from AntOS release site
|
||||||
- 0.0.18: Add some public API on grid view
|
- 0.0.18: Add some public API on grid view
|
||||||
- 0.0.17: Use lastest AntOS d.ts file
|
- 0.0.17: Use lastest AntOS d.ts file
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class LinuxJob extends AntOSDKBaseJob {
|
class BackendJob extends AntOSDKBaseJob {
|
||||||
constructor(data)
|
constructor(data)
|
||||||
{
|
{
|
||||||
super(data);
|
super(data);
|
||||||
@ -6,7 +6,7 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
execute()
|
execute()
|
||||||
{
|
{
|
||||||
switch (this.job.cmd) {
|
switch (this.job.cmd) {
|
||||||
case 'linux-exec':
|
case 'cmd-exec':
|
||||||
/**
|
/**
|
||||||
* Execute a linux command with the
|
* Execute a linux command with the
|
||||||
* help of a server side lua API
|
* help of a server side lua API
|
||||||
@ -14,6 +14,9 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
*/
|
*/
|
||||||
this.exec();
|
this.exec();
|
||||||
break;
|
break;
|
||||||
|
case 'lua-exec':
|
||||||
|
this.xlua(this.job.data.path, this.job.data.params);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
const err_msg = `Unkown job ${this.job.cmd}`;
|
const err_msg = `Unkown job ${this.job.cmd}`;
|
||||||
this.log_error(err_msg);
|
this.log_error(err_msg);
|
||||||
@ -24,6 +27,21 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
exec()
|
exec()
|
||||||
{
|
{
|
||||||
const path = "pkg://libantosdk/core/lua/api.lua".abspath(this.job.root);
|
const path = "pkg://libantosdk/core/lua/api.lua".abspath(this.job.root);
|
||||||
|
if(!this.job.data.pwd)
|
||||||
|
{
|
||||||
|
this.job.data.pwd = this.job.root;
|
||||||
|
}
|
||||||
|
const params = {
|
||||||
|
action: "exec",
|
||||||
|
args: this.job.data
|
||||||
|
};
|
||||||
|
this.xlua(path, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
xlua(path, params)
|
||||||
|
{
|
||||||
const url = API.REST.replace("http","ws") + "/system/apigateway?ws=1";
|
const url = API.REST.replace("http","ws") + "/system/apigateway?ws=1";
|
||||||
try{
|
try{
|
||||||
const socket = new WebSocket(url);
|
const socket = new WebSocket(url);
|
||||||
@ -37,17 +55,10 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
this.result("Done");
|
this.result("Done");
|
||||||
};
|
};
|
||||||
socket.onopen = (e) => {
|
socket.onopen = (e) => {
|
||||||
if(!this.job.data.pwd)
|
|
||||||
{
|
|
||||||
this.job.data.pwd = this.job.root;
|
|
||||||
}
|
|
||||||
// send the command
|
// send the command
|
||||||
const cmd = {
|
const cmd = {
|
||||||
path: path,
|
path: path,
|
||||||
parameters: {
|
parameters: params
|
||||||
action: "exec",
|
|
||||||
args: this.job.data
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
socket.send(JSON.stringify(cmd));
|
socket.send(JSON.stringify(cmd));
|
||||||
};
|
};
|
||||||
@ -71,4 +82,7 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
API.jobhandle["linux-exec"] = LinuxJob;
|
|
||||||
|
|
||||||
|
API.jobhandle["cmd-exec"] = BackendJob;
|
||||||
|
API.jobhandle["lua-exec"] = BackendJob;
|
@ -7,7 +7,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "mrsang@iohub.dev"
|
"email": "mrsang@iohub.dev"
|
||||||
},
|
},
|
||||||
"version": "0.1.0-b",
|
"version": "0.1.1-b",
|
||||||
"category": "Development",
|
"category": "Development",
|
||||||
"iconclass": "fa fa-cog",
|
"iconclass": "fa fa-cog",
|
||||||
"mimes": [
|
"mimes": [
|
||||||
|
Binary file not shown.
@ -1,4 +1,4 @@
|
|||||||
class LinuxJob extends AntOSDKBaseJob {
|
class BackendJob extends AntOSDKBaseJob {
|
||||||
constructor(data)
|
constructor(data)
|
||||||
{
|
{
|
||||||
super(data);
|
super(data);
|
||||||
@ -6,7 +6,7 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
execute()
|
execute()
|
||||||
{
|
{
|
||||||
switch (this.job.cmd) {
|
switch (this.job.cmd) {
|
||||||
case 'linux-exec':
|
case 'cmd-exec':
|
||||||
/**
|
/**
|
||||||
* Execute a linux command with the
|
* Execute a linux command with the
|
||||||
* help of a server side lua API
|
* help of a server side lua API
|
||||||
@ -14,6 +14,9 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
*/
|
*/
|
||||||
this.exec();
|
this.exec();
|
||||||
break;
|
break;
|
||||||
|
case 'lua-exec':
|
||||||
|
this.xlua(this.job.data.path, this.job.data.params);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
const err_msg = `Unkown job ${this.job.cmd}`;
|
const err_msg = `Unkown job ${this.job.cmd}`;
|
||||||
this.log_error(err_msg);
|
this.log_error(err_msg);
|
||||||
@ -24,6 +27,21 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
exec()
|
exec()
|
||||||
{
|
{
|
||||||
const path = "pkg://libantosdk/core/lua/api.lua".abspath(this.job.root);
|
const path = "pkg://libantosdk/core/lua/api.lua".abspath(this.job.root);
|
||||||
|
if(!this.job.data.pwd)
|
||||||
|
{
|
||||||
|
this.job.data.pwd = this.job.root;
|
||||||
|
}
|
||||||
|
const params = {
|
||||||
|
action: "exec",
|
||||||
|
args: this.job.data
|
||||||
|
};
|
||||||
|
this.xlua(path, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
xlua(path, params)
|
||||||
|
{
|
||||||
const url = API.REST.replace("http","ws") + "/system/apigateway?ws=1";
|
const url = API.REST.replace("http","ws") + "/system/apigateway?ws=1";
|
||||||
try{
|
try{
|
||||||
const socket = new WebSocket(url);
|
const socket = new WebSocket(url);
|
||||||
@ -37,17 +55,10 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
this.result("Done");
|
this.result("Done");
|
||||||
};
|
};
|
||||||
socket.onopen = (e) => {
|
socket.onopen = (e) => {
|
||||||
if(!this.job.data.pwd)
|
|
||||||
{
|
|
||||||
this.job.data.pwd = this.job.root;
|
|
||||||
}
|
|
||||||
// send the command
|
// send the command
|
||||||
const cmd = {
|
const cmd = {
|
||||||
path: path,
|
path: path,
|
||||||
parameters: {
|
parameters: params
|
||||||
action: "exec",
|
|
||||||
args: this.job.data
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
socket.send(JSON.stringify(cmd));
|
socket.send(JSON.stringify(cmd));
|
||||||
};
|
};
|
||||||
@ -71,4 +82,7 @@ class LinuxJob extends AntOSDKBaseJob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
API.jobhandle["linux-exec"] = LinuxJob;
|
|
||||||
|
|
||||||
|
API.jobhandle["cmd-exec"] = BackendJob;
|
||||||
|
API.jobhandle["lua-exec"] = BackendJob;
|
@ -7,7 +7,7 @@
|
|||||||
"author": "Xuan Sang LE",
|
"author": "Xuan Sang LE",
|
||||||
"email": "mrsang@iohub.dev"
|
"email": "mrsang@iohub.dev"
|
||||||
},
|
},
|
||||||
"version": "0.1.0-b",
|
"version": "0.1.1-b",
|
||||||
"category": "Development",
|
"category": "Development",
|
||||||
"iconclass": "fa fa-cog",
|
"iconclass": "fa fa-cog",
|
||||||
"mimes": [
|
"mimes": [
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "libantosdk",
|
|
||||||
"css": ["main.css"],
|
|
||||||
"javascripts": [],
|
|
||||||
"coffees": [],
|
|
||||||
"ts": ["ts/main.ts", "ts/app.ts"],
|
|
||||||
"copies": ["core","package.json","scheme.html", "README.md"]
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user