Show error if the upload failed

Contributes to issue CURA-8609.
This commit is contained in:
Ghostkeeper 2021-10-11 14:57:21 +02:00
parent ffee4a2443
commit ffd3277854
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
3 changed files with 23 additions and 5 deletions

View file

@ -405,6 +405,8 @@ class MaterialManagementModel(QObject):
job.uploadCompleted.connect(self.exportUploadCompleted) job.uploadCompleted.connect(self.exportUploadCompleted)
job.start() job.start()
def exportUploadCompleted(self): def exportUploadCompleted(self, job_result: UploadMaterialsJob.Result):
if job_result == UploadMaterialsJob.Result.FAILED:
self._sync_all_dialog.setProperty("syncStatusText", catalog.i18nc("@text", "Something went wrong when sending the materials to the printers."))
self._export_upload_status = "idle" self._export_upload_status = "idle"
self.exportUploadStatusChanged.emit() self.exportUploadStatusChanged.emit()

View file

@ -79,9 +79,11 @@ class UploadMaterialsJob(Job):
if error is not None: if error is not None:
Logger.error(f"Failed to upload material archive: {error}") Logger.error(f"Failed to upload material archive: {error}")
self.setResult(self.Result.FAILED) self.setResult(self.Result.FAILED)
return else:
self.setResult(self.Result.SUCCESS) self.setResult(self.Result.SUCCESS)
self.uploadCompleted.emit() self.uploadCompleted.emit(self.getResult())
def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]): def onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]):
pass # TODO: Handle errors. Logger.error(f"Failed to upload material archive: {error}")
self.setResult(self.Result.FAILED)
self.uploadCompleted.emit(self.getResult())

View file

@ -23,6 +23,7 @@ Window
property variant materialManagementModel property variant materialManagementModel
property alias pageIndex: swipeView.currentIndex property alias pageIndex: swipeView.currentIndex
property alias syncStatusText: syncStatusLabel.text
SwipeView SwipeView
{ {
@ -358,6 +359,19 @@ Window
return materialManagementModel.exportUploadStatus != "uploading"; return materialManagementModel.exportUploadStatus != "uploading";
} }
} }
Label
{
id: syncStatusLabel
anchors.right: syncButton.left
anchors.rightMargin: UM.Theme.getSize("default_margin").width
anchors.verticalCenter: parent.verticalCenter
visible: syncButton.visible
text: ""
color: UM.Theme.getColor("text")
font: UM.Theme.getFont("default")
}
Item Item
{ {
anchors.right: parent.right anchors.right: parent.right