Hide sharing tables depending on server features
This commit is contained in:
@@ -44,7 +44,13 @@ export class ShareCollectionScene {
|
|||||||
|
|
||||||
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
|
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
|
||||||
/** @type {HTMLElement} */ let share_by_token_btn = html_scene.querySelector(
|
/** @type {HTMLElement} */ let share_by_token_btn = html_scene.querySelector(
|
||||||
"[data-name=sharebytoken]"
|
"button[data-name=sharebytoken]"
|
||||||
|
);
|
||||||
|
/** @type {HTMLElement} */ let share_by_token_div = html_scene.querySelector(
|
||||||
|
"div[data-name=sharebytoken]"
|
||||||
|
);
|
||||||
|
/** @type {HTMLElement} */ let share_by_map_div = html_scene.querySelector(
|
||||||
|
"div[data-name=sharebymap]"
|
||||||
);
|
);
|
||||||
|
|
||||||
/** @type {HTMLElement} */ let title = html_scene.querySelector("[data-name=title]");
|
/** @type {HTMLElement} */ let title = html_scene.querySelector("[data-name=title]");
|
||||||
@@ -70,12 +76,27 @@ export class ShareCollectionScene {
|
|||||||
scene_index = scene_stack.length - 1;
|
scene_index = scene_stack.length - 1;
|
||||||
html_scene.classList.remove("hidden");
|
html_scene.classList.remove("hidden");
|
||||||
cancel_btn.onclick = oncancel;
|
cancel_btn.onclick = oncancel;
|
||||||
if (server_features["sharing"]["PermittedCreateCollectionByToken"]) {
|
if (server_features.sharing && server_features.sharing.PermittedCreateCollectionByToken) {
|
||||||
share_by_token_btn.classList.remove("hidden");
|
if (share_by_token_btn) {
|
||||||
share_by_token_btn.onclick = onsharebytoken;
|
share_by_token_btn.classList.remove("hidden");
|
||||||
|
share_by_token_btn.onclick = onsharebytoken;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
share_by_token_btn.classList.add("hidden");
|
if (share_by_token_btn) share_by_token_btn.classList.add("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (server_features.sharing && server_features.sharing.FeatureEnabledCollectionByToken) {
|
||||||
|
if (share_by_token_div) share_by_token_div.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
if (share_by_token_div) share_by_token_div.classList.add("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (server_features.sharing && server_features.sharing.FeatureEnabledCollectionByMap) {
|
||||||
|
if (share_by_map_div) share_by_map_div.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
if (share_by_map_div) share_by_map_div.classList.add("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
title.textContent = collection.displayname || collection.href;
|
title.textContent = collection.displayname || collection.href;
|
||||||
update_share_list(user, password, collection);
|
update_share_list(user, password, collection);
|
||||||
};
|
};
|
||||||
@@ -186,11 +207,9 @@ function add_share_rows(user, password, collection, shares) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function maybe_enable_sharing_options() {
|
export function maybe_enable_sharing_options() {
|
||||||
if (!server_features["sharing"]) return;
|
if (!server_features.sharing) return;
|
||||||
let map_is_enabled =
|
let map_is_enabled = server_features.sharing.FeatureEnabledCollectionByMap || false;
|
||||||
server_features["sharing"]["FeatureEnabledCollectionByMap"] || false;
|
let token_is_enabled = server_features.sharing.FeatureEnabledCollectionByToken || false;
|
||||||
let token_is_enabled =
|
|
||||||
server_features["sharing"]["FeatureEnabledCollectionByToken"] || false;
|
|
||||||
if (map_is_enabled || token_is_enabled) {
|
if (map_is_enabled || token_is_enabled) {
|
||||||
let share_options = document.querySelectorAll("[data-name=shareoption]");
|
let share_options = document.querySelectorAll("[data-name=shareoption]");
|
||||||
for (let i = 0; i < share_options.length; i++) {
|
for (let i = 0; i < share_options.length; i++) {
|
||||||
|
|||||||
@@ -21,7 +21,22 @@
|
|||||||
import { COLOR_RE, ROOT_PATH, SERVER } from "./constants.js";
|
import { COLOR_RE, ROOT_PATH, SERVER } from "./constants.js";
|
||||||
import { Collection, CollectionType } from "./models.js";
|
import { Collection, CollectionType } from "./models.js";
|
||||||
import { escape_xml } from "./utils.js";
|
import { escape_xml } from "./utils.js";
|
||||||
|
/**
|
||||||
|
* @typedef {Object} SharingFeatures
|
||||||
|
* @property {number} [ApiVersion]
|
||||||
|
* @property {string} [Status]
|
||||||
|
* @property {boolean} [FeatureEnabledCollectionByMap]
|
||||||
|
* @property {boolean} [PermittedCreateCollectionByMap]
|
||||||
|
* @property {boolean} [FeatureEnabledCollectionByToken]
|
||||||
|
* @property {boolean} [PermittedCreateCollectionByToken]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ServerFeatures
|
||||||
|
* @property {SharingFeatures} [sharing]
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {ServerFeatures} */
|
||||||
export let server_features = {};
|
export let server_features = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -147,42 +147,45 @@
|
|||||||
<h1>Sharing</h1>
|
<h1>Sharing</h1>
|
||||||
<p>Manage sharing for collection <span class="title" data-name="title">title</span>
|
<p>Manage sharing for collection <span class="title" data-name="title">title</span>
|
||||||
</p>
|
</p>
|
||||||
<h2>By Token</h2>
|
<div data-name="sharebytoken">
|
||||||
<table>
|
<h2>By Token</h2>
|
||||||
<tbody>
|
<table>
|
||||||
<tr data-name="sharetokenrowtemplate" class="hidden">
|
<tbody>
|
||||||
<td>
|
<tr data-name="sharetokenrowtemplate" class="hidden">
|
||||||
<button type="button" class="red inline" data-name="delete"><img src="css/icons/delete.svg"
|
<td>
|
||||||
class="small_icon" alt="Delete"></button>
|
<button type="button" class="red inline" data-name="delete"><img src="css/icons/delete.svg"
|
||||||
</td>
|
class="small_icon" alt="Delete"></button>
|
||||||
<td><img src="css/icons/edit.svg" class="med_icon" alt="RW" data-name="rw" /><img src="css/icons/eye.svg"
|
</td>
|
||||||
class="med_icon" alt="RO" data-name="ro" /></td>
|
<td><img src="css/icons/edit.svg" class="med_icon" alt="RW" data-name="rw" /><img src="css/icons/eye.svg"
|
||||||
<td><input type="text" data-name="pathortoken" value="" readonly=""
|
class="med_icon" alt="RO" data-name="ro" /></td>
|
||||||
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
|
<td><input type="text" data-name="pathortoken" value="" readonly=""
|
||||||
</tr>
|
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
|
||||||
<tr>
|
</tr>
|
||||||
<td></td>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><button type="button" class="blue inline" data-name="sharebytoken"><img src="css/icons/new.svg"
|
<td></td>
|
||||||
class="small_icon" alt="New Share by Token"></button>
|
<td><button type="button" class="blue inline" data-name="sharebytoken"><img src="css/icons/new.svg"
|
||||||
</td>
|
class="small_icon" alt="New Share by Token"></button>
|
||||||
</tr>
|
</td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
</tbody>
|
||||||
<h2>By Map</h2>
|
</table>
|
||||||
<table>
|
</div>
|
||||||
<tbody>
|
<div data-name="sharebymap">
|
||||||
<tr data-name="sharemaprowtemplate" class="hidden">
|
<h2>By Map</h2>
|
||||||
<td>
|
<table>
|
||||||
<button type="button" class="red inline" data-name="delete"><img src="css/icons/delete.svg"
|
<tbody>
|
||||||
class="small_icon" alt="Delete"></button>
|
<tr data-name="sharemaprowtemplate" class="hidden">
|
||||||
</td>
|
<td>
|
||||||
<td><img src="css/icons/edit.svg" class="med_icon" alt="RW" data-name="rw" /><img src="css/icons/eye.svg"
|
<button type="button" class="red inline" data-name="delete"><img src="css/icons/delete.svg"
|
||||||
class="med_icon" alt="RO" data-name="ro" /></td>
|
class="small_icon" alt="Delete"></button>
|
||||||
<td><input type="text" data-name="pathortoken" value="" readonly=""
|
</td>
|
||||||
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
|
<td><img src="css/icons/edit.svg" class="med_icon" alt="RW" data-name="rw" /><img src="css/icons/eye.svg"
|
||||||
</tr>
|
class="med_icon" alt="RO" data-name="ro" /></td>
|
||||||
<!--
|
<td><input type="text" data-name="pathortoken" value="" readonly=""
|
||||||
|
onfocus="this.setSelectionRange(0, 99999);" class="inline"></td>
|
||||||
|
</tr>
|
||||||
|
<!--
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
@@ -192,8 +195,9 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
-->
|
-->
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
<form>
|
<form>
|
||||||
<button type="button" class="green" data-name="cancel">Close</button>
|
<button type="button" class="green" data-name="cancel">Close</button>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user