mirror of
https://github.com/esiur/esiur-js.git
synced 2025-06-27 15:23:11 +00:00
IIP v3.3
This commit is contained in:
4
tools/manager/js/IUIView.js
Normal file
4
tools/manager/js/IUIView.js
Normal file
@ -0,0 +1,4 @@
|
||||
class IUIView extends IUIWidget
|
||||
{
|
||||
|
||||
}
|
30
tools/manager/js/app.js
Normal file
30
tools/manager/js/app.js
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
function init()
|
||||
{
|
||||
iui("dlgLogin").dialog().show();
|
||||
|
||||
var local = new MemoryStore();
|
||||
Warehouse.put(local, "local");
|
||||
|
||||
iui("divContent").browser();
|
||||
}
|
||||
|
||||
function connect()
|
||||
{
|
||||
var url = document.getElementById("txtURL").value;
|
||||
var domain = document.getElementById("txtDomain").value;
|
||||
var username = document.getElementById("txtUsername").value;
|
||||
var password = document.getElementById("txtPassword").value;
|
||||
|
||||
iui("dlgLogin").setLoading(true);
|
||||
|
||||
var con = new DistributedConnection(url, domain, username, password);
|
||||
Warehouse.put(con, "remote");
|
||||
|
||||
con.on("ready", function (d) {
|
||||
iui("divContent").setConnection(con);
|
||||
iui("dlgLogin").hide();
|
||||
}).on("error", function(sender, code, msg){
|
||||
console.log(sender, code, msg);
|
||||
});
|
||||
}
|
132
tools/manager/js/browser.js
Normal file
132
tools/manager/js/browser.js
Normal file
@ -0,0 +1,132 @@
|
||||
class ResourceBrowser extends IUIWidget
|
||||
{
|
||||
|
||||
loadClass(className)
|
||||
{
|
||||
var rt = new AsyncReply();
|
||||
|
||||
if (this.scripts[className] != null)
|
||||
{
|
||||
rt.trigger(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
var script = document.createElement('script');
|
||||
var self = this;
|
||||
script.onload = function () {
|
||||
self.scripts[classsName] = script;
|
||||
rt.trigger(true);
|
||||
};
|
||||
|
||||
script.src = className + ".js";
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
}
|
||||
|
||||
constructor(el, properties)
|
||||
{
|
||||
super(el, IUI.extend(properties,
|
||||
{
|
||||
customClass: "browser",
|
||||
visible: false
|
||||
})
|
||||
);
|
||||
|
||||
var treeLayout = [
|
||||
{width: '200px', field: "instance", title: "Name", formatter: function(d, v){
|
||||
|
||||
if(v.instance.attributes.item("name") == null)
|
||||
return v.instance.name;
|
||||
else
|
||||
return v.instance.attributes.item("name");
|
||||
}},
|
||||
];
|
||||
|
||||
/*
|
||||
var contentLayout = [
|
||||
{field: "instance", title: "Name", formatter: function(d, v){
|
||||
return v.instance.attributes.item("name");
|
||||
}},
|
||||
{field: "instance", title: "Type", formatter: function(d, v){
|
||||
return v.instance.template.name;
|
||||
}}
|
||||
];
|
||||
*/
|
||||
|
||||
|
||||
this.tree = iui(document.createElement("div")).table({tree: true, layout: treeLayout});
|
||||
// this.content = iui(document.createElement("div")).table({layout: contentLayout});
|
||||
this.bar = iui(document.createElement("div")).bar();
|
||||
this.el.classList.add(this.customClass);
|
||||
this.el.appendChild(this.bar.el);
|
||||
this.el.appendChild(this.tree.el);
|
||||
// this.el.appendChild(this.content.el);
|
||||
|
||||
var self = this;
|
||||
this.tree.on("dblclick", function(item){
|
||||
|
||||
self.tree.clear();
|
||||
self.connection.getAttributes(item, ["name", "parents", "type"]).then(function(attrs){
|
||||
self.tree.add(item);
|
||||
// self.content.add(item);
|
||||
});
|
||||
|
||||
}).on("expand", function(e){
|
||||
self.connection.getAttributes(e.item, ["children"]).then(function(attrs){
|
||||
|
||||
attrs.children.forEach(function(child){
|
||||
self.connection.getAttributes(child, ["name", "parents", "childrenCount", "type"]).then(function(cAttars){
|
||||
self.tree.add(child, cAttars.childrenCount > 0);
|
||||
e.success();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
setConnection(connection, query = "")
|
||||
{
|
||||
var self = this;
|
||||
this.connection = connection;
|
||||
this.connection.query(query).then(function(rt)
|
||||
{
|
||||
rt.forEach(function(item){
|
||||
connection.getAttributes(item, ["name", "childrenCount", "type"]).then(function(attrs){
|
||||
|
||||
//connection.getAttributes(item, ["name", "children", "type"]).then(function(attrs){
|
||||
self.tree.add(item, attrs.childrenCount > 0);
|
||||
|
||||
/*
|
||||
var children = attrs.children;
|
||||
|
||||
for(var i = 0; i < children.length; i++)
|
||||
{
|
||||
|
||||
if (!children[i].instance.attributes.contains("parents"))
|
||||
children[i].instance.attributes.add("parents", []);
|
||||
|
||||
children[i].instance.attributes.item("parents").push(item);
|
||||
|
||||
self.tree.add(children[i]);
|
||||
}
|
||||
*/
|
||||
});
|
||||
});
|
||||
|
||||
/*
|
||||
for(var i = 0; i < rt.length; i++)
|
||||
{
|
||||
var item = rt[i];
|
||||
connection.getAttributes(rt[i]).then(function(attrs){
|
||||
self.tree.add(rt[i]);
|
||||
self.content.add(rt[i]);
|
||||
});
|
||||
}
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
IUI.module("browser", ResourceBrowser);
|
Reference in New Issue
Block a user