Skip to content

Commit

Permalink
[DLT-1110] Update style
Browse files Browse the repository at this point in the history
  • Loading branch information
AronPerez committed Jan 14, 2025
1 parent 3679a4f commit 474673e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
28 changes: 18 additions & 10 deletions web/static/components/transfer/transfer-templates.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { escapeHTML } from "../../util.js";
import { TransferMode } from "../../models/transfer-model.js";

/**
* @module TransferTemplates
Expand All @@ -7,21 +8,27 @@ import { escapeHTML } from "../../util.js";

/**
* Gets mode-specific options template HTML
* @param {boolean} isGetMode - Whether in GET transfer mode
* @param {TransferMode[keyof TransferMode]} mode - The transfer mode
* @returns {string} Mode-specific options template HTML
*/
export function getModeSpecificOptionsTemplate(isGetMode) {
return isGetMode
? `<br>File extension override: <input id='ext' type='text'><br>`
: `<br><label for='orig_fname'>Download to original filename(s)</label>
export function getModeSpecificOptionsTemplate(mode) {
let responseHTML = "";
if (mode === TransferMode.TT_DATA_GET) {
responseHTML = `<br>File extension override: <input id='ext' type='text'><br>`;
} else if (mode === TransferMode.TT_DATA_PUT) {
responseHTML = `<br><label for='orig_fname'>Download to original filename(s)</label>
<input id='orig_fname' type='checkbox'>`;
}

return responseHTML;
}

/**
* Gets the transfer options template HTML
* @param {TransferMode[keyof TransferMode]} mode - The transfer mode
* @returns {string} Transfer options template HTML
*/
export function getTransferOptionsTemplate() {
export function getTransferOptionsTemplate(mode) {
return `
<br>Transfer Encryption:&nbsp
<input type='radio' id='encrypt_none' name='encrypt_mode' value='0'>
Expand All @@ -30,18 +37,19 @@ export function getTransferOptionsTemplate() {
<label for='encrypt_avail'>If Available</label>&nbsp
<input type='radio' id='encrypt_req' name='encrypt_mode' value='2'/>
<label for='encrypt_req'>Required</label><br>
${getModeSpecificOptionsTemplate()}
${getModeSpecificOptionsTemplate(mode)}
`;
}

/**
* Gets the dialog template HTML
* @param {Object} labels - The labels for dialog elements
* @param {TransferMode[keyof TransferMode]} mode - The transfer mode
* @param {string} labels.record - Record label text
* @param {string} labels.endpoint - Endpoint label text
* @returns {string} The dialog template HTML
*/
export function getDialogTemplate(labels) {
export function getDialogTemplate(labels, mode) {
return `
<div class='ui-widget' style='height:95%'>
${labels.record}: <span id='title'></span><br>
Expand All @@ -63,7 +71,7 @@ export function getDialogTemplate(labels) {
size='7' style='width: 100%;' disabled>
<option disabled selected>No Matches</option>
</select>
${getTransferOptionsTemplate()}
${getTransferOptionsTemplate(mode)}
</div>
</div>
</div>
Expand All @@ -86,7 +94,7 @@ export function createMatchesHtml(endpoints) {
html.push(`
<option title="${escapeHTML(ep.description || "(no info)")}">${escapeHTML(
ep.display_name || ep.name,
)} (${ep.status})</option>
)}</option>
`);
});

Expand Down
2 changes: 1 addition & 1 deletion web/static/components/transfer/transfer-ui-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class TransferUIManager {
*/
createDialog(labels) {
this.state.frame = $(document.createElement("div"));
this.state.frame.html(getDialogTemplate(labels));
this.state.frame.html(getDialogTemplate(labels, this.#controller.model.mode));
return this.state.frame;
}

Expand Down
16 changes: 10 additions & 6 deletions web/static/models/transfer-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ export class TransferModel {
* @returns {Object} Record info
*/
getRecordInfo(item) {
if (item.size === 0) return { info: "(empty)", selectable: false };
if (item.locked) return { info: "(locked)", selectable: false };
return {
info: util.sizeToString(item.size),
selectable: true,
};
if (item.size === 0) {
return { info: "(empty)", selectable: false };
} else if (item.locked) {
return { info: "(locked)", selectable: false };
} else {
return {
info: util.sizeToString(item.size),
selectable: true,
};
}
}
}

0 comments on commit 474673e

Please sign in to comment.