Simon Hunt

GUI -- Cleaning up use of sendMessage() to make consistent.

Change-Id: Id3703e00aa93e6414a1509db5eaf2e91f4ec9977
...@@ -928,8 +928,8 @@ ...@@ -928,8 +928,8 @@
928 } 928 }
929 929
930 function equalizeMasters() { 930 function equalizeMasters() {
931 - flash('Equalizing master roles');
932 sendMessage('equalizeMasters'); 931 sendMessage('equalizeMasters');
932 + flash('Equalizing master roles');
933 } 933 }
934 934
935 function toggleSummary() { 935 function toggleSummary() {
...@@ -942,11 +942,11 @@ ...@@ -942,11 +942,11 @@
942 942
943 // request overall summary data 943 // request overall summary data
944 function requestSummary() { 944 function requestSummary() {
945 - sendMessage('requestSummary', {}); 945 + sendMessage('requestSummary');
946 } 946 }
947 947
948 function cancelSummary() { 948 function cancelSummary() {
949 - sendMessage('cancelSummary', {}); 949 + sendMessage('cancelSummary');
950 hideSummaryPane(); 950 hideSummaryPane();
951 } 951 }
952 952
...@@ -996,12 +996,11 @@ ...@@ -996,12 +996,11 @@
996 // request details for the selected element 996 // request details for the selected element
997 // invoked from selection of a single node. 997 // invoked from selection of a single node.
998 function requestDetails() { 998 function requestDetails() {
999 - var data = getSel(0).obj, 999 + var data = getSel(0).obj;
1000 - payload = { 1000 + sendMessage('requestDetails', {
1001 id: data.id, 1001 id: data.id,
1002 class: data.class 1002 class: data.class
1003 - }; 1003 + });
1004 - sendMessage('requestDetails', payload);
1005 } 1004 }
1006 1005
1007 function addHostIntentAction() { 1006 function addHostIntentAction() {
...@@ -1024,7 +1023,7 @@ ...@@ -1024,7 +1023,7 @@
1024 1023
1025 1024
1026 function cancelTraffic() { 1025 function cancelTraffic() {
1027 - sendMessage('cancelTraffic', {}); 1026 + sendMessage('cancelTraffic');
1028 } 1027 }
1029 1028
1030 function requestTrafficForMode() { 1029 function requestTrafficForMode() {
...@@ -1044,13 +1043,16 @@ ...@@ -1044,13 +1043,16 @@
1044 } 1043 }
1045 1044
1046 function requestSelectTraffic() { 1045 function requestSelectTraffic() {
1046 + function hoverValid() {
1047 + return hoverMode === hoverModeIntents &&
1048 + hovered &&
1049 + (hovered.class === 'host' || hovered.class === 'device');
1050 + }
1051 +
1047 if (validateSelectionContext()) { 1052 if (validateSelectionContext()) {
1048 - var hoverId = (hoverMode === hoverModeIntents && hovered &&
1049 - (hovered.class === 'host' || hovered.class === 'device'))
1050 - ? hovered.id : '';
1051 sendMessage('requestTraffic', { 1053 sendMessage('requestTraffic', {
1052 ids: selectOrder, 1054 ids: selectOrder,
1053 - hover: hoverId 1055 + hover: hoverValid() ? hovered.id : ''
1054 }); 1056 });
1055 } 1057 }
1056 } 1058 }
...@@ -1063,12 +1065,15 @@ ...@@ -1063,12 +1065,15 @@
1063 } 1065 }
1064 1066
1065 function requestDeviceLinkFlows() { 1067 function requestDeviceLinkFlows() {
1068 + function hoverValid() {
1069 + return hoverMode === hoverModeFlows &&
1070 + hovered && (hovered.class === 'device');
1071 + }
1072 +
1066 if (validateSelectionContext()) { 1073 if (validateSelectionContext()) {
1067 - var hoverId = (hoverMode === hoverModeFlows && hovered &&
1068 - (hovered.class === 'device')) ? hovered.id : '';
1069 sendMessage('requestDeviceLinkFlows', { 1074 sendMessage('requestDeviceLinkFlows', {
1070 ids: selectOrder, 1075 ids: selectOrder,
1071 - hover: hoverId 1076 + hover: hoverValid() ? hovered.id : ''
1072 }); 1077 });
1073 } 1078 }
1074 } 1079 }
...@@ -1081,7 +1086,7 @@ ...@@ -1081,7 +1086,7 @@
1081 } 1086 }
1082 1087
1083 function requestAllTraffic() { 1088 function requestAllTraffic() {
1084 - sendMessage('requestAllTraffic', {}); 1089 + sendMessage('requestAllTraffic');
1085 } 1090 }
1086 1091
1087 function validateSelectionContext() { 1092 function validateSelectionContext() {
...@@ -2228,10 +2233,11 @@ ...@@ -2228,10 +2233,11 @@
2228 } 2233 }
2229 2234
2230 function sendMessage(evType, payload) { 2235 function sendMessage(evType, payload) {
2231 - var toSend = { 2236 + var p = payload || {},
2237 + toSend = {
2232 event: evType, 2238 event: evType,
2233 sid: ++sid, 2239 sid: ++sid,
2234 - payload: payload 2240 + payload: p
2235 }, 2241 },
2236 asText = JSON.stringify(toSend); 2242 asText = JSON.stringify(toSend);
2237 wsTraceTx(asText); 2243 wsTraceTx(asText);
...@@ -2607,7 +2613,7 @@ ...@@ -2607,7 +2613,7 @@
2607 sendMessage('updateMeta', { 2613 sendMessage('updateMeta', {
2608 id: d.id, 2614 id: d.id,
2609 'class': d.class, 2615 'class': d.class,
2610 - 'memento': metaUi 2616 + memento: metaUi
2611 }); 2617 });
2612 } 2618 }
2613 2619
......