|
33 | 33 | text-transform: uppercase; |
34 | 34 | } |
35 | 35 |
|
36 | | - #fileURL{ |
| 36 | + #fileId{ |
37 | 37 | width: 350px; |
38 | 38 | } |
39 | 39 |
|
|
95 | 95 | margin-bottom: 0px; |
96 | 96 | } |
97 | 97 |
|
| 98 | + .footer-action |
| 99 | + { |
| 100 | + border-top: 1px solid #e5e5e5; |
| 101 | + padding: 18px 0; |
| 102 | + } |
| 103 | + |
| 104 | + .form-group |
| 105 | + { |
| 106 | + margin-bottom: 19px; |
| 107 | + } |
| 108 | + |
98 | 109 | </style> |
99 | 110 | </head> |
100 | 111 |
|
|
106 | 117 | <div class="sample-title">Create a 3D print job</div> |
107 | 118 | <hr> |
108 | 119 | <section class="form_field pull-left"> |
109 | | - <label for="fileURL"> |
| 120 | + <label for="fileId"> |
110 | 121 | Choose file to print <span class="field-label"> / printable_id</span><i class="required"></i> |
111 | 122 | <i class="spark_icon si-help with_hover"></i> |
112 | | - <i class="stooltip"><span style="display: none;width:400px;">Enter the URL of a printable 3D file, the Spark ID of a printable 3D file or browse to locate one on your desktop. Printable files can be STL, OBJ or BLT 3D files, or a printable file created by Spark.</span></i> |
| 123 | + <i class="stooltip"><span style="display: none;width:400px;">Enter the Spark ID of a printable 3D file or browse to select an existing file. Printable files can be gcode files, or a printable file created by Spark.</span></i> |
113 | 124 | </label> |
114 | 125 | <div class="clearfix"></div> |
115 | 126 | <!--<input type="text" class="form-control" id="fileURL" placeholder="File URL" required value="http://cdn.spark.com/print/abcefg">--> |
116 | 127 | <div class="pull-left"> |
117 | | - <input type="text" class="form-control" id="fileURL" placeholder="Enter file URL" required> |
| 128 | + <input type="text" class="form-control" id="fileId" placeholder="Enter printable file id" required> |
118 | 129 | <div class="field_error hidden"> |
119 | 130 | <span>Required</span> |
120 | 131 | </div> |
121 | 132 | </div> |
122 | | - <div class="pull-left or-browse">OR</div><a class="spark_btn empty browse_btn pull-left" href="#" onclick="eventBroadCaster.broadcastEvent('printIframe.chooseAsset')"><i class="spark_print_icon print-si-browse"></i><span>Browse...</span></a> |
| 133 | + <div class="pull-left or-browse">OR</div><a class="spark_btn empty browse_btn pull-left" href="#" onclick="eventBroadCaster.broadcastEvent('printIframe.chooseFile')"><i class="spark_print_icon print-si-browse"></i><span>Browse...</span></a> |
123 | 134 | </section> |
124 | 135 | <div class="spacer clearfix"></div> |
125 | 136 | <section class="form_field"> |
|
147 | 158 | </div> |
148 | 159 | <input type="hidden" id="assetId"> |
149 | 160 | </div> |
150 | | - <div class="pull-right"> |
151 | | - <input class="spark_btn primary" type="submit" value="Print and continue" id="print"> |
| 161 | + <div class="footer-action "> |
| 162 | + <input class="spark_btn primary pull-right" type="submit" value="Print and continue" id="print"> |
152 | 163 | </div> |
153 | 164 | </form> |
154 | 165 |
|
|
158 | 169 | <div class="modal-content"> |
159 | 170 | <div class="modal-header"> |
160 | 171 | <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
161 | | - <h4>WARNING</h4> |
| 172 | + <h4>ERROR</h4> |
162 | 173 | </div> |
163 | 174 | <div class="modal-body"> |
164 | | - An error occurred. |
| 175 | + |
165 | 176 | </div> |
166 | 177 | <div class="modal-footer"> |
167 | 178 | <a class="spark_btn small cancel" type="button">Close</a> |
@@ -207,7 +218,8 @@ <h4>WARNING</h4> |
207 | 218 | var urlParams = spark.util.extractParamsFromURL(); |
208 | 219 | currentFileId = urlParams['fileId'] ? urlParams['fileId'] : ""; |
209 | 220 | if (currentFileId != "") { |
210 | | - $("#fileURL").val(currentFileId); |
| 221 | + //sending a printable id from the tray since currently there is a bug and we cant print files from the drive |
| 222 | + $("#fileId").val("17223875"); |
211 | 223 | } |
212 | 224 |
|
213 | 225 | var getAllPrinters = function(){ |
@@ -237,19 +249,27 @@ <h4>WARNING</h4> |
237 | 249 |
|
238 | 250 | $("#print-job-form").on('submit', function (e) { |
239 | 251 | e.preventDefault(); |
240 | | - if (common.validateInput($('#fileURL')) && common.validateInput($('#printers-select'))) { |
| 252 | + if (common.validateInput($('#fileId')) && common.validateInput($('#printers-select'))) { |
241 | 253 |
|
242 | | - var fileUrl = $('#fileURL').val(); |
| 254 | + var fileId = $('#fileId').val(); |
243 | 255 | var printerId = $('#printers-select option:selected').val(); |
244 | | - var settings = JSON.parse($('#printer-settings').val()); |
245 | | - |
246 | | - sparkPrint.printJob(fileUrl, printerId, settings, function (response) { |
247 | | - var printerId = response.printer_id; |
248 | | - eventBroadCaster.broadcastEvent('printIframe.jobExist'); |
249 | | - }, |
250 | | - function (response) { |
251 | | - $('#myModal').modal('show'); |
252 | | - }); |
| 256 | + |
| 257 | + try{ |
| 258 | + var settings = JSON.parse($('#printer-settings').val()); |
| 259 | + sparkPrint.printJob(fileId, printerId, settings, function (response) { |
| 260 | + var printerId = response.printer_id; |
| 261 | + eventBroadCaster.broadcastEvent('printIframe.jobExist'); |
| 262 | + }, |
| 263 | + function (response) { |
| 264 | + var res = JSON.parse(response); |
| 265 | + var message = res.message != undefined && res.message != "" ? res.message : "An error occurred."; |
| 266 | + $('#myModal').find(".modal-body").html("<span>" + message + "</span>"); |
| 267 | + $('#myModal').modal('show'); |
| 268 | + }); |
| 269 | + }catch(e){ |
| 270 | + $('#myModal').find(".modal-body").html("<span>The Settings parameter must be in JSON format!</span>"); |
| 271 | + $('#myModal').modal('show'); |
| 272 | + } |
253 | 273 | } |
254 | 274 | }); |
255 | 275 |
|
|
0 commit comments