Skip to content

Commit 2134426

Browse files
jgosmanntcstewar
authored andcommitted
Add an indicator for failed save.
Addresses #785.
1 parent 47b7daf commit 2134426

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

nengo_gui/components/ace_editor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ def message(self, msg):
8686
try:
8787
with open(self.page.filename, 'w') as f:
8888
f.write(self.current_code)
89+
self.pending_messages.append(json.dumps({
90+
'save_success': True}))
8991
except IOError:
9092
print("Could not save %s; permission denied" %
9193
self.page.filename)

nengo_gui/static/ace.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Nengo.Ace.prototype.save_file = function () {
171171
var editor_code = this.editor.getValue();
172172
this.ws.send(JSON.stringify({code:editor_code, save:true}));
173173
this.disable_save();
174+
$('#Save_file').addClass('in-progress');
174175
}
175176
}
176177

@@ -184,7 +185,11 @@ Nengo.Ace.prototype.disable_save = function () {
184185

185186
Nengo.Ace.prototype.on_message = function (event) {
186187
var msg = JSON.parse(event.data)
187-
if (msg.code !== undefined) {
188+
if (msg.save_success !== undefined) {
189+
if (msg.save_success) {
190+
$('#Save_file').removeClass('in-progress');
191+
}
192+
} else if (msg.code !== undefined) {
188193
this.editor.setValue(msg.code);
189194
this.current_code = msg.code;
190195
this.editor.gotoLine(1);

nengo_gui/static/top_toolbar.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@
6969
background: #eee;
7070
}
7171

72+
#top_toolbar_div li.in-progress a.glyphicon {
73+
color: #ccc;
74+
background: #c22;
75+
}
76+
7277
#global_config_menu {
7378
background: purple;
7479
height: 20em;

0 commit comments

Comments
 (0)