ONOS-6730: Topo View i18n for:
- device and host label op flash messages
- hosts visible/hidden, offline devices visible/hidden
- bad links, reset node locations
- packet/optical/all layers shown
- port highlighting
- instance show/hide panel, devices
Change-Id: I0f1cfb43ba3e03a806c716394f42ba064ba99bd7
diff --git a/web/gui/src/main/webapp/app/view/topo/topo.js b/web/gui/src/main/webapp/app/view/topo/topo.js
index 07b29c7..24eee02 100644
--- a/web/gui/src/main/webapp/app/view/topo/topo.js
+++ b/web/gui/src/main/webapp/app/view/topo/topo.js
@@ -326,8 +326,18 @@
// --- Background Map ------------------------------------------------
+ function recenterLabel(g) {
+ var box = g.node().getBBox();
+
+ box.x -= box.width/2;
+ box.y -= box.height/2;
+ g.attr('transform', sus.translate(box.x, box.y));
+
+ }
+
function setUpNoDevs() {
- var g, box;
+ var g;
+
noDevsLayer = svg.append('g').attr({
id: 'topo-noDevsLayer',
transform: sus.translate(500, 500),
@@ -337,20 +347,16 @@
g = noDevsLayer.append('g');
gs.addGlyph(g, 'bird', 100).attr('class', 'noDevsBird');
- g.append('text').text(topoLion('no_devices_are_connected'))
- .attr({ x: 120, y: 80 });
-
- box = g.node().getBBox();
- box.x -= box.width/2;
- box.y -= box.height/2;
- g.attr('transform', sus.translate(box.x, box.y));
-
+ g.append('text').text('').attr({x: 120, y: 80 });
+ recenterLabel(g);
showNoDevs(true);
}
function lionNoDevs() {
- d3.select('#topo-noDevsLayer g text')
- .text(topoLion('no_devices_are_connected'));
+ var g = d3.select('#topo-noDevsLayer g');
+
+ g.select('text').text(topoLion('no_devices_are_connected'));
+ recenterLabel(g);
}
function showNoDevs(b) {
@@ -719,6 +725,10 @@
// DOM elements...
lionNoDevs();
+ // pass lion bundle function ref to other topo modules
+ tfs.setLionBundle(topoLion);
+ tis.setLionBundle(topoLion);
+
// now we have the map projection, we are ready for
// the server to send us device/host data...
tes.start();
diff --git a/web/gui/src/main/webapp/app/view/topo/topoD3.js b/web/gui/src/main/webapp/app/view/topo/topoD3.js
index 6146082..9aafc98 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoD3.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoD3.js
@@ -25,6 +25,11 @@
// injected refs
var sus, is, ts, ps, ttbs;
+ // function to be replaced by the localization bundle function
+ var topoLion = function (x) {
+ return '#tfs#' + x + '#';
+ };
+
// api to topoForce
var zoomer, api;
/*
@@ -126,9 +131,9 @@
function incDevLabIndex() {
setDevLabIndex(deviceLabelIndex+1);
switch (deviceLabelIndex) {
- case 0: return 'Hide device labels';
- case 1: return 'Show friendly device labels';
- case 2: return 'Show device ID labels';
+ case 0: return topoLion('fl_device_labels_hide');
+ case 1: return topoLion('fl_device_labels_show_friendly');
+ case 2: return topoLion('fl_device_labels_show_id');
}
}
@@ -142,9 +147,9 @@
function incHostLabIndex() {
setHostLabIndex(hostLabelIndex+1);
switch (hostLabelIndex) {
- case 0: return 'Show friendly host labels';
- case 1: return 'Show host IP Addresses';
- case 2: return 'Show host MAC Addresses';
+ case 0: return topoLion('fl_host_labels_show_friendly');
+ case 1: return topoLion('fl_host_labels_show_ip');
+ case 2: return topoLion('fl_host_labels_show_mac');
}
}
@@ -603,6 +608,11 @@
labels.exit().remove();
}
+ // invoked after the localization bundle has been received from the server
+ function setLionBundle(bundle) {
+ topoLion = bundle;
+ }
+
// ==========================
// Module definition
@@ -653,6 +663,8 @@
transformLabel: transformLabel,
applyPortLabels: applyPortLabels,
applyNumLinkLabels: applyNumLinkLabels,
+
+ setLionBundle: setLionBundle,
};
}]);
}());
diff --git a/web/gui/src/main/webapp/app/view/topo/topoFilter.js b/web/gui/src/main/webapp/app/view/topo/topoFilter.js
index b24bf53..b5a5283 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoFilter.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoFilter.js
@@ -33,6 +33,11 @@
link() // get ref to D3 selection of links
*/
+ // function to be replaced by the localization bundle function
+ var topoLion = function (x) {
+ return '#tfltr#' + x + '#';
+ };
+
var smax = 'suppressedmax';
// which "layer" a particular item "belongs to"
@@ -61,25 +66,26 @@
{
type: 'all',
action: function () { suppressLayers(false); },
- msg: 'All Layers Shown',
},
{
type: 'pkt',
action: function () { showLayer('pkt'); },
- msg: 'Packet Layer Shown',
},
{
type: 'opt',
action: function () { showLayer('opt'); },
- msg: 'Optical Layer Shown',
},
],
- layer = 0;
+ layer = 0,
+ layerType,
+ lionKey;
function clickAction() {
layer = (layer + 1) % dispatch.length;
dispatch[layer].action();
- flash.flash(dispatch[layer].msg);
+ layerType = dispatch[layer].type;
+ lionKey = 'fl_layer_' + layerType;
+ flash.flash(topoLion(lionKey));
}
function selected() {
@@ -119,6 +125,11 @@
unsuppressLayer(which);
}
+ // invoked after the localization bundle has been received from the server
+ function setLionBundle(bundle) {
+ topoLion = bundle;
+ }
+
// === -----------------------------------------------------
// === MODULE DEFINITION ===
@@ -137,6 +148,7 @@
clickAction: clickAction,
selected: selected,
inLayer: inLayer,
+ setLionBundle: setLionBundle,
};
},
]);
diff --git a/web/gui/src/main/webapp/app/view/topo/topoForce.js b/web/gui/src/main/webapp/app/view/topo/topoForce.js
index c7d1dca..b8f3a48 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoForce.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoForce.js
@@ -26,6 +26,11 @@
var $log, $timeout, fs, sus, ts, flash, wss, tov,
tis, tms, td3, tss, tts, tos, fltr, tls, uplink, svg, tpis;
+ // function to be replaced by the localization bundle function
+ var topoLion = function (x) {
+ return '#tfs#' + x + '#';
+ };
+
// configuration
var linkConfig = {
light: {
@@ -486,7 +491,8 @@
}
function vis(b) {
- return b ? 'visible' : 'hidden';
+ var lionKey = b ? 'visible' : 'hidden';
+ return topoLion(lionKey);
}
function toggleHosts(x) {
@@ -495,7 +501,7 @@
showHosts = on;
updateHostVisibility();
- flash.flash('Hosts ' + vis(on));
+ flash.flash(topoLion('hosts') + ' ' + vis(on));
return on;
}
@@ -505,7 +511,7 @@
showOffline = on;
updateOfflineVisibility();
- flash.flash('Offline devices ' + vis(on));
+ flash.flash(topoLion('fl_offline_devices') + ' ' + vis(on));
return on;
}
@@ -586,7 +592,7 @@
function showBadLinks() {
var badLinks = tms.findBadLinks();
- flash.flash('Bad Links: ' + badLinks.length);
+ flash.flash(topoLion('fl_bad_links') + ': ' + badLinks.length);
$log.debug('Bad Link List (' + badLinks.length + '):');
badLinks.forEach(function (d) {
$log.debug('bad link: (' + d.bad + ') ' + d.key, d);
@@ -650,7 +656,7 @@
tms.resetAllLocations();
updateNodes();
tick(); // force nodes to be redrawn in their new locations
- flash.flash('Reset Node Locations');
+ flash.flash(topoLion('fl_reset_node_locations'));
}
// ==========================================
@@ -1105,6 +1111,14 @@
updateNodes();
}
+ // invoked after the localization bundle has been received from the server
+ function setLionBundle(bundle) {
+ topoLion = bundle;
+ td3.setLionBundle(bundle);
+ fltr.setLionBundle(bundle);
+ tls.setLionBundle(bundle);
+ }
+
angular.module('ovTopo')
.factory('TopoForceService',
['$log', '$timeout', 'FnService', 'SvgUtilService',
@@ -1263,6 +1277,8 @@
updateLink: updateLink,
removeLink: removeLink,
topoStartDone: topoStartDone,
+
+ setLionBundle: setLionBundle,
};
}]);
}());
diff --git a/web/gui/src/main/webapp/app/view/topo/topoInst.js b/web/gui/src/main/webapp/app/view/topo/topoInst.js
index 9544d4e..4e89822 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoInst.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoInst.js
@@ -45,6 +45,11 @@
oiShowMaster,
oiBox;
+ // function to be replaced by the localization bundle function
+ var topoLion = function (x) {
+ return '#tinst#' + x + '#';
+ };
+
function addInstance(data) {
var id = data.id;
@@ -165,7 +170,7 @@
.data(onosOrder, function (d) { return d.id; });
function nSw(n) {
- return 'Devices: ' + n;
+ return topoLion('devices') + ': ' + n;
}
// operate on existing onos instances if necessary
@@ -307,11 +312,16 @@
hideInsts();
}
}
- verb = on ? 'Show' : 'Hide';
- flash.flash(verb + ' instances panel');
+ verb = on ? topoLion('show') : topoLion('hide');
+ flash.flash(verb + ' ' + topoLion('fl_panel_instances'));
return on;
}
+ // invoked after the localization bundle has been received from the server
+ function setLionBundle(bundle) {
+ topoLion = bundle;
+ }
+
// ==========================
angular.module('ovTopo')
@@ -343,6 +353,7 @@
hide: hideInsts,
toggle: toggleInsts,
showMaster: function () { return oiShowMaster; },
+ setLionBundle: setLionBundle,
};
}]);
}());
diff --git a/web/gui/src/main/webapp/app/view/topo/topoLink.js b/web/gui/src/main/webapp/app/view/topo/topoLink.js
index c0faa8c..ed06ce1 100644
--- a/web/gui/src/main/webapp/app/view/topo/topoLink.js
+++ b/web/gui/src/main/webapp/app/view/topo/topoLink.js
@@ -36,6 +36,10 @@
// SVG elements;
var svg;
+ // function to be replaced by the localization bundle function
+ var topoLion = function (x) {
+ return '#tlink#' + x + '#';
+ };
// ======== ALGORITHM TO FIND LINK CLOSEST TO MOUSE ========
@@ -288,7 +292,8 @@
function togglePorts(x) {
var kev = (x === 'keyev'),
on = kev ? !showPorts : !!x,
- what = on ? 'Enable' : 'Disable',
+ what = on ? topoLion('enable') : topoLion('disable'),
+ philite = topoLion('fl_port_highlighting'),
handler = on ? mouseMoveHandler : null;
showPorts = on;
@@ -297,7 +302,7 @@
enhanceLink(null);
}
svg.on('mousemove', handler);
- flash.flash(what + ' port highlighting');
+ flash.flash(what + ' ' + philite);
return on;
}
@@ -312,6 +317,11 @@
}
}
+ // invoked after the localization bundle has been received from the server
+ function setLionBundle(bundle) {
+ topoLion = bundle;
+ }
+
// ==========================
// Module definition
@@ -350,6 +360,7 @@
destroyLink: destroyLink,
togglePorts: togglePorts,
deselectAllLinks: deselectAllLinks,
+ setLionBundle: setLionBundle,
};
}]);
}());