19
19
20
20
from werkzeug .datastructures import Headers
21
21
22
+ from octoprint .filemanager import FileDestinations
23
+
22
24
from octoprint_PrintJobHistory import PrintJobModel , TemperatureModel , FilamentModel
23
25
from octoprint_PrintJobHistory .api import TransformPrintJob2JSON , TransformSlicerSettings2JSON
24
26
25
27
from octoprint_PrintJobHistory .common import StringUtils
28
+ from octoprint_PrintJobHistory .common import PrintJobUtils
29
+
26
30
from octoprint_PrintJobHistory .common .SettingsKeys import SettingsKeys
27
31
28
32
from octoprint_PrintJobHistory .CameraManager import CameraManager
@@ -164,6 +168,14 @@ def _createSamplePrintModel(self):
164
168
################################################### APIs
165
169
166
170
171
+ ####################################################################################### CONFIRM MESSAGE
172
+ @octoprint .plugin .BlueprintPlugin .route ("/confirmMessageDialog" , methods = ["PUT" ])
173
+ def put_confirmMessageDialog (self ):
174
+ self ._settings .set ([SettingsKeys .SETTINGS_KEY_MESSAGE_CONFIRM_DATA ], None )
175
+ self ._settings .save ()
176
+
177
+ return flask .jsonify ([])
178
+
167
179
####################################################################################### DEACTIVATE PLUGIN CHECK
168
180
@octoprint .plugin .BlueprintPlugin .route ("/deactivatePluginCheck" , methods = ["PUT" ])
169
181
def put_pluginDependencyCheck (self ):
@@ -172,7 +184,6 @@ def put_pluginDependencyCheck(self):
172
184
173
185
return flask .jsonify ([])
174
186
175
-
176
187
####################################################################################### LOAD STATISTIC BY QUERY
177
188
@octoprint .plugin .BlueprintPlugin .route ("/loadStatisticByQuery" , methods = ["GET" ])
178
189
def get_statisticByQuery (self ):
@@ -182,7 +193,6 @@ def get_statisticByQuery(self):
182
193
183
194
return flask .jsonify (statistic )
184
195
185
-
186
196
####################################################################################### COMPARE Slicer Settings
187
197
@octoprint .plugin .BlueprintPlugin .route ("/compareSlicerSettings/" , methods = ["GET" ])
188
198
def get_compareSlicerSettings (self ):
@@ -212,23 +222,53 @@ def get_compareSlicerSettings(self):
212
222
213
223
return flask .jsonify ()
214
224
215
-
216
-
217
225
####################################################################################### LOAD ALL JOBS BY QUERY
218
226
@octoprint .plugin .BlueprintPlugin .route ("/loadPrintJobHistoryByQuery" , methods = ["GET" ])
219
227
def get_printjobhistoryByQuery (self ):
220
228
221
229
tableQuery = flask .request .values
222
230
allJobsModels = self ._databaseManager .loadPrintJobsByQuery (tableQuery )
223
231
# allJobsAsDict = self._convertPrintJobHistoryModelsToDict(allJobsModels)
224
- allJobsAsDict = TransformPrintJob2JSON .transformAllPrintJobModels (allJobsModels )
232
+ # selectedFile = self._file_manager.path_on_disk(fileLocation, selectedFilename)
233
+ allJobsAsDict = TransformPrintJob2JSON .transformAllPrintJobModels (allJobsModels , self ._file_manager )
225
234
226
235
totalItemCount = self ._databaseManager .countPrintJobsByQuery (tableQuery )
227
236
return flask .jsonify ({
228
237
"totalItemCount" : totalItemCount ,
229
238
"allPrintJobs" : allJobsAsDict
230
239
})
231
240
241
+ ####################################################################################### SELECT JOB FOR PRINTING
242
+ @octoprint .plugin .BlueprintPlugin .route ("/selectPrintJobForPrint/<int:databaseId>" , methods = ["PUT" ])
243
+ def put_select_printjob (self , databaseId ):
244
+
245
+ printJobModel = self ._databaseManager .loadPrintJob (databaseId );
246
+ if (printJobModel == None ):
247
+ # PrintJob was deleted
248
+ message = "PrintJob not in database anymore! Selection not possible."
249
+ self ._logger .error (message )
250
+ self ._sendDataToClient (dict (action = "errorPopUp" ,
251
+ title = "Print selection not possible" ,
252
+ message = message ))
253
+ return flask .jsonify ()
254
+
255
+ printJobPrintable = PrintJobUtils .isPrintJobReprintable (self ._file_manager ,
256
+ printJobModel .fileOrigin ,
257
+ printJobModel .filePathName ,
258
+ printJobModel .fileName )
259
+ fullFileLocation = printJobPrintable ["fullFileLocation" ]
260
+ if (printJobPrintable ["isRePrintable" ] == False ):
261
+ message = "PrintJob not found in: " + fullFileLocation
262
+ self ._logger .error (message )
263
+ self ._sendDataToClient (dict (action = "errorPopUp" ,
264
+ title = "Print selection not possible" ,
265
+ message = message ))
266
+ return flask .jsonify ()
267
+ sd = False if (printJobModel .fileOrigin != None and printJobModel .fileOrigin == "local" ) else True
268
+ self ._printer .select_file (fullFileLocation , sd )
269
+
270
+ return flask .jsonify ()
271
+
232
272
####################################################################################### DELETE JOB
233
273
@octoprint .plugin .BlueprintPlugin .route ("/removePrintJob/<int:databaseId>" , methods = ["DELETE" ])
234
274
def delete_printjob (self , databaseId ):
@@ -369,7 +409,7 @@ def delete_snapshot(self, snapshotFilename):
369
409
370
410
####################################################################################### DOWNLOAD DATABASE-FILE
371
411
@octoprint .plugin .BlueprintPlugin .route ("/downloadDatabase" , methods = ["GET" ])
372
- def download_database (self ):
412
+ def get_download_database (self ):
373
413
return send_file (self ._databaseManager .getDatabaseFileLocation (),
374
414
mimetype = 'application/octet-stream' ,
375
415
attachment_filename = 'printJobHistory.db' ,
@@ -388,7 +428,7 @@ def delete_database(self):
388
428
389
429
####################################################################################### EXPORT DATABASE as CSV
390
430
@octoprint .plugin .BlueprintPlugin .route ("/exportPrintJobHistory/<string:exportType>" , methods = ["GET" ])
391
- def exportPrintJobHistoryData (self , exportType ):
431
+ def get_exportPrintJobHistoryData (self , exportType ):
392
432
393
433
if exportType == "CSV" :
394
434
if "databaseIds" in flask .request .values :
0 commit comments