diff --git a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py index 6431d09b7b..0eb0644676 100644 --- a/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py +++ b/plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py @@ -21,6 +21,7 @@ from cura.PrinterOutput.PrinterOutputDevice import ConnectionType from .CloudApiClient import CloudApiClient from ..ExportFileJob import ExportFileJob +from ..Messages.PrintJobAwaitingApprovalMessage import PrintJobPendingApprovalMessage from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOutputDevice from ..Messages.PrintJobUploadBlockedMessage import PrintJobUploadBlockedMessage from ..Messages.PrintJobUploadErrorMessage import PrintJobUploadErrorMessage @@ -30,7 +31,7 @@ from ..Models.Http.CloudClusterResponse import CloudClusterResponse from ..Models.Http.CloudClusterStatus import CloudClusterStatus from ..Models.Http.CloudPrintJobUploadRequest import CloudPrintJobUploadRequest from ..Models.Http.CloudPrintResponse import CloudPrintResponse -from ..Models.Http.CloudPrintJobResponse import CloudPrintJobResponse +from ..Models.Http.CloudPrintJobResponse import CloudPrintJobResponse, CloudUploadStatus from ..Models.Http.ClusterPrinterStatus import ClusterPrinterStatus from ..Models.Http.ClusterPrintJobStatus import ClusterPrintJobStatus @@ -230,6 +231,10 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice): :param job_response: The response received from the cloud API. """ + + if job_response.status is CloudUploadStatus.WAIT_APPROVAL: + PrintJobPendingApprovalMessage().show() + if not self._tool_path: return self._onUploadError() self._pre_upload_print_job = job_response # store the last uploaded job to prevent re-upload of the same file diff --git a/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py b/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py new file mode 100644 index 0000000000..cacfcd362b --- /dev/null +++ b/plugins/UM3NetworkPrinting/src/Messages/PrintJobAwaitingApprovalMessage.py @@ -0,0 +1,25 @@ +# Copyright (c) 2022 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. +from UM import i18nCatalog +from UM.Message import Message + + +I18N_CATALOG = i18nCatalog("cura") + + +class PrintJobPendingApprovalMessage(Message): + """Message shown when waiting for approval on an uploaded print job.""" + + def __init__(self) -> None: + super().__init__( + text = I18N_CATALOG.i18nc("@info:status", "The print job was succesfully submitted"), + title=I18N_CATALOG.i18nc("@info:title", "You will recieve a confirmation via email when the print job is approved"), + message_type=Message.MessageType.POSITIVE + ) + self.self.addAction("learn_more", + I18N_CATALOG.i18nc("@action", "Learn more"), + "", + "", + "", + button_style = Message.ActionButtonStyle.LINK, + button_align = Message.ActionButtonAlignment.ALIGN_LEFT) diff --git a/plugins/UM3NetworkPrinting/src/Models/Http/CloudPrintJobResponse.py b/plugins/UM3NetworkPrinting/src/Models/Http/CloudPrintJobResponse.py index 83cbb5a030..eb824c2708 100644 --- a/plugins/UM3NetworkPrinting/src/Models/Http/CloudPrintJobResponse.py +++ b/plugins/UM3NetworkPrinting/src/Models/Http/CloudPrintJobResponse.py @@ -1,5 +1,6 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +from enum import Enum from typing import Optional from ..BaseModel import BaseModel @@ -25,7 +26,7 @@ class CloudPrintJobResponse(BaseModel): """ self.job_id = job_id - self.status = status + self.status: CloudUploadStatus = CloudUploadStatus(status) self.download_url = download_url self.job_name = job_name self.upload_url = upload_url @@ -33,3 +34,9 @@ class CloudPrintJobResponse(BaseModel): self.status_description = status_description self.slicing_details = slicing_details super().__init__(**kwargs) + + +class CloudUploadStatus(Enum): + FAILED = "failed", + QUEUED = "queued", + WAIT_APPROVAL = "wait_approval"