Improved property check.

This commit is contained in:
Christian P. MOMON 2020-10-29 19:41:53 +01:00
parent f9b49ab7f0
commit 1c59d56532
3 changed files with 101 additions and 31 deletions

View file

@ -19,6 +19,7 @@
package fr.devinsy.statoolinfos.checker; package fr.devinsy.statoolinfos.checker;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.regex.Pattern;
import fr.devinsy.statoolinfos.core.Service.Status; import fr.devinsy.statoolinfos.core.Service.Status;
@ -48,9 +49,11 @@ public class PropertyChecks extends ArrayList<PropertyCheck>
result = new PropertyChecks(); result = new PropertyChecks();
Pattern pattern = Pattern.compile("^(\\s*[^#\\s]|#\\s*\\[).*$");
for (PropertyCheck check : this) for (PropertyCheck check : this)
{ {
if (!check.getLine().matches("^(|#\\s?[^\\[].*)$")) if (pattern.matcher(check.getLine()).matches())
{ {
result.add(check); result.add(check);
} }

View file

@ -33,6 +33,7 @@ import fr.devinsy.statoolinfos.checker.PropertyChecks;
import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Service; import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Service.Status;
import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.data.TagDataManager;
@ -108,36 +109,19 @@ public class PropertyFileCheckPage
data.setContent("line", index, "lineIndex", check.getIndex()); data.setContent("line", index, "lineIndex", check.getIndex());
data.setEscapedContent("line", index, "lineComment", check.getComment()); data.setEscapedContent("line", index, "lineComment", check.getComment());
data.setEscapedContent("line", index, "lineContent", check.getLine()); data.setEscapedContent("line", index, "lineContent", check.getLine());
data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus()));
// index += 1;
String statusClass;
switch (check.getStatus())
{
case OK:
statusClass = "bg_ok";
break;
case WARNING:
statusClass = "bg_warning";
break;
case ALERT:
statusClass = "bg_alert";
break;
case ERROR:
statusClass = "bg_error";
break;
case OVER:
statusClass = "bg_over";
break;
case VOID:
default:
statusClass = "bg_void";
} }
data.setAttribute("line", index, "lineContent", "class", statusClass);
index = 0;
for (PropertyCheck check : checks.extractActiveLines())
{
//
data.setContent("shrunkLine", index, "shrunkLineIndex", check.getIndex());
data.setEscapedContent("shrunkLine", index, "shrunkLineContent", check.getLine());
data.setEscapedContent("shrunkLine", index, "shrunkLineComment", check.getComment());
data.setAttribute("shrunkLine", index, "shrunkLineContent", "class", statusToCSS(check.getStatus()));
index += 1; index += 1;
} }
@ -157,4 +141,47 @@ public class PropertyFileCheckPage
// //
return result; return result;
} }
/**
* Status to CSS.
*
* @param status
* the status
* @return the string
*/
public static String statusToCSS(final Status status)
{
String result;
switch (status)
{
case OK:
result = "bg_ok";
break;
case WARNING:
result = "bg_warning";
break;
case ALERT:
result = "bg_alert";
break;
case ERROR:
result = "bg_error";
break;
case OVER:
result = "bg_over";
break;
case VOID:
default:
result = "bg_void";
}
//
return result;
}
} }

View file

@ -16,7 +16,15 @@
<h2 id="statsTitle">n/a</h2> <h2 id="statsTitle">n/a</h2>
</div> </div>
<br/> <br/>
<div style="width: 100%;"> <div id="rawgroupedswitch" style="margin: 4px;">
<span style="display: inline-block; padding-top: 6px; vertical-align: text-top;"><a href="#part2">Shrunk</a></span>
<label class="switch">
<input type="checkbox" onclick="javascript:viewFlip();" />
<span class="slider round"></span>
</label>
</div>
<div id="fullBlock" style="width: 100%;">
<table class="table_simple"> <table class="table_simple">
<tbody> <tbody>
<tr id="line"> <tr id="line">
@ -27,6 +35,38 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div id="shrunkBlock" style="width: 100%; display: none;">
<table class="table_simple">
<tbody>
<tr id="shrunkLine">
<td id="shrunkLineIndex" style="width: 30px; text-align: right;">000</td>
<td id="shrunkLineContent" style="padding-left: 10px;">n/a</td>
<td id="shrunkLineComment" style="width: 200px; padding-left: 10px;">n/a</td>
</tr>
</tbody>
</table>
</div> </div>
</div>
<script type="text/javascript">
var showView = 'FULL';
function viewFlip ()
{
if (showView == 'FULL')
{
document.getElementById ('fullBlock').style.display = 'none';
document.getElementById ('shrunkBlock').style.display = 'block';
showView = 'SHRUNK';
}
else
{
document.getElementById ('fullBlock').style.display = 'block';
document.getElementById ('shrunkBlock').style.display = 'none';
showView = 'FULL';
}
}
</script>
</body> </body>
</html> </html>