add menu option to confirm dialog
hook up to "K" action for killing a controller
diff --git a/web/ons-demo/css/skin.default.css b/web/ons-demo/css/skin.default.css
index f473124..2b07e33 100644
--- a/web/ons-demo/css/skin.default.css
+++ b/web/ons-demo/css/skin.default.css
@@ -528,3 +528,21 @@
background-color: black;
}
+select {
+ margin-top: 1em;
+ -webkit-appearance: none;
+ border-radius: 0px;
+ font-size: 18px;
+ padding: .5em;
+ background-color: black;
+ color: white;
+ border: 1px solid white;
+}
+
+select:after {
+ content: 'a';
+ position: absolute;
+ right: 0px;
+ top: 0px;
+}
+
diff --git a/web/ons-demo/index.html b/web/ons-demo/index.html
index 1b88b4a..460188f 100644
--- a/web/ons-demo/index.html
+++ b/web/ons-demo/index.html
@@ -23,10 +23,11 @@
<div id='cluster-label'>ONOS Node Cluster</div>
<div id='controllers'></div>
<div id='actions'>
- <div id='action-all' class='action'>A</div>
<div id='action-local' class='action'>1</div>
- <div id='action-scale' class='action'>S</div>
<div id='action-reset' class='action'>R</div>
+ <div id='action-scale' class='action'>S</div>
+ <div id='action-all' class='action'>A</div>
+ <div id='action-kill' class='action'>K</div>
</div>
</div>
@@ -50,6 +51,7 @@
<div id='confirm-background'></div>
<div id='confirm-panel'>
<div id='confirm-prompt'>A PROMPT</div>
+ <select id='confirm-select'></select>
<div id='confirm-buttons'>
<div id='confirm-ok' class='confirm-button'>OK</div>
<div id='confirm-cancel' class='confirm-button'>CANCEL</div>
diff --git a/web/ons-demo/js/init.js b/web/ons-demo/js/init.js
index f7bd55b..23f4649 100644
--- a/web/ons-demo/js/init.js
+++ b/web/ons-demo/js/init.js
@@ -33,5 +33,13 @@
alert('reset')
});
+ d3.select('#action-kill').on('click', function () {
+ var prompt = "Kill ONOS node?";
+ var options = model.activeControllers;
+ doConfirm(prompt, function (result) {
+ controllerDown(result);
+ }, options);
+ });
+
createTopologyView(cb);
}
diff --git a/web/ons-demo/js/utils.js b/web/ons-demo/js/utils.js
index 265c661..1b4c38c 100644
--- a/web/ons-demo/js/utils.js
+++ b/web/ons-demo/js/utils.js
@@ -204,10 +204,24 @@
/***************************************************************************************************
***************************************************************************************************/
-function doConfirm(prompt, cb) {
+function doConfirm(prompt, cb, options) {
var confirm = d3.select('#confirm');
confirm.select('#confirm-prompt').text(prompt);
+ var select = d3.select(document.getElementById('confirm-select'));
+ if (options) {
+ select.style('display', 'block');
+ select.text('');
+ select.selectAll('option').
+ data(options)
+ .enter()
+ .append('option')
+ .attr('value', function (d) {return d})
+ .text(function (d) {return d});
+ } else {
+ select.style('display', 'none');
+ }
+
function show() {
confirm.style('display', '-webkit-box');
confirm.style('opacity', 0);
@@ -227,7 +241,11 @@
confirm.select('#confirm-ok').on('click', function () {
d3.select(this).on('click', null);
dismiss();
- cb(true);
+ if (options) {
+ cb(select[0][0].value);
+ } else {
+ cb(true);
+ }
});
confirm.select('#confirm-cancel').on('click', function () {