Skip to content

Commit

Permalink
Updates for new mappersession features; removed 'clear on load' dialo…
Browse files Browse the repository at this point in the history
…g since clearing all maps needs to be an explicit standalone action to avoid accidentally removing maps that belong to other users. With new mappersession features the 'unload' button will only unload the most recently-loaded session file rather than all active maps.
  • Loading branch information
malloch committed Jul 12, 2023
1 parent 61f3ebc commit 2fe3d94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
21 changes: 5 additions & 16 deletions js/SaverLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ class SaverLoader {
"<div id='sessionTitle' class='topMenuTitle half'><strong>SESSION</strong></div>"+
"<div class='topMenuContainer'>"+
"<div style='width:100%;height:30%'>"+
"<div id='loadButton' style='width:50%;display:inline-block'>Open</div>"+
"<div id='loadButton' style='width:50%;display:inline-block'>Load</div>"+
"<div id='saveButton' style='width:50%;display:inline-block'>Save</div>"+
"</div>"+
"<div style='padding:0px'>"+
"<button id='unloadFile' style='display:inline-block'>Clear</button>"+
"<button id='unloadFile' style='display:inline-block'>Unload</button>"+
"<p id='fileName' style='display:inline-block;float left;padding-left:10px'>No file loaded</p>"+
"</div>"+
"</div>"+
"</div>");
$('#unloadFile').on('click', function(e) {
e.stopPropagation();
command.send("clear");
command.send("unload", [$('#fileName').text()]);
$('#fileName').text("No file loaded");
});

Expand All @@ -43,19 +43,8 @@ class SaverLoader {
$('#fileName').text(data.name.replace(/\.[^/.]+$/, ""));
let sessionText = await data.text();
let parsed = tryParseJSON(sessionText);

$.confirm({
title: 'Clear active maps?',
content: '',
buttons: {
yes: function () {
command.send("load", [parsed, true]);
},
no: function () {
command.send("load", [parsed, false]);
}
}
});

command.send("load", [parsed, $('#fileName').text()]);
});

command.unregister("save_session");
Expand Down
14 changes: 8 additions & 6 deletions webmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ def set_sig_properties(props):
sig[key] = props[key]

def on_save(args):
sessionJson = session.save("", "", [], [])
global graph
sessionJson = session.save("", "", [], [], graph=graph)
server.send_command("save_session", sessionJson)

def start_monitor_sig(sig_name):
Expand All @@ -333,11 +334,12 @@ def stop_monitor_sig(args):
map.push()

def on_load(args):
print("Clear: ", args[1])
views = session.load_json(args[0], True, args[1])
global graph
views = session.load_json(args[0], args[1], graph=graph)

def on_clear(args):
session.clear()
def on_unload(args):
global graph
session.unload(args[0], graph=graph)

# Returns a readable network interface name from a win32 guid
def win32_get_name_from_guid(iface_guid):
Expand Down Expand Up @@ -499,7 +501,7 @@ def poll_and_push():

server.add_command_handler("save", on_save)
server.add_command_handler("load", on_load)
server.add_command_handler("clear", on_clear)
server.add_command_handler("unload", on_unload)

server.add_command_handler("select_interface", select_interface)
server.add_command_handler("get_interfaces", get_interfaces)
Expand Down

0 comments on commit 2fe3d94

Please sign in to comment.