Files
meta-kit/root/api/meta.js
2019-04-16 19:22:26 +08:00

115 lines
2.7 KiB
JavaScript

const meta = {
getTableList(callback) {
red.getJSON("/meta/tablelist",{}, json => callback(json));
},
getTableDetail({name}, callback) {
red.getJSON("/meta/tableinfo",{name}, json => callback(json));
},
getServiceList(callback) {
red.getJSON("/meta/service_list",{}, json => {
json = red.replacePoint(json);
callback(json);
});
},
getServiceInfo({name}, callback) {
red.getJSON("/meta/service_info",{name}, res => {
/*let row = red.replacePoint(res)
console.log(row)
//let [name, comment, table, edits, imports, shows, exports, filters] = red.replacePoint(res);
row.shows = row.shows || [];
row.exports = row.exports || [];
row.imports = row.imports || [];
row.filters = row.filters || [];*/
let {name, comment, table, edits, imports, shows, exports, filters} = red.replacePoint(res)
callback({name, comment, table, edits, imports, shows, exports, filters});
});
},
getServiceDetail({name}, callback) {
red.getJSON("/meta/service_detail",{name}, json => {
json = red.replacePoint(json)
callback(json);
});
},
getCfg({name}) {
return red.postX("/meta/cfg",{name}, res => {
return red.replacePoint(res)
});
},
getDataList({name, filters, orders, limit}, callback) {
let fbean = red.replace$({name, filters, orders, limit})
red.getJSON("/data/list",{fBean: JSON.stringify(fbean)}, (json = {rows:[], total:0}) => {
callback(json)
})
},
tableLinkList() {
return red.postX('/meta/table_link_list')
},
linkSave({link}) {
return red.postX('/meta/link_save', {link: JSON.stringify(link)})
},
linkInfo({alias}) {
return red.postX('/meta/link_info', {alias})
},
tableInfo({name, alias}) {
return red.postX('/meta/tableinfo', {name, alias})
}
}
let a = [
{
name: '',
alias: '',
link: [
{"a.id": "b.x"}
],
}
]
/*
let list = [
{id: 1, pid:0},
{id: 2, pid:0},
{id: 3, pid:0},
{id: 4, pid:1},
{id: 5, pid:2},
{id: 6, pid:5},
{id: 7, pid:1},
{id: 8, pid:0},
]
class Tree {
constructor(id, pid) {
this.id = id
this.pid = pid
this.left = undefined;
this.right = undefined;
this.nodes = []
}
add(tree) {
this.nodes.push(tree)
}
}
let nodes = new Tree(null, 0);
for (let x of list) {
if (x.pid == 0) {
nodes.add(x)
continue
}
for (let i = 0; i < x.nodes.length; i++) {
}
}*/