mirror of
https://github.com/antos-rde/antosdk-apps.git
synced 2024-11-08 06:28:29 +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": [
|
||||
{
|
||||
"name": "ts-import",
|
||||
"data": ["sdk://core/ts/core.d.ts", "sdk://core/ts/jquery.d.ts","sdk://core/ts/antos.d.ts"]
|
||||
"name": "ts-antos-sdk",
|
||||
"data": {
|
||||
"version": "2.0.x"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "ts-compile",
|
||||
|
Binary file not shown.
@ -2,6 +2,7 @@
|
||||
AntOSDK: development API for AntOS based applications/projects
|
||||
|
||||
## 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.0.18: Add some public API on grid view
|
||||
- 0.0.17: Use lastest AntOS d.ts file
|
||||
|
@ -2,6 +2,7 @@
|
||||
AntOSDK: development API for AntOS based applications/projects
|
||||
|
||||
## 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.0.18: Add some public API on grid view
|
||||
- 0.0.17: Use lastest AntOS d.ts file
|
||||
|
@ -1,4 +1,4 @@
|
||||
class LinuxJob extends AntOSDKBaseJob {
|
||||
class BackendJob extends AntOSDKBaseJob {
|
||||
constructor(data)
|
||||
{
|
||||
super(data);
|
||||
@ -6,7 +6,7 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
execute()
|
||||
{
|
||||
switch (this.job.cmd) {
|
||||
case 'linux-exec':
|
||||
case 'cmd-exec':
|
||||
/**
|
||||
* Execute a linux command with the
|
||||
* help of a server side lua API
|
||||
@ -14,6 +14,9 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
*/
|
||||
this.exec();
|
||||
break;
|
||||
case 'lua-exec':
|
||||
this.xlua(this.job.data.path, this.job.data.params);
|
||||
break;
|
||||
default:
|
||||
const err_msg = `Unkown job ${this.job.cmd}`;
|
||||
this.log_error(err_msg);
|
||||
@ -24,6 +27,21 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
exec()
|
||||
{
|
||||
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";
|
||||
try{
|
||||
const socket = new WebSocket(url);
|
||||
@ -37,17 +55,10 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
this.result("Done");
|
||||
};
|
||||
socket.onopen = (e) => {
|
||||
if(!this.job.data.pwd)
|
||||
{
|
||||
this.job.data.pwd = this.job.root;
|
||||
}
|
||||
// send the command
|
||||
const cmd = {
|
||||
path: path,
|
||||
parameters: {
|
||||
action: "exec",
|
||||
args: this.job.data
|
||||
}
|
||||
parameters: params
|
||||
};
|
||||
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",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.1.0-b",
|
||||
"version": "0.1.1-b",
|
||||
"category": "Development",
|
||||
"iconclass": "fa fa-cog",
|
||||
"mimes": [
|
||||
|
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
class LinuxJob extends AntOSDKBaseJob {
|
||||
class BackendJob extends AntOSDKBaseJob {
|
||||
constructor(data)
|
||||
{
|
||||
super(data);
|
||||
@ -6,7 +6,7 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
execute()
|
||||
{
|
||||
switch (this.job.cmd) {
|
||||
case 'linux-exec':
|
||||
case 'cmd-exec':
|
||||
/**
|
||||
* Execute a linux command with the
|
||||
* help of a server side lua API
|
||||
@ -14,6 +14,9 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
*/
|
||||
this.exec();
|
||||
break;
|
||||
case 'lua-exec':
|
||||
this.xlua(this.job.data.path, this.job.data.params);
|
||||
break;
|
||||
default:
|
||||
const err_msg = `Unkown job ${this.job.cmd}`;
|
||||
this.log_error(err_msg);
|
||||
@ -24,6 +27,21 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
exec()
|
||||
{
|
||||
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";
|
||||
try{
|
||||
const socket = new WebSocket(url);
|
||||
@ -37,17 +55,10 @@ class LinuxJob extends AntOSDKBaseJob {
|
||||
this.result("Done");
|
||||
};
|
||||
socket.onopen = (e) => {
|
||||
if(!this.job.data.pwd)
|
||||
{
|
||||
this.job.data.pwd = this.job.root;
|
||||
}
|
||||
// send the command
|
||||
const cmd = {
|
||||
path: path,
|
||||
parameters: {
|
||||
action: "exec",
|
||||
args: this.job.data
|
||||
}
|
||||
parameters: params
|
||||
};
|
||||
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",
|
||||
"email": "mrsang@iohub.dev"
|
||||
},
|
||||
"version": "0.1.0-b",
|
||||
"version": "0.1.1-b",
|
||||
"category": "Development",
|
||||
"iconclass": "fa fa-cog",
|
||||
"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