mirror of
https://github.com/blw1138/Zordon.git
synced 2026-06-09 13:39:24 -05:00
REST API endpoint streamlining and cleanup (#133)
* Consolidate engine_info api calls * Change api methods to use POST when possible * Delete engine API cleanup * Remove redundant installed_engines endpoint * Update proxy to use similar named methods to new API calls * More API cleanup * Jobs API cleanup * More jobs API cleanup * Fix add jobs error due to null queue * Remove unnecessary full_status and snapshot API endpoints * Streamline add job POST endpoint * Fix test after method name change
This commit is contained in:
@@ -334,7 +334,7 @@ class MainWindow(QMainWindow):
|
||||
default_image_path = "error.png"
|
||||
before_fetch_hostname = self.current_server_proxy.hostname
|
||||
|
||||
response = self.current_server_proxy.request(f'job/{job_id}/thumbnail?size=big')
|
||||
response = self.current_server_proxy.request(f'jobs/{job_id}/thumbnail?size=big')
|
||||
if response.ok:
|
||||
try:
|
||||
with io.BytesIO(response.content) as image_data_stream:
|
||||
@@ -547,7 +547,8 @@ class MainWindow(QMainWindow):
|
||||
"""
|
||||
selected_job_ids = self.selected_job_ids()
|
||||
if selected_job_ids:
|
||||
url = f'http://{self.current_server_proxy.hostname}:{self.current_server_proxy.port}/api/job/{selected_job_ids[0]}/logs'
|
||||
url = (f'http://{self.current_server_proxy.hostname}:{self.current_server_proxy.port}'
|
||||
f'/api/jobs/{selected_job_ids[0]}/logs')
|
||||
self.log_viewer_window = LogViewer(url)
|
||||
self.log_viewer_window.show()
|
||||
|
||||
@@ -562,7 +563,7 @@ class MainWindow(QMainWindow):
|
||||
return
|
||||
|
||||
if len(job_ids) == 1:
|
||||
job = next((job for job in self.current_server_proxy.get_all_jobs() if job.get('id') == job_ids[0]), None)
|
||||
job = next((job for job in self.current_server_proxy.get_jobs() if job.get('id') == job_ids[0]), None)
|
||||
if job:
|
||||
display_name = job.get('name', os.path.basename(job.get('input_path', '')))
|
||||
message = f"Are you sure you want to stop job: {display_name}?"
|
||||
@@ -591,7 +592,7 @@ class MainWindow(QMainWindow):
|
||||
return
|
||||
|
||||
if len(job_ids) == 1:
|
||||
job = next((job for job in self.current_server_proxy.get_all_jobs() if job.get('id') == job_ids[0]), None)
|
||||
job = next((job for job in self.current_server_proxy.get_jobs() if job.get('id') == job_ids[0]), None)
|
||||
if job:
|
||||
display_name = job.get('name', os.path.basename(job.get('input_path', '')))
|
||||
message = f"Are you sure you want to delete the job:\n{display_name}?"
|
||||
@@ -616,8 +617,8 @@ class MainWindow(QMainWindow):
|
||||
return
|
||||
|
||||
import webbrowser
|
||||
download_url = (f"http://{self.current_server_proxy.hostname}:{self.current_server_proxy.port}"
|
||||
f"/api/job/{job_ids[0]}/download_all")
|
||||
download_url = (f'http://{self.current_server_proxy.hostname}:{self.current_server_proxy.port}'
|
||||
f'/api/jobs/{job_ids[0]}/download_all')
|
||||
webbrowser.open(download_url)
|
||||
|
||||
def open_files(self, event):
|
||||
@@ -626,7 +627,7 @@ class MainWindow(QMainWindow):
|
||||
return
|
||||
|
||||
for job_id in job_ids:
|
||||
job_info = self.current_server_proxy.get_job_info(job_id)
|
||||
job_info = self.current_server_proxy.get_job(job_id)
|
||||
path = os.path.dirname(job_info['output_path'])
|
||||
launch_url(path)
|
||||
|
||||
@@ -665,7 +666,7 @@ class BackgroundUpdater(QThread):
|
||||
ZeroconfServer.get_hostname_properties(x)['api_version'] == API_VERSION]
|
||||
if self.window.current_server_proxy:
|
||||
self.window.job_data[self.window.current_server_proxy.hostname] = \
|
||||
self.window.current_server_proxy.get_all_jobs(ignore_token=False)
|
||||
self.window.current_server_proxy.get_jobs(ignore_token=False)
|
||||
self.needs_update = False
|
||||
self.updated_signal.emit()
|
||||
time.sleep(0.05)
|
||||
|
||||
Reference in New Issue
Block a user