2024-12-14 18:35:27 +08:00

55 lines
2.7 KiB
JavaScript

Volcanos(chat.ONIMPORT, {
_init: function(can, msg) {
if (can.isCmdMode()) {
can.ui = can.onappend.layout(can), can.onimport.service(can, msg)
} else {
msg.Dump(can)
}
},
service: function(can, msg) { var list = {}
msg.Table(function(value) { if (list[value.service_uid]) { list[value.service_uid].push(value); return } list[value.service_uid] = [value]
can.onimport.item(can, {icon: value.service_icon, name: value.service_name, _hash: value.service_name.split(" ")[0]}, function(event, item, show, target) { if (show) { return }
can.request(event, {view: "table", pod: value.nodename})
can._root.Action.run(event, [ctx.ACTION, ctx.RUN, value.index, value.place_uid], function(msg) {
can.onimport.index(can, msg, value, target)
})
})
}), can.db.list = list
},
index: function(can, msg, value, target) {
can.onimport.itemlist(can, msg.Table(function(item) {
item._hash = [value.service_name.split(" ")[0], item.name], item.__title = item.name
if (item.enable == "false" || can.base.isIn(item.index, "web.team.gonganxitong.credit", "web.team.gonganxitong.setting") || item.order > 500) { return }
return item
}), function(event, item, show, target) {
if (show) { return }
var hash = [value.service_name.split(" ")[0], item.name]
can.onimport.itemlist(can, can.core.List(can.db.list[value.service_uid], function(value) {
value._hash = hash.concat(value.place_name), value.__title = [item.name, value.place_name].join(" ")
value.icon = value.service_icon, value.name = value.place_name
return value
}), function(event, value, show, target) { if (show) { return }
can.onimport.content(can, value, item)
}, null, target)
}, null, target)
},
content: function(can, value, item) {
if (can.onmotion.cache(can, function() { return [value.service_uid, value.place_uid, item.index] }, can.ui.content)) { return }
var uid = can.db.hash[3] && can.db.hash.slice(0, 3).join(",") == value._hash.join(",")? can.db.hash[3]: null
can.onappend.plugin(can._root.Action, {space: value.nodename, index: item.index, args: [value.place_uid].concat(uid? [uid]: [])}, function(sub) {
sub.run = function(event, cmds, cb) { can.request(event, {pod: value.nodename})
can._root.Action.run(event, [ctx.ACTION, ctx.RUN, value.index, ctx.ACTION, ctx.RUN, item.index].concat(cmds), cb)
}
if (uid) { sub._history.push([value.place_uid]) }
sub.onexport.output = function(_sub, msg) { if (!can.isCmdMode()) { return }
if (msg.IsDetail()) {
can.user.title(value.__title+" "+(msg.Append("name")||msg.Append("title")))
can.onexport.hash(can, value._hash.concat(sub.Option(UID)))
} else {
can.user.title(value.__title)
can.onexport.hash(can, value._hash)
}
}
}, can.ui.content)
},
})