diff --git a/MeshCentral b/MeshCentral new file mode 160000 index 00000000..b6bfdbbc --- /dev/null +++ b/MeshCentral @@ -0,0 +1 @@ +Subproject commit b6bfdbbc91375c12700a81048f29b6fc5dfd3e96 diff --git a/MeshCentralServer.njsproj b/MeshCentralServer.njsproj index 802c6cf3..91e8d00e 100644 --- a/MeshCentralServer.njsproj +++ b/MeshCentralServer.njsproj @@ -71,6 +71,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -84,6 +120,11 @@ + + + + + diff --git a/public/styles/style.css b/public/styles/style.css index f7864034..f9580679 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -512,37 +512,4 @@ a { .notification:hover { background-color: #EFE8B6; -} - -.map-PlaceDeviceMarker tr:nth-child(odd) { - background-color: #C9C9C9; -} - -.map-PlaceDeviceMarker tr:nth-child(even) { - background-color: #D8D8D8; -} - -.map-PlaceDeviceMarker tr:hover{ - background-color: #A9A9A9; -} - -.map-PlaceDeviceMarker td { - border-top: thin solid #808080; - border-bottom: thin solid #808080; - color: #282828; -} - -.map-PlaceDeviceMarker td:first-child { - border-left: thin solid #808080; -} - -.map-PlaceDeviceMarker td:last-child { - border-right: thin solid #808080; -} - -.flexboxdiv { - display: flex; - align-items: center; - display: -webkit-flex; - -webkit-align-items: center; } \ No newline at end of file diff --git a/views/default.handlebars b/views/default.handlebars index bcd6d569..2dd7cee9 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -9,7 +9,6 @@ - @@ -586,8 +585,6 @@
- -
@@ -1728,7 +1725,7 @@ { text: 'Refresh', callback: function () { refreshMap(true, true); } }, { text: 'Zoom to fit extent', callback: function () { zoomToFitExtent(); } }, { text: 'Center map here', callback: function(obj) { xxmap.mapView.animate({ center: obj.coordinate } ); } }, - { text: 'Place a node', callback: function (obj) { placeNode(obj.coordinate); } } + { text: 'Place node here', callback: function(obj) { placeNode(obj.coordinate); } } ]; function stringToIntHash(str) { @@ -2048,33 +2045,24 @@ // Called When Place a node option is clicked from context menu function placeNode(coords) { if (xxdialogMode) return; - clearSelectedNode(); - var x = '
  
'; - x += '
'; - var count = 0; - var table = updatePlaceNodeTable('', false); - if (table != 0) { x += table; count = 1; x += '
'; } else { count = 0;} - if (count == 0) { - var noNodesFound = ''; - if (!meshExists()) { - noNodesFound = '
No nodes found. To create a mesh network and add devices, go to My Account page.
'; - } else { - noNodesFound = '
No nodes found. To add devices, go to My Devices page.
'; - } - setDialogMode(2, "Select a Node to place marker", 1, null, noNodesFound, null); - } else { - setDialogMode(2, "Select a Node to place marker", 18, placeNodeEx, x, coords); + var x = '
  
'; + for (var i in nodes) { + x += '
'; + x += '
' + nodes[i].name + '
'; } + setDialogMode(2, "Select a node to place", 3, placeNodeEx, x + '
', coords); + onPlaceNodeInputChange(); } - function placeNodeEx(button, coords){ - for (var i in xxmap.selectedNodes) { - var node = getNodeFromId(i); - if (node) { - var feature = xxmap.markersSource.getFeatureById(i); - var v = ol.proj.transform(coords, 'EPSG:3857', 'EPSG:4326'); - var vx = [ v[1], v[0] ]; // Flip the coordinates around, lat/long - if (button == 2) { + function placeNodeEx(button, coords) { + var elements = document.getElementsByName("PlaceMapDeviceCheckbox"); + for (var i in elements) { + if (elements[i].checked) { + var node = getNodeFromId(elements[i].id.substring(0, elements[i].id.length - 8)); + if (node) { + var feature = xxmap.markersSource.getFeatureById(i); + var v = ol.proj.transform(coords, 'EPSG:3857', 'EPSG:4326'); + var vx = [ v[1], v[0] ]; // Flip the coordinates around, lat/long if (feature) { feature.getGeometry().setCoordinates(coords); var activeInteraction = getActiveInteractions(feature); @@ -2087,117 +2075,47 @@ meshserver.Send({ action: 'changedevice', nodeid: node._id, userloc: vx }); // This Node is not yet added to maps. } } - else if (button == 1) { //Dont send changes to server since its just 'place' - if (feature) { - feature.getGeometry().setCoordinates(coords); - modifyMarkerloc(feature); - } else { - //if (map_parseNodeLoc(node.iploc) != null) { - addFeature(node, v[0], v[1]); - var newFeature = xxmap.markersSource.getFeatureById(node._id); - modifyMarkerloc(newFeature); - //} - } - } } } } - // Close place node dialog - function closePNDialog(id){ - dialogclose(1); - switch (id) { - case 1: - Q('viewselect').options.selectedIndex = 0; - onDeviceViewChange(); - break; - case 2: - go(2); //Go to My Accounts tab - break; - } + // Called when the user changes the search box + function onPlaceNodeInputChange() { + updatePlaceNodeTable(Q('selectnode-search').value.trim().toLowerCase()); } - // On input search change in Place Node dialogue box - function onPNSearchInputChange() { - var inputSearchData = Q('selectnode-search').value; - QH('placenode', ''); - updatePlaceNodeTable(inputSearchData.trim().toLowerCase(), true); - } - - //Update the place Node Table - function updatePlaceNodeTable(inputSearch,searchFlag) { - var x = ''; - var count = 0; + // Update the list of devices in the "place on map" table + function updatePlaceNodeTable(inputSearch) { + var elements = document.getElementsByName("PlaceMapDeviceCheckbox"), count = 0; for (var i in nodes) { - if (nodes[i].mtype == 2) { - if ((nodes[i].name.toLowerCase().indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].hostl != undefined && nodes[i].hostl.toLowerCase().indexOf(inputSearch) >= 0)) { - count++; - x+=''; - x+=''; - x+=''; - x+=''; - } + var visible = ((nodes[i].namel.indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].hostl != undefined && nodes[i].hostl.indexOf(inputSearch) >= 0)); + if (visible) { count++; } + QV(nodes[i]._id + '-rowid', visible); + } + QV('noNodesMapPlace', count == 0); + /* + console.log(selected); + for (var i in nodes) { + if ((nodes[i].name.toLowerCase().indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].hostl != undefined && nodes[i].hostl.toLowerCase().indexOf(inputSearch) >= 0)) { + console.log(selected.indexOf(nodes[i]._id)); + x += '
= 0)?'checked':'') + ' />'; + x += '
' + nodes[i].name + '
'; } } - x+='
'+ nodes[i].name + '
'; - if (searchFlag) { //Flag is true when user searches for a Device using placeNode search input. - if (count == 0) { //If No Device name is found that matches the search - QH('placenode', '
No Nodes found with this Search Criteria.
'); } - else { - QH('placenode', x);} - }else { - if (count == 0) { return 0; } - else { return x; } - } + if (x == '') { x = '
No devices found.
'; } + QH('placenode', ''); + */ } - //On click-change the checkbox class and save selected Device - function selectNodetoplace(id){ - var imgeElement = Q(id + '-img'); - if (xxmap.selectedNodes[id]) { //If user clicks on already selected Device. - imgeElement.classList.remove('fa-check-square-o'); - imgeElement.classList.add('fa-square'); - delete xxmap.selectedNodes[id]; - checkSelectedNodes(); - } else { - imgeElement.classList.remove('fa-square'); - imgeElement.classList.add('fa-check-square-o'); - xxmap.selectedNodes[id] = { color: Q(id+'-rowid').style.backgroundColor}; - QE('idx_dlgPlaceandSave', true); - QE('idx_dlgPlaceButton', true); - } - } + // Called when a user clicks on a device to toggle selection for placement on map. + function selectNodeToPlace(e, id) { + // Toggle checkbox if needed + if (e.target.name != 'PlaceMapDeviceCheckbox') { var inputElement = Q(id + '-checkid'); inputElement.checked = !inputElement.checked; } - function checkSelectedNodes() { - var c = 0; - for (var i in xxmap.selectedNodes) { if (xxmap.selectedNodes[i]) { c++; } } - if (c == 0) { //If no nodes are checked then disable place and Save buttons - QE('idx_dlgPlaceandSave', false); - QE('idx_dlgPlaceButton', false); - } - } - - // Set selected node to null - function clearSelectedNode() { - xxmap.selectedNodes = {}; - QE('idx_dlgPlaceandSave', false); - QE('idx_dlgPlaceButton', false); - } - - // Change radio button on mouseover and out for 'select a node to place dialog' - function changeRadioImg(name) { - var index = name.indexOf("mouseout"); - var element = name.split('!#!'); - if (!xxmap.selectedNodes[element[0]]) { - var imgeElement= Q(element[0]+'-img'); - if (index > -1) { - imgeElement.classList.remove('fa-square'); - imgeElement.classList.add('fa-square-o'); - } else { - imgeElement.classList.remove('fa-square-o'); - imgeElement.classList.add('fa-square'); - } - } + // Check button state + var elements = document.getElementsByName("PlaceMapDeviceCheckbox"), checkcount = 0; + for (var i in elements) { if (elements[i].checked) checkcount++; } + QE('idx_dlgOkButton', checkcount > 0); } // Add option for available meshes in mesh Dropdown @@ -4537,16 +4455,12 @@ xxdialogFunc = f; xxdialogButtons = b; xxdialogTag = tag; - QE('idx_dlgPlaceandSave', false); - QE('idx_dlgPlaceButton', false); QE('idx_dlgOkButton', true); QV('idx_dlgOkButton', b & 1); QV('idx_dlgCancelButton', b & 2); QV('id_dialogclose', (b & 2) || (b & 8)); QV('idx_dlgDeleteButton', b & 4); QV('idx_dlgButtonBar', b & 7); - QV('idx_dlgPlaceButton', (b & 18) && (b%2 == 0)); - QV('idx_dlgPlaceandSave', (b & 18) && (b%2 == 0)); if (y) QH('id_dialogtitle', y); for (var i = 1; i < 24; i++) { QV('dialog' + i, i == x); } // Edit this line when more dialogs are added QV('dialog', x);