Commit 1afbca25 authored by Dietmar's avatar Dietmar

initial commit

parent 56fe7045
body{
font-family:Helvetica,Arial,sans-serif;
font-size:14px;
}
input, select, textarea{
margin:5px;
vertical-align:middle;
}
.green {
color: green;
}
.orange {
color: orange;
}
.red {
color: red;
}
input[type=text]{
width:200px;
}
.main_frame{
margin: 15px;
}
#results{
overflow: auto;
}
.spinner{
border: 0;
height:100px;
position: absolute;
top: 30%;
left: 50%;
z-index: 30000;
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
#spinner_background {
position:fixed;
width:100%;
left:0;right:0;top:0;bottom:0;
background-color: rgba(255,255,255,0.7);
z-index:9999;
display:block;
}
textarea{
min-width:300px;
min-height:150px;
}
label{
display:inline;
vertical-align:middle;
}
hr{
clear:both;
margin:10px 0px;
}
#mapDiv{
width:100%;
height:480px;
margin:10px 0px;
position:relative;
}
#loadingImg{
display:none;
position:absolute;
left:50%;
top:50%;
z-index:10002;
}
.leaflet-clickable{
cursor:pointer;
}
.olLayerDiv image, .olLayerDiv polyline{
cursor:pointer;
}
#mapDiv_gc image, #mapDiv_gc path{
cursor:pointer;
}
.topic{
padding:5px;
margin:2px;
border:1px solid #EEE;
float:left;
}
/* Library Generated Form Element Containers */
.fmes-form-component{
clear:left;
float:left;
display:block;
width:100%;
margin:4px 0px;
}
select[name="Datatype"] {
width: 20% !important;
}
/* Drag and Drop Elements */
.drop{
height:110px;
width:100%;
display:block;
}
.drop-file{
opacity:0;
filter:alpha(opacity=0);
position:absolute;
z-index:100;
top:0;
left:0;
margin:0;
}
#drop{
margin:20px 0px 0px;
padding:55px 0px;
height:40px;
line-height:40px;
border:1px solid #CCC;
background-color:#EEE;
color:#DDD;
font-size:40px;
text-align:center;
position:relative;
cursor:default !important;
}
#drop:hover{
border:1px solid #999;
color:#999;
}
/* End of Drag and Drop Elements */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!-- Upload Files Drag and Drop Example from FME Server Developer Playground -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>XML-Checker</title>
<!-- Styles for example -->
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="css/XML_Checker.css" type="text/css" />
<!-- Include FMEServer.js -->
<!-- <script defer type="text/javascript" src="js/bootstrap.min.js"></script> -->
<script src="js/jquery.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/FMEServer.js"></script>
<script type="text/javascript" src="js/XML_Checker.js"></script>
</head>
<body>
<div class="main_frame">
<div id="spinner_background"></div>
<div id="spinner" class="spinner">
<img src="../../images/hzg2.gif" alt="spinner" class="spinner"/>
</div>
<h1> XML-Checker</span></h1>
<form id="UploadForm">
<!-- <input id="repository-name" type="hidden" name="repository" value="Samples" /><br /> -->
<input id="repository-name" type="hidden" name="repository" value="TomcatBackend" /><br />
<!-- <input id="workspace-name" type="hidden" name="workspace" value="easyTranslator.fmw" /> -->
<input id="workspace-name" type="hidden" name="workspace" value="XML_Checker.fmw" />
</form>
<hr />
<form id="options"></form>
<hr />
<div id="error" class="alert alert-info" role="alert"></div>
<!-- <label><b>Liste der hochgeladenen Dateien</b>: </label> -->
<div id="manage">
<input id="refresh" type="button" class="btn btn-primary" onclick="clear_results();" value="Ergebnisse leeren" />
<div id="fileList" hidden></div>
<hr />
</div>
<div id="results"></div>
</div>
</body>
</html>
This diff is collapsed.
var developing_env = true;
var session, path, fileInput, files, repository, workspace, last_upload;
window.onload = function() {
wait_for_results(); // hide initial
toggle_div("error");
document.getElementById("manage").style.display = "none";
FMEServer.init({
server : "http://a1sv0000160:3099",
token : "7491024f500fd4977d60d292b1e367fd0a3f2f9a"
});
// Initialize variables
setWorkspace();
// Ask FME Server for the current session id and set it
FMEServer.getSession( repository, workspace, setVars );
// Get options for the workspace
generateOptions();
};
function toggle_div(div_name,message) {
var x = document.getElementById(div_name);
if (message) x.innerHTML = message;
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
function setVars( json ) {
if( json.serviceResponse.files ) {
session = json.serviceResponse.session;
path = json.serviceResponse.files.folder[0].path;
} else {
showResults( json );
}
}
function setWorkspace() {
repository = document.getElementById( "repository-name" ).value.trim();
workspace = document.getElementById( "workspace-name" ).value.trim();
}
function uploadFile() {
setWorkspace();
last_upload = fileInput.files[0].name;
if (developing_env) console.log("last_upload",last_upload);
// Ask FME Server to upload the files
FMEServer.dataUpload( repository, workspace, fileInput, session, processFiles );
}
function clear_results() {
document.getElementById("results").innerHTML = "";
document.getElementById("fileList").innerHTML = "";
last_upload = "";
document.getElementById("manage").style.display = "none";
}
function show_wrongs(my_array,mode,div,json) {
var exists = false;
var text_array = [];
for (var i = 0; i < my_array.length; i++) {
if (json[0][my_array[i]] != 1) {
exists = true;
text_array.push(my_array[i]);
}
}
if (exists) {
if (mode=="Warning"){
// div.innerHTML += "<h2>Mode: " + mode + "</h2>";
div.innerHTML += "<br>Um die Qualit&auml;t zu verbessern geben Sie bitte folgende Felder an:<b> " + text_array.join(", ") + "</b>.<br>";
}
if (mode=="Error"){
// div.innerHTML += "<h2>Mode: " + mode + "</h2>";
div.innerHTML += "<br>Die Minimalanforderungen an die Qualit&auml;t erfordern folgende Felder:<b> " + text_array.join(", ") + "</b>.<br>";
}
}
}
function wait_for_results () {
toggle_div("spinner");
toggle_div("spinner_background");
}
function showResults( json ) {
wait_for_results();
if (developing_env) console.log("showResults",json);
// The following is to write out the return object
if (json[0].json_featuretype == "Success") {
document.getElementById("manage").style.display = "block";
document.getElementById("error").style.display = "none";
//Answer
var div = document.createElement( "div" );
div.innerHTML = "<hr /><h1>" + json[0].Quality;
var error_fields = json[0].Error_fields.split(",");
var warning_fields = json[0].Warning_fields.split(",");
show_wrongs(error_fields,"Error",div,json);
show_wrongs(warning_fields,"Warning",div,json);
var results = document.getElementById( "results" )
results.insertBefore( div, results.firstChild );
} else {
toggle_div("error",json[0].Message);
}
}
function processFiles( json ) {
if (developing_env) console.log("processFiles", json);
var list = document.getElementById( "fileList" );
// if( list != undefined ) {
if( json.serviceResponse != undefined ) {
list.innerHTML = "";
files = json.serviceResponse.files.file;
if (developing_env) console.log("files", files);
for( var file in files ){
list.innerHTML += "<p>"+files[file].name+", <em>"+files[file].size+" bytes</em></p>";
}
archives = json.serviceResponse.files.archive;
for( var archive in archives ){
list.innerHTML += "<p>"+archives[archive].name+", <em>"+archives[archive].size+" bytes</em></p>";
}
runWorkspace(json)
// }
} else {
// Required for proper list refresh on IE9 below and older browsers
setTimeout("getFiles();", 2000);
}
}
function processParams() {
var inputs = document.getElementById( "options" ).getElementsByTagName( "input" );
var selects = document.getElementById( "options" ).getElementsByTagName( "select" );
var options = [];
var properties = "";
// Convert HTML NodeList types to regular array types
inputs = Array.prototype.slice.call( inputs );
selects = Array.prototype.slice.call( selects );
// Merge the regular arrays
options = inputs.concat( selects );
for( var opt in options ) {
var option = options[opt];
if( option.value && option.name != fileInput.name && option.type != "button" ) {
properties += option.name+"=";
if( option.type == "select" ) {
properties += option[ option.selectedIndex ].value;
} else {
properties += option.value;
}
properties += "&";
}
}
properties = properties.substr( 0, properties.length - 1 );
return properties;
}
function hide_labels(){
// change later maybe
var labels = document.getElementById( "options" ).getElementsByTagName( "label" );
for (var i = 0; i < labels.length; i++) {
labels[i].style.display = "none";
}
}
function buildOptions( json ) {
// Use the API to build the form items
FMEServer.generateFormItems( "options", json );
if (developing_env) console.log("options", json);
hide_labels();
document.getElementsByName("Datatype")[0].classList.add("form-control");
// Attach the upload button to the form file input
var inputs = document.getElementById( "options" ).getElementsByTagName( "input" );
var added = false;
for( var i in inputs ) {
if( inputs[i].type == "file" && added === false ){
fileInput = inputs[i];
var drop = document.createElement( "div" );
drop.id = "drop";
drop.setAttribute( "class", "drop" );
fileInput.setAttribute( "class", "drop drop-file" );
fileInput.id = "filebox";
fileInput.parentNode.insertBefore( drop, fileInput.nextSibling );
var droptext = "Drag & Drop Datei hierher, oder Doppel-Klick um Datei auszuw&auml;hlen";
// Custom Code for Internet Explorer
if( navigator.appName == 'Microsoft Internet Explorer' ) {
drop.innerHTML = droptext;
window.addEventListener( "drop", function( event ) {
event.stopPropagation();
event.preventDefault();
}, false );
window.addEventListener( "dragover", function( event ) {
event.stopPropagation();
event.preventDefault();
}, false );
fileInput.addEventListener( "drop", function( event ) {
if( event.dataTransfer.files !== undefined ) {
fileInput = {
files : event.dataTransfer.files
};
uploadFile();
}
}, false );
} else { // All modern browsers
drop.innerHTML = droptext;
// Add the on "drop" handler
fileInput.onchange = function() {
uploadFile();
};
}
drop.appendChild( fileInput );
// End Drop Area Code
added = true;
}
}
}
function generateOptions() {
setWorkspace();
// Get the workspace parameters from FME Server
FMEServer.getWorkspaceParameters( repository, workspace, buildOptions );
}
function runWorkspace(my_json) {
if (developing_env) console.log("my_json",my_json);
wait_for_results();
if( files != undefined || archives != undefined ) {
if( archives != undefined) {
files = archives;
}
setWorkspace();
var path;
var datatype_select = document.getElementsByName("Datatype")[0];
for( var file in files ){
if (files[file].name == last_upload) path = files[file].path;
}
if (developing_env) console.log("path",path);
var params = {
opt_responseformat: "json",
SourceDataset: path,
Datatype: datatype_select.options[datatype_select.selectedIndex].value
}
if (developing_env) console.log("params",params);
workspace += "?opt_responseformat=json&Source=" + params.SourceDataset + "&Datatype=" + params.Datatype;
if (developing_env) console.log("workspace",workspace);
// Ask FME Server to run the workspace with the uploaded data
FMEServer.runDataStreaming( repository, workspace, params, showResults );
} else {
toggle_div("error","Noch keine Datei hochgeladen zum Leeren!");
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment