Added a message for pending approval status.

Updated CloudPrintJobResponse to use an enum for status

CURA-9221
This commit is contained in:
joeydelarago 2022-08-10 17:34:48 +02:00
parent e8c9df1794
commit ad70566dc6
3 changed files with 39 additions and 2 deletions

View file

@ -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

View file

@ -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)

View file

@ -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"