forked from routetopa/deep-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
executable file
·279 lines (227 loc) · 10.1 KB
/
demo.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="datalets/shared_js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<script type="text/javascript" src="configuration.js"></script>
<link rel="import" href="bower_components/iron-component-page/iron-component-page.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html">
<!-- <script type="text/javascript" src="docs/js/editarea_0_8_2/edit_area/edit_area_full.js"></script> -->
<style is="custom-style">
#creator_container {
width: 100%;
height: 100%;
}
#creator_container * {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
}
#text_container {
padding: 8px;
//background: #BBDEFB;
background: #B6B6B6;
margin-top: 8px;
}
#controllet_iframe {
height: 100%;
width: 100%;
}
#iframe_container {
//border: 2px solid #BBDEFB;
border: 2px solid #B6B6B6;
border-top: 0;
width: calc(100% - 4px);
height: 698px;
}
#toolbar {
background: #00b4ff;
}
.title {
font-weight: 700 !important;
}
#logo{
width: 64px;
height: 64px;
background-image: url("http://spod.routetopa.eu/ow_static/themes/spod_theme_matter/images/logo.png");
background-repeat: no-repeat;
background-position: center center;
}
paper-icon-button {
--paper-icon-button-ink-color: #FFFFFF;
height: 48px;
width: 48px;
padding: 8px;
}
a {
color: #FFFFFF;
text-decoration: none;
}
#text_area_container {
width: 100%;
height: calc(100vh - 884px);
min-height: 192px;
margin-top: 8px;
/*background: red;*/
}
#text_area {
width: calc(100% - 18px);
height: calc(100% - 18px);
margin: 0;
padding: 8px;
}
/* EXPORT TO HTML */
.export_html_textarea {
margin-top: 36px;
height: 200px;
}
.button-close {
display: inline-block;
width: 16px;
height: 16px;
position: absolute;
top: 10px;
right: 10px;
cursor: pointer;
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAowAAAKMB8MeazgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAB5SURBVDiNrZPRCcAwCEQfnUiySAZuF8kSWeH6Yz8KrQZMQAicJ+epAB0YwAmYJKIADLic0/GPPCbQAnLznCd/4NWUFfkgy1VjH8CryA95ApYltAiTRCZxpuoW+gz9WXE6NPeg+ra1UDIxGlWEObe4SGxY5fIxlc75Bkt9V4JS7KWJAAAAAElFTkSuQmCC59ef34356faa7edebc7ed5432ddb673d');
}
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.6);
z-index: 1000000;
}
.modal-content {
padding: 20px 30px;
width: 600px;
position: relative;
min-height: 300px;
margin: 5% auto 0;
background: #fff;
}
.error-modal-content {
padding: 20px 30px;
width: 600px;
position: relative;
height: 100px;
margin: 5% auto 0;
background: #fff;
}
/* EXPORT TO HTML */
</style>
</head>
<body>
<div id="creator_container">
<paper-toolbar id="toolbar">
<span class="title">DatalEts-Ecosystem Provider - Datalet Creator</span>
<a href="docs/docs.html" target="_blank"><paper-icon-button icon="description" title="DEEP Documentation"></paper-icon-button></a>
</paper-toolbar>
<div id="text_container">
Using this page you can create a Datalet, a off-the-shelf, reusable web-component able to load,
query, filter, and visualise any dataset content (e.g. through HighCharts Javascript library).
Datalet are reusable since they can be placed in every web page, like institutional web-sites,
blogs, forums and so on, without any knowledge on how it effectively is implemented.
</div>
<div id="iframe_container">
<iframe id="controllet_iframe" frameborder="0" src="./iframe_controllet.html"></iframe>
</div>
<!-- <div id="text_area_container" style="display:none"> -->
<!-- <textarea id="text_area">Copy and paste this code to inject the datalet in you page.</textarea> -->
<!-- </div> -->
<div id="text_area_container" style="display:none">
<div class="overlay" id="overlay">
<div class="modal-content">
<div style="display:inline-block"> <h5 style="margin:0px">Datalet Created!</h5><span class="button-close" onclick="document.getElementById('text_area_container').style.display = 'none'"></span></div>
<div class="modal-body">
<p>Embed this html snippet into your web site.</p>
<textarea style="width:100%;margin:0px" class="export_html_textarea" id="export_html_textarea"></textarea>
</div>
<div class="modal-footer">
<button onclick="copyToClipboard()">Copy</button>
</div>
</div></div>
</div>
<div id="error_area_container" style="display:none">
<div class="overlay" id="errorOverlay">
<div class="error-modal-content">
<div style="display:inline-block"> <h5 style="margin:0px">Error in Datalet creation!</h5><span class="button-close" onclick="document.getElementById('error_area_container').style.display = 'none'"></span></div>
<div><p id="errorMess"></p></div>
</div></div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function () {
document.getElementById('controllet_iframe').src = "controllet_odf.html" + window.location.search;
});
var copyToClipboard = function(){
var copyText = document.getElementById("export_html_textarea");
copyText.select();
document.execCommand("copy");
}
var createHTML = function(e)
{
var dataletHTML = "";
dataletHTML = '<' + e.detail.data.datalet;
var title="";
var description="";
//console.log(e.detail.data);
for (var property in e.detail.data.params) {
if (e.detail.data.params.hasOwnProperty(property)) {
if(property != "_colorIndex" && property != "data-url")
dataletHTML += ' ' + property + '=\'' + e.detail.data.params[property] + '\'';
else if(property == "data-url")
dataletHTML += ' ' + property + '=\'' + unescape(e.detail.data.params[property]) + '\'';
}
if(property=="datalettitle"){
title=e.detail.data.params[property];
}
if(property=="description"){
description=e.detail.data.params[property];
}
}
dataletHTML += ' fields=\'' + JSON.stringify(e.detail.data.fields) + '\'';
var format=e.detail.data.format;
if(format!=undefined && format.toLowerCase()=='csv'){
dataletHTML += ' data=\'' + e.detail.data.staticData + '\'';
}
dataletHTML += ' format=\'' +format + '\'';
dataletHTML += '>';
dataletHTML += '</'+e.detail.data.datalet+'>';
//var dataletImport = '\<script type="text/javascript" src="https://cdn.jsdelivr.net/webcomponentsjs/0.7.16/webcomponents-lite.min.js"\>\<\/script\>\n' +
var dataletImport = '\<script type="text/javascript" src="'+getDeepBaseUrl()+'deep-components/bower_components/webcomponentsjs/webcomponents-lite.min.js"\>\<\/script\>\n' +
'\<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.min.js"\>\<\/script\>\n' +
'<!-- REMOVE THE PREVIOUS SCRIPT TAGS IF YOUR PAGE ALREADY USES JQUERY AND POLYFILL LIBRARIES -->\n';
var dataletLink = '<link rel="import" href="'+getDeepBaseUrl()+'deep-components/datalets/'+e.detail.data.datalet+'/'+e.detail.data.datalet+'.html" /> \n';
$(".export_html_textarea").val(dataletImport+dataletLink+dataletHTML);
//editAreaLoader.setValue("text_area", dataletImport+dataletLink+dataletHTML);
//Polymer.dom(this.root).appendChild(div);
var storeDatalet = e.detail.storeDatalet;
$.ajax({
url: getODFUrl()+"Idra/api/v1/client/catalogues/"+storeDatalet.nodeID+"/dataset/"+storeDatalet.datasetID+"/distribution/"+storeDatalet.distributionID+"/createDatalet",
type: "POST",
//dataType:"json",
contentType: "application/json",
data: JSON.stringify({
"datalet_html": dataletLink+dataletHTML,
"title":title,
"description":description
}),
success: function(data, textStatus, xhr){
document.getElementById('text_area_container').style.display = "block";
// $("#add_button").attr("disabled", "disabled");
//document.getElementById('controllet_iframe').contentWindow.document.getElementById('add_button').disable=true;
},
error:function(data, textStatus,xhr){
$("#errorMess").text("Unable to create datalet!");
document.getElementById('error_area_container').style.display = "block";
}
});
}
</script>
</body>
</html>