diff --git a/source/file_size_metrics/.editorconfig b/source/file_size_metrics/.editorconfig new file mode 100644 index 000000000..778e78303 --- /dev/null +++ b/source/file_size_metrics/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[{info.json,*.py}] +indent_size = 4 diff --git a/source/file_size_metrics/changelog.md b/source/file_size_metrics/changelog.md index 0db16e637..7775d4a6c 100644 --- a/source/file_size_metrics/changelog.md +++ b/source/file_size_metrics/changelog.md @@ -1,3 +1,6 @@ +**0.1.1** +- When viewing on mobile, show individual file metrics in a dialog popup + **0.1.0** - New layout to try and make better use of space diff --git a/source/file_size_metrics/info.json b/source/file_size_metrics/info.json index eb839d827..3b1a95751 100644 --- a/source/file_size_metrics/info.json +++ b/source/file_size_metrics/info.json @@ -1,15 +1,15 @@ { - "author": "Josh.5, EspadaV8", - "compatibility": [1, 2], - "description": "Aggregate changes in file size metrics for processed files and add a data panel for displaying the results.", - "icon": "https://raw.githubusercontent.com/Josh5/unmanic.plugin.file_size_metrics/master/icon.png", - "id": "file_size_metrics", - "name": "File Size Metrics Data Panel", - "platform": ["all"], - "priorities": { - "on_worker_process": 1, - "on_postprocessor_task_results": 0 - }, - "tags": "data panel", - "version": "0.1.0" + "author": "Josh.5, EspadaV8", + "compatibility": [1, 2], + "description": "Aggregate changes in file size metrics for processed files and add a data panel for displaying the results.", + "icon": "https://raw.githubusercontent.com/Josh5/unmanic.plugin.file_size_metrics/master/icon.png", + "id": "file_size_metrics", + "name": "File Size Metrics Data Panel", + "platform": ["all"], + "priorities": { + "on_worker_process": 1, + "on_postprocessor_task_results": 0 + }, + "tags": "data panel", + "version": "0.1.1" } diff --git a/source/file_size_metrics/plugin.py b/source/file_size_metrics/plugin.py index dec06ec74..f53a6e29f 100644 --- a/source/file_size_metrics/plugin.py +++ b/source/file_size_metrics/plugin.py @@ -317,12 +317,12 @@ def prepare_filtered_historic_tasks(self, request_dict): self.db_stop() return return_data - def save_source_item(self, abspath, size, task_success=False): + def save_source_item(self, abspath, size, start_time=None, task_success=False): self.db_start() basename = os.path.basename(abspath) task_label = basename - start_time = datetime.datetime.now() + start_time = start_time if start_time is not None else datetime.datetime.now() finish_time = None try: new_historic_task = HistoricTasks.create( @@ -412,10 +412,10 @@ def get_total_size_change_data_details(data): return json.dumps(results, indent=2) -def save_source_size(abspath, size): +def save_source_details(abspath, size, start_time=None): # Return a list of historical tasks based on the request JSON body data = Data() - task_id = data.save_source_item(abspath, size) + task_id = data.save_source_item(abspath, size, start_time) return task_id @@ -458,7 +458,10 @@ def on_worker_process(data): with open(plugin_data_file, 'w') as f: required_data = { + 'file_in': data.get('file_in'), + 'original_file_path': data.get('original_file_path'), 'source_size': source_size, + 'start_time': datetime.datetime.now().isoformat(), } json.dump(required_data, f, indent=4) @@ -491,11 +494,15 @@ def on_postprocessor_task_results(data): # Get the file out and store (if it exists) src_file_hash = hashlib.md5(original_source_path.encode('utf8')).hexdigest() plugin_data_file = os.path.join(profile_directory, '{}.json'.format(src_file_hash)) + start_time = None + if os.path.exists(plugin_data_file): # The store exists with open(plugin_data_file) as infile: task_metadata = json.load(infile) + source_size = task_metadata.get('source_size') + start_time = datetime.datetime.fromisoformat(task_metadata.get('start_time')) if 'start_time' in task_metadata else datetime.datetime.now() else: # The store did not exist, resort to fetching the data from the original source file (hopefully unchanged) logger.warning("Plugin data file is missing. Fetching source size direct from source path.") @@ -504,7 +511,9 @@ def on_postprocessor_task_results(data): if not source_size: logger.error("Plugin data file is missing 'source_size'.") return data - task_id = save_source_size(original_source_path, source_size) + + task_id = save_source_details(original_source_path, source_size, start_time) + if task_id is None: logger.error("Failed to create source size entry for this file") return data diff --git a/source/file_size_metrics/static/css/style.css b/source/file_size_metrics/static/css/style.css index d7904f690..dddcf0b55 100644 --- a/source/file_size_metrics/static/css/style.css +++ b/source/file_size_metrics/static/css/style.css @@ -85,9 +85,8 @@ html { background-color: var(--q-card-head-hover); } -.content { +.card-content { background-color: var(--q-card); - display: none; overflow: hidden; padding: 0 18px; } @@ -126,7 +125,10 @@ html { } #individual_file_size_chart { + display: block; order: 2; + overflow: hidden; + padding: 0 3px; } #individual_file_size_chart .card { @@ -195,6 +197,7 @@ html { #individual_file_size_chart { order: 1; + display: none; } #individual_file_size_chart .card { @@ -210,3 +213,35 @@ html { padding-top: 20px; } } + +dialog { + color: var(--q-text); + border: none; + background-color: var(--q-card); + width: 100%; + padding: 0; +} + +dialog::backdrop { + background-color: var(--q-card-head); + opacity: 0.85; +} + +dialog .card-content { + padding: 0 10px; +} + +dialog .card-footer { + padding: 0 0 10px 0; +} + +dialog .q-btn { + background: var(--q-primary); + border: 0; + color: #fff; + font-size: 14px; + font-weight: 500; + outline: 0; + padding: 8px 20px; + text-transform: uppercase; +} diff --git a/source/file_size_metrics/static/index.html b/source/file_size_metrics/static/index.html index 4ad873642..7347036e6 100644 --- a/source/file_size_metrics/static/index.html +++ b/source/file_size_metrics/static/index.html @@ -51,6 +51,12 @@
+