Skip to content

Commit

Permalink
Fix jobs download on jobs page in web UI
Browse files Browse the repository at this point in the history
  • Loading branch information
TheophileDiot committed Apr 18, 2024
1 parent 23a88f5 commit 65fe15d
Show file tree
Hide file tree
Showing 16 changed files with 360 additions and 388 deletions.
1 change: 1 addition & 0 deletions .gitleaksignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ src/ui/templates/settings_plugins.html:hashicorp-tf-password:87
src/ui/templates/settings_plugins.html:hashicorp-tf-password:297
src/ui/templates/settings_plugins.html:hashicorp-tf-password:106
src/ui/templates/account.html:hashicorp-tf-password:154
src/ui/templates/account.html:hashicorp-tf-password:162
2 changes: 2 additions & 0 deletions src/common/db/Database.py
Original file line number Diff line number Diff line change
Expand Up @@ -1876,6 +1876,7 @@ def get_jobs(self) -> Dict[str, Dict[str, Any]]:
with self.__db_session() as session:
return {
job.name: {
"plugin_id": job.plugin_id,
"every": job.every,
"reload": job.reload,
"success": job.success,
Expand All @@ -1898,6 +1899,7 @@ def get_jobs(self) -> Dict[str, Dict[str, Any]]:
for job in (
session.query(Jobs).with_entities(
Jobs.name,
Jobs.plugin_id,
Jobs.every,
Jobs.reload,
Jobs.success,
Expand Down
7 changes: 4 additions & 3 deletions src/ui/static/js/jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,18 @@ class Download {
.hasAttribute(`data-${this.prefix}-download`)
) {
const btnEl = e.target.closest("button");
const pluginId = btnEl.getAttribute("data-jobs-plugin");
const jobName = btnEl.getAttribute("data-jobs-download");
const fileName = btnEl.getAttribute("data-jobs-file");
this.sendFileToDL(jobName, fileName);
this.sendFileToDL(pluginId, jobName, fileName);
}
} catch (err) {}
});
}

async sendFileToDL(jobName, fileName) {
async sendFileToDL(pluginId, jobName, fileName) {
window.open(
`${location.href}/download?job_name=${jobName}&file_name=${fileName}`,
`${location.href}/download?plugin_id=${pluginId}&job_name=${jobName}&file_name=${fileName}`,
);
}
}
Expand Down
116 changes: 62 additions & 54 deletions src/ui/templates/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ <h5 class="text-xl my-1 text-center transition duration-300 ease-in-out font-bol
<p class="my-2 mr-2 dark:text-gray-300 text-center font-bold">{{ pro_services }} services allowed</p>
{% endif %}
{% if pro_expire %}
<p class="my-2 mr-2 dark:text-gray-300 text-center">License expiration date : <span data-expire class="font-bold">{{ pro_expire }}</span></p>
<p class="my-2 mr-2 dark:text-gray-300 text-center">
License expiration date : <span data-expire class="font-bold">{{ pro_expire }}</span>
</p>
{% endif %}
</div>
{% endif %}
Expand All @@ -115,60 +117,66 @@ <h5 class="text-xl my-1 text-center transition duration-300 ease-in-out font-bol
</div>
{% endif %}
</div>
<form class="mt-6 relative col-span-12 grid grid-cols-12 w-full justify-items-center"
id="activate-key-form"
action="account"
method="POST"
autocomplete="off">
<div class="col-span-12">
<h5 class="text-xl my-1 transition duration-300 ease-in-out text-md font-bold m-0 dark:text-gray-200">{%if is_pro_version %}UPDATE KEY {% else %} ACTIVATE KEY {% endif %}</h5>
</div>
<input type="hidden" name="operation" value="activate-key" />
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden"
name="next"
value="{{ request.values.get('next', '') }}" />
<div data-input-group
class="flex flex-col relative col-span-12 px-4 my-2 md:px-6 md:my-3 lg:px-6 lg:my-3 max-w-[400px] w-full">
<h5 class="input-title">License key</h5>
<label class="sr-only" for="license">License key</label>
<input type="password"
id="license"
name="license"
class="col-span-12 regular-input"
placeholder="enter new license key"
value=""
pattern="^.*$"
required />
<div data-setting-password-container
class="absolute flex right-6 md:right-8 h-5 w-5 top-[55%] md:top-[53%]">
<button data-setting-password="visible"
class="h-5 w-5 flex items-center align-middle dark:fill-blue-500 hover:brightness-75 transition-all"
type="button">
<svg class="fill-primary pointer-events-none dark:fill-blue-500 hover:brightness-75 transition-all"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 576 512">
<path d="M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM432 256c0 79.5-64.5 144-144 144s-144-64.5-144-144s64.5-144 144-144s144 64.5 144 144zM288 192c0 35.3-28.7 64-64 64c-11.5 0-22.3-3-31.6-8.4c-.2 2.8-.4 5.5-.4 8.4c0 53 43 96 96 96s96-43 96-96s-43-96-96-96c-2.8 0-5.6 .1-8.4 .4c5.3 9.3 8.4 20.1 8.4 31.6z" />
</svg>
</button>
<button data-setting-password="invisible"
class="hidden -translate-y-0.2 scale-110 h-5 w-5 items-center align-middle"
type="button">
<svg class="fill-primary pointer-events-none dark:fill-blue-500 hover:brightness-75 transition-all"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 640 512">
<path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zM223.1 149.5C248.6 126.2 282.7 112 320 112c79.5 0 144 64.5 144 144c0 24.9-6.3 48.3-17.4 68.7L408 294.5c5.2-11.8 8-24.8 8-38.5c0-53-43-96-96-96c-2.8 0-5.6 .1-8.4 .4c5.3 9.3 8.4 20.1 8.4 31.6c0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zm223.1 298L373 389.9c-16.4 6.5-34.3 10.1-53 10.1c-79.5 0-144-64.5-144-144c0-6.9 .5-13.6 1.4-20.2L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5z" />
</svg>
</button>
</div>
</div>
<div class="col-span-12 flex justify-center mt-6">
<button type="submit"
id="activate-key-button"
name="activate-key-button"
class="valid-btn">SAVE</button>
<form class="mt-6 relative col-span-12 grid grid-cols-12 w-full justify-items-center"
id="activate-key-form"
action="account"
method="POST"
autocomplete="off">
<div class="col-span-12">
<h5 class="text-xl my-1 transition duration-300 ease-in-out text-md font-bold m-0 dark:text-gray-200">
{% if is_pro_version %}
UPDATE KEY
{% else %}
ACTIVATE KEY
{% endif %}
</h5>
</div>
<input type="hidden" name="operation" value="activate-key" />
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden"
name="next"
value="{{ request.values.get('next', '') }}" />
<div data-input-group
class="flex flex-col relative col-span-12 px-4 my-2 md:px-6 md:my-3 lg:px-6 lg:my-3 max-w-[400px] w-full">
<h5 class="input-title">License key</h5>
<label class="sr-only" for="license">License key</label>
<input type="password"
id="license"
name="license"
class="col-span-12 regular-input"
placeholder="enter new license key"
value=""
pattern="^.*$"
required />
<div data-setting-password-container
class="absolute flex right-6 md:right-8 h-5 w-5 top-[55%] md:top-[53%]">
<button data-setting-password="visible"
class="h-5 w-5 flex items-center align-middle dark:fill-blue-500 hover:brightness-75 transition-all"
type="button">
<svg class="fill-primary pointer-events-none dark:fill-blue-500 hover:brightness-75 transition-all"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 576 512">
<path d="M288 32c-80.8 0-145.5 36.8-192.6 80.6C48.6 156 17.3 208 2.5 243.7c-3.3 7.9-3.3 16.7 0 24.6C17.3 304 48.6 356 95.4 399.4C142.5 443.2 207.2 480 288 480s145.5-36.8 192.6-80.6c46.8-43.5 78.1-95.4 93-131.1c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C433.5 68.8 368.8 32 288 32zM432 256c0 79.5-64.5 144-144 144s-144-64.5-144-144s64.5-144 144-144s144 64.5 144 144zM288 192c0 35.3-28.7 64-64 64c-11.5 0-22.3-3-31.6-8.4c-.2 2.8-.4 5.5-.4 8.4c0 53 43 96 96 96s96-43 96-96s-43-96-96-96c-2.8 0-5.6 .1-8.4 .4c5.3 9.3 8.4 20.1 8.4 31.6z" />
</svg>
</button>
<button data-setting-password="invisible"
class="hidden -translate-y-0.2 scale-110 h-5 w-5 items-center align-middle"
type="button">
<svg class="fill-primary pointer-events-none dark:fill-blue-500 hover:brightness-75 transition-all"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 640 512">
<path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L525.6 386.7c39.6-40.6 66.4-86.1 79.9-118.4c3.3-7.9 3.3-16.7 0-24.6c-14.9-35.7-46.2-87.7-93-131.1C465.5 68.8 400.8 32 320 32c-68.2 0-125 26.3-169.3 60.8L38.8 5.1zM223.1 149.5C248.6 126.2 282.7 112 320 112c79.5 0 144 64.5 144 144c0 24.9-6.3 48.3-17.4 68.7L408 294.5c5.2-11.8 8-24.8 8-38.5c0-53-43-96-96-96c-2.8 0-5.6 .1-8.4 .4c5.3 9.3 8.4 20.1 8.4 31.6c0 10.2-2.4 19.8-6.6 28.3l-90.3-70.8zm223.1 298L373 389.9c-16.4 6.5-34.3 10.1-53 10.1c-79.5 0-144-64.5-144-144c0-6.9 .5-13.6 1.4-20.2L83.1 161.5C60.3 191.2 44 220.8 34.5 243.7c-3.3 7.9-3.3 16.7 0 24.6c14.9 35.7 46.2 87.7 93 131.1C174.5 443.2 239.2 480 320 480c47.8 0 89.9-12.9 126.2-32.5z" />
</svg>
</button>
</div>
</form>
</div>
<div class="col-span-12 flex justify-center mt-6">
<button type="submit"
id="activate-key-button"
name="activate-key-button"
class="valid-btn">SAVE</button>
</div>
</form>
</div>
<div data-tab-item="username"
class="hidden grid grid-cols-12 w-full justify-items-center">
Expand Down
19 changes: 6 additions & 13 deletions src/ui/templates/bans.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,12 @@ <h5 class="font-bold dark:text-white/90 mx-2 text-white">No bans found</h5>
<div class="{% if bans|length == 0 %}hidden{% endif %} h-fit col-span-12 md:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border">
<h5 class="mb-2 font-bold dark:text-white/90">INFO</h5>
<div role="grid" class="card-detail-container">
{% for info in bans_info %}
<div role="row"
class="card-detail-item">
<p role="gridcell"
class="card-detail-item-title">
{{ info['name'] }}
</p>
<p role="gridcell"
class="card-detail-item-subtitle">
{{ info['data'] }}
</p>
</div>
{% endfor %}
{% for info in bans_info %}
<div role="row" class="card-detail-item">
<p role="gridcell" class="card-detail-item-title">{{ info['name'] }}</p>
<p role="gridcell" class="card-detail-item-subtitle">{{ info['data'] }}</p>
</div>
{% endfor %}
</div>
</div>
<!-- end info -->
Expand Down
4 changes: 3 additions & 1 deletion src/ui/templates/bans_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@
<input data-ban-add-inp type="hidden" name="data" value="" />
<!-- action button -->
<div class="w-full justify-center flex mt-6 mb-4">
<button data-bans-modal-close type="button" class="dark:bg-slate-800 close-btn mr-3 text-base">Close</button>
<button data-bans-modal-close
type="button"
class="dark:bg-slate-800 close-btn mr-3 text-base">Close</button>
<button disabled data-bans-modal-submit type="submit" class="valid-btn">Add</button>
</div>
<!-- end action button-->
Expand Down
23 changes: 9 additions & 14 deletions src/ui/templates/configs.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,16 @@
] %}
<div class="h-fit col-span-12 md:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border">
<h5 class="mb-2 font-bold dark:text-white/90">INFO</h5>
<div role="grid" class="card-detail-container">
{% for info in configs_info %}
<div role="row"
class="card-detail-item">
<p role="gridcell"
class="card-detail-item-title">
{{ info['name'] }}
</p>
<p data-info-{{ info['id'] }} role="gridcell"
class="card-detail-item-subtitle">
{{ info['data'] }}
</p>
<div role="grid" class="card-detail-container">
{% for info in configs_info %}
<div role="row" class="card-detail-item">
<p role="gridcell" class="card-detail-item-title">{{ info['name'] }}</p>
<p data-info-{{ info['id'] }} role="gridcell" class="card-detail-item-subtitle">
{{ info['data'] }}
</p>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
</div>
<!-- end info -->
<!-- filter -->
Expand Down
1 change: 0 additions & 1 deletion src/ui/templates/global_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ <h5 class="my-1 transition duration-300 ease-in-out text-sm sm:text-md font-bold
role="listbox"
data-global-config-setting-select-dropdown="{{ filter['id'] }}"
class="mt-1 hidden z-100 absolute flex-col w-full translate-y-16 max-h-[350px] overflow-hidden overflow-y-auto">

{% for value in filter['values'] %}
<button role="option"
data-global-config-setting-select-dropdown-btn="{{ filter['id'] }}"
Expand Down
13 changes: 3 additions & 10 deletions src/ui/templates/instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,9 @@ <h5 class="col-span-11 break-words font-bold dark:text-white/90 transition durat
{% set instance_details = [{"name" : "TYPE", "value" : instance['_type']},{"name" : "HOSTNAME", "value" : instance['hostname']}] %}
<!-- detail -->
{% for detail in instance_details %}
<div role="row"
class="card-detail-item">
<p role="gridcell"
class="card-detail-item-title">
{{ detail['name'] }}
</p>
<p role="gridcell"
class="card-detail-item-subtitle">
{{ detail['value'] }}
</p>
<div role="row" class="card-detail-item">
<p role="gridcell" class="card-detail-item-title">{{ detail['name'] }}</p>
<p role="gridcell" class="card-detail-item-subtitle">{{ detail['value'] }}</p>
</div>
{% endfor %}
<!-- end detail -->
Expand Down
22 changes: 8 additions & 14 deletions src/ui/templates/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
<div class="h-fit col-span-12 md:col-span-4 3xl:col-span-3 p-4 relative min-w-0 break-words bg-white shadow-xl dark:bg-slate-850 dark:shadow-dark-xl rounded-2xl bg-clip-border">
<h5 class="mb-2 font-bold dark:text-white/90">INFO</h5>
<div role="grid" class="card-detail-container">
{% for info in jobs_info %}
<div role="row"
class="card-detail-item">
<p role="gridcell"
class="card-detail-item-title">
{{ info['name'] }}
</p>
<p role="gridcell"
class="card-detail-item-subtitle">
{{ info['data'] }}
</p>
</div>
{% endfor %}
{% for info in jobs_info %}
<div role="row" class="card-detail-item">
<p role="gridcell" class="card-detail-item-title">{{ info['name'] }}</p>
<p role="gridcell" class="card-detail-item-subtitle">{{ info['data'] }}</p>
</div>
{% endfor %}
</div>
</div>
<!-- end info -->
Expand Down Expand Up @@ -251,7 +244,8 @@ <h5 class="mb-4 mt-2 font-bold dark:text-white/90 mx-2">JOBS LIST</h5>
<div data-jobs-setting-select-dropdown="{{ job_name }}"
class="hidden z-100 absolute h-full flex-col w-full translate-y-0.5">
{% for file in value['cache'] %}
<button data-jobs-download="{{ job_name }}"
<button data-jobs-plugin="{{ value['plugin_id'] }}"
data-jobs-download="{{ job_name }}"
data-jobs-file="{{ file['file_name'] }}"
data-jobs-setting-select-dropdown-btn="{{ job_name }}"
value="files"
Expand Down
Loading

0 comments on commit 65fe15d

Please sign in to comment.