From 42bc19736d45f242ade7f438f1dd1b5f0bd89835 Mon Sep 17 00:00:00 2001 From: Weidong Shao Date: Thu, 2 Jan 2014 23:00:39 +0000 Subject: [PATCH] Update UI code per API changes --- public/ods/fixtures/fixtures.js | 41 +++++++------ public/ods/models/cluster.js | 11 ++++ public/ods/ods.js | 3 +- public/ods/ui/host_config/host_config.css | 13 +++- public/ods/ui/host_config/host_config.js | 60 +++++++++++++++++-- .../ods/ui/host_config/host_config_test.html | 9 ++- public/ods/ui/host_config/views/init.ejs | 1 + .../ods/ui/host_config/views/server_row.ejs | 16 ++++- .../ods/ui/install_review/install_review.js | 14 +++-- .../install_review/install_review_test.html | 15 +++++ .../ods/ui/install_review/views/install.ejs | 37 ++++++------ public/ods/ui/networking/networking.js | 1 + public/ods/ui/servers/servers.js | 7 ++- 13 files changed, 172 insertions(+), 56 deletions(-) diff --git a/public/ods/fixtures/fixtures.js b/public/ods/fixtures/fixtures.js index 811bbe9..3fc3d04 100644 --- a/public/ods/fixtures/fixtures.js +++ b/public/ods/fixtures/fixtures.js @@ -211,7 +211,7 @@ steal("jquery/dom/fixture", "jquery/lang/json", function(){ steal.dev.log("fixture cluster action hostIds : ", hostIds); var returnData = { "status": "OK", - "clusterHosts": [] + "cluster_hosts": [] }; for(var i = 0; i" + this.adapterRoles[i].description + ""); + } + el.multipleSelect({ + placeholder: "auto", + selectAll: false + }); + el.multipleSelect("setSelects", selectedRoles); + }, + fillHostnameBySwitchIp: function() { var serverData = this.options.odsState.servers_config; this.server_count = 0; @@ -130,7 +169,13 @@ steal( var serverData = this.options.odsState.servers_config; var servers = serverData[switchIp]; for (var i = 0; i < servers.length; i++) { - $('#tab1 table tbody').append(this.view('server_row', servers[i])); + $('#hostconfig-table tbody').append(this.view('server_row', servers[i])); + var roles = servers[i].roles; + var rolesDropdown = $("#hostconfig-table tbody tr").eq(i).find(".roles"); + if(!roles) { + roles = []; + } + this.fillRolesDropdowns(rolesDropdown, roles); } }, @@ -143,6 +188,11 @@ steal( for (var i = 0; i < this.options.odsState.servers_config[currentSwitch].length; i++) { this.options.odsState.servers_config[currentSwitch][i].hostname = $("#hostconfig-table tbody tr").eq(i).find(".hostname").val(); this.options.odsState.servers_config[currentSwitch][i].server_ip = $("#hostconfig-table tbody tr").eq(i).find(".serverIp").val(); + var roles = $("#hostconfig-table tbody tr").eq(i).find(".roles").val(); + if(!roles) { + roles = []; + } + this.options.odsState.servers_config[currentSwitch][i].roles = roles; } }, @@ -198,6 +248,7 @@ steal( var clusterhost_id = servers[i]['clusterhost_id']; var hostname = servers[i]['hostname']; var server_ip = servers[i]['server_ip']; + var roles = servers[i]['roles']; var clusterhostConfigData = { "hostname": hostname, @@ -207,7 +258,8 @@ steal( "ip": server_ip } } - } + }, + "roles": roles }; Ods.ClusterHost.update(clusterhost_id, clusterhostConfigData, this.proxy('onHostconfigData'), this.proxy('onHostconfigDataErr')); diff --git a/public/ods/ui/host_config/host_config_test.html b/public/ods/ui/host_config/host_config_test.html index 0a435cf..acac3fa 100644 --- a/public/ods/ui/host_config/host_config_test.html +++ b/public/ods/ui/host_config/host_config_test.html @@ -28,7 +28,8 @@ port: "1", server_ip: "10.2.172.9", switch_ip: "172.29.8.40", - vlan: "1" + vlan: "1", + roles: [] }; var server2 = { @@ -39,7 +40,8 @@ port: "2", server_ip: "10.2.172.9", switch_ip: "172.29.8.40", - vlan: "2" + vlan: "2", + roles: [] }; if (config["172.29.8.40"] == undefined) { @@ -60,7 +62,8 @@ feature: null, machines: [], switches: [], - snmp: 1 + snmp: 1, + adapter_id: 1 }; var state = new $.Observe(odsState); diff --git a/public/ods/ui/host_config/views/init.ejs b/public/ods/ui/host_config/views/init.ejs index afa88b4..d108977 100644 --- a/public/ods/ui/host_config/views/init.ejs +++ b/public/ods/ui/host_config/views/init.ejs @@ -32,6 +32,7 @@ Port Host name IP address + Roles diff --git a/public/ods/ui/host_config/views/server_row.ejs b/public/ods/ui/host_config/views/server_row.ejs index edc01f8..ce41daf 100644 --- a/public/ods/ui/host_config/views/server_row.ejs +++ b/public/ods/ui/host_config/views/server_row.ejs @@ -1,5 +1,15 @@ - <%= port %> - - + + <%= port %> + + + + + + + + + + diff --git a/public/ods/ui/install_review/install_review.js b/public/ods/ui/install_review/install_review.js index d111d41..8a4bd1d 100644 --- a/public/ods/ui/install_review/install_review.js +++ b/public/ods/ui/install_review/install_review.js @@ -350,7 +350,7 @@ steal( "background": "#0000ff", "opacity": 0.5 }); - this.totalProgressLabel.text(total * 100 + "%"); + this.totalProgressLabel.text(Math.round(total * 100) + "%"); this.totalProgressbarValue.css({ "width": total * this.totalProgressbar.width() }); @@ -411,9 +411,15 @@ steal( right: 120, bottom: 0, left: 130 - }, - width = 1000 - margin.right - margin.left, - height = 500 - margin.top - margin.bottom; + }; + + var serversHeight = this.options.odsState.servers.length * 68; + if (serversHeight < 500) { + serversHeight = 500; + } + + var width = 1000 - margin.right - margin.left, + height = serversHeight - margin.top - margin.bottom; imgWidth = 163; imgHeight = 32; diff --git a/public/ods/ui/install_review/install_review_test.html b/public/ods/ui/install_review/install_review_test.html index 275f283..5102c2b 100644 --- a/public/ods/ui/install_review/install_review_test.html +++ b/public/ods/ui/install_review/install_review_test.html @@ -47,9 +47,23 @@ if (config["172.29.8.40"] == undefined) { config["172.29.8.40"] = [server1]; config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); } else { config["172.29.8.40"].push(server1); config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); + config["172.29.8.40"].push(server2); } var odsState = { @@ -68,6 +82,7 @@ var state = new $.Observe(odsState); state.servers_config = config; state.cluster_id = 1; + state.servers = [{},{},{},{},{},{},{},{},{}]; $('#install_review-test').ods_ui_install_review({ "odsState" : state }); diff --git a/public/ods/ui/install_review/views/install.ejs b/public/ods/ui/install_review/views/install.ejs index 7c345ad..a76640e 100644 --- a/public/ods/ui/install_review/views/install.ejs +++ b/public/ods/ui/install_review/views/install.ejs @@ -4,6 +4,24 @@

Click here to go to OpenStack dashboard when deployment is finished.

+
+ + + + + + + + +
Total Progress: +
+
Waiting...
+ +
+
  Errors: 0
+
+
  • Graph
  • @@ -23,24 +41,5 @@
-
- -
- - - - - - - - -
Total Progress: -
-
Waiting...
- -
-
  Errors: 0
-
diff --git a/public/ods/ui/networking/networking.js b/public/ods/ui/networking/networking.js index 384c17c..c92c36a 100644 --- a/public/ods/ui/networking/networking.js +++ b/public/ods/ui/networking/networking.js @@ -162,6 +162,7 @@ steal( if (!isConfiged) { server['hostname'] = ''; + server['roles'] = []; } server['server_ip'] = this.startPrefix + (parseInt(this.startLastDigit) + i); diff --git a/public/ods/ui/servers/servers.js b/public/ods/ui/servers/servers.js index 00553c6..c3ff3d0 100644 --- a/public/ods/ui/servers/servers.js +++ b/public/ods/ui/servers/servers.js @@ -161,6 +161,7 @@ steal( "adapter_id": 1 } }, this.proxy('onClusterCreated'), this.proxy('onClusterCreatedErr')); + this.options.odsState.adapter_id = 1; } else { // replace all hosts in current cluster var cluster_id = this.options.odsState.cluster_id; @@ -556,10 +557,10 @@ steal( $("#server_continue_err").hide(); if (xhr.status == 200) { // OK - // Assume the machine orders are same in returned data (data.clusterHosts) + // Assume the machine orders are same in returned data (data.cluster_hosts) // and cached data (this.options.odsState.servers) - for (var i = 0; i < data.clusterHosts.length; i++) { - this.options.odsState.servers[i]['clusterhost_id'] = data.clusterHosts[i].id; + for (var i = 0; i < data.cluster_hosts.length; i++) { + this.options.odsState.servers[i]['clusterhost_id'] = data.cluster_hosts[i].id; } $("#continuing").css("opacity", 0); this.options.nav.gotoStep("3");