1
0
Fork 0
mirror of https://github.com/Ylianst/MeshCentral.git synced 2025-03-09 15:40:18 +00:00

Fixed the PlaceNode issue and added fontAwesome css folder

1)Fixed the PlaceNode issue.
2)Added fontAwesome css folder (public/styles/font-awesome)
3)Added come css stlying for placeNode table in style.css
This commit is contained in:
Ganeshr93 2017-09-29 14:20:08 -07:00
parent 646bc67365
commit cba77d2e55
38 changed files with 8798 additions and 86 deletions

View file

@ -9,6 +9,7 @@
<link type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
<link type="text/css" href="styles/ol.css" media="screen" rel="stylesheet" title="CSS" />
<link type="text/css" href="styles/ol3-contextmenu.min.css" media="screen" rel="stylesheet" title="CSS" />
<link type="text/css" href="styles/font-awesome/css/font-awesome.css" media="screen" rel="stylesheet" title="CSS" />
<script type="text/javascript" src="scripts/common-0.0.1.js"></script>
<script type="text/javascript" src="scripts/meshcentral.js"></script>
<script type="text/javascript" src="scripts/amt-0.2.0.js"></script>
@ -488,7 +489,7 @@
</div>
<br id="column_l_bottomgap" />
</div>
<div id=footer class=noselect>
<div id=footer class=noselect>
<table cellpadding=0 cellspacing=10 style="width:100%">
<tr>
<td style="text-align:left"></td>
@ -585,6 +586,8 @@
<div id="idx_dlgButtonBar" style="padding:10px;margin-bottom:4px">
<input id="idx_dlgCancelButton" type="button" value="Cancel" style="float:right;width:80px;margin-left:5px" onclick="dialogclose(0)">
<input id="idx_dlgOkButton" type="button" value="OK" style="float:right;width:80px" onclick="dialogclose(1)">
<input id="idx_dlgPlaceandSave" type="button" value="Place & Save" style="float:right;margin-left:5px;" onclick="dialogclose(2)" disabled="disabled">
<input id="idx_dlgPlaceButton" type="button" value="Place" style="float:right;width:50px" onclick="dialogclose(1)" disabled="disabled" />
<div style="height:25px"><input id=idx_dlgDeleteButton type=button value=Delete style="width:80px;display:none" onclick="dialogclose(2)"></div>
</div>
</div>
@ -711,33 +714,33 @@
function updateSiteAdmin() {
var noServerBackup = {{{noServerBackup}}};
var siteRights = userinfo.siteadmin;
if (noServerBackup == 1) { siteRights &= 0xFFFFFFFA; } // If not server backups allowed, remove server backup and restore permissions
var siteRights = userinfo.siteadmin;
if (noServerBackup == 1) { siteRights &= 0xFFFFFFFA; } // If not server backups allowed, remove server backup and restore permissions
// Update account actions
QV('p2AccountActions', (features & 4) == 0); // Hide Account Actions if in single user mode
QV('p2ServerActions', siteRights & 5);
QV('p2ServerActionsBackup', siteRights & 1);
QV('p2ServerActionsRestore', siteRights & 4);
QV('p2ServerActionsVersion', siteRights & 16);
QV('MainMenuMyFiles', siteRights & 8);
if (((siteRights & 8) == 0) && (xxcurrentView == 5)) { go(1); }
// Update account actions
QV('p2AccountActions', (features & 4) == 0); // Hide Account Actions if in single user mode
QV('p2ServerActions', siteRights & 5);
QV('p2ServerActionsBackup', siteRights & 1);
QV('p2ServerActionsRestore', siteRights & 4);
QV('p2ServerActionsVersion', siteRights & 16);
QV('MainMenuMyFiles', siteRights & 8);
if (((siteRights & 8) == 0) && (xxcurrentView == 5)) { go(1); }
// Update user management state
if ((userinfo.siteadmin & 2) != 0)
{
// We are user administrator
if (users == null) { meshserver.Send({ action: 'users' }); }
if (wssessions == null) { meshserver.Send({ action: 'wssessioncount' }); }
} else {
// We are not user administrator
users = null;
wssessions = null;
updateUsers();
if (xxcurrentView == 4) go(1);
}
meshserver.Send({ action: 'events' });
QV('p2deleteall', userinfo.siteadmin == 0xFFFFFFFF);
// Update user management state
if ((userinfo.siteadmin & 2) != 0)
{
// We are user administrator
if (users == null) { meshserver.Send({ action: 'users' }); }
if (wssessions == null) { meshserver.Send({ action: 'wssessioncount' }); }
} else {
// We are not user administrator
users = null;
wssessions = null;
updateUsers();
if (xxcurrentView == 4) go(1);
}
meshserver.Send({ action: 'events' });
QV('p2deleteall', userinfo.siteadmin == 0xFFFFFFFF);
}
function onMessage(server, message) {
@ -820,7 +823,7 @@
if (message.nodeid != undefined) { n.nodeid = message.nodeid; }
if (message.tag != undefined) { n.tag = message.tag; }
addNotification(n);
}
}
}
}
break;
@ -1196,6 +1199,7 @@
QV('devMapToolbar', view == 3);
QV('devListToolbarSort', view < 3);
if (view == 3) {
QV('NoNodesPanel',false); //Hide NoNodesPanel user views Map
setTimeout( function() { if (xxmap.map != null) { xxmap.map.updateSize(); } }, 200);
// TODO
} else {
@ -1680,7 +1684,7 @@
var boundingBox = null;
for (var i in nodes) {
var loc = map_parseNodeLoc(nodes[i]);
var feature = xxmap.markersSource.getFeatureById(nodes[i]._id); // Remove if present
var feature = xxmap.markersSource.getFeatureById(nodes[i]._id);
if ((loc != null) && ((nodes[i].meshid == selectedMesh) || (selectedMesh == undefined))) { // Draw markers for devices with locations
lat = loc[0];
lon = loc[1];
@ -1721,7 +1725,7 @@
// Context menu for clicks other than on feature
var contextmenu_items = [
{ text: 'Refresh', callback: function () { refreshMap(false, true); } },
{ 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); } }
@ -1820,7 +1824,7 @@
defaultItems: false, // defaultItems are Zoom In/Zoom Out
items: contextmenu_items
});
// On right click open the context menu
contextmenu.on("open", function (evt) {
var feature = xxmap.map.forEachFeatureAtPixel(evt.pixel, function(ft, l){ return ft; });
@ -2045,31 +2049,19 @@
function placeNode(coords) {
if (xxdialogMode) return;
clearSelectedNode();
var x = '<div style="float: left; margin-bottom: 6px"><label for="selectnode-search">Search</label>&nbsp&nbsp<input type="text" placeholder="Device Name" id="selectnode-search" onchange="onPNSearchInputChange()" onkeyup="onPNSearchInputChange()" autocomplete="off" style="width: 120px"></div>';
var selectMeshElement = Q("select-mesh");
var selectedIndex = selectMeshElement.selectedIndex;
var selectedMeshValue = 'all';
if (selectedIndex != 0) {
x += '<div class="selectedmesh"> Mesh: ' + selectMeshElement[selectedIndex].text + '</div>';
selectedMeshValue=selectMeshElement[selectedIndex].value;
}
x += '<div id="placenode" style="max-height:258px;overflow-y:auto;width:100%;">';
var x = '<div style="margin-bottom: 6px"><label for="selectnode-search">Search</label>&nbsp&nbsp<input type="text" placeholder="Device Name" id="selectnode-search" onchange="onPNSearchInputChange()" onkeyup="onPNSearchInputChange()" autocomplete="off" style="width: 120px"></div>';
x += '<div id="placenode" style="max-height:258px;overflow-y:auto;width:100%;margin: 12px 1px 4px 1px;">';
var count = 0;
var table = updatePlaceNodeTable('', selectedIndex, selectedMeshValue);
var table = updatePlaceNodeTable('', false);
if (table != 0) { x += table; count = 1; x += '</div>'; } else { count = 0;}
if (count == 0) {
if (selectedIndex != 0) {
var noMeshNodes='<div class="flexboxdiv"><div style="margin-right:10px"><i class="fa fa-info-circle fa-3x" style="color:green" aria-hidden="true"></i></div><div style="max-width: 300px">No nodes found in Mesh '+ selectMeshElement[selectedIndex].text + '. Go to mesh <a onclick="closePNDialog(\''+selectMeshElement[selectedIndex].value+'\')" style="cursor:pointer">'+ selectMeshElement[selectedIndex].text +'</a> in My Account page to add a node.</div></div>';
setDialogMode(2, "Select a Node to place marker", 1, null, noMeshNodes, null);
var noNodesFound = '';
if (!meshExists()) {
noNodesFound = '<div class="flexboxdiv"><div style="margin-right:10px"><i class="fa fa-info-circle fa-3x" style="color:green" aria-hidden="true"></i></div><div style="max-width: 300px"> No nodes found. To create a mesh network and add devices, go to <a onclick="closePNDialog(2)" style="cursor:pointer">My Account</a> page.</div></div>';
} else {
var noNodesFound = '';
if (!meshExists()) {
noNodesFound = '<div class="flexboxdiv"><div style="margin-right:10px"><i class="fa fa-info-circle fa-3x" style="color:green" aria-hidden="true"></i></div><div style="max-width: 300px"> No nodes found. To create a mesh network and add devices, go to <a onclick="closePNDialog(2)" style="cursor:pointer">My Account</a> page.</div></div>';
} else {
noNodesFound = '<div class="flexboxdiv"><div style="margin-right:10px"><i class="fa fa-info-circle fa-3x" style="color:green" aria-hidden="true"></i></div><div style="max-width: 300px"> No nodes found. To add devices, go to <a onclick="closePNDialog(1)" style="cursor:pointer">My Devices</a> page.</div></div>';
}
setDialogMode(2, "Select a Node to place marker", 1, null, noNodesFound, null);
noNodesFound = '<div class="flexboxdiv"><div style="margin-right:10px"><i class="fa fa-info-circle fa-3x" style="color:green" aria-hidden="true"></i></div><div style="max-width: 300px"> No nodes found. To add devices, go to <a onclick="closePNDialog(1)" style="cursor:pointer">My Devices</a> page.</div></div>';
}
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);
}
@ -2079,7 +2071,7 @@
for (var i in xxmap.selectedNodes) {
var node = getNodeFromId(i);
if (node) {
var feature = markersSource.getFeatureById(i);
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) {
@ -2088,22 +2080,22 @@
var activeInteraction = getActiveInteractions(feature);
if (activeInteraction) {
saveMarkerloc(feature);
} else { // If this feature is not modified, then send updated coords to server.
meshserver.Send({ action: 'changedevice', nodeid: node._id, value: vx }); // Send them to server to save changes
} else { // If this feature is not saved after its location is changed, then send updated coords to server.
meshserver.Send({ action: 'changedevice', nodeid: node._id, userloc: vx }); // Send them to server to save changes
}
} else {
meshserver.Send({ action: 'changedevice', nodeid: node._id, value: vx }); // This Node is not yet added to maps.
meshserver.Send({ action: 'changedevice', nodeid: node._id, userloc: vx }); // This Node is not yet added to maps.
}
}
else if (button == 1) {
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 = markersSource.getFeatureById(node._id);
modifyMarkerloc(newFeature);
addFeature(node, v[0], v[1]);
var newFeature = xxmap.markersSource.getFeatureById(node._id);
modifyMarkerloc(newFeature);
//}
}
}
@ -2116,58 +2108,57 @@
dialogclose(1);
switch (id) {
case 1:
Q("showselect")[0].selected = true;
onShowSelectChange();
go(1);
Q('viewselect').options.selectedIndex = 0;
onDeviceViewChange();
break;
case 2:
go(2);
go(2); //Go to My Accounts tab
break;
default:
gotoMesh(id);
}
}
// On input search change
// On input search change in Place Node dialogue box
function onPNSearchInputChange() {
var inputSearchData = Q('selectnode-search').value;
QH('placenode', '');
var inputSearchData = Q('selectnode-search').value.toLowerCase();
var selectMeshElement=Q("select-mesh");
var selectedIndex = selectMeshElement.selectedIndex;
var selectedMeshValue=selectMeshElement[selectedIndex].value;
updatePlaceNodeTable(inputSearchData, selectedIndex, selectedMeshValue, 1);
updatePlaceNodeTable(inputSearchData.trim().toLowerCase(), true);
}
function updatePlaceNodeTable(inputSearch, selectedIndex, selectedMeshValue, innerHtmlflag) {
var x = '<table id="placenode-table" class="selectnode-table"><tbody>';
//Update the place Node Table
function updatePlaceNodeTable(inputSearch,searchFlag) {
var x = '<table class="map-PlaceDeviceMarker" style="width: 100%"><tbody>';
var count = 0;
for (var i in nodes) {
if (nodes[i].mtype == 2) {
if ((nodes[i].meshid == selectedMeshValue || selectedIndex == 0) && ((nodes[i].name.toLowerCase().indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].hostl != undefined && nodes[i].hostl.toLowerCase().indexOf(inputSearch) >= 0))) {
if ((nodes[i].name.toLowerCase().indexOf(inputSearch) >= 0 || inputSearch == '') || (nodes[i].hostl != undefined && nodes[i].hostl.toLowerCase().indexOf(inputSearch) >= 0)) {
count++;
x+='<tr id="'+ nodes[i]._id +'-rowid" onclick=selectNodetoplace(\''+ nodes[i]._id +'\') onmouseover="changeRadioImg(\''+ nodes[i]._id +'!#!mouseover'+ '\')" onmouseout="changeRadioImg(\''+ nodes[i]._id +'!#!mouseout'+ '\')">';
x+='<td style="width: 30px; border-radius: 4px; text-align: center;"><i class="fa fa-square-o fa-lg selectnode-checkbox " id="'+ nodes[i]._id +'-img' +'" style="border-color: #7CFC00;" aria-hidden="true"></i></td>';
x+='<td class="selectnode-td">'+ nodes[i].name + '</td>';
x+='<tr style="height:35px; text-align: center;cursor: pointer;" id="'+ nodes[i]._id +'-rowid" onclick=selectNodetoplace(\''+ nodes[i]._id +'\') onmouseover="changeRadioImg(\''+ nodes[i]._id +'!#!mouseover'+ '\')" onmouseout="changeRadioImg(\''+ nodes[i]._id +'!#!mouseout'+ '\')">';
x+='<td style="width:55px"><i class="fa fa-square-o fa-lg" style="color:#003800" id="'+ nodes[i]._id +'-img' +'" style="border-color: #7CFC00;" aria-hidden="true"></i></td>';
x+='<td style="font-weight: bold; font-size: 11pt;">'+ nodes[i].name + '</td>';
x+='</tr>';
}
}
}
x+='</tbody></table>';
if (innerHtmlflag) {
if (count == 0) { QH('placenode', '<div class="flexboxdiv"><div style="margin: 0px 10px 0px 4px"><i class="fa fa-exclamation-circle fa-2x" style="color:red" aria-hidden="true"></i></div><div style="max-width: 300px"><b>No Nodes found with this Search Criteria.</b></div></div>'); } else { QH('placenode', x);}
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', '<div class="flexboxdiv"><div style="margin: 0px 10px 0px 4px"><i class="fa fa-exclamation-circle fa-2x" style="color:red" aria-hidden="true"></i></div><div style="max-width: 300px"><b>No Nodes found with this Search Criteria.</b></div></div>'); }
else {
QH('placenode', x);}
}else {
if (count == 0) { return 0; }
else { return x; }
}
}
}
//On click-change the checkbox class and save selected Device
function selectNodetoplace(id){
var imgeElement = Q(id + '-img');
if (xxmap.selectedNodes[id]) {
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];
CheckedNodesforPN();
checkSelectedNodes();
} else {
imgeElement.classList.remove('fa-square');
imgeElement.classList.add('fa-check-square-o');
@ -2177,10 +2168,10 @@
}
}
function CheckedNodesforPN() {
function checkSelectedNodes() {
var c = 0;
for (var i in xxmap.selectedNodes) { if (xxmap.selectedNodes[i]) { c++; } }
if (c == 0) {
if (c == 0) { //If no nodes are checked then disable place and Save buttons
QE('idx_dlgPlaceandSave', false);
QE('idx_dlgPlaceButton', false);
}
@ -2378,7 +2369,7 @@
var nname = EscapeHtml(node.name);
if (nname.length == 0) { nname = '<i>None</i>'; }
if ((meshrights & 4) != 0) { nname = '<span onclick=showEditNodeValueDialog(0) style=cursor:pointer>' + nname + '</span>'; }
QH('p10deviceName', nname);
QH('p10deviceName', nname);
QH('p11deviceName', nname);
QH('p12deviceName', nname);
QH('p13deviceName', nname);
@ -3182,7 +3173,7 @@
p13updateFiles();
}
}
function p13getCheckedNames() {
// Save all existing checked boxes
var checkedNames = [], checkboxes = document.getElementsByName('fd');
@ -3545,7 +3536,7 @@
QE('p15uploadCore', online);
} else {
QH('p15statetext', 'Access Denied');
QE('p15consoleText', false);
QE('p15consoleText', false);
QE('p15uploadCore', false);
}
@ -4546,12 +4537,16 @@
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);