Skip to content
Snippets Groups Projects

Add verification option checkboxes to FC /verification page

1 file
+ 54
31
Compare changes
  • Side-by-side
  • Inline
@@ -2,13 +2,13 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<meta content="width=device-width, initialscale=1.0" name="viewport">
<title>Verify Self-Description</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<style>
html,body {
@@ -23,6 +23,7 @@
}
</style>
</head>
@@ -33,14 +34,31 @@
<br>
Please upload a file OR copy / paste in textarea:<br>
<br>
<input type="file" id="sdFile" name="datafile" size="40" accept="application/json" class="btn btn-info">
<input accept="application/json" class="btn btn-info" id="sdFile" name="datafile" size="40" type="file">
</p>
<textarea id="content-target" style="width:800px;height:500px;" placeholder="Please upload or copy paste"></textarea>
<br><br><br>
<textarea id="content-target" placeholder="Please upload or copy paste"
style="width:800px;height:500px;"></textarea>
<div class="form-check form-check-inline">
<input checked class="form-check-input" id="verifySemantics" type="checkbox" value="true"/>
<label class="form-check-label" for="verifySemantics"> Verify Semantics </label>
</div>
<div class="form-check form-check-inline">
<input checked class="form-check-input" id="verifySchema" type="checkbox" value="true"/>
<label class="form-check-label" for="verifySchema"> Verify Schema </label>
</div>
<div class="form-check form-check-inline">
<input checked class="form-check-input" id="verifySignatures" type="checkbox" value="true"/>
<label class="form-check-label" for="verifySignatures"> Verify Signature </label>
</div>
<!--<br><br><br>-->
<button class="btn btn-primary" onclick="verifySD()">Verify</button>
<br>
<br><label id="result" style="padding:5px; font-weight:bold; float:left; width:150px; "></label>
<br><label id="result" style="padding:5px; font-weight:bold; float:left; width: 800px "></label>
<script>
<!--Getting authorization token from response and passing again to server for authentication purpose -->
@@ -71,36 +89,41 @@ function placeFileContent(target, file) {
function readFileContent(file) {
const reader = new FileReader()
return new Promise((resolve, reject) => {
reader.onload = event => resolve(event.target.result)
reader.onerror = error => reject(error)
reader.readAsText(file)
})
return new Promise((resolve, reject) => {
reader.onload = event => resolve(event.target.result)
reader.onerror = error => reject(error)
reader.readAsText(file)
})
}
<!--Post call for verify sd to server -->
function verifySD(){
$('#result').text("");
if(document.getElementById('content-target').value=="" || document.getElementById('content-target').value==null){
alert("Please add Self-Description");
return;
}
$.ajax('/verification', {
type: 'POST', // http method
contentType: "application/json;charset=utf-8",
// beforeSend: function(xhr){xhr.setRequestHeader('Authorization', Authorization);}, //to enable token header with value
data: JSON.stringify(JSON.parse(document.getElementById('content-target').value)), // data to submit
success: function (data, status, xhr) {
console.log("post verify success");
$('#result').append('Status: ' + status + ', Result: ' + JSON.stringify({data}));
},
error: function (jqXhr, textStatus, errorMessage) {
console.log("post verify failure");
$('#result').append('Error' + errorMessage);
$('#result').text("");
if(document.getElementById('content-target').value=="" || document.getElementById('content-target').value==null){
alert("Please add Self-Description");
return;
}
});
var checkVerifySemantics = $("#verifySemantics").is(":checked") ? "true" : "false";
var checkVerifySchema = $("#verifySchema").is(":checked") ? "true" : "false";
var checkVerifySignatures = $("#verifySignatures").is(":checked") ? "true" : "false";
var urlWithParam = "/verification?verifySemantics="+checkVerifySemantics+"&verifySchema="+checkVerifySchema+"&verifySignatures="+checkVerifySignatures;
$.ajax(urlWithParam,{
type: 'POST',
contentType: "application/json;charset=utf-8",
data: document.getElementById('content-target').value,
success: function (data, status, xhr) {
$('#result').append('Status : ' + status + ', Result: ' + JSON.stringify({data}));
},
error: function (jqXhr, textStatus, errorMessage) {
$('#result').append('Error : ' + JSON.stringify(jqXhr.responseJSON));
}
});
}
</script>
</div>
</div>
Loading