Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions emhttp/languages/en_US/helptext.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1553,6 +1553,13 @@ Uncheck all disks in order to not exclude any disks
disks which represent a subset of the Included/Excluded disks defined here.
:end

:shares_emptying_disks_help:
This setting designates array disk(s) that are being *emptied* of User Share data,
typically as a prelude to removing the disk(s) from the array.

Unlike the other Global Share Settings, this setting may be changed while the array is **Started**.
:end

:shares_exclusive_shares_help:
If set to Yes, share directories under /mnt/user are actually symlinks to the share directory on a storage volume
provided the following conditions are met:
Expand Down
65 changes: 42 additions & 23 deletions emhttp/plugins/dynamix/ShareSettings.page
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Tag="share-alt"
?>
<?
$disabled = _var($var,'fsState')!='Stopped' ? 'disabled' : '';
/* The "Emptying disk(s)" setting is accepted by emhttpd while the array is Started,
so it is not gated on array state - only on user shares being enabled. */
$emptyingDisabled = _var($var,'shareUser')=='-' ? 'disabled' : '';
$disks = array_filter($disks,'my_disks');
$width = [166,300];

Expand Down Expand Up @@ -61,18 +64,6 @@ async function prepareShare(form) {
item.value = exclude;
item.selected = true;

var emptying = '';
for (var i=0,item; item=form.shareUserEmptying.options[i]; i++) {
if (item.selected) {
if (emptying.length) emptying += ',';
emptying += item.value;
item.selected = false;
}
}
item = form.shareUserEmptying.options[0];
item.value = emptying;
item.selected = true;

/* Validate file count input against fileMax */
try {
const fileCountInput = form.querySelector('#file_count');
Expand All @@ -96,15 +87,34 @@ async function prepareShare(form) {
return true;
}

/* Collapse the Emptying disk(s) multi-select into a single value before submit. */
function prepareEmptying(form) {
var emptying = '';
for (var i=0,item; item=form.shareUserEmptying.options[i]; i++) {
if (item.selected) {
if (emptying.length) emptying += ',';
emptying += item.value;
item.selected = false;
}
}
item = form.shareUserEmptying.options[0];
item.value = emptying;
item.selected = true;
return true;
}

function presetShare(form,shares) {
var disabled = shares==null ? <?=$disabled ? 'true':'false'?> : shares=='-';
var onOff = disabled ? 'disable':'enable';
form.shareUserInclude.disabled = disabled;
form.shareUserExclude.disabled = disabled;
form.shareUserEmptying.disabled = disabled;
$('#s1').dropdownchecklist(onOff);
$('#s2').dropdownchecklist(onOff);
$('#s3').dropdownchecklist(onOff);
/* Emptying disk(s) lives in its own form so it can be changed while the array is
Started - emhttpd accepts it. Only disable it when user shares are turned off. */
var emptyingDisabled = shares==null ? <?=$emptyingDisabled ? 'true':'false'?> : shares=='-';
document.share_emptying.shareUserEmptying.disabled = emptyingDisabled;
$('#s3').dropdownchecklist(emptyingDisabled ? 'disable':'enable');
}
</script>
<form markdown="1" name="share_settings" method="POST" action="/update.htm" target="progressFrame" onsubmit="return prepareShare(this)">
Expand Down Expand Up @@ -144,15 +154,6 @@ _(Excluded disk(s))_:

:shares_excluded_disks_help:

_(Emptying disk(s))_:
: <select id="s3" name="shareUserEmptying" multiple="multiple" style="display:none">
<?foreach ($disks as $disk):?>
<?=mk_option_luks(_var($disk,'name'),_var($var,'shareUserEmptying'),strstr(_var($disk,'fsType'),':',true))?>
<?endforeach;?>
</select>

:shares_emptying_disks_help:

_(Permit exclusive shares)_:
: <select name="shareUserExclusive" <?=$disabled?>>
<?=mk_option($var['shareUserExclusive'], "no", _('No'))?>
Expand Down Expand Up @@ -191,3 +192,21 @@ _(Number of fuse File Descriptors)_:
</span>
<?if ($disabled):?>*_(Array must be **Stopped** to change)_*<?endif;?>
</form>

<form markdown="1" name="share_emptying" method="POST" action="/update.htm" target="progressFrame" onsubmit="return prepareEmptying(this)">

_(Emptying disk(s))_:
: <select id="s3" name="shareUserEmptying" multiple="multiple" style="display:none">
<?foreach ($disks as $disk):?>
<?=mk_option_luks(_var($disk,'name'),_var($var,'shareUserEmptying'),strstr(_var($disk,'fsType'),':',true))?>
<?endforeach;?>
</select>

:shares_emptying_disks_help:

&nbsp;
: <span class="inline-block">
<input type="submit" name="changeShare" value="_(Apply)_" disabled>
<input type="button" value="_(Done)_" onclick="done()">
</span>
</form>
Loading