mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-21 20:19:32 +08:00
change _parseModels -> _parseResponse since it now parses responses with no models included.
Move status check into _parseResponse Don't give PrintJobUploadSuccessMessage() if printis awaiting approval. The print has successfully uploaded but it is pending approval instead so it does not make sense to display both messages. CURA-9221
This commit is contained in:
parent
30692bb4b8
commit
a58690c774
@ -190,9 +190,9 @@ class CloudApiClient:
|
||||
Logger.logException("e", "Could not parse the stardust response: %s", error.toDict())
|
||||
return status_code, {"errors": [error.toDict()]}
|
||||
|
||||
def _parseModels(self, response: Dict[str, Any], on_finished: Union[Callable[[CloudApiClientModel], Any],
|
||||
Callable[[List[CloudApiClientModel]], Any]], model_class: Type[CloudApiClientModel]) -> None:
|
||||
"""Parses the given models and calls the correct callback depending on the result.
|
||||
def _parseResponse(self, response: Dict[str, Any], on_finished: Union[Callable[[CloudApiClientModel], Any],
|
||||
Callable[[List[CloudApiClientModel]], Any]], model_class: Type[CloudApiClientModel]) -> None:
|
||||
"""Parses the given response and calls the correct callback depending on the result.
|
||||
|
||||
:param response: The response from the server, after being converted to a dict.
|
||||
:param on_finished: The callback in case the response is successful.
|
||||
@ -201,7 +201,11 @@ class CloudApiClient:
|
||||
|
||||
if "data" in response:
|
||||
data = response["data"]
|
||||
if isinstance(data, list):
|
||||
if "status" in data and data["status"] == "wait_approval":
|
||||
PrintJobPendingApprovalMessage().show()
|
||||
on_finished_empty = cast(Callable[[List], Any], on_finished)
|
||||
on_finished_empty([])
|
||||
elif isinstance(data, list):
|
||||
results = [model_class(**c) for c in data] # type: List[CloudApiClientModel]
|
||||
on_finished_list = cast(Callable[[List[CloudApiClientModel]], Any], on_finished)
|
||||
on_finished_list(results)
|
||||
@ -242,10 +246,8 @@ class CloudApiClient:
|
||||
status_code, response = self._parseReply(reply)
|
||||
if status_code >= 300 and on_error is not None:
|
||||
on_error()
|
||||
elif "data" in response and "status" in response["data"] and response["data"]["status"] == "wait_approval":
|
||||
PrintJobPendingApprovalMessage().show()
|
||||
else:
|
||||
self._parseModels(response, on_finished, model)
|
||||
self._parseResponse(response, on_finished, model)
|
||||
|
||||
self._anti_gc_callbacks.append(parse)
|
||||
return parse
|
||||
|
@ -259,16 +259,19 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||
"""
|
||||
self._uploaded_print_job = self._pre_upload_print_job
|
||||
self._progress.hide()
|
||||
message = PrintJobUploadSuccessMessage()
|
||||
message.addAction("monitor print",
|
||||
name=I18N_CATALOG.i18nc("@action:button", "Monitor print"),
|
||||
icon="",
|
||||
description=I18N_CATALOG.i18nc("@action:tooltip", "Track the print in Ultimaker Digital Factory"),
|
||||
button_align=message.ActionButtonAlignment.ALIGN_RIGHT)
|
||||
df_url = f"https://digitalfactory.ultimaker.com/app/jobs/{self._cluster.cluster_id}?utm_source=cura&utm_medium=software&utm_campaign=message-printjob-sent"
|
||||
message.pyQtActionTriggered.connect(lambda message, action: (QDesktopServices.openUrl(QUrl(df_url)), message.hide()))
|
||||
|
||||
message.show()
|
||||
if response:
|
||||
message = PrintJobUploadSuccessMessage()
|
||||
message.addAction("monitor print",
|
||||
name=I18N_CATALOG.i18nc("@action:button", "Monitor print"),
|
||||
icon="",
|
||||
description=I18N_CATALOG.i18nc("@action:tooltip", "Track the print in Ultimaker Digital Factory"),
|
||||
button_align=message.ActionButtonAlignment.ALIGN_RIGHT)
|
||||
df_url = f"https://digitalfactory.ultimaker.com/app/jobs/{self._cluster.cluster_id}?utm_source=cura&utm_medium=software&utm_campaign=message-printjob-sent"
|
||||
message.pyQtActionTriggered.connect(lambda message, action: (QDesktopServices.openUrl(QUrl(df_url)), message.hide()))
|
||||
|
||||
message.show()
|
||||
|
||||
self.writeFinished.emit()
|
||||
|
||||
def _onPrintUploadSpecificError(self, reply: "QNetworkReply", _: "QNetworkReply.NetworkError"):
|
||||
|
Loading…
x
Reference in New Issue
Block a user