Handle submit for each step independantly

(watch commit state change in wizard controller and each step's controller)

Change-Id: I33b61a21b354ddc4e6250ec66fc89ddba1f897b8
This commit is contained in:
jiahuay 2014-06-25 22:45:58 -07:00
parent b00149d8e5
commit e100a863f1
9 changed files with 765 additions and 453 deletions

View File

@ -31,6 +31,10 @@
"title": "OS Reinstall",
"field": "os_installed",
"visible": true
}, {
"title": "Adapter",
"field": "adapter",
"visible": true
}, {
"title": "State",
"field": "state",
@ -68,6 +72,10 @@
"title": "OS Reinstall",
"field": "os_installed",
"visible": false
}, {
"title": "Adapter",
"field": "adapter",
"visible": false
}, {
"title": "State",
"field": "state",

97
v2/data/timezone.json Normal file
View File

@ -0,0 +1,97 @@
[{
"value": "-12.00",
"timezone": "Eniwetok, Kwajalein"
}, {
"value": "-11.00",
"timezone": "Midway Island, Samoa"
}, {
"value": "-10.00",
"timezone": "Hawaii"
}, {
"value": "-9.00",
"timezone": "Alaska"
}, {
"value": "-8.00",
"timezone": "Pacific Time (US & Canada)"
}, {
"value": "-7.00",
"timezone": "Mountain Time (US & Canada)"
}, {
"value": "-6.00",
"timezone": "Central Time (US & Canada), Mexico City"
}, {
"value": "-5.00",
"timezone": "Eastern Time (US & Canada), Bogota, Lima"
}, {
"value": "-4.00",
"timezone": "Atlantic Time (Canada), Caracas, La Paz"
}, {
"value": "-3:30",
"timezone": "Newfoundland"
}, {
"value": "-3.00",
"timezone": "Brazil, Buenos Aires, Georgetow"
}, {
"value": "-2.00",
"timezone": "Mid-Atlantic"
}, {
"value": "-1.00",
"timezone": "Azores, Cape Verde Islands"
}, {
"value": "0.00",
"timezone": "Western Europe Time, London, Lisbon, Casablanca"
}, {
"value": "+1.00",
"timezone": "Brussels, Copenhagen, Madrid, Paris"
}, {
"value": "+2.00",
"timezone": "Kaliningrad, South Africa"
}, {
"value": "+3:00",
"timezone": "Baghdad, Riyadh, Moscow, St. Petersburg"
}, {
"value": "+3:00",
"timezone": "Baghdad, Riyadh, Moscow, St. Petersburg"
}, {
"value": "+3:30",
"timezone": "Tehran"
}, {
"value": "+4:00",
"timezone": "Abu Dhabi, Muscat, Baku, Tbilisi"
}, {
"value": "+4:30",
"timezone": "Kabul"
}, {
"value": "+5:00",
"timezone": "Ekaterinburg, Islamabad, Karachi, Tashkent"
}, {
"value": "+5:30",
"timezone": "Bombay, Calcutta, Madras, New Delhi"
}, {
"value": "+5:45",
"timezone": "Kathmandu"
}, {
"value": "+6:00",
"timezone": "Almaty, Dhaka, Colombo"
}, {
"value": "+7:00",
"timezone": "Bangkok, Hanoi, Jakarta"
}, {
"value": "+8:00",
"timezone": "Beijing, Perth, Singapore, Hong Kong"
}, {
"value": "+9:00",
"timezone": "Tokyo, Seoul, Osaka, Sapporo, Yakutsk"
}, {
"value": "+9:30",
"timezone": "Adelaide, Darwin"
}, {
"value": "+10:00",
"timezone": "Eastern Australia, Guam, Vladivostok"
}, {
"value": "+11:00",
"timezone": "Magadan, Solomon Islands, New Caledonia"
}, {
"value": "+12:00",
"timezone": "Auckland, Wellington, Fiji, Kamchatka"
}]

View File

@ -1,48 +1,56 @@
{
"os_and_ts": [{
"id": 1,
"name": "sv_selection",
"title": "Server Selection",
"state": "active",
"template": "src/app/wizard/server_selection.tpl.html",
"description": "Select the servers you want to use for OpenStack"
}, {
"id": 2,
"name": "os_global",
"title": "OS Global Config",
"state": "",
"template": "src/app/wizard/global.tpl.html",
"description": ""
}, {
"id": 3,
"name": "network",
"title": "Network",
"state": "",
"template": "src/app/wizard/network.tpl.html",
"description": ""
}, {
"id": 4,
"name": "partition",
"title": "Partition",
"state": "",
"template": "src/app/wizard/partition.tpl.html",
"description": ""
}, {
"id": 5,
"name": "security",
"title": "Security",
"state": "",
"template": "src/app/wizard/security.tpl.html",
"description": ""
}, {
"id": 6,
"name": "role_assign",
"title": "Role Assignment",
"state": "",
"template": "src/app/wizard/role_assignment.tpl.html",
"description": ""
}, {
"id": 7,
"name": "network_mapping",
"title": "Network Mapping",
"state": "",
"template": "src/app/wizard/network_mapping.tpl.html",
"description": ""
}, {
"id": 8,
"name": "review",
"title": "Review",
"state": "",
"template": "src/app/wizard/review.tpl.html",

View File

@ -91,7 +91,15 @@ app.service('dataService', ['$http', 'settings',
this.postClusterSubnetConfig = function(id, subnet_config) {
return $http.post(settings.apiUrlBase + '/clusters/' + id + '/subnet-config', angular.toJson(subnet_config));
}
};
this.postRoutingTable = function(id, routing_table) {
return $http.post(settings.apiUrlBase + '/clusters/' + id + '/routing-table', angular.toJson(routing_table));
};
this.getTimezones = function() {
return $http.get(settings.metadataUrlBase + '/timezone.json');
};
}
]);
@ -99,6 +107,21 @@ app.service('dataService', ['$http', 'settings',
app.factory('wizardFactory', [
function() {
var wizard = {};
wizard.reset = function() {
wizard.cluster = {};
wizard.steps = [];
wizard.commit = {};
wizard.servers = [];
wizard.allServers = [];
wizard.adapter = {}; //
wizard.generalConfig = {};
wizard.subnetworks = [];
wizard.routingtable = [];
wizard.generalConfig = {};
wizard.interfaces = [];
};
wizard.reset();
wizard.setClusterInfo = function(cluster) {
wizard.cluster = cluster;
@ -116,22 +139,23 @@ app.factory('wizardFactory', [
return wizard.steps;
};
wizard.setStepCommit = function(stepId, commitState, message) {
angular.forEach(wizard.steps, function(step) {
if(step.id == stepId) {
step.commit = commitState;
step.message = message;
}
})
wizard.setCommitState = function(commitState) {
wizard.commit = commitState;
//console.info("wizard.setCommit ", wizard.commit);
};
wizard.getStepCommit = function(stepId) {
angular.forEach(wizard.steps, function(step) {
if(step.id == stepId) {
return step;
}
})
}
wizard.getCommitState = function() {
//console.info("wizard.getCommit ", wizard.commit);
return wizard.commit;
};
wizard.setAllMachinesHost = function(server) {
wizard.allServers = server;
};
wizard.getAllMachinesHost = function() {
return wizard.allServers;
};
wizard.setServers = function(servers) {
wizard.servers = servers;
@ -141,14 +165,22 @@ app.factory('wizardFactory', [
return wizard.servers;
};
wizard.setAdapter = function(adapter) {
wizard.setAdapter = function(adapter) { ////
wizard.adapter = adapter;
};
wizard.getAdapter = function() {
wizard.getAdapter = function() { /////
return wizard.adapter;
};
/*
wizard.setGeneralConfig = function(config) {
wizard.generalConfig = config;
};
wizard.getGeneralConfig = function() {
return wizard.generalConfig;
};
wizard.setSubnetworks = function(subnetworks) {
wizard.subnetworks = subnetworks;
};
@ -156,7 +188,23 @@ app.factory('wizardFactory', [
wizard.getSubnetworks = function() {
return wizard.subnetworks;
};
*/
wizard.setRoutingTable = function(routingTb) {
wizard.routingtable = routingTb;
};
wizard.getRoutingTable = function() {
return wizard.routingtable;
};
wizard.setInterfaces = function(interfaces) {
wizard.interfaces = interfaces;
};
wizard.getInterfaces = function() {
return wizard.interfaces;
};
return wizard;
}
]);

View File

@ -69,6 +69,7 @@ compassAppDev.run(function($httpBackend, settings, $http) {
"hostname": "sv-1",
"clusters": ["cluster1", "cluster2"],
"os": "CentOS",
"adapter": "OpenStack",
"roles": [{
"display_name": "Compute",
"name": "os-compute-worker"
@ -93,6 +94,7 @@ compassAppDev.run(function($httpBackend, settings, $http) {
"hostname": "sv-2",
"clusters": ["cluster1"],
"os": "CentOS",
"adapter": "OpenStack",
"roles": [{
"display_name": "Network",
"name": "os-network"
@ -167,30 +169,53 @@ compassAppDev.run(function($httpBackend, settings, $http) {
$httpBackend.whenPUT(/\.*\/clusters\/[1-9][0-9]*\/config/).respond(function(method, url, data) {
console.log(method, url, data);
return [200, {}, {}];
var config = JSON.parse(data);
return [200, config, {}];
});
$httpBackend.whenGET(/\.*\/clusters\/[1-9][0-9]*\/subnet-config/).respond(function(method, url, data) {
console.log(method, url);
var subnetworks = [{
"subnet_id": 1,
"name": "net1",
"subnet": "192.168.1.0",
"netmask": "255.255.255.0",
}, {
"subnet_id": 2,
"name": "net2",
"subnet": "172.165.1.0",
"netmask": "255.255.255.0",
}
];
"subnet_id": 1,
"name": "net1",
"subnet": "192.168.1.0",
"netmask": "255.255.255.0",
}, {
"subnet_id": 2,
"name": "net2",
"subnet": "172.165.1.0",
"netmask": "255.255.255.0",
}];
return [200, subnetworks, {}];
});
$httpBackend.whenPOST(/\.*\/clusters\/[1-9][0-9]*\/subnet-config/).respond(function(method, url, data) {
console.log(method, url, data);
return [200, {}, {}];
var subnetConfig = JSON.parse(data);
var i = 1;
angular.forEach(subnetConfig, function(subnet) {
subnet.subnet_id = i;
i++;
});
console.log(subnetConfig);
return [200, subnetConfig, {}];
});
$httpBackend.whenPOST(/\.*\/clusters\/[1-9][0-9]*\/routing-table/).respond(function(method, url, data) {
console.log(method, url, data);
var routingTable = JSON.parse(data);
var i = 1;
angular.forEach(routingTable, function(rt) {
rt.id = i;
i++;
});
console.log(routingTable);
return [200, routingTable, {}];
})
});

View File

@ -1,17 +1,17 @@
<div class="row">
<div class="col-xs-12">
<div class="accordion-style1 panel-group accordion-style2" id="accordion">
<accordion close-others="true">
<accordion-group is-open="status1.open">
<accordion-heading>
<i class="ace-icon fa fa-angle-right" ng-class="{'fa-angle-down': status1.open, 'fa-angle-right': !status1.open}"></i> General
</accordion-heading>
<div class="row">
<div class="col-xs-12">
<form id="generalForm" class="form-horizontal" role="form">
<!-- Use metadata to generate the form. might be used later -->
<!--<div class="form-group" ng-repeat="(key, data) in os_global_config['general']">
<div ng-controller="globalCtrl">
<div class="row">
<div class="col-xs-12">
<div class="accordion-style1 panel-group accordion-style2" id="accordion">
<accordion close-others="true">
<accordion-group is-open="status1.open">
<accordion-heading>
<i class="ace-icon fa fa-angle-right" ng-class="{'fa-angle-down': status1.open, 'fa-angle-right': !status1.open}"></i> General
</accordion-heading>
<div class="row">
<div class="col-xs-12">
<form id="generalForm" class="form-horizontal" role="form">
<!-- Use metadata to generate the form. might be used later -->
<!--<div class="form-group" ng-repeat="(key, data) in os_global_config['general']">
<div ng-if="key!='_self'">
<label class="col-sm-4 control-label no-padding-right">{{data.display}}</label>
<div class="col-sm-8">
@ -19,237 +19,206 @@
</div>
</div>
</div>-->
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">HTTP Proxy</label>
<div class="col-sm-8">
<input ng-model="general.http_proxy" type="text" class="col-xs-10 col-sm-5" placeholder="HTTP Proxy" name="http_proxy">
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">HTTP Proxy</label>
<div class="col-sm-8">
<input ng-model="general.http_proxy" type="text" class="col-xs-10 col-sm-5" placeholder="HTTP Proxy" name="http_proxy">
</div>
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">NTP Server</label>
<div class="col-sm-8">
<input ng-model="general.ntp_server" type="text" class="col-xs-10 col-sm-5" placeholder="NTP Server" name="ntp_server">
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">NTP Server</label>
<div class="col-sm-8">
<input ng-model="general.ntp_server" type="text" class="col-xs-10 col-sm-5" placeholder="NTP Server" name="ntp_server">
</div>
</div>
</div>
</div>
<div ng-repeat="dns_server in general.dns_servers track by $index" class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">
<span ng-if="$index==0">DNS Servers</span>
</label>
<div class="col-sm-8">
<input ng-model="general.dns_servers[$index]" type="text" class="col-xs-10 col-sm-5" placeholder="DNS Server" name="dns_servers">
<span class="col-xs-2 col-sm-3">
<div ng-repeat="dns_server in general.dns_servers track by $index" class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">
<span ng-if="$index==0">DNS Servers</span>
</label>
<div class="col-sm-8">
<input ng-model="general.dns_servers[$index]" type="text" class="col-xs-10 col-sm-5" placeholder="DNS Server" name="dns_servers">
<span class="col-xs-2 col-sm-3">
<!--Add Action-->
<span class="action" ng-click="addDNSServer()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<!--Remove Action-->
<span ng-show="general.dns_servers.length > 1" class="action" ng-click="general.dns_servers.splice($index,1)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</span>
</div>
</div>
</div>
<div ng-repeat="search_path in general.search_path track by $index" class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">
<span ng-if="$index==0">Search Path</span>
</label>
<div class="col-sm-8">
<input ng-model="general.search_path[$index]" type="text" class="col-xs-10 col-sm-5" placeholder="Search Path" name="search_path">
<span class="col-xs-2 col-sm-3">
<!--Add Action-->
<span class="action" ng-click="addSearchPath()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<!--Remove Action-->
<span ng-show="general.search_path.length > 1" class="action" ng-click="general.search_path.splice($index,1)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</span>
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Domain</label>
<div class="col-sm-8">
<input ng-model="general.domain" type="text" class="col-xs-10 col-sm-5" placeholder="Domain" name="domain">
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Gateway</label>
<div class="col-sm-8">
<input ng-model="general.gateway" type="text" class="col-xs-10 col-sm-5" placeholder="Gateway" name="gateway">
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Timezone</label>
<div class="col-sm-8">
<select ng-model="general.timezone" name="timezone" class="col-xs-10 col-sm-5">
<option ng-repeat="tm in timezones" value="{{tm.value}}">(GMT {{tm.value}}) {{tm.timezone}}</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Language</label>
<div class="col-sm-8">
<select ng-model="general.language" name="language" class="col-xs-10 col-sm-5">
<option value="en">English</option>
<option value="cn">Chinese</option>
</select>
</div>
</div>
</div>
</form>
</div>
</div>
</accordion-group>
<accordion-group is-open="status2.open">
<accordion-heading>
<i class="ace-icon fa fa-angle-right" ng-class="{'fa-angle-down': status2.open, 'fa-angle-right': !status2.open}"></i> Subnetwork
</accordion-heading>
<div class="row">
<div class="col-lg-2">
</div>
<div class="col-lg-8">
<table class="table table-hover nowrap">
<thead>
<tr>
<th>Name</th>
<th>Subnet</th>
<th>Netmask</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="sub in subnetworks">
<td>
<input type="text" ng-model="sub.name" placeholder="Name" />
</td>
<td>
<input type="text" ng-model="sub.subnet" placeholder="Subnet" />
</td>
<td>
<input type="text" ng-model="sub.netmask" placeholder="Netmask" />
</td>
<td>
<!--Add Action-->
<span class="action" ng-click="addDNSServer()">
<span class="action" ng-click="addSubnetwork()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<!--Remove Action-->
<span ng-show="general.dns_servers.length > 1" class="action" ng-click="general.dns_servers.splice($index,1)">
<span ng-show="subnetworks.length > 1" class="action" ng-click="removeSubnetwork($index)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</span>
</div>
</div>
</div>
<div ng-repeat="search_path in general.search_path track by $index" class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">
<span ng-if="$index==0">Search Path</span>
</label>
<div class="col-sm-8">
<input ng-model="general.search_path[$index]" type="text" class="col-xs-10 col-sm-5" placeholder="Search Path" name="search_path">
<span class="col-xs-2 col-sm-3">
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-2">
</div>
</div>
</accordion-group>
<accordion-group is-open="status.open">
<accordion-heading>
<i class="ace-icon fa fa-angle-right" ng-class="{'fa-angle-down': status.open, 'fa-angle-right': !status.open}"></i> Routing Table
</accordion-heading>
<div class="row">
<div class="col-lg-2">
</div>
<div class="col-lg-8">
<table class="table table-hover nowrap">
<thead>
<tr>
<th>Name</th>
<th>Subnet</th>
<th>Netmask</th>
<th>Gateway</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="route in routingtable">
<td>
<input type="text" ng-model="route.name" placeholder="Name" />
</td>
<td>
<input type="text" ng-model="route.subnet" placeholder="Subnet" />
</td>
<td>
<input type="text" ng-model="route.netmask" placeholder="Netmask" />
</td>
<td>
<input type="text" ng-model="route.gateway" placeholder="Gateway" />
</td>
<td>
<!--Add Action-->
<span class="action" ng-click="addSearchPath()">
<span class="action" ng-click="addRoute()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<!--Remove Action-->
<span ng-show="general.search_path.length > 1" class="action" ng-click="general.search_path.splice($index,1)">
<span ng-show="routingtable.length > 1" class="action" ng-click="removeRoute($index)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</span>
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Domain</label>
<div class="col-sm-8">
<input ng-model="general.domain" type="text" class="col-xs-10 col-sm-5" placeholder="Domain" name="domain">
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Gateway</label>
<div class="col-sm-8">
<input ng-model="general.gateway" type="text" class="col-xs-10 col-sm-5" placeholder="Gateway" name="gateway">
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Timezone</label>
<div class="col-sm-8">
<select ng-model="general.timezone" name="timezone" class="col-xs-10 col-sm-5">
<option value="-12.0">(GMT -12:00) Eniwetok, Kwajalein</option>
<option value="-11.0">(GMT -11:00) Midway Island, Samoa</option>
<option value="-10.0">(GMT -10:00) Hawaii</option>
<option value="-9.0">(GMT -9:00) Alaska</option>
<option value="-8.0">(GMT -8:00) Pacific Time (US &amp; Canada)</option>
<option value="-7.0">(GMT -7:00) Mountain Time (US &amp; Canada)</option>
<option value="-6.0">(GMT -6:00) Central Time (US &amp; Canada), Mexico City</option>
<option value="-5.0">(GMT -5:00) Eastern Time (US &amp; Canada), Bogota, Lima</option>
<option value="-4.0">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
<option value="-3.5">(GMT -3:30) Newfoundland</option>
<option value="-3.0">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
<option value="-2.0">(GMT -2:00) Mid-Atlantic</option>
<option value="-1.0">(GMT -1:00 hour) Azores, Cape Verde Islands</option>
<option value="0.0">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
<option value="1.0">(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris</option>
<option value="2.0">(GMT +2:00) Kaliningrad, South Africa</option>
<option value="3.0">(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg</option>
<option value="3.5">(GMT +3:30) Tehran</option>
<option value="4.0">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
<option value="4.5">(GMT +4:30) Kabul</option>
<option value="5.0">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
<option value="5.5">(GMT +5:30) Bombay, Calcutta, Madras, New Delhi</option>
<option value="5.75">(GMT +5:45) Kathmandu</option>
<option value="6.0">(GMT +6:00) Almaty, Dhaka, Colombo</option>
<option value="7.0">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
<option value="8.0">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
<option value="9.0">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
<option value="9.5">(GMT +9:30) Adelaide, Darwin</option>
<option value="10.0">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
<option value="11.0">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
<option value="12.0">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div>
<label class="col-sm-4 control-label no-padding-right">Language</label>
<div class="col-sm-8">
<select ng-model="general.language" name="language" class="col-xs-10 col-sm-5">
<option value="en">English</option>
<option value="cn">Chinese</option>
</select>
</div>
</div>
</div>
</form>
</div>
</div>
</accordion-group>
</td>
</tr>
<accordion-group is-open="status2.open">
<accordion-heading>
<i class="ace-icon fa fa-angle-right" ng-class="{'fa-angle-down': status2.open, 'fa-angle-right': !status2.open}"></i> Subnetwork
</accordion-heading>
<div class="row">
<div class="col-lg-2">
</tbody>
</table>
</div>
<div class="col-sm-2">
</div>
</div>
<div class="col-lg-8">
<table class="table table-hover nowrap">
<thead>
<tr>
<th>Name</th>
<th>Subnet</th>
<th>Netmask</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="sub in subnetworks">
<td>
<input type="text" ng-model="sub.name" placeholder="Name" />
</td>
<td>
<input type="text" ng-model="sub.subnet" placeholder="Subnet" />
</td>
<td>
<input type="text" ng-model="sub.netmask" placeholder="Netmask" />
</td>
<td>
<!--Add Action-->
<span class="action" ng-click="addSubnetwork()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<!--Remove Action-->
<span ng-show="subnetworks.length > 1" class="action" ng-click="removeSubnetwork($index)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-2">
</div>
</div>
</accordion-group>
<accordion-group is-open="status.open">
<accordion-heading>
<i class="ace-icon fa fa-angle-right" ng-class="{'fa-angle-down': status.open, 'fa-angle-right': !status.open}"></i> Routing Table
</accordion-heading>
<div class="row">
<div class="col-lg-2">
</div>
<div class="col-lg-8">
<table class="table table-hover nowrap">
<thead>
<tr>
<th>Name</th>
<th>Subnet</th>
<th>Netmask</th>
<th>Gateway</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="route in routingtable">
<td>
<input type="text" ng-model="route.name" placeholder="Name" />
</td>
<td>
<input type="text" ng-model="route.subnet" placeholder="Subnet" />
</td>
<td>
<input type="text" ng-model="route.netmask" placeholder="Netmask" />
</td>
<td>
<input type="text" ng-model="route.gateway" placeholder="Gateway" />
</td>
<td>
<!--Add Action-->
<span class="action" ng-click="addRoute()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<!--Remove Action-->
<span ng-show="routingtable.length > 1" class="action" ng-click="removeRoute($index)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-2">
</div>
</div>
</accordion-group>
</accordion>
</accordion-group>
</accordion>
</div>
</div>
</div>
</div>

View File

@ -12,9 +12,10 @@
</div>
</form>
</div>
<div class="pull-left">
<span class="input-icon">
<input type="text" placeholder="Search" ng-model="search">
<input type="text" placeholder="Search" ng-model="search.$">
<i class="ace-icon fa fa-search blue"></i>
</span>
</div>
@ -46,7 +47,7 @@
<div class="row">
<table ng-table="tableParams" class="table table-hover table-striped">
<thead>
<thead>
<tr>
<th></th>
<th ng-repeat="column in server_columns" ng-show="column.visible" class="sortable" ng-class="{
@ -63,7 +64,7 @@
</thead>
<tbody>
<tr ng-repeat="server in $data | filter:search" ng-init="serverIndex = $index">
<tr ng-repeat="server in $data | filter: search" ng-init="serverIndex = $index">
<td>
<input ng-model="server.checked" type="checkbox">
</td>
@ -74,7 +75,9 @@
<span ng-if="column.field!='hostname'">
{{server[column.field]}}
</span>
{{server.network}}
</td>
<td ng-repeat="interface in interfaces" ng-init="server.network[interface]={};">
<input ng-model="server.network[interface].ip" placeholder="IP Address" class="form-control margin-bottom-10 max-width-200" type="text">
<select ng-model="server.network[interface].subnet_id" class="form-control margin-bottom-10 max-width-200">
@ -83,8 +86,7 @@
</option>
</select>
<span>
<!--TODO: validate management network (each sv can only have one mgmt network) -->
<!--radio not working here to bind model-->
<input ng-model="server.network[interface].is_mgmt" name="mgmt-{{serverIndex}}" type="checkbox"> Is Mgmt Network
</span>
</td>

View File

@ -1,4 +1,4 @@
<div class="svSelectCtrl">
<div ng-controller="svSelectCtrl">
<div class="row">
<div class="pull-left">
<span class="input-icon">
@ -9,52 +9,67 @@
<div class="pull-right">
<div class="checkbox">
<label>
<input type="checkbox" class="ace">
<span class="lbl">Show Only Selected Servers</span>
<input ng-model="hideunselected" ng-change="hideUnselected()" type="checkbox" class="ace">
<span class="lbl">&nbsp;Hide Unselected Servers</span>
</label>
</div>
</div>
<div class="pull-right">
<!-- Column Show / Hide button -->
<div class="btn-group" dropdown>
<button type="button" class="btn btn-white btn-default dropdown-toggle">
Column Show / Hide
<span class="ace-icon fa fa-caret-down icon-on-right"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li ng-repeat="column in server_columns" ng-click="column.visible=!column.visible">
<a class="action">
<span ng-class="{'opacity-zero': !column.visible}">
<i class="ace-icon fa fa-check blue"></i>
</span>
{{column.title}}
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="row">
<table class="table table-hover table-striped">
<table ng-table="tableParams" class="table table-hover table-striped">
<thead>
<tr>
<th>
<input type="checkbox" ng-model="selectall" ng-change="selectAllServers(selectall)">
</th>
<th>Host MAC</th>
<th>Switch IP</th>
<th>Port</th>
<th>Hostname</th>
<th>Cluster</th>
<th>OS</th>
<th>OS Installation</th>
<th>Target System</th>
<th>State</th>
<th ng-repeat="column in server_columns" ng-show="column.visible" class="sortable" ng-class="{
'sort-asc': tableParams.isSortBy(column.field, 'asc'),
'sort-desc': tableParams.isSortBy(column.field, 'desc')
}" ng-click="tableParams.sorting(column.field, tableParams.isSortBy(column.field, 'asc') ? 'desc' : 'asc')">
{{column.title}}
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="server in allservers | filter:search">
<tr ng-repeat="server in $data | filter:search">
<td>
<input ng-model="server.selected" type="checkbox">
</td>
<td>{{server["mac"]}}</td>
<td>{{server["switch_ip"]}}</td>
<td>{{server["port"]}}</td>
<td>{{server["hostname"]}}</td>
<td>{{server["cluster"]}}</td>
<td>{{server["os"]}}</td>
<td>
<span ng-if="server['os']">
<input type="checkbox" ng-model="server.reinstallos">Reinstall OS
<td ng-repeat="column in server_columns" ng-show="column.visible" sortable="column.field">
<span ng-if="column.field=='os_installed'">
<span ng-if="server['os']">
<input type="checkbox" ng-model="server.reinstallos">
<span class="lbl">&nbsp;Reinstall OS</span>
</span>
<span ng-if="!server['os']">
-
</span>
</span>
<span ng-if="!server['os']">
-
<span ng-if="column.field!='os_installed'">
{{server[column.field]}}
</span>
</td>
<td>{{server["adapter"]}}</td>
<td>{{server["state"]}}</td>
</tr>
</tbody>
</table>

View File

@ -43,41 +43,46 @@ angular.module('compass.wizard', [
// go to next step
$scope.stepForward = function() {
if ($scope.steps[$scope.currentStep - 1].title == "Server Selection") {
var selectedServers = [];
var noSelection = true;
angular.forEach($scope.allservers, function(sv) {
if (sv.selected) {
noSelection = false;
selectedServers.push(sv);
}
})
if (noSelection) {
alert("Please select at least one server");
} else {
//TODO: api call - add host
wizardFactory.setServers(selectedServers);
console.info("wizardFactory.getServers", wizardFactory.getServers());
$scope.next();
}
// trigger commit for current step
var commitState = {
"name": $scope.steps[$scope.currentStep - 1].name,
"state": "triggered",
"message": ""
};
wizardFactory.setCommitState(commitState);
} else if ($scope.steps[$scope.currentStep - 1].title == "OS Global Config") {
//var general_config = $('#generalForm').serializeObject();
//$scope.general = general_config;
var global_os_config = {
"os_config": {
"global": $scope.general,
"subnetworks": $scope.subnetworks,
"route_table": $scope.routingtable
}
};
console.log(global_os_config);
//TODO modify api call
dataService.updateClusterConfig(1, global_os_config).success(function(data) {
console.info("success")
$scope.next();
})
} else if ($scope.steps[$scope.currentStep - 1].title == "Partition") {
// watch commit state change
$scope.$watch(function() {
return wizardFactory.getCommitState()
}, function(newCommitState, oldCommitState) {
switch (newCommitState.name) {
case "sv_selection":
case "os_global":
case "network":
case "partition":
case "security":
case "role_assign":
case "network_mapping":
if (newCommitState.name == $scope.steps[$scope.currentStep - 1].name && newCommitState.state == "success") {
console.info("### catch success in wizardCtrl ###", newCommitState, oldCommitState);
$scope.next();
} else if (newCommitState.state == "error") {
// TODO: error handling / display error message
}
break;
case "review":
// TODO: go to cluster overview page
break;
default:
break;
}
})
/*
if ($scope.steps[$scope.currentStep - 1].title == "Partition") {
var partitionData = {};
angular.forEach($scope.partition, function(pa) {
console.log(pa);
@ -99,9 +104,8 @@ angular.module('compass.wizard', [
dataService.updateClusterConfig(1, partitionData).success(function(data) {
$scope.next();
})
} else {
$scope.next();
}
*/
};
$scope.next = function() {
@ -111,40 +115,23 @@ angular.module('compass.wizard', [
// go to previous step
$scope.stepBackward = function() {
if ($scope.currentStep > 1)
if ($scope.currentStep > 1) {
$scope.currentStep = $scope.currentStep - 1;
}
};
// go to step by stepId
$scope.goToStep = function(stepId) {
$scope.currentStep = stepId;
};
});
dataService.getServers().success(function(data) {
$scope.allservers = data;
wizardFactory.setAllMachinesHost(data);
});
//For Server Selection Section
$scope.selectall = false;
$scope.selectAllServers = function(flag) {
if (flag) {
angular.forEach($scope.allservers, function(sv) {
sv.selected = true;
})
} else {
angular.forEach($scope.allservers, function(sv) {
sv.selected = false;
})
}
}
//TODO: show only selected servers
dataService.getAdapterConfig().success(function(data) {
$scope.os_global_config = data['os_config']['centos']['global'];
//console.log("###", $scope.os_global_config);
@ -159,50 +146,6 @@ angular.module('compass.wizard', [
//console.log($scope.security);
});
//For General Section
$scope.general = {
"dns_servers": [""],
"search_path": [""]
};
$scope.addDNSServer = function() {
$scope.general['dns_servers'].push("");
}
$scope.addSearchPath = function() {
$scope.general['search_path'].push("");
}
//For Subnetworks Section
$scope.subnetworks = [];
$scope.addSubnetwork = function() {
$scope.subnetworks.push({});
console.log($scope.subnetworks);
};
$scope.removeSubnetwork = function(index) {
$scope.subnetworks.splice(index, 1)
};
$scope.$watch('subnetworks', function() {
if ($scope.subnetworks.length == 0) {
$scope.subnetworks.push({});
}
}, true);
//For Routing Table Section
$scope.routingtable = [];
$scope.addRoute = function() {
$scope.routingtable.push({});
console.log($scope.routingtable);
};
$scope.removeRoute = function(index) {
$scope.routingtable.splice(index, 1)
};
$scope.$watch('routingtable', function() {
if ($scope.routingtable.length == 0) {
$scope.routingtable.push({});
}
}, true);
//For Partition Section
$scope.partition = []
@ -290,9 +233,266 @@ angular.module('compass.wizard', [
})
.controller('svSelectCtrl', function($scope, wizardFactory, dataService, $filter, ngTableParams) {
$scope.hideunselected = '';
$scope.allservers = wizardFactory.getAllMachinesHost();
$scope.selectAllServers = function(flag) {
if (flag) {
angular.forEach($scope.allservers, function(sv) {
sv.selected = true;
})
} else {
angular.forEach($scope.allservers, function(sv) {
sv.selected = false;
})
}
};
dataService.getServerColumns().success(function(data) {
$scope.server_columns = data.showall;
});
$scope.hideUnselected = function() {
if ($scope.hideunselected) {
$scope.search.selected = true;
} else {
delete $scope.search.selected;
}
};
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: $scope.allservers.length // count per page
}, {
counts: [], // hide count-per-page box
total: $scope.allservers.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.sorting() ?
$filter('orderBy')($scope.allservers, params.orderBy()) : $scope.allservers;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
$scope.$watch(function() {
return wizardFactory.getCommitState()
}, function(newCommitState, oldCommitState) {
if (newCommitState !== undefined) {
if (newCommitState.name == "sv_selection" && newCommitState.state == "triggered") {
$scope.commit();
}
}
});
$scope.commit = function() {
var selectedServers = [];
var noSelection = true;
angular.forEach($scope.allservers, function(sv) {
if (sv.selected) {
noSelection = false;
selectedServers.push(sv);
}
})
if (noSelection) {
alert("Please select at least one server");
wizardFactory.setCommitState({});
} else {
wizardFactory.setServers(selectedServers);
wizardFactory.setAllMachinesHost($scope.allservers);
console.info("wizardFactory.getServers", wizardFactory.getServers());
console.info("wizardFactory.getAllMachinesHost", wizardFactory.getAllMachinesHost());
var commitState = {
"name": "sv_selection",
"state": "success",
"message": ""
};
wizardFactory.setCommitState(commitState);
}
};
})
.controller('globalCtrl', function($scope, wizardFactory, dataService) {
var cluster = wizardFactory.getClusterInfo();
//For General Section
$scope.general = {
"dns_servers": [""],
"search_path": [""]
};
$scope.addDNSServer = function() {
$scope.general['dns_servers'].push("");
};
$scope.addSearchPath = function() {
$scope.general['search_path'].push("");
};
dataService.getTimezones().success(function(data) {
$scope.timezones = data;
});
//For Subnetworks Section
$scope.subnetworks = wizardFactory.getSubnetworks();
$scope.addSubnetwork = function() {
$scope.subnetworks.push({});
console.log($scope.subnetworks);
};
$scope.removeSubnetwork = function(index) {
$scope.subnetworks.splice(index, 1)
};
$scope.$watch('subnetworks', function() {
if ($scope.subnetworks.length == 0) {
$scope.subnetworks.push({});
}
}, true);
//For Routing Table Section
$scope.routingtable = wizardFactory.getRoutingTable();
$scope.addRoute = function() {
$scope.routingtable.push({});
console.log($scope.routingtable);
};
$scope.removeRoute = function(index) {
$scope.routingtable.splice(index, 1)
};
$scope.$watch('routingtable', function() {
if ($scope.routingtable.length == 0) {
$scope.routingtable.push({});
}
}, true);
$scope.$watch(function() {
return wizardFactory.getCommitState()
}, function(newCommitState, oldCommitState) {
if (newCommitState !== undefined) {
if (newCommitState.name == "os_global" && newCommitState.state == "triggered") {
$scope.commit();
}
}
});
$scope.commit = function() {
var os_global_general = {
"os_config": {
"general": $scope.general
}
};
dataService.updateClusterConfig(cluster.id, os_global_general).success(function(configData) {
wizardFactory.setGeneralConfig(configData);
dataService.postClusterSubnetConfig(cluster.id, $scope.subnetworks).success(function(subnetData) {
wizardFactory.setSubnetworks(subnetData);
dataService.postRoutingTable(cluster.id, $scope.routingtable).success(function(routingTbdata) {
wizardFactory.setRoutingTable(routingTbdata);
console.info("$$$$ ", wizardFactory.getSubnetworks(), wizardFactory.getRoutingTable(), wizardFactory.getGeneralConfig())
var commitState = {
"name": "os_global",
"state": "success",
"message": ""
};
wizardFactory.setCommitState(commitState);
})
})
})
};
})
.controller('networkCtrl', function($scope, wizardFactory, dataService, $filter, ngTableParams) {
var cluster = wizardFactory.getClusterInfo();
$scope.servers = wizardFactory.getServers();
dataService.getServerColumns().success(function(data) {
$scope.server_columns = data.showless;
});
$scope.subnetworks = wizardFactory.getSubnetworks();
$scope.interfaces = wizardFactory.getInterfaces();
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: $scope.servers.length + 1 // count per page
}, {
counts: [], // hide count-per-page box
total: $scope.servers.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.sorting() ?
$filter('orderBy')($scope.servers, params.orderBy()) : $scope.servers;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
$scope.addInterface = function(newInterface) {
var isExist = false;
angular.forEach($scope.interfaces, function(interface) {
if (interface == newInterface) {
isExist = true;
alert("This interface already exists. Please try another one");
}
})
if (!isExist) {
$scope.interfaces.push(newInterface);
}
$scope.newInterface = "";
};
$scope.deleteInterface = function(delInterface) {
var delIndex = $scope.interfaces.indexOf(delInterface);
$scope.interfaces.splice(delIndex, 1);
angular.forEach($scope.servers, function(sv) {
delete sv.network[delInterface];
})
};
$scope.$watch(function() {
return wizardFactory.getCommitState()
}, function(newCommitState, oldCommitState) {
console.info("### catch commit change in networkCtrl ###", newCommitState);
if (newCommitState !== undefined) {
if (newCommitState.name == "network" && newCommitState.state == "triggered") {
$scope.commitNetwork();
} else if (newCommitState.name == "network_mapping" && newCommitState.state == "triggered") {
$scope.commitNetworkMapping();
}
}
});
$scope.commitNetwork = function() {
var commitState = {
"name": "network",
"state": "success",
"message": ""
};
wizardFactory.setCommitState(commitState);
};
$scope.commitNetworkMapping = function() {
var commitState = {
"name": "network_mapping",
"state": "success",
"message": ""
};
wizardFactory.setCommitState(commitState);
};
$scope.autofill = function() {
//TODO: add auto fill
alert("Autofill coming soon");
}
})
.controller('roleAssignCtrl', function($scope, wizardFactory) {
$scope.servers = wizardFactory.getServers();
console.info("~~~~~", wizardFactory.getServers());
$scope.roles = wizardFactory.getAdapter().roles;
@ -321,63 +521,3 @@ angular.module('compass.wizard', [
}
};
})
.controller('networkCtrl', function($scope, wizardFactory, dataService, $filter, ngTableParams) {
var cluster = wizardFactory.getClusterInfo();
$scope.servers = wizardFactory.getServers();
dataService.getServerColumns().success(function(data) {
console.info(data)
$scope.server_columns = data.showless;
});
dataService.getClusterSubnetConfig(cluster.id).success(function(data) {
$scope.subnetworks = data;
});
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: $scope.servers.length // count per page
}, {
counts: [], // hide count-per-page box
total: $scope.servers.length, // length of data
getData: function($defer, params) {
// use build-in angular filter
var orderedData = params.sorting() ?
$filter('orderBy')($scope.servers, params.orderBy()) : $scope.servers;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
$scope.interfaces = ["eth0", "eth1", "eth2", "eth3"];
$scope.addInterface = function(newInterface) {
var isExist = false;
angular.forEach($scope.interfaces, function(interface) {
if (interface == newInterface) {
isExist = true;
alert("This interface already exists. Please try another one");
}
})
if (!isExist) {
$scope.interfaces.push(newInterface);
}
$scope.newInterface = "";
};
$scope.deleteInterface = function(delInterface) {
var delIndex = $scope.interfaces.indexOf(delInterface);
$scope.interfaces.splice(delIndex, 1);
angular.forEach($scope.servers, function(sv) {
delete sv.network[delInterface];
})
}
$scope.autofill = function() {
//TODO: add auto fill
alert("Autofill coming soon");
}
})