73bcce88
luigser
COMPONENTS
|
1
|
<!--
|
5e6ba8af
isisadmin
datalet doc update
|
2
3
4
|
@license
The MIT License (MIT)
|
94601c1f
Renato De Donato
trevieww multitable
|
5
|
Copyright (c) 2015 Dipartimento di Informatica - Universit� di Salerno - Italy
|
5e6ba8af
isisadmin
datalet doc update
|
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
|
a1f0799c
isisadmin
datalet global re...
|
24
25
|
-->
|
ae17a8dc
Luigi Serra
Controllet and da...
|
26
|
<!--
|
950d181d
Luigi Serra
license updates
|
27
28
|
* Developed by :
* ROUTE-TO-PA Project - grant No 645860. - www.routetopa.eu
|
ae17a8dc
Luigi Serra
Controllet and da...
|
29
30
31
|
*
-->
|
a1f0799c
isisadmin
datalet global re...
|
32
33
34
|
<link rel="import" href="../../bower_components/polymer/polymer.html">
<!--
|
5e6ba8af
isisadmin
datalet doc update
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
The `base-datalet` is the base component that includes datalet footer (with information about dataset domain and ROUTE-TO-PA project).
Base datalet includes polymer.html and the BaseDataletBehaviors javascript file that define the datalet workcycle and the datalet base properties : dataUrl, fields and data.
Every datalet must include this one in its `<template>` section.
Example :
<dom-module id="every-datalet">
<template>
...
<base-datalet data-url="{{dataUrl}}" fields="{{fields}}"></base-datalet>
...
</template>
</dom-module>
@element base-datalet
@status v0.1
@homepage
@group datalets
|
73bcce88
luigser
COMPONENTS
|
53
|
-->
|
73bcce88
luigser
COMPONENTS
|
54
55
56
57
|
<dom-module id="base-datalet">
<template>
<style>
|
0f6424fe
root
update new data-s...
|
58
59
60
61
62
63
64
65
|
a {
color: #00BCD4;
text-decoration: none;
}
a:hover {
color: #2db395;
text-decoration: underline;
}
|
94601c1f
Renato De Donato
trevieww multitable
|
66
|
#base_datalet_container {
|
59100bec
Renato De Donato
localization + ba...
|
67
|
/*display: flex;*/
|
94601c1f
Renato De Donato
trevieww multitable
|
68
|
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
59100bec
Renato De Donato
localization + ba...
|
69
70
71
72
|
/*color: #212121;*/
padding-top: 2px;
/*padding: 16px;*/
border-top: 2px solid #B6B6B6;
|
94601c1f
Renato De Donato
trevieww multitable
|
73
74
|
}
#base_datalet_rtp {
|
59100bec
Renato De Donato
localization + ba...
|
75
|
/*background-color: red;*/
|
94601c1f
Renato De Donato
trevieww multitable
|
76
|
display: flex;
|
59100bec
Renato De Donato
localization + ba...
|
77
|
padding-top: 4px;
|
94601c1f
Renato De Donato
trevieww multitable
|
78
|
}
|
0f6424fe
root
update new data-s...
|
79
|
#rtp {
|
59100bec
Renato De Donato
localization + ba...
|
80
|
/*width: 152px;*/
|
94601c1f
Renato De Donato
trevieww multitable
|
81
82
|
padding-top: 8px;
padding-right: 8px;
|
73bcce88
luigser
COMPONENTS
|
83
84
|
font-size: small;
}
|
0f6424fe
root
update new data-s...
|
85
|
#rtpalogo {
|
0b7cbd33
Renato De Donato
title-desciption
|
86
|
height: 32px;
|
94601c1f
Renato De Donato
trevieww multitable
|
87
|
width: 32px;
|
73bcce88
luigser
COMPONENTS
|
88
|
}
|
0f6424fe
root
update new data-s...
|
89
|
#base_datalet_spin {
|
0b7cbd33
Renato De Donato
title-desciption
|
90
|
height: 64px;
|
73cc8795
pina
dataset page and ...
|
91
|
width: 100%;
|
0b7cbd33
Renato De Donato
title-desciption
|
92
|
margin-top: 64px;
|
59100bec
Renato De Donato
localization + ba...
|
93
|
}
|
0b7cbd33
Renato De Donato
title-desciption
|
94
|
|
59100bec
Renato De Donato
localization + ba...
|
95
96
97
|
#base_datalet_source_link{
padding-top: 12px;
}
|
0b7cbd33
Renato De Donato
title-desciption
|
98
99
100
101
102
103
104
105
|
#span_title{
font-size: small;
}
#span_description{
color: #727272;
}
|
73bcce88
luigser
COMPONENTS
|
106
107
|
</style>
|
73cc8795
pina
dataset page and ...
|
108
|
<div id="base_datalet_imgWaitDatalet">
|
b4accc86
Renato De Donato
datalet improved
|
109
|
<img id="base_datalet_spin" src="static/images/spin.svg">
|
73cc8795
pina
dataset page and ...
|
110
|
</div>
|
0f6424fe
root
update new data-s...
|
111
|
|
94601c1f
Renato De Donato
trevieww multitable
|
112
|
<div id="base_datalet_container">
|
0f6424fe
root
update new data-s...
|
113
|
|
59100bec
Renato De Donato
localization + ba...
|
114
|
<div id="base_datalet_title_description">
|
0b7cbd33
Renato De Donato
title-desciption
|
115
|
<span id="span_title"><b>{{title}}</b> <span id="span_description">{{description}}</span></span>
|
59100bec
Renato De Donato
localization + ba...
|
116
117
118
119
120
|
</div>
<div id="base_datalet_source_link">
<b>Source:</b> <a id="base_datalet_source" target="_blank"></a> (<a id="base_datalet_link" target="_blank">dataset</a>)
</div>
|
0f6424fe
root
update new data-s...
|
121
|
|
94601c1f
Renato De Donato
trevieww multitable
|
122
|
<div id="base_datalet_rtp">
|
73cc8795
pina
dataset page and ...
|
123
|
<div id="rtp">Powered by ROUTE-TO-PA</div>
|
9579b866
Renato De Donato
firefox bug fix
|
124
|
<div><a href="http://www.routetopa.eu/" target="_blank"><img id="rtpalogo" src="static/images/rtpalogo.png" ></a></div>
|
94601c1f
Renato De Donato
trevieww multitable
|
125
|
</div>
|
b4accc86
Renato De Donato
datalet improved
|
126
|
|
94601c1f
Renato De Donato
trevieww multitable
|
127
128
|
</div>
|
73bcce88
luigser
COMPONENTS
|
129
130
|
</template>
|
4e7eacf4
Luigi Serra
Controllets and d...
|
131
132
|
<script src="static/js/BaseDataletBehavior.js"></script>
<script src="static/js/WorkcycleBehavior.js"></script>
|
73bcce88
luigser
COMPONENTS
|
133
134
135
136
|
<script>
BaseDatalet = Polymer({
is: 'base-datalet',
|
3c812cc9
Renato De Donato
title-desciption ...
|
137
138
139
140
141
|
properties: {
title : {
type : String,
|
4b79b3c8
Renato De Donato
datalet-selection...
|
142
|
value : ""
|
3c812cc9
Renato De Donato
title-desciption ...
|
143
144
145
146
|
},
description : {
type : String,
|
4b79b3c8
Renato De Donato
datalet-selection...
|
147
|
value : ""
|
3c812cc9
Renato De Donato
title-desciption ...
|
148
149
150
151
|
}
},
|
73cc8795
pina
dataset page and ...
|
152
153
154
155
156
157
158
159
160
161
162
163
164
|
objectDatalet: {
/**
* It contains the json data from async xhr call returned from core-ajax core component
*
* @attribute json_resultDatalet
* @type object
* @default 'null'.
*/
json_resultDatalet: {
type: Object,
value: {}
}
},
|
59100bec
Renato De Donato
localization + ba...
|
165
|
|
0b7cbd33
Renato De Donato
title-desciption
|
166
167
168
|
hideFooter: function() {
this.$.base_datalet_container.innerHTML = "";
this.$.base_datalet_container.style.border = 0;
|
59100bec
Renato De Donato
localization + ba...
|
169
|
|
0b7cbd33
Renato De Donato
title-desciption
|
170
171
172
|
// this.$.base_datalet_source_link.innerHTML = "";
// this.$.base_datalet_rtp.innerHTML = "";
},
|
59100bec
Renato De Donato
localization + ba...
|
173
|
|
0b7cbd33
Renato De Donato
title-desciption
|
174
175
176
177
178
179
180
181
182
183
184
|
setFooter: function(title, description) {
this.title = title;
if(title != "" && description != "")
this.description = "- " + description;
else
this.description = description;
if (this.title == "" && this.description == "")
this.$.base_datalet_title_description.style.display = "none";
else
this.$.base_datalet_title_description.style.display = "block";
|
59100bec
Renato De Donato
localization + ba...
|
185
186
|
},
|
5e6ba8af
isisadmin
datalet doc update
|
187
|
/**
|
94601c1f
Renato De Donato
trevieww multitable
|
188
|
* It is called after the element�s template has been stamped and all elements inside the element�s local
|
5e6ba8af
isisadmin
datalet doc update
|
189
190
191
|
* DOM have been configured (with values bound from parents, deserialized attributes, or else default values)
* and had their ready method called.
*
|
73cc8795
pina
dataset page and ...
|
192
193
194
195
|
* Extract
* 1) the dataset domain
* 2) the page of a datalet
* from the entire URL and set the text content of the datalet footer.
|
5e6ba8af
isisadmin
datalet doc update
|
196
|
* @method ready
|
5e6ba8af
isisadmin
datalet doc update
|
197
|
*/
|
73bcce88
luigser
COMPONENTS
|
198
|
ready: function(){
|
59100bec
Renato De Donato
localization + ba...
|
199
|
if(this.dataUrl != undefined) {
|
0f6424fe
root
update new data-s...
|
200
|
|
59100bec
Renato De Donato
localization + ba...
|
201
202
|
//cKan organized with or not catalog
var queryInitial = this.dataUrl.substring(0, this.dataUrl.indexOf("api")); //SOURCE
|
0f6424fe
root
update new data-s...
|
203
|
|
59100bec
Renato De Donato
localization + ba...
|
204
205
206
|
var urlSource = this.dataUrl.split("/")[0] + "//" + this.dataUrl.split("/")[2];
this.$.base_datalet_source.innerHTML = urlSource;
this.$.base_datalet_source.setAttribute("href", urlSource);
|
73cc8795
pina
dataset page and ...
|
207
|
|
73cc8795
pina
dataset page and ...
|
208
|
|
59100bec
Renato De Donato
localization + ba...
|
209
210
211
212
213
214
215
216
217
|
//OpenDataSoft check
if(this.dataUrl.indexOf("/records/") > -1 )
{
//Resourceid of a datalet
var query = this.dataUrl.substring(this.dataUrl.indexOf("?"), this.dataUrl.length);
var params = this.decomponeQueryString(query);
var resultIssyIdDatalet = params["dataset"];
var resultIssyAPI = "explore/dataset/";
var urlPageDatasetIssy = queryInitial + resultIssyAPI + resultIssyIdDatalet + "/";
|
73cc8795
pina
dataset page and ...
|
218
|
|
59100bec
Renato De Donato
localization + ba...
|
219
220
221
222
223
224
|
this.$.base_datalet_link.setAttribute("href", urlPageDatasetIssy);
}
else
{
//CKAN portal
var urlDatalet;
|
0f6424fe
root
update new data-s...
|
225
|
|
59100bec
Renato De Donato
localization + ba...
|
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
var apiIdResource = "resource_show?id=";
//Resourceid of a datalet
var query = this.dataUrl.substring(this.dataUrl.indexOf("?"), this.dataUrl.length);
var params = this.decomponeQueryString(query);
//CKAN
var resultIdDatalet = params["resource_id"];
//cKan organized with or not catalog
var queryFinal = this.dataUrl.substring(this.dataUrl.indexOf("api"), this.dataUrl.indexOf("datastore_search"));
urlDatalet = queryInitial + queryFinal + apiIdResource + resultIdDatalet;
this.requestDataletData(urlDatalet);
}
|
6cf27113
pina
add link dataset ...
|
240
|
}
|
59100bec
Renato De Donato
localization + ba...
|
241
|
|
035bbee3
Luigi Serra
Datalets and cont...
|
242
243
244
245
246
247
|
},
/**
* Set the domain url to show in the footer
*/
setDomain: function(url){
this.$.domain.textContent = url;
|
73cc8795
pina
dataset page and ...
|
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
280
281
282
283
284
|
},
/**
* Get the (key, value) query string parameters
**/
decomponeQueryString: function (querystring) {
// remove any preceding url and split
querystring = querystring.substring(querystring.indexOf('?')+1).split('&');
var params = {}, pair, d = decodeURIComponent;
// march and parse
for (var i = querystring.length - 1; i >= 0; i--) {
pair = querystring[i].split('=');
params[d(pair[0])] = d(pair[1]);
}
return params;
},
/**
* Make an AJAX call to the dataset URL to retrieve package_id
*
* @method urlDatalet
*/
requestDataletData: function(urlDatalet){
var comp = this;
$.ajax({
url: urlDatalet, //url con package
dataType: "json",
success: function(e){
comp.handleDataletResponse(e);
}
});
},
/**
* Called when core-ajax component receive the json data from called url.
*
* @method handleResponse
*/
handleDataletResponse: function(e) {
this.objectDatalet.json_resultDatalet.value = e;
|
73cc8795
pina
dataset page and ...
|
285
286
287
288
289
290
291
292
293
294
295
296
|
//packageId of a give datalet
packageIdDatalet = this.objectDatalet.json_resultDatalet.value.result.package_id;
resourceId = this.objectDatalet.json_resultDatalet.value.result.id;
//url complete of download
urlDatasetDownload = this.objectDatalet.json_resultDatalet.value.result.url;
if(this.dataUrl != undefined){
//static url
lastStringResourceId = this.dataUrl.split("/")[5];
resourceId = lastStringResourceId.split('=')[1];
var urlDatalet = this.dataUrl.split("/")[0]+ "//" + this.dataUrl.split("/")[2] + "/dataset/" + packageIdDatalet +"/resource/" +resourceId;
|
035bbee3
Luigi Serra
Datalets and cont...
|
297
|
|
73cc8795
pina
dataset page and ...
|
298
299
300
|
urlDatalet = urlDatasetDownload.replace(/\/download\/.*/, '');
urlSource = this.dataUrl.split("/")[0] + "//" + this.dataUrl.split("/")[2];
|
0f6424fe
root
update new data-s...
|
301
|
this.$.base_datalet_link.setAttribute("href", urlDatalet);
|
73cc8795
pina
dataset page and ...
|
302
|
}
|
59100bec
Renato De Donato
localization + ba...
|
303
304
305
306
|
},
|
73bcce88
luigser
COMPONENTS
|
307
308
309
|
});
</script>
</dom-module>
|