Files
webgui/emhttp/plugins/dynamix/ParityCheck.page
Tom Mortensen f9ec00b488 repo reorg
2023-06-02 12:49:33 -07:00

230 lines
7.3 KiB
Plaintext

Menu="Scheduler:1"
Title="Parity Check"
Tag="calendar"
---
<?PHP
/* Copyright 2012-2023, Bergware International.
* Copyright 2005-2023, Lime Technology
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
if (_var($disks['parity'],'status')=='DISK_NP_DSBL' && _var($disks['parity2'],'status')=='DISK_NP_DSBL') {
echo "<p class='notice'>"._('No Parity disk present')."!</p>";
}
$width = [166,300];
$mode = ['Disabled','Daily','Weekly','Monthly','Yearly','Custom'];
$days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
$months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
$memory = '/tmp/memory.tmp';
if (file_exists($memory)) {
parse_str(file_get_contents($memory), $parity);
if (empty($parity['hour'])) $parity['hour'] = "";
if (empty($parity['day'])) $parity['day'] = "";
if (empty($parity['dotm'])) $parity['dotm'] = "";
if (empty($parity['month'])) $parity['month'] = "";
if (empty($parity['write'])) $parity['write'] = "NOCORRECT";
}
if ($parity['mode']<2) $parity['cumulative'] = '';
if ($parity['mode']==2) $parity['frequency'] = '1';
?>
<script>
<?if ($parity['mode']==5):?>
$(function() {
$("#s1").dropdownchecklist({emptyText:"_(Every day)_", width:<?=$width[0]?>, explicitClose:"..._(close)_"});
$("#s2").dropdownchecklist({emptyText:"_(Every month)_", width:<?=$width[0]?>, explicitClose:"..._(close)_"});
});
// Simulate a single input field
function prepareParity(form) {
var days = '';
for (var i=0,item; item=form.day.options[i]; i++) {
if (item.selected) {
if (days.length) days += ',';
days += item.value;
item.selected = false;
}
}
item = form.day.options[0];
item.value = days || '*';
item.selected = true;
var months = '';
for (var i=0,item; item=form.month.options[i]; i++) {
if (item.selected) {
if (months.length) months += ',';
months += item.value;
item.selected = false;
}
}
item = form.month.options[0];
item.value = months || '*';
item.selected = true;
}
<?else:?>
function prepareParity(form) {
// do nothing
}
<?endif;?>
$(function() {
<?if (file_exists($memory)):?>
setTimeout(function(){$('input[value="_(Apply)_"]').removeAttr('disabled');},0);
$('input[value="_(Done)_"]').val("_(Reset)_").prop('onclick',null).click(function(){refresh($(this).parentsUntil('form').parent().offset().top)});
<?unlink($memory);?>
<?endif;?>
presetParity(document.parity_settings);
});
function presetParity(form) {
var mode = form.mode.value;
form.day.disabled = mode!=2 && mode!=5;
form.dotm.disabled = mode<3;
form.hour.disabled = mode==0;
form.month.disabled = mode<4;
form.write.disabled = mode==0;
}
function showCumulative(val,pace) {
if (val=='') $('#cumulative').hide(pace); else $('#cumulative').show(pace);
}
$(function(){
showCumulative($('select[name="cumulative"]').val());
});
</script>
<form markdown="1" name="parity_settings" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareParity(this)">
<input type="hidden" name="#file" value="dynamix/dynamix.cfg"/>
<input type="hidden" name="#section" value="parity"/>
<input type="hidden" name="#include" value="/webGui/include/update.parity.php"/>
_(Scheduled parity check)_:
: <select name="mode" onchange="submit()">
<?for ($m=0; $m<count($mode); $m++):?>
<?=mk_option($parity['mode'], strval($m), _($mode[$m]))?>
<?endfor;?>
</select>
:parity_check_scheduled_help:
_(Day of the week)_:
<?if ($parity['mode']==2):?>
: <select name="day">
<?for ($d=0; $d<count($days); $d++):?>
<?=mk_option($parity['day'], strval($d), ucfirst(_($days[$d],0)))?>
<?endfor;?>
<?elseif ($parity['mode']==5):?>
: <select id="s1" name="day" multiple="multiple" style="display:none">
<?for ($d=0; $d<count($days); $d++):?>
<?=mk_option_check($parity['day'], strval($d), ucfirst(_($days[$d],0)))?>
<?endfor;?>
<?else:?>
: <select name="day">
<?=mk_option($parity['day'], "*", "--------")?>
<?endif;?>
</select>
:parity_day_of_the_week_help:
<?if ($parity['mode']<5):?>
_(Day of the month)_:
<?else:?>
_(Week of the month)_:
<?endif;?>
: <select name="dotm">
<?if ($parity['mode']>=3):?>
<?if ($parity['mode']==5):?>
<?=mk_option($parity['dotm'], "*", _("Every week"))?>
<?=mk_option($parity['dotm'], "W1", _("First week"))?>
<?=mk_option($parity['dotm'], "W2", _("Second week"))?>
<?=mk_option($parity['dotm'], "W3", _("Third week"))?>
<?=mk_option($parity['dotm'], "W4", _("Fourth week"))?>
<?=mk_option($parity['dotm'], "WL", _("Last week"))?>
<?else:?>
<?=mk_option($parity['dotm'], "1", _("First day"))?>
<?=mk_option($parity['dotm'], "28-31", _("Last day"))?>
<?for ($d=2; $d<=31; $d++):?>
<?=mk_option($parity['dotm'], strval($d), sprintf("%02d", $d))?>
<?endfor;?>
<?endif;?>
<?else:?>
<?=mk_option($parity['dotm'], "*", "--------")?>
<?endif;?>
</select>
:parity_week_of_the_month_help:
_(Time of the day)_:
: <select name="hour">
<?if ($parity['mode']>0):?>
<?for ($h=0; $h<24; $h++):?>
<?=mk_option($parity['hour'], sprintf("0 %d", $h), sprintf("%02d:00", $h))?>
<?=mk_option($parity['hour'], sprintf("30 %d",$h), sprintf("%02d:30", $h))?>
<?endfor;?>
<?else:?>
<?=mk_option($parity['hour'], "*", "--------")?>
<?endif;?>
</select>
:parity_time_of_the_day_help:
_(Month of the year)_:
<?if ($parity['mode']>=4):?>
<?if ($parity['mode']==5):?>
: <select id="s2" name="month" multiple="multiple" style="display:none">
<?for ($m=0; $m<count($months); $m++):?>
<?=mk_option_check($parity['month'], strval($m+1), ucfirst(_($months[$m],0)))?>
<?endfor;?>
<?else:?>
: <select name="month">
<?for ($m=0; $m<count($months); $m++):?>
<?=mk_option($parity['month'], strval($m+1), ucfirst(_($months[$m],0)))?>
<?endfor;?>
<?endif;?>
<?else:?>
: <select name="month">
<?=mk_option($parity['month'], "*", "--------")?>
<?endif;?>
</select>
:parity_month_of_the_year_help:
_(Write corrections to parity disk)_:
: <select name="write">
<?=mk_option($parity['write'], "NOCORRECT", _("No"))?>
<?=mk_option($parity['write'], "", _("Yes"))?>
</select>
:parity_write_corrections_help:
_(Cumulative parity check)_:
: <select name="cumulative" onchange="showCumulative(this.value,'slow')" <?=$parity['mode']>1?'':'disabled'?>>
<?=mk_option(_var($parity,'cumulative'), "", _("No"))?>
<?=mk_option(_var($parity,'cumulative'), "1", _("Yes"))?>
</select>
:parity_cumulative_check_help:
<div markdown="1" id="cumulative" style="display:none">
_(Accumulation frequency)_:
: <select name="frequency">
<?=mk_option(_var($parity,'frequency'), "1", _("Daily"))?>
<?=mk_option(_var($parity,'frequency'), "7", _("Weekly"),$parity['mode']==2 ? 'disabled' : '')?>
</select>
:parity_accumulation_frequency_help:
_(Accumulation duration)_:
: <select name="duration">
<?for ($h=1; $h<24; $h++):?>
<?=mk_option(_var($parity,'duration'), $h, $h.' '._('hour'.($h==1?'':'s')))?>
<?endfor;?>
</select>
:parity_accumulation_duration_help:
</div>
&nbsp;
: <input type="submit" name="#apply" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()"></td>
</form>