agent-backend/contracts/AppDataSource/naiveDAC/naiveDAC.yjs

59 lines
1.5 KiB
Plaintext
Raw Permalink Normal View History

2021-09-26 04:49:24 +00:00
module NaiveDAC{
function initDAC(req){
Global.acceptList = {
};
Global.applyList = {
};
Global.owner = req;
}
function checkPermission(req){
return (Global.acceptList[req]!=undefined);
}
export function hasPermission(arg){
return (Global.acceptList[requester]!=undefined);
}
export function accept(req){
if (requester==Global.owner){
Global.acceptList[req] = Global.applyList[req];
if (Global.applyList[req] != undefined)
Global.applyList[req] = undefined;
return true;
}
return false;
}
export function cancel(req){
if (requester==Global.owner){
Global.applyList[req] = Global.acceptList[req];
if (Global.acceptList[req] != undefined)
Global.acceptList[req] = undefined;
return true;
}
return false;
}
export function apply(remark){
if (remark != undefined && requester !=undefined){
Global.applyList[requester] = remark;
return "success";
}
return "failed"
}
export function needRender(arg){
return true;
}
export function getMainFrame(arg){
return "/naiveDAC/naiveDAC.html";
}
export function loadResource(arg){
return Global.Resources.loadAsString(arg);
}
export function isOwner(arg){
return Global.owner==requester;
}
export function getApplyList(arg){
return JSON.stringify(Global.applyList);
}
export function getAcceptList(arg){
return JSON.stringify(Global.acceptList);
}
}