
| Current Path : /var/www/web-klick.de/dsh/50_dev2017/1303__autotestfrontend/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/50_dev2017/1303__autotestfrontend/MainContent.js |
/* ************************************************************************
Copyright:
License:
Authors:
************************************************************************ */
/* ************************************************************************
#asset(autotest/*)
************************************************************************ */
/**
* This is the MainContent Class which delivers a TabView for the MainContent Area
*/
qx.Class.define("autotest.MainContent", {
extend : qx.application.Standalone,
// constructor:
// basic initialization
// gets Application.js as argument which is set to this.application
construct : function(app)
{
// Call super class
this.base(arguments);
this.application = app;
this.settings = new autotest.Settings(this);
qx.Class.include(qx.ui.treevirtual.TreeVirtual,qx.ui.treevirtual.MNode);
},
members : {
// General constants:
testTree : null,
rpc_url : "http://localhost/cgi-bin/autotest_0_84/autotest/index.cgi",
rpc_service : "DivBasicF.AutoRPC",
// Label formats:
f_big : {font: qx.bom.Font.fromString("18px sans-serif")},
f_normal : {font: qx.bom.Font.fromString("13px sans-serif")},
//*********************************************************************
getLoginScreen: function() {
this.loginInfo = new qx.ui.basic.Label("..").set({textColor: "red"});
this.loginForm = new qx.ui.form.Form();
this.loginForm.addGroupHeader("Please log in to continue");
var account = new qx.ui.form.TextField().set({required:true});
this.loginForm.add(account, "Username");
var password = new qx.ui.form.PasswordField().set({required:true});
this.loginForm.add(password, "Password");
this.login_window = new qx.ui.window.Window("Login ").set({width: 250, height: 200, showClose : false, showMinimize : false });
this.login_window.setLayout(new qx.ui.layout.Basic());
var button = new qx.ui.form.Button("Login");
button.addListener("execute", function(e) {
this.tabView.setEnabled(true);
this.logged_in(account,password);
this.login_window.close();
}, this);
password.addListener("keypress", function(e) {
if (e.getKeyCode()==13) button.execute();
});
this.loginForm.addButton(button);
this.login_window.add(this.loginInfo,{left:10, top:0});
this.login_window.add(new qx.ui.form.renderer.Single(this.loginForm), {left: 10, top: 20});
return this.login_window;
},
autotest_loop : function() {
this.tabView = new qx.ui.tabview.TabView();
this.tabView.set({ width: 870, height: 500});
this.testprojects = new Array();
this.aktproject = 1;
this.testtree_screen = new qx.ui.tabview.Page("Testtree","autotest/tree.png");
this.requirement_screen = new qx.ui.tabview.Page("Requirements","autotest/requirement.png");
this.archuser_screen = new qx.ui.tabview.Page("Architekturen/User","autotest/user.png");
this.settings_screen = new qx.ui.tabview.Page("Login / Einstellungen","autotest/settings.png");
this.tabView.add(this.testtree_screen);
this.tabView.add(this.requirement_screen);
this.tabView.add(this.archuser_screen);
this.tabView.add(this.settings_screen);
this.logged_out();
return this.tabView;
},
//******************************************************************************
logged_out : function () {
this.settings_screen.removeAll();
this.settings_screen.setLayout (new qx.ui.layout.Basic());
this.user = null;
this.password = null;
this.testtree_screen.removeAll();
this.testtree_screen.setLayout (new qx.ui.layout.VBox(20));
this.testprojects = new Array();
this.aktproject = -1;
this.getLoginScreen();
this.loginInfo.setValue("");
this.login_window.open();
this.login_window.moveTo(300,300);
this.tabView.setEnabled(false);
/*
var account_label = new qx.ui.basic.Label("Account").set(this.f_normal);
var password_label = new qx.ui.basic.Label("Password").set(this.f_normal);
var account = new qx.ui.form.TextField();
var password = new qx.ui.form.TextField();
account_label.setWidth(120);
password_label.setWidth(120);
account.setWidth(120);
password.setWidth(120);
account_label.setHeight(30);
password_label.setHeight(30);
account.setHeight(30);
password.setHeight(30);
account.setPlaceholder("username...");
password.setPlaceholder("password...");
this.settings_screen.add(account_label, {left: 10, top: 27});
this.settings_screen.add(password_label, {left: 10, top: 72});
this.settings_screen.add(account, {left: 85, top: 20});
this.settings_screen.add(password, {left: 85, top: 65});
var button = new qx.ui.form.Button("Login");
button.setFont("bold");
button.setWidth(120);
button.setHeight(30);
button.addListener("execute", function(e) {
this.logged_in(account,password);
}, this);
this.settings_screen.add(button, {left: 85, top: 110});
*/
},
//********************************************************************
logged_in : function(account,password) {
this.settings_screen.removeAll();
this.settings_screen.setLayout (new qx.ui.layout.Basic());
this.user = account.getValue();
this.password = password.getValue();
var rpc = new qx.io.remote.Rpc();
rpc.setUrl(this.rpc_url);
rpc.setServiceName(this.rpc_service);
rpc.callAsync(qx.lang.Function.bind(this.logged_in_1,this),"testtrees",
this.user,this.password);
},
//***********************************************************************
logged_in_1 : function(result,exc) {
if (exc != null) { this.error("RPC-Call failed in logged_in_1: " + exc); }
var o; var o1; var o2;
if (typeof result == "string") {
var button = new qx.ui.form.Button("Go Back");
button.setFont("bold");
button.setWidth(120);
button.setHeight(30);
button.addListener("execute", function(e) {
this.logged_out();
}, this);
o = "Unknown error. " + result;
if (result == "ERROR101") { var o = "User does not exist !"; }
if (result == "ERROR102") { var o = "Wrong password !"; }
//o = new qx.ui.basic.Label(o).set(this.f_big);
//o.setTextColor("red");
this.loginInfo.setValue(o);
this.login_window.getChildren().pop();
this.login_window.open();
//this.settings_screen.add(o, {left: 10, top: 10});
//this.settings_screen.add(button, {left: 10, top: 60});
this.tabView.setEnabled(false);
return 1;
}
this.login_window.close();
this.tabView.setEnabled(true);
var zaehler = 0;
this.mark = new qx.ui.basic.Atom("","autotest/right.png");
this.mark.setFont("bold");
this.mark.setWidth(40);
this.mark.setHeight(30);
var button_logout = new qx.ui.form.Button("Logout");
button_logout.setFont("bold");
button_logout.setWidth(120);
button_logout.setHeight(30);
button_logout.addListener("execute", function(e) {
this.logged_out();
}, this);
while (0 == 0) {
o1 = result.shift();
if (o1 == null) { break; }
var button = new qx.ui.form.Button(o1[0]);
button.setWidth(120);
button.setHeight(30);
eval("this.tmp_fkt = function(e) { this.logged_in_2(e,"
+ zaehler + ",'" + o1[0] + "','" + o1[1] + "'); this.tabView.setSelection([this.testtree_screen]);} ");
button.addListener('execute',this.tmp_fkt,this);
this.settings_screen.add(button, {left: 90, top: 100 + zaehler*45 });
zaehler = zaehler + 1;
}
o = new qx.ui.basic.Label("Logged in as: ").set(this.f_big);
o.setWidth(200);
o.setHeight(50);
o2 = new qx.ui.basic.Label(this.user).set(this.f_big);
o2.setTextColor("green");
o2.setWidth(250);
o2.setHeight(50);
var project = new qx.ui.basic.Label("Projects:").set(this.f_big);
project.setWidth(120);
project.setHeight(30);
this.settings_screen.add(o, {left: 10, top: 10});
this.settings_screen.add(o2, {left: 135, top: 10});
this.settings_screen.add(project, {left: 10, top: 60});
this.settings_screen.add(button_logout, {left: 700, top: 10});
this.tabView.setSelection([this.settings_screen]);
},
//********************************************************************
logged_in_2 : function (e,zaehler,testtree_path,testproject_name) {
this.settings_screen.add(this.mark, {left: 42, top: 100 + zaehler*45} );
this.testtree_screen.removeAll();
this.testtree_screen.setLayout (new qx.ui.layout.VBox(20));
this.testtree_pane = new qx.ui.splitpane.Pane("horizontal");
this.tree = new qx.ui.container.Composite(new qx.ui.layout.VBox(10)); // Tree-Feld
this.detail = new qx.ui.container.Composite(new qx.ui.layout.VBox(10)); // Detail-Feld
this.tree.setWidth(400);
this.akt_testtree_path = testtree_path;
var title = new qx.ui.basic.Label(testtree_path);
this.tree.add(title);
this.detail.add(new qx.ui.basic.Label(testproject_name));
this.testtree_pane.add(this.tree,0);
this.testtree_pane.add(this.detail,1);
this.testtree_screen.add(this.testtree_pane);
this.testtree_rpc_call_is_active = 0;
// First implementation CG
this.testtree_lines = [];
this.testtree_lines['::'] = [title,0]; // entry opened/closed
this.parent_testitem = "::";
// Second implementation CG
this.testtree_data = new qx.ui.treevirtual.TreeVirtual(["Item","Result", "Remark", ""]).set({width: 300});
this.testtree_model = this.testtree_data.getDataModel(); // tree data model
this.testtree_data.addListener("treeClose", this.remove_children, this);
this.testtree_data.addListener("treeOpenWithContent", this.create_children, this);
this.testtree_data.addListener("cellClick", this.run_clicked, this);
this.parent_branch = null;
var fkt = null;
this.actualize_testtree(); fkt = this.add_to_testtree; // first model
// this.tree.add(this.testtree_data); fkt = this.append_children; // second model
var rpc = new qx.io.remote.Rpc().set({Url: this.rpc_url, ServiceName: this.rpc_service});
rpc.callAsync(qx.lang.Function.bind(fkt,this),
"report",this.akt_testtree_path,"","-1");
},
//******************************************************************************************
create_children : function(e) {
this.parent_branch = e.getData().nodeId;
this.parent_testitem = ":" + e.getData().label + ":";
this.info("createChildren: rpc call async for ",e.getData().label);
try {
if (this.testtree_rpc_call_is_active == 0) {
this.testtree_rpc_call_is_active == 1;
var rpc = new qx.io.remote.Rpc().set({Url: this.rpc_url, ServiceName: this.rpc_service});
rpc.callAsync(qx.lang.Function.bind(this.append_children,this),"report","../klimatest",e.getData().label,"-1");
}
} catch(exc) {
this.error("createChildren: Exception during RPC call, please check your RPC call: " ,"report","../klimatest",
e.getData().label,"-1", "\n" + exc);
}
},
//********************************************************************
append_children : function (result,exc) {
try { this.testtree_model.prune(this.parent_branch, false); } catch(e) { 1; }
this.info("append children on " + this.parent_testitem);
var has_branches = 0;
while (0 == 0) {
var item = result.shift();
if (item == null) { break; }
this.info("MainContent.add_to_testtree(): got RPC Result: " + item[2]);
if (":"+item[2]+":" == this.parent_testitem) { continue; }
var o = this.testtree_model.addBranch(this.parent_branch, item[2]);
has_branches = 1;
this.testtree_model.setColumnData(o,1,item[3]);
this.testtree_model.setColumnData(o,2,item[5]);
this.testtree_model.setColumnData(o,3,"run");
this.testtree_model.addBranch(o, "loading...");
}
if (has_branches == 0) {
this.testtree_model.addBranch(this.parent_branch, "loading...");
this.testtree_data.nodeSetOpened(this.parent_branch, false);
}
this.testtree_model.setData();
this.testtree_rpc_call_is_active = 0;
},
//******************************************************************************************
remove_children : function(e) {
this.testtree_model.prune(e.getData().nodeId, false);
this.testtree_model.addBranch(e.getData().nodeId, "loading...");
this.testtree_model.setData();
},
//***********************************************************************************************
run_clicked : function (e) {
this.info(e.getType(), e.getRow(), e.getColumn());
if (e.getColumn() == 3) {
alert("run "+this.testtree_model.getRowData(e.getRow())[0].label);
}
},
//********************************************************************
add_to_testtree : function (result,exc) {
if (exc != null) {
this.error("RPC-Call failed in add_to_testtree: " + exc);
return;
}
this.testtree_lines[this.parent_testitem][1] = 1; // Button opened
this.info("MainContent.add_to_testtree(): got RPC Result: "+ result);
while (0 == 0) {
var item = result.pop();
if (item == null) { break; }
if (":"+item[2]+":" == this.parent_testitem) { continue; }
var newitem = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
newitem.add(new qx.ui.basic.Label(item[2].replace(/[^\:]/g,"").replace(/\:/g,".........")));
this.testtree_lines[":"+item[2]+":"] = [newitem,0];
var newitem_toggle = new qx.ui.form.ToggleButton("","autotest/folder.png");
this.info("MainContent.add_to_testtree: calling eval function, param"+item[2] );
eval("this.tmp_fkt = function(e) { this.toggle_testtree_item(e,'" + item[2] + "'); } ");
newitem_toggle.addListener('execute',this.tmp_fkt,this);
newitem.add(newitem_toggle);
newitem.add(new qx.ui.basic.Label(item[2].replace(/^(.*::)(.*)$/,"$2") + ", Result: " + item[3]));
this.info("MainContent.add_to_testtree: calling tree.addAfter with params:"+newitem, ""+ this.testtree_lines[this.parent_testitem][0]);
this.tree.addAfter(newitem,this.testtree_lines[this.parent_testitem][0]);
}
this.testtree_rpc_call_is_active == 0;
},
//********************************************************************
toggle_testtree_item : function(e,item) {
this.parent_testitem = ":" + item + ":";
if (this.testtree_lines[this.parent_testitem][1] == 1) { // collapse - alle Unter-Items werden aus der Liste genommen
this.testtree_lines[this.parent_testitem][1] = 0;
var original = this.testtree_lines[this.parent_testitem][0]; // das Item, auf das gerade geklickt wurde
var original_level = original.getChildren()[0].getValue().length; // Einrueckung
var original_index = this.tree.indexOf(original); // Index des Items
while (0 == 0) {
var children = this.tree.getChildren(); // Liste aller Items
if (children.length < original_index) { break; } // wenn das Item das letrzte in der Liste ist, ist nichts mehr zu tun
var next_obj = children[original_index+1]; // das dem Item folgende Item
var level = next_obj.getChildren()[0].getValue().length; // ... dessen Einrueckung
if (level <= original_level) { break; }
this.tree.remove(next_obj);
}
} else { // expand
if (this.testtree_rpc_call_is_active == 0) {
this.testtree_rpc_call_is_active == 1;
var rpc = new qx.io.remote.Rpc().set({Url: this.rpc_url, ServiceName: this.rpc_service});
rpc.callAsync(qx.lang.Function.bind(this.add_to_testtree,this),
"report",this.akt_testtree_path,item,"-1");
}
}
},
//********************************************************************
actualize_testtree : function() {
var pane = this.testtree_screen.getChildren()[0];
var tree = pane.getChildren()[0].getChildren()[0].getValue();
var testItem = pane.getChildren()[1].getChildren()[0].getValue();
this.callTestTree(tree,testItem);
this.testtree_screen.add(this.testTree);
},
//********************************************************************
callTestTree : function(tree,testItem) {
if (typeof tree != null){
this.settings.setCallParams(tree,testItem);
}
var call = this.settings.getTestTreeCall();
try {
this.info("callTestTree:",tree,testItem);
this.testTree = new qx.ui.treevirtual.TreeVirtual(["Item","Result", "Remark", ""]).set({width: 300});
this.settings.rpc.callAsync(qx.lang.Function.bind(this.initTestTree,this),call[0],call[1],call[2],call[3],call[4],call[5]);
} catch(exc) {
this.error("Exception during RPC call, please check your RPC call: " + call + "\n" + exc);
}
},
//*********************************************************************
initTestTree: function(result, exc) {
// check tree data
if (exc!=null) {
this.error("MainContent.setTestTree(): RPC Call exception:" + exc );
return;
}
else if (result == null || (typeof result) != "object" || result.length == 0) {
this.error("MainContent.setTestTree():expected Array for TestTree input but got \n\n"+ (typeof result));return;
}
else {
for (i in result) {
this.info("setTestTree: TestTreeData: ",result[i]);
}
}
this.dataModel = this.testTree.getDataModel(); // tree data model
var te1 = this.dataModel.addBranch(null, result[0][2], true);
this.dataModel.setColumnData(te1, 1, result[0][3]);
if (result[0][3]>1 && result[0][3]<1000) {
this.info("cell style:", this.testTree.nodeGetCellStyle(te1));
this.testTree.nodeSetLabelStyle(te1, "background-color: orange;");
this.info("cell style new:", this.testTree.nodeGetCellStyle(te1));
}
else if (result[0][3]>1 == 1) {
this.testTree.nodeSetLabelStyle(te1, "background-color: green; ");
}
else if (result[0][3] > 1000) {
this.testTree.nodeSetLabelStyle(te1, "background-color: red;");
}
this.dataModel.setColumnData(te1, 2, result[0][5]);
this.dataModel.setColumnData(te1, 3, "run");
for (var i=1; i<result.length;i++) {
var tmpId =this.dataModel.addBranch(te1,result[i][2]);
this.dataModel.addBranch(tmpId, "loading...");
this.dataModel.setColumnData(tmpId, 1, result[i][3]);
if (result[i][3] > 1 && result[i][3]<1000) {
this.testTree.nodeSetLabelStyle(tmpId, "background-color: orange; ");
}
else if (result[i][3] > 1 == 1) {
this.testTree.nodeSetLabelStyle(tmpId, "background-color: green;");
}
else if (result[i][3]>1000) {
this.testTree.nodeSetLabelStyle(tmpId, "background-color: red;");
}
this.dataModel.setColumnData(tmpId, 2, result[i][5]);
this.dataModel.setColumnData(tmpId, 3, "run");
}
this.dataModel.setData();
this.testTree.addListener("treeOpenWithContent",this.createChildren, this);
this.testTree.addListener("cellClick", this.cellClicked, this);
},
//***********************************************************************************************
cellClicked : function (e) {
this.info(e.getType(), e.getRow(), e.getColumn());
if (e.getColumn()==3) {
alert("run "+this.dataModel.getRowData(e.getRow())[0].label);
}
},
//***********************************************************************************************
createChildren : function(e) {
var node = e.getData();
var item=node.nodeId;
var testItem=node.label;
var rpc = new qx.io.remote.Rpc().set({Url: this.rpc_url, ServiceName: this.rpc_service});
this.info("createChildren: rpc call async for ", testItem);
try {
rpc.callAsync(qx.lang.Function.bind(this.appendChildren,[item, testItem,this]),"report","../klimatest",testItem,"-1");
} catch(exc) {
this.error("createChildren: Exception during RPC call, please check your RPC call: " ,"report","../klimatest",testItem,"-1", "\n" + exc);
}
},
//***********************************************************************************************
appendChildren : function(result, exc){
var parent = this[0];
var testItem = this[1]
this[2].info("appendChildren: testItem is", testItem);
// check tree data
if (exc!=null) {
this[2].error("MainContent.setTestTree(): RPC Call exception: " + exc );return;
}
else if (result == null || (typeof result) != "object" || result.length == 0) {
this[2].error("MainContent.setTestTree():expected Array for TestTree input but got \n\n"+ (typeof result));return;
}
else {
for (i in result) {
this[2].info("TestTreeData: ",result[i]);
}
}
var items = result;
this[2].dataModel.prune(parent, false);
for (var i = 1; i < items.length; i++) {
var rootelement=items[i][2].split("::");
var tmpId = this[2].dataModel.addBranch(parent, items[i][2]);
this[2].dataModel.addBranch(tmpId, "loading...");
this[2].dataModel.setColumnData(tmpId, 1, items[i][3]);
if (items[i][3] > 1 && items[i][3] < 1000) {
this[2].testTree.nodeSetLabelStyle(tmpId, "background-color: orange;");
}
else if (items[i][3]>1 == 1) {
this[2].testTree.nodeSetLabelStyle(tmpId, "background-color: green;");
}
else if (items[i][3]>1000) {
this[2].testTree.nodeSetLabelStyle(tmpId, "background-color: red;");
}
this[2].dataModel.setColumnData(tmpId, 2, items[i][5]);
this[2].dataModel.setColumnData(tmpId, 3, "run");
}
if (items.length==1){
this[2].dataModel.addBranch(parent, "loading...");
this[2].testTree.nodeSetOpened(parent, false);
}
this[2].dataModel.setData();
},
//********************************************************************
getMainContent : function(app) {
var pane = new qx.ui.splitpane.Pane("horizontal");
var treeContainer = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
this.callTestTree(); // create tree
var tree = new qx.ui.treevirtual.TreeVirtual("Test-Tree").set({width: 300,rowHeight: 22});
tree.setAlwaysShowOpenCloseSymbol(true);
this.dataModel = tree.getDataModel();
var button = new qx.ui.form.Button("Settings");
button.addListener("execute", function(e) {
this.mainView.remove(this.testView);
this.mainView.add(this.settings.settingContainer,1);
}, this);
treeContainer.add(button);
treeContainer.add(tree);
pane.add(treeContainer,0);
pane.add(this.getTestView(), 1);
this.mainView=pane;
return pane;
},
//*********************************************************************
getTestView : function() {
var tabView = new qx.ui.tabview.TabView();
tabView.set({ width: 980, height: 605});
////////////////// TEST PAGE 1 ////////////////////
var page1 = new qx.ui.tabview.Page("Test-Item-Ansicht");
page1.setLayout(new qx.ui.layout.VBox());
var testItem = new autotest.TestItem();
page1.add(testItem.getTestItemContainer());
tabView.add(page1);
////////////////// TEST PAGE 2 ////////////////////
var page2 = new qx.ui.tabview.Page("Requirement-Ansicht");
page2.setLayout(new qx.ui.layout.VBox());
page2.add(new qx.ui.basic.Label("Requirement-Ansicht..."));
tabView.add(page2);
////////////////// TEST PAGE 3 ////////////////////
var page3 = new qx.ui.tabview.Page("Architekturen/User");
page3.setLayout(new qx.ui.layout.VBox());
page3.add(new qx.ui.basic.Label("Architekturen/User..."));
tabView.add(page3);
////////////////// TEST PAGE 4 ////////////////////
var page4 = new qx.ui.tabview.Page("Reporting-Ansicht");
page4.setLayout(new qx.ui.layout.VBox());
page4.add(new qx.ui.basic.Label("Reporting-Ansicht..."));
tabView.add(page4);
////////////////// TEST PAGE 5 ////////////////////
var page5 = new qx.ui.tabview.Page("Einstellungen");
page5.setLayout(new qx.ui.layout.VBox());
page5.add(new qx.ui.basic.Label("Einstellungen..."));
tabView.add(page5);
this.testView=tabView;
return tabView;
},
//*********************************************************************
endofclass : null } });