code cleanup. fixed drag n drop of svgs. fixed gcode file list entries

This commit is contained in:
Teja 2015-07-17 09:56:36 +02:00
parent 1f2f29336e
commit 9460f78d12
7 changed files with 32 additions and 82 deletions

View file

@ -1621,7 +1621,8 @@ input.search-query,
}
#wa_filelist .file_list_entry .title {
max-width: 80%;
/*float: left;*/
text-overflow: ellipsis;
overflow: hidden;
}
#wa_filelist .file_list_entry .detail_information {
clear: both;

View file

@ -507,7 +507,7 @@ $(function() {
sb += "Radius to end of arc differs from radius to start:\n";
sb += "r1=" + radius + "\n";
sb += "r2=" + r2 + "\n";
console.error("gcode_parser.js convertG2G3", sb);
console.warn("gcode_parser.js convertG2G3", sb);
}
// this is the real line calculation.

View file

@ -63,7 +63,7 @@ Snap.plugin(function (Snap, Element, Paper, global) {
var path_elem = elem.convertToPath();
if (!path_elem || path_elem.attr('d') === '' || path_elem.attr('d') === null)
return;
path_elem.attr('d', 'M 0 0');
// Rounding coordinates to dec decimals
if (dec || dec === 0) {

View file

@ -635,6 +635,10 @@ $(function(){
}
});
};
self.onBeforeBinding = function(){
self.files.workingArea = self;
};
}

View file

@ -108,52 +108,6 @@ $(function() {
alwaysVisible: true,
scrollBy: "102px"
});
//
// //~~ Gcode upload
//
// function gcode_upload_done(e, data) {
// var filename = undefined;
// var location = undefined;
// if (data.result.files.hasOwnProperty("sdcard")) {
// filename = data.result.files.sdcard.name;
// location = "sdcard";
// } else if (data.result.files.hasOwnProperty("local")) {
// filename = data.result.files.local.name;
// location = "local";
// }
// gcodeFilesViewModel.requestData(filename, location);
//=======
//<<<<<<< HEAD
//
// if(data.result.files.hasOwnProperty("local")){
// var f = data.result.files.local;
// if(_.endsWith(filename.toLowerCase(), ".svg")){
// f.type = "model"
// viewModelMap['workingAreaViewModel'].placeSVG(f);
// }
// if(_.endsWith(filename.toLowerCase(), ".gco")){
// f.type = "machinecode"
// viewModelMap['workingAreaViewModel'].placeGcode(f);
// }
// }
// }
//
// function gcode_upload_fail(e, data) {
// var error = "<p>" + gettext("Could not upload the file. Make sure that it is a SVG file and has the extension \".svg\" or a GCode file and has extension \".gco\" or \".gcode\" ") + "</p>";
// error += pnotifyAdditionalInfo("<pre>" + data.jqXHR.responseText + "</pre>");
// new PNotify({
// title: "Upload failed",
// text: error,
// type: "error",
// hide: false
// });
// $("#gcode_upload_progress .bar").css("width", "0%");
// $("#gcode_upload_progress").removeClass("progress-striped").removeClass("active");
// $("#gcode_upload_progress .bar").text("");
// }
//=======
// map any additional view model bindings we might need to make
var additionalBindings = {};
@ -245,17 +199,6 @@ $(function() {
}
log.info("... dependency resolution done");
//<<<<<<< HEAD
// window.dropZoneTimeout = setTimeout(function () {
// window.dropZoneTimeout = null;
// dropOverlay.removeClass("in");
// if (dropZoneLocal) dropZoneLocalBackground.removeClass("hover");
// if (dropZoneSd) dropZoneSdBackground.removeClass("hover");
// if (dropZone) dropZoneBackground.removeClass("hover");
// }, 1000);
// });
//=======
//>>>>>>> upstream/maintenance
var dataUpdater = new DataUpdater(allViewModels);
@ -459,17 +402,6 @@ $(function() {
});
//<<<<<<< HEAD
// if (printerStateViewModel.isSdReady() && loginStateViewModel.isUser()) {
// enable_sd_dropzone();
// } else {
// disable_sd_dropzone();
// }
// }
//
//=======
// prevent default action for drag-n-drop
$(document).bind("drop dragover", function (e) {
e.preventDefault();

View file

@ -7,6 +7,8 @@ $(function() {
self.loginState = parameters[1];
self.slicing = parameters[2];
self.workingArea = undefined; // will be injected by the working area
self.isErrorOrClosed = ko.observable(undefined);
self.isOperational = ko.observable(undefined);
self.isPrinting = ko.observable(undefined);
@ -383,18 +385,29 @@ $(function() {
//~~ Gcode upload
self.uploadButton = $("#gcode_upload");
self.uploadButton = $("#gcode_upload");
function gcode_upload_done(e, data) {
var filename = undefined;
var location = undefined;
if (data.result.files.hasOwnProperty("sdcard")) {
filename = data.result.files.sdcard.name;
location = "sdcard";
} else if (data.result.files.hasOwnProperty("local")) {
// if (data.result.files.hasOwnProperty("sdcard")) {
// filename = data.result.files.sdcard.name;
// location = "sdcard";
// } else if (data.result.files.hasOwnProperty("local")) {
if(data.result.files.hasOwnProperty("local")){
filename = data.result.files.local.name;
location = "local";
}
self.requestData(filename, location);
var f = data.result.files.local;
if(_.endsWith(filename.toLowerCase(), ".svg")){
f.type = "model"
self.workingArea.placeSVG(f);
}
if(_.endsWith(filename.toLowerCase(), ".gco")){
f.type = "machinecode"
self.workingArea.placeGcode(f);
}
}
self.requestData(filename, location);
if (_.endsWith(filename.toLowerCase(), ".stl")) {
self.slicing.show(location, filename);
}
@ -406,9 +419,8 @@ $(function() {
}
}
function gcode_upload_fail(e, data) {
var error = "<p>" + gettext("Could not upload the file. Make sure that it is a GCODE file and has the extension \".gcode\" or \".gco\" or that it is an STL file with the extension \".stl\".") + "</p>";
var error = "<p>" + gettext("Could not upload the file. Make sure that it is a SVG file and has the extension \".svg\" or a GCode file and has extension \".gco\" or \".gcode\" ") + "</p>";
error += pnotifyAdditionalInfo("<pre>" + data.jqXHR.responseText + "</pre>");
new PNotify({
title: "Upload failed",
@ -574,7 +586,7 @@ $(function() {
if (dropZoneLocal) dropZoneLocalBackground.removeClass("hover");
if (dropZoneSd) dropZoneSdBackground.removeClass("hover");
if (dropZone) dropZoneBackground.removeClass("hover");
}, 100);
}, 1000);
});
self.requestData();

View file

@ -188,10 +188,11 @@
<script type="text/html" id="wa_template_machinecode">
<div class="file_list_entry">
<div class="title muted" data-bind="text: name" style="color:#ADADAD;"></div>
<div class="title muted pull-left" data-bind="text: name"></div>
<div class="btn-group action-buttons pull-right">
<div class="btn btn-mini" data-bind="click: function(){ $root.removeGcode($data); }"><i class="icon-remove" title="{{ _('Remove') }}"></i></div>
</div>
<div class="detail_information" ></div>
</div>
</script>