Merge pull request #1970 from dlandon/share_edit_read_write_not_working

Read and Write shares not working.
This commit is contained in:
tom mortensen
2025-01-06 10:35:57 -08:00
committed by GitHub
+41 -26
View File
@@ -554,6 +554,9 @@ _(Mover action)_:
<script>
let form = document.share_edit;
/* Global flag to skip prepareEdit. */
let skipPrepareEdit = false;
/* Primary variables to check for valid selection of missing pool. */
let changeMadePrimary = false;
let checkRequiredPrimary = false;
@@ -918,6 +921,15 @@ function parseDiskSize(sizeStr) {
/* Compose input fields. */
function prepareEdit() {
/* Skip the function if readShare() filled the values */
if (skipPrepareEdit) {
/* Reset the flag. */
skipPrepareEdit = false;
/* Allow the form to submit. */
return true;
}
/* Declare variables at the function scope */
let share, reserved, pools;
@@ -1018,38 +1030,39 @@ function prepareEdit() {
}
function readShare() {
/* Declare variables at the function scope */
var name, data, disk, include, exclude, i, j;
let name, data;
name = $('select[name="readshare"]').val();
initDropdown(true);
name = $('select[name="readshare"]').val();
$.get('/webGui/include/ShareData.php', { name: name }, function(json) {
data = $.parseJSON(json);
form.shareAllocator.value = data.allocator;
form.shareFloor.value = data.floor;
form.shareSplitLevel.value = data.splitLevel;
form.shareInclude.value = data.include;
form.shareExclude.value = data.exclude;
form.shareUseCache.value = data.useCache;
form.shareCOW.value = data.cow;
$.get('/webGui/include/ShareData.php', { name: name }, function(json) {
data = $.parseJSON(json);
let form = document.forms['share_edit'];
for (i = 0; (disk = data.include.split(',')[i]); i++) {
for (j = 0; (include = form.shareInclude.options[j]); j++) {
if (include.value == disk) include.selected = true;
}
/* Fill in the form values */
form.shareAllocator.value = data.allocator;
form.shareFloor.value = data.floor;
form.shareSplitLevel.value = data.splitLevel;
form.shareInclude.value = data.include;
form.shareExclude.value = data.exclude;
form.shareUseCache.value = data.useCache;
form.shareCachePool2.value = data.cachePool2;
form.shareCOW.value = data.cow;
/* Populate the primary storage field (shareCachePool) */
let primaryField = document.getElementById('primary');
if (primaryField) {
/* Set to retrieved value or default. */
primaryField.value = data.cachePool || '';
}
for (i = 0; (disk = data.exclude.split(',')[i]); i++) {
for (j = 0; (exclude = form.shareExclude.options[j]); j++) {
if (exclude.value == disk) exclude.selected = true;
}
}
/* Set flag to skip prepareEdit */
skipPrepareEdit = true;
initDropdown(false);
});
$(form).find('select').trigger('change');
/* Enable and trigger the submit button */
const submitButton = document.getElementById('cmdEditShare');
submitButton.disabled = false;
submitButton.click();
});
}
function writeShare(data, n, i) {
@@ -1081,6 +1094,8 @@ function writeShare(data, n, i) {
newData[i]['shareInclude'] = '<?=addslashes(htmlspecialchars($share['include']))?>';
newData[i]['shareExclude'] = '<?=addslashes(htmlspecialchars($share['exclude']))?>';
newData[i]['shareUseCache'] = '<?=addslashes(htmlspecialchars($share['useCache']))?>';
newData[i]['shareCachePool'] = '<?=addslashes(htmlspecialchars($share['cachePool']))?>';
newData[i]['shareCachePool2'] = '<?=addslashes(htmlspecialchars($share['cachePool2']))?>';
newData[i]['cmdEditShare'] = 'Apply';
i++;
}