Disable "Upload to SD" ui elements while printing

As suggested by @ntoff in #1914
This commit is contained in:
Gina Häußge 2017-05-15 15:21:36 +02:00
parent 7795320fc8
commit 9ad180c02a
3 changed files with 8 additions and 7 deletions

View file

@ -841,13 +841,14 @@ $(function() {
function evaluateDropzones() {
var enableLocal = self.loginState.isUser();
var enableSd = enableLocal && CONFIG_SD_SUPPORT && self.printerState.isSdReady();
var enableSd = enableLocal && CONFIG_SD_SUPPORT && self.printerState.isSdReady() && !self.isPrinting();
self._setDropzone("local", enableLocal);
self._setDropzone("sdcard", enableSd);
}
self.loginState.isUser.subscribe(evaluateDropzones);
self.printerState.isSdReady.subscribe(evaluateDropzones);
self.isPrinting.subscribe(evaluateDropzones);
evaluateDropzones();
self.requestData();
@ -1106,7 +1107,7 @@ $(function() {
if (foundLocal) {
self.dropZoneLocalBackground.addClass("hover");
self.dropZoneSdBackground.removeClass("hover");
} else if (foundSd && self.printerState.isSdReady()) {
} else if (foundSd && self.printerState.isSdReady() && !self.isPrinting()) {
self.dropZoneSdBackground.addClass("hover");
self.dropZoneLocalBackground.removeClass("hover");
} else if (found) {

View file

@ -4,7 +4,7 @@
{% if enableSdSupport %}
<div class="dropzone" id="drop_locally"><span class="text"><i class="icon-upload-alt"></i><br>{{ _('Upload locally') }}</span></div>
<div class="dropzone_background" id="drop_locally_background"></div>
<div class="dropzone" id="drop_sd"><span class="text"><i class="icon-upload-alt"></i><br>{{ _('Upload to SD') }}<br><small data-bind="visible: !isSdReady()">({{ _('SD not initialized') }})</small></span></div>
<div class="dropzone" id="drop_sd"><span class="text"><i class="icon-upload-alt"></i><br>{{ _('Upload to SD') }}<br><small data-bind="visible: isSdReady() && isPrinting()">({{ _('Cannot upload to printer\'s SD while printing') }})</small><small data-bind="visible: !isSdReady()">({{ _('SD not initialized') }})</small></span></div>
<div class="dropzone_background" id="drop_sd_background"></div>
{% else %}
<div class="dropzone" id="drop"><span class="text"><i class="icon-upload-alt"></i><br>{{ _('Upload') }}</span></div>

View file

@ -55,18 +55,18 @@
</div>
<div class="row-fluid upload-buttons">
{% if enableSdSupport %}
<span class="btn btn-primary fileinput-button span6" data-bind="css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
<span class="btn btn-primary fileinput-button span6" data-bind="enable: $root.loginState.isUser(), css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
<i class="icon-upload-alt icon-white"></i>
<span>{{ _('Upload') }}</span>
<input id="gcode_upload" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button" data-bind="enable: loginState.isUser()">
</span>
<span class="btn btn-primary fileinput-button span6" data-bind="css: {disabled: !$root.loginState.isUser() || !$root.isSdReady()}" style="margin-bottom: 10px">
<span class="btn btn-primary fileinput-button span6" data-bind="enable: $root.loginState.isUser() && $root.isSdReady() && !$root.isPrinting(), css: {disabled: !$root.loginState.isUser() || !$root.isSdReady() || $root.isPrinting()}" style="margin-bottom: 10px">
<i class="icon-upload-alt icon-white"></i>
<span>{{ _('Upload to SD') }}</span>
<input id="gcode_upload_sd" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button" data-bind="enable: loginState.isUser() && isSdReady()">
<input id="gcode_upload_sd" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button" data-bind="enable: loginState.isUser() && isSdReady() && !isPrinting()">
</span>
{% else %}
<span class="btn btn-primary fileinput-button span12" data-bind="css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
<span class="btn btn-primary fileinput-button span12" data-bind="enable: $root.loginState.isUser(), css: {disabled: !$root.loginState.isUser()}" style="margin-bottom: 10px">
<i class="icon-upload-alt icon-white"></i>
<span>{{ _('Upload') }}</span>
<input id="gcode_upload" accept="{{ ",".join(supportedExtensions) }}" type="file" name="file" class="fileinput-button" data-bind="enable: loginState.isUser()">