This commit is contained in:
fanfuxiaoran 2013-12-04 11:40:58 +08:00
parent ab64bb9360
commit 6d3397dba4
2 changed files with 113 additions and 72 deletions

View File

@ -1,8 +1,7 @@
var container = $('#container');
var containerHeader = $('#containerHeader');
var testPlanId;
var containerModel = new ContainerModel();
var urlModel=new UrlModel();
var urlModel = new UrlModel();
var testBriefModelField = new Array("name", "uuid", "scripts", "SUT", "status");
var scriptModelField = new Array("name", "id", "load", "warm up", "execute",
"cool down", "finished");
@ -11,39 +10,41 @@ function ContainerModel() {
this.scriptBox = "scriptBox";
this.monitorBox = "monitorBox";
this.scriptList = "scriptList";
this.scriptResultBox="scriptResultBox";
this.scriptResultBox = "scriptResultBox";
}
function UrlModel(){
this.runInfo="getRunningInfo";
this.scriptResult="getScriptBriefStatus";
function UrlModel() {
var containerModel = new ContainerModel();
this.runInfo = "getRunningInfo";
this.scriptResult = "getScriptBriefStatus";
}
$(document).ready(function() {
/* testPlanId = getvars()['testPlanId'];*/
testPlanId=1;
getRunningInfo(urlModel.runInfo,testPlanId);
/* getScriptResult(urlModel.scriptResult,testPlanId,initScriptResultContainer); */
/* testPlanId = getvars()['testPlanId']; */
testPlanId = 1;
getRunningInfo(urlModel.runInfo, testPlanId);
/* getScriptResult(urlModel.scriptResult,testPlanId,initScriptResultContainer); */
});
function getRunningInfo(url, testPlanId) {
$.post(url, {
testPlanId : testPlanId
}, function(data){processTestBriefInfo(data);},"json");
}, function(data) {
processTestBriefInfo(data);
}, "json");
}
function getScriptResult(url, testPlanId, scriptId, callback) {
$.post(url, {
testPlanId : testPlanId,
scriptId : scriptId
}, callback(data),"json");
}, callback(data), "json");
}
// getMonitorInfo...
function processTestBriefInfo(data) {
if (data != null) {
initTestInfoContainer(containerHeader, data);
if (data.scriptIndexModels != null
&& data.scriptIndexModels.length > 0){
if (data.scriptIndexModels != null && data.scriptIndexModels.length > 0) {
initTestScriptContainer(containerHeader, data.scriptIndexModels);
initScriptResultContainer(container, data.scriptIndexModels);
}
if (data.monitorModels != null && data.monitorModels.length > 0)
@ -53,62 +54,79 @@ function processTestBriefInfo(data) {
alert("get testplan runing info is error! ");
}
function initTestInfoContainer(parent, data) {
var box = createDefaultBox(containerModel.testBox, 4, "Test");
var box = createtBox(4, "Test");
addBoxId(box, containerModel.testBox);
addCloseAndMinIcons(box);
parent.append(box);
var ul = createUl("dashboard-list");
box.children('.box-content').append(ul);
ul.append(createLi("name",data.name,"green","icon-arrow-up") );
ul.append(createLi("name", data.name, "green", "icon-arrow-up"));
if (data.scriptIndexModels != null && data.scriptIndexModels.length > 0)
ul.append(createLi("script",data.scriptIndexModels.length,"red","icon-minus") );
ul.append(createLi("script", data.scriptIndexModels.length, "red",
"icon-minus"));
if (data.monitorModels != null && data.monitorModels.length > 0)
ul.append(createLi("SUT",data.monitorModels.length,"yellow","icon-comment") );
ul.append(createLi("status",data.status,"green","icon-arrow-up") );
ul.append(createLi("SUT", data.monitorModels.length, "yellow",
"icon-comment"));
ul.append(createLi("status", data.status, "green", "icon-arrow-up"));
}
function initTestScriptContainer(parent, data) {
var box = createDefaultBox(containerModel.scriptBox, 8, "Scripts");
var box = createBox(8, "Scripts");
addBoxId(box, containerModel.scriptBox);
addCloseAndMinIcons(box);
parent.append(box);
var tableClass = "table table-striped table-bordered bootstrap-datatable datatable dataTable";
var table = createTable(containerModel.scriptList, tableClass,
scriptModelField);
box.children('.box-content').append(table);
setTable(table);
for (var i = 0; i <data.length; i++) {
for ( var i = 0; i < data.length; i++) {
table.dataTable().fnAddData(
[ data[i].scriptName, data[i].scriptId,data[i].requireLoad, data[i].config.warmUp,
data[i].config.executeRange, data[i].config.coolDown,data[i].finished]);
[ data[i].scriptName, data[i].scriptId, data[i].requireLoad,
data[i].config.warmUp, data[i].config.executeRange,
data[i].config.coolDown, data[i].finished ]);
}
}
function initSUTContainer(data) {
}
function initScriptResultContainer(parent,data){
initScriptChart(parent,data);
function initScriptResultContainer(parent, data) {
var scriptClass=new ScriptClass("scripts",scriptModelField);
initScriptChart(parent, data);
}
function initScriptChart(parent,data){
var addGraph=createDropButton("add graph");
var deleteGraph=createDropButton("delete graph");
var boxIcons=new Array(addGraph,deleteGraph);
var box=createBox(containerModel.scriptResultBox,12,"chart",boxIcons);
function initChart(parent, title, data, classes, currentShowSeries) {
var box = createChartBox(12, title);
initAddGraph(box, classes, currentShowSeries);
parent.append(box);
}
function initAddGraph(parent,models,currentGraphs){
for(var i=0;i<models.length;i++){
var model=models[i];
var checkBox=createCheckBox(model);
}
function initAddGraph(parentBox, classes, currentShowSeries) {
var parent = parentBox.children(".box-header").children("#addGraph");
var box = createBox(3, "chart");
var container = box.children(".box-content");
for ( var i = 0; i < classes.length; i++) {
var singleClass = classes[i];
box.append(createLable(singleClass.key));
var options = new Array();
for ( var j = 0; j < singleClass.value.length; j++) {
options.add(singleClass.value[j]);
}
container.append(createSelect(options));
contianer.append($("<div></div>"));
}
parent.add(box);
}
function NewModel(key,vlaue){
this.key=key;
this.value=value;
function deleteGraph(model, currenGraphs) {
}
function deleteGraph(model,currenGraphs){
function ChartClass(key,classField) {
this.key = key;
this.value = classFieldw;
}
function getvars() {

View File

@ -1,39 +1,37 @@
function createDefaultBox(id,size,title){
var box=$("<div class='box'></div>");
size='span'+size;
box.addClass(size);
var boxHeader=$("<div class='box-header well'><h2>"+
"<i class='icon-th'></i></h2><div class='box-icon'>" +
"<a href='#' class='btn btn-minimize btn-round'><i class='icon-chevron-up'></i></a>"+
"<a href='#'class='btn btn-close btn-round'><i class='icon-remove'></i></a></div></div>");
boxHeader.children("h2").text(title);
box.append(boxHeader);
var boxContent=$("<div class='box-content'></div>");
box.append(boxContent);
return box;
function addCloseAndMinIcons(box){
var icons=new Array("<a href='#' class='btn btn-minimize btn-round'><i class='icon-chevron-up'></i></a>",
"<a href='#'class='btn btn-close btn-round'><i class='icon-remove'></i></a>");
setBoxIcons(icons);
}
function createBox(id,size,title,boxIcons){
function addBoxId(box,id){
box.attr("id",id);
return box;
}
function addBoxIcons(box,boxIcons){
var boxHeader=box.children('.box-header');
for(var i=0;i<boxIcons.length;i++){
boxHeader.children('.box-icon').append(boxIcons[i]);
}
}
function createBox(size,title){
var box=$("<div class='box'></div>");
size='span'+size;
box.addClass(size);
var boxHeader=$("<div class='box-header well'><h2>"+
"<i class='icon-th'></i></h2><div class='box-icon'>" +
"</div></div>");
boxHeader.children("h2").text(title);
for(var i=0;i<boxIcons.length;i++){
boxHeader.children('.box-icon').append(boxIcons[i]);
}
box.append(boxHeader);
var boxContent=$("<div class='box-content'></div>");
box.append(boxContent);
return box;
"<i class='icon-th'></i></h2><div class='box-icon'>" +
"</div></div>");
boxHeader.children("h2").text(title);
box.append(boxHeader);
var boxContent=$("<div class='box-content'></div>");
box.append(boxContent);
return header;
}
function createTable(id,tableClass,model){
var table=$("<table></table>");
table.attr("id",id);
table.addClass(tableClass);
table.append(createTableHead(model));
return table;
}
function createTableHead( model) {
@ -51,6 +49,7 @@ function createUl(ulClass){
return ul;
};
//will be unused
function createLi(tagTxt,txt,txtColor,iconClass){
var a=$("<a ></a>");
var li=$("<li></li>");
@ -74,9 +73,33 @@ function setTable(table){
}
} );
}
function createDropButton(title){
function createDropButton(id,title){
var button=$("<div class='btn-group div-left'><button type='button' class='btn btn-primary dropdown-toggle' "+
"data-toggle='dropdown'> <span class='caret'></span> </button></div>");
button.children("button").text(title);
button.attr("id",id)
return button;
}
function createSelect(options){
var select=$("<select></select>");
select.addClass("form-control");
for(var i=0;i<options.length;i++){
var option=$("<option></option>");
option.text(options[i]);
select.append(option);
}
return select;
}
function createChartBox(size,title){
var addGraph=createDropButton("add graph");
var deleteGraph=createDropButton("delete graph");
var boxIcons=new Array(addGraph,deleteGraph);
var box=createBox(12,"chart");
addBoxICons(boxIcons);
return box;
}
function createLable(text){
var lable="<lable></lable>";
lable.text(text);
retrun lable;
}