base-datalet.html
7.25 KB
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
<!--
@license
The MIT License (MIT)
Copyright (c) 2015 Dipartimento di Informatica - Universit� di Salerno - Italy
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.
-->
<!--
* Developed by :
* ROUTE-TO-PA Project - grant No 645860. - www.routetopa.eu
*
-->
<link rel="import" href="../../bower_components/polymer/polymer.html">
<!--
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
-->
<dom-module id="base-datalet">
<template>
<style>
a {
color: #00BCD4;
text-decoration: none;
}
a:hover {
color: #2db395;
text-decoration: underline;
}
#base_datalet_container {
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
padding-top: 2px;
border-top: 2px solid #B6B6B6;
}
#base_datalet_rtp {
display: flex;
padding-top: 4px;
}
#rtp {
padding-top: 8px;
padding-right: 8px;
font-size: small;
}
#rtpalogo {
height: 32px;
width: 32px;
}
#base_datalet_spin {
height: 64px;
width: 100%;
margin-top: 64px;
}
#base_datalet_source_link{
padding-top: 12px;
}
#span_title{
font-size: small;
}
#span_description{
font-style: italic;
color: #727272;
}
</style>
<div id="base_datalet_imgWaitDatalet">
<img id="base_datalet_spin" src="static/images/spin.svg">
</div>
<div id="base_datalet_container">
<div id="base_datalet_title_description">
<span id="span_title"><b>{{title}}</b> <span id="span_description">{{description}}</span></span>
</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>
<div id="base_datalet_rtp">
<div id="rtp">Powered by ROUTE-TO-PA</div>
<div><a href="http://www.routetopa.eu/" target="_blank"><img id="rtpalogo" src="static/images/rtpalogo.png" ></a></div>
</div>
</div>
</template>
<script src="static/js/BaseDataletBehavior.js"></script>
<script src="static/js/WorkcycleBehavior.js"></script>
<script>
BaseDatalet = Polymer({
is: 'base-datalet',
/**
*
* It is called after the element's template has been stamped and all elements inside the element's local
* DOM have been configured (with values bound from parents, deserialized attributes, or else default values)
* and had their ready method called.
*
* Extract
* 1) the dataset domain
* 2) the page of a datalet
* from the entire URL and set the text content of the datalet footer.
* @method ready
*/
ready: function(){
if(this.dataUrl != undefined) {
var urlSource = this.dataUrl.split("/")[0] + "//" + this.dataUrl.split("/")[2];
this.$.base_datalet_source.innerHTML = urlSource;
this.$.base_datalet_source.setAttribute("href", urlSource);
//OpenDataSoft check
if(this.dataUrl.indexOf("/records/") > -1 )
{
this.$.base_datalet_link.setAttribute("href", urlSource + "/explore/dataset/" + this.dataUrl.substring(this.dataUrl.indexOf("=")+1,this.dataUrl.indexOf("&")));
}
// CKAN
else if(this.dataUrl.indexOf("datastore_search?resource_id") > -1 )
{
var comp = this;
$.ajax({
url: this.dataUrl.replace("datastore_search?resource_id", "resource_show?id"),
dataType: "json",
success: function(e){
comp.$.base_datalet_link.setAttribute("href", urlSource + "/dataset/" + e.result.package_id + "/resource/" + e.result.id);
}
});
}
}
else {
this.hideFooter();
this.$.base_datalet_spin.remove();
}
},
attached: function(){
// if(this.title == undefined)
// this.title = "";
//
// if(this.description == undefined)
// this.description = "";
//
// if(this.title != "" && this.description != "")
// this.description = "- " + this.description;
},
/**
* Set the domain url to show in the footer
*/
setDomain: function(url){
this.$.domain.textContent = url;
},
hideFooter: function() {
this.$.base_datalet_container.innerHTML = "";
this.$.base_datalet_container.style.border = 0;
}
});
</script>
</dom-module>