Skip to content
Snippets Groups Projects
Commit 9003fe52 authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

#30 Enable/Disable Actions - Configuration

parent d0d7faab
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,5 @@ public enum ActionScope {
INPUT_DATA,
INPUT_COLUMN,
OUTPUT_COLUMN,
DECISION_TABLE,
DECISION
}
......@@ -7,12 +7,34 @@
body {
font-family: 'Open Sans', sans-serif;
}
label {
margin: 5px;
}
#globalSettings {
margin-bottom: 15px;
}
.row {
margin-bottom: 10px;
}
.cell {
display: table-cell;
width: 200px;
}
</style>
</head>
<body>
<div id="metricContainer">
<h1>Actions - Configuration</h1>
<div id="configContent"></div>
<div id="configContent">
<div id="globalSettings"></div>
<div id="allowedActions"></div>
</div>
</div>
<!-- load jquery -->
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js" type="text/javascript"></script>
......@@ -22,13 +44,13 @@
loadData();
});
const $checkbox = $(`<input type="checkbox" onchange="update()"/>"`);
const $globalCheckbox = $(`<input type="checkbox" onchange="updateGlobal()"/>"`);
const rootUrl = 'http://' + window.location.hostname + ':8080/';
const dmnApi = rootUrl + 'api/dmn/';
function loadData() {
let $root = $('#configContent');
$root.empty();
let $globalSettings = $('#globalSettings');
$globalSettings.empty();
$.ajax({
timeout: 1000,
url: dmnApi + 'verification/actions/global',
......@@ -37,17 +59,59 @@
alert("No connection.");
},
success: function (active) {
$root.append("<label>Active:</label>");
$root.append($checkbox);
$checkbox[0].checked = (active === 'true');
$globalSettings.append("<label>Global active:</label>");
$globalSettings.append($globalCheckbox);
$globalCheckbox[0].checked = (active === 'true');
}
});
let $allowedActions = $('#allowedActions');
$.ajax({
timeout: 1000,
url: dmnApi + 'verification/actions/allowedActions',
type: 'GET',
error: function (err) {
alert("No connection.");
},
success: function (allowedActions) {
for (const [actionScope, typeBol] of Object.entries(allowedActions)) {
let $row = $(`<div class="row"><label>${actionScope}:</label></div>`);
$allowedActions.append($row);
for (const [actionType, value] of Object.entries(typeBol)) {
let $checkbox = $(
`<input type="checkbox" data-actionscope="${actionScope}" data-actiontype="${actionType}" onchange="updateAllowedAction(this)"/>"`);
$checkbox[0].checked = value;
let $cell = $(`<div class="cell"><label>${actionType}</label></div>`);
$cell.append($checkbox);
$row.append($cell);
}
}
}
});
}
function updateGlobal() {
$.ajax({
timeout: 1000,
url: dmnApi + 'verification/actions/global/' + $globalCheckbox[0].checked,
type: 'POST',
error: function (err) {
alert("No connection.");
},
success: function (active) {
$('#allowedActions').css('display', $globalCheckbox[0].checked ? '' : 'none')
}
});
}
function update() {
function updateAllowedAction(checkbox) {
console.log(checkbox.checked);
console.log(checkbox.dataset.actionscope);
console.log(checkbox.dataset.actiontype);
$.ajax({
timeout: 1000,
url: dmnApi + 'verification/actions/global/' + $checkbox[0].checked,
url: dmnApi + 'verification/actions/allowedActions/' + checkbox.dataset.actionscope + "/"
+ checkbox.dataset.actiontype + "/" + checkbox.checked,
type: 'POST',
error: function (err) {
alert("No connection.");
......
......@@ -260,16 +260,18 @@ span.select2 {
display: flex;
flex-direction: row;
justify-content: stretch;
margin: 10px;
margin: 4px;
min-height: 35px;
border-top: #0d82b7 2px;
border-top-style: ridge;
border-radius: 3px;
align-items: center;
}
.dmn-verification-icon {
width: 32px;
height: 30px;
display: inline-block;
flex: 0 0 24px;
background-repeat: no-repeat;
background-size: contain;
background-position: center center;
......@@ -292,7 +294,6 @@ span.select2 {
}
.verification-message {
padding-top: 8px;
padding-left: 8px;
width: 100%;
flex-shrink: 1;
......@@ -301,18 +302,20 @@ span.select2 {
.verification-container-fix-buttons {
float: right;
padding-top: 8px;
display: flex;
flex-direction: row;
flex-grow: 1;
justify-content: space-between;
justify-content: flex-end;
flex-wrap: wrap;
align-items: center;
}
.verification-fix-button {
height: 25px;
height: 28px;
min-width: 100px;
margin: 2px 2px 5px 10px;
margin-right: 4px;
margin-top: 4px;
margin-bottom: 4px;
}
.highlight {
......
......@@ -106,9 +106,6 @@ function performVerificationFixSHOW(verificationEntry, fixAction) {
case 'OUTPUT_COLUMN':
fixSHOW_OUTPUT_COLUMN(verificationEntry, fixAction);
break;
case 'DECISION_TABLE':
fixSHOW_DECISION_TABLE(verificationEntry, fixAction);
break;
case 'DECISION':
fixSHOW_DECISION(verificationEntry, fixAction);
break;
......@@ -172,15 +169,6 @@ function fixSHOW_OUTPUT_COLUMN(verificationEntry, fixAction) {
highlightColumns(verificationEntry.elements, 'outputId');
}
/**
*
* @param {VerificationEntry} verificationEntry
* @param {Action} fixAction
*/
function fixSHOW_DECISION_TABLE(verificationEntry, fixAction) {
highlightDecision(verificationEntry.elements);
}
/**
*
* @param {VerificationEntry} verificationEntry
......@@ -291,7 +279,6 @@ function performVerificationFixDELETE(verificationEntry, fixAction) {
break;
case 'INPUT_ENTRY':
case 'OUTPUT_ENTRY':
case 'DECISION_TABLE':
case 'DECISION':
default:
alert("ACTION undefined: " + fixAction.actionType + ' -> '
......@@ -361,7 +348,6 @@ function performVerificationFixUPDATE(verificationEntry, fixAction) {
case 'OUTPUT_COLUMN':
case 'INPUT_ENTRY':
case 'OUTPUT_ENTRY':
case 'DECISION_TABLE':
default:
alert("ACTION undefined: " + fixAction.actionType + ' -> '
+ fixAction.actionScope);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment