Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
TG-20 Replace handlebars with jinya-html
Browse files Browse the repository at this point in the history
Added jinya-html for jobs page
  • Loading branch information
DerKnerd committed Jul 20, 2022
1 parent 5f86c9c commit 911ecfe
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 6,917 deletions.
150 changes: 0 additions & 150 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,156 +44,6 @@
<div class="cosmo-page-body" data-role="page-body"></div>
</main>

<script type="text/x-handlebars-template" id="jobListTemplate">
<div class="cosmo-page-body__content">
<div class="cosmo-list">
<nav class="cosmo-list__items">
{{#jobs}}
<a class="cosmo-list__item" data-action="change-job" data-job-id="{{id}}">{{name}}</a>
{{/jobs}}
<button class="cosmo-button cosmo-button--full-width" data-action="add-job">Create Job</button>
</nav>
<div class="cosmo-list__content">
</div>
</div>
</div>
</script>
<script type="text/x-handlebars-template" id="jobItemDetailsTemplate">
<div class="cosmo-tab-control">
<div class="cosmo-tab-control__tabs">
<a data-action="details" class="cosmo-tab-control__tab-link cosmo-tab-control__tab-link--active">Details</a>
<a data-action="backups" class="cosmo-tab-control__tab-link">Backups</a>
</div>
<div class="cosmo-tab-control__content" data-content-type="details">
<div class="cosmo-toolbar">
<div class="cosmo-toolbar__group">
<button type="button" data-id="{{id}}" class="cosmo-button" data-action="edit-job">Edit</button>
</div>
<div class="cosmo-toolbar__group">
<button type="button" data-id="{{id}}" class="cosmo-button" data-action="delete-job">Delete</button>
</div>
</div>
<span class="cosmo-title">{{job.name}}</span>
<dl class="cosmo-key-value-list">
<dt class="cosmo-key-value-list__key">ID</dt>
<dd class="cosmo-key-value-list__value">{{job.id}}</dd>
<dt class="cosmo-key-value-list__key">Type</dt>
<dd class="cosmo-key-value-list__value">{{job.type}}</dd>
<dt class="cosmo-key-value-list__key">Host</dt>
<dd class="cosmo-key-value-list__value">{{job.host}}</dd>
<dt class="cosmo-key-value-list__key">Port</dt>
<dd class="cosmo-key-value-list__value">{{job.port}}</dd>
<dt class="cosmo-key-value-list__key">Remote path</dt>
<dd class="cosmo-key-value-list__value">{{job.remotePath}}</dd>
<dt class="cosmo-key-value-list__key">Local path</dt>
<dd class="cosmo-key-value-list__value">{{job.localPath}}</dd>
</dl>
</div>
<div class="cosmo-tab-control__content jinya-hidden" data-content-type="backups">
<table class="cosmo-table">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Backup Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{#each backups}}
<tr>
<td>{{id}}</td>
<td>{{name}}</td>
<td>{{formatDate backupDate}}</td>
<td>
<div class="cosmo-toolbar__group">
<a target="_blank" href="/api/backup-job/{{job.id}}/backup/{{id}}"
class="cosmo-button">Download</a>
<button type="button" data-job-id="{{job.id}}" data-id="{{id}}" class="cosmo-button"
data-action="delete-backup">Delete
</button>
</div>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</script>
<script type="text/x-handlebars-template" id="createJobTemplate">
<form class="cosmo-modal" data-role="add-job-modal">
<h1 class="cosmo-modal__title">Add FTP job</h1>
<div class="cosmo-modal__content">
<div class="cosmo-input__group">
<label class="cosmo-label" for="name">Name</label>
<input class="cosmo-input" id="name" placeholder="Name" required type="text">
<label class="cosmo-label" for="type">Server type</label>
<select class="cosmo-select" id="type" required>
<option value="ftp" selected>FTP</option>
<option value="sftp">SFTP</option>
</select>
<label class="cosmo-label" for="host">Host</label>
<input class="cosmo-input" id="host" placeholder="Host" required type="text">
<label class="cosmo-label" for="port">Port</label>
<input class="cosmo-input" id="port" placeholder="Port" required type="number">
<label class="cosmo-label" for="username">Username</label>
<input class="cosmo-input" id="username" placeholder="Username" required
type="text">
<label class="cosmo-label" for="password">Password</label>
<input class="cosmo-input" id="password" placeholder="Password" required
type="password">
<label class="cosmo-label" for="remotePath">Remote path</label>
<input class="cosmo-input" id="remotePath" placeholder="Remote path" required
type="text">
<label class="cosmo-label" for="localPath">Local path</label>
<input class="cosmo-input" id="localPath" placeholder="Local path" required
type="text">
</div>
</div>
<div class="cosmo-modal__button-bar">
<button class="cosmo-button" type="submit">Save job</button>
<button class="cosmo-button" data-role="cancel-job-modal" type="button">Cancel</button>
</div>
</form>
</script>
<script type="text/x-handlebars-template" id="editJobTemplate">
<form class="cosmo-modal" data-role="edit-job-modal">
<h1 class="cosmo-modal__title">Edit FTP job</h1>
<div class="cosmo-modal__content">
<div class="cosmo-input__group">
<label class="cosmo-label" for="name">Name</label>
<input class="cosmo-input" id="name" placeholder="Name" required type="text" value="{{name}}">
<label class="cosmo-label" for="type">Server type</label>
<select class="cosmo-select" id="type" required>
<option {{#eq host.type 'ftp'}}selected{{/eq}} value="ftp">FTP</option>
<option {{#eq host.type 'sftp'}}selected{{/eq}} value="sftp">SFTP</option>
</select>
<label class="cosmo-label" for="host">Host</label>
<input class="cosmo-input" id="host" placeholder="Host" required type="text" value="{{host}}">
<label class="cosmo-label" for="port">Port</label>
<input class="cosmo-input" id="port" placeholder="Port" required type="number" value="{{port}}">
<label class="cosmo-label" for="username">Username</label>
<input class="cosmo-input" id="username" placeholder="Username" required type="text"
value="{{username}}">
<label class="cosmo-label" for="password">Password</label>
<input class="cosmo-input" id="password" placeholder="Password" type="password" value="{{password}}">
<label class="cosmo-label" for="remotePath">Remote path</label>
<input class="cosmo-input" id="remotePath" placeholder="Remote path" required type="text"
value="{{remotePath}}">
<label class="cosmo-label" for="localPath">Local path</label>
<input class="cosmo-input" id="localPath" placeholder="Local path" required type="text"
value="{{localPath}}">
</div>
</div>
<div class="cosmo-modal__button-bar">
<button class="cosmo-button" type="submit">Save job</button>
<button class="cosmo-button" data-role="cancel-job-modal" type="button">Cancel</button>
</div>
</form>
</script>

<script src="lib/js/handlebars.js"></script>
<script type="module" src="js/index.js"></script>
</body>
</html>
6 changes: 0 additions & 6 deletions web/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import {displayLogin} from "./login.js";
import {displayUsers} from "./users.js";
import {displayImportExport} from "./importExport.js";

Handlebars.registerHelper('eq', function (a, b, options) {
if (a === b) {
return options.fn(this);
}
});

function initGlobalActions() {
document.querySelector('[data-action=logout]').addEventListener('click', async () => {
await request('/api/login/', 'DELETE');
Expand Down
Loading

0 comments on commit 911ecfe

Please sign in to comment.