Blame view

datalets/base-datalet/base-datalet.html 7.17 KB
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 {

94601c1f   Renato De Donato   trevieww multitable
67
                  font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;

59100bec   Renato De Donato   localization + ba...
68
                  padding-top: 2px;

59100bec   Renato De Donato   localization + ba...
69
                  border-top: 2px solid #B6B6B6;

c94733d2   Renato De Donato   paper-card modify
70
                  margin-top: 8px;

94601c1f   Renato De Donato   trevieww multitable
71
72
              }

              #base_datalet_rtp {

94601c1f   Renato De Donato   trevieww multitable
73
                  display: flex;

59100bec   Renato De Donato   localization + ba...
74
                  padding-top: 4px;

94601c1f   Renato De Donato   trevieww multitable
75
              }

0f6424fe   root   update new data-s...
76
              #rtp {

94601c1f   Renato De Donato   trevieww multitable
77
78
                  padding-top: 8px;

                  padding-right: 8px;

c94733d2   Renato De Donato   paper-card modify
79
                  font-size: 12px;

73bcce88   luigser   COMPONENTS
80
              }

0f6424fe   root   update new data-s...
81
              #rtpalogo {

0b7cbd33   Renato De Donato   title-desciption
82
                  height: 32px;

94601c1f   Renato De Donato   trevieww multitable
83
                  width: 32px;

73bcce88   luigser   COMPONENTS
84
              }

0f6424fe   root   update new data-s...
85
              #base_datalet_spin {

0b7cbd33   Renato De Donato   title-desciption
86
                  height: 64px;

73cc8795   pina   dataset page and ...
87
                  width: 100%;

0b7cbd33   Renato De Donato   title-desciption
88
                  margin-top: 64px;

59100bec   Renato De Donato   localization + ba...
89
              }

0b7cbd33   Renato De Donato   title-desciption
90
  

59100bec   Renato De Donato   localization + ba...
91
92
93
              #base_datalet_source_link{

                  padding-top: 12px;

              }

0b7cbd33   Renato De Donato   title-desciption
94
95
96
97
98
99
  

              #span_title{

                  font-size: small;

              }

  

              #span_description{

28265108   Renato De Donato   new link-text con...
100
                  font-style: italic;

0b7cbd33   Renato De Donato   title-desciption
101
102
                  color: #727272;

              }

73bcce88   luigser   COMPONENTS
103
104
          </style>

  

73cc8795   pina   dataset page and ...
105
          <div id="base_datalet_imgWaitDatalet">

b4accc86   Renato De Donato   datalet improved
106
              <img id="base_datalet_spin" src="static/images/spin.svg">

73cc8795   pina   dataset page and ...
107
          </div>

0f6424fe   root   update new data-s...
108
  

94601c1f   Renato De Donato   trevieww multitable
109
          <div id="base_datalet_container">

0f6424fe   root   update new data-s...
110
  

59100bec   Renato De Donato   localization + ba...
111
              <div id="base_datalet_title_description">

0b7cbd33   Renato De Donato   title-desciption
112
                  <span id="span_title"><b>{{title}}</b> <span id="span_description">{{description}}</span></span>

59100bec   Renato De Donato   localization + ba...
113
114
115
116
117
              </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...
118
  

94601c1f   Renato De Donato   trevieww multitable
119
              <div id="base_datalet_rtp">

73cc8795   pina   dataset page and ...
120
                  <div id="rtp">Powered by ROUTE-TO-PA</div>

9579b866   Renato De Donato   firefox bug fix
121
                  <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
122
              </div>

b4accc86   Renato De Donato   datalet improved
123
  

94601c1f   Renato De Donato   trevieww multitable
124
125
          </div>

  

73bcce88   luigser   COMPONENTS
126
127
      </template>

  

4e7eacf4   Luigi Serra   Controllets and d...
128
129
      <script src="static/js/BaseDataletBehavior.js"></script>

      <script src="static/js/WorkcycleBehavior.js"></script>

73bcce88   luigser   COMPONENTS
130
131
132
133
  

      <script>

          BaseDatalet = Polymer({

              is: 'base-datalet',

3c812cc9   Renato De Donato   title-desciption ...
134
  

5e6ba8af   isisadmin   datalet doc update
135
              /**

21107197   Andrea Petta   test
136
               *

7be24196   Renato De Donato   test2
137
               * It is called after the element's template has been stamped and all elements inside the element's local

5e6ba8af   isisadmin   datalet doc update
138
139
140
               * 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 ...
141
142
143
144
               * 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
145
               * @method ready

5e6ba8af   isisadmin   datalet doc update
146
               */

73bcce88   luigser   COMPONENTS
147
              ready: function(){

59100bec   Renato De Donato   localization + ba...
148
                  if(this.dataUrl != undefined) {

0f6424fe   root   update new data-s...
149
  

59100bec   Renato De Donato   localization + ba...
150
151
152
                      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 ...
153
  

73cc8795   pina   dataset page and ...
154
  

59100bec   Renato De Donato   localization + ba...
155
156
157
                      //OpenDataSoft check

                      if(this.dataUrl.indexOf("/records/") > -1 )

                      {

8c25f3d6   Renato De Donato   issy
158
159
160
161
162
163
164
                          var i;

                          if(this.dataUrl.indexOf("&") > -1)

                              i = this.dataUrl.indexOf("&");

                          else

                              i = this.dataUrl.length;

  

                          this.$.base_datalet_link.setAttribute("href", urlSource + "/explore/dataset/" + this.dataUrl.substring(this.dataUrl.indexOf("=")+1, i));

59100bec   Renato De Donato   localization + ba...
165
                      }

2b65b828   isisadmin   base datalet fix
166
167
                      // CKAN

                      else if(this.dataUrl.indexOf("datastore_search?resource_id") > -1 )

59100bec   Renato De Donato   localization + ba...
168
                      {

2b65b828   isisadmin   base datalet fix
169
170
171
172
173
174
175
176
                          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);

                              }

                          });

59100bec   Renato De Donato   localization + ba...
177
                      }

6cf27113   pina   add link dataset ...
178
                  }

b4190b56   Renato De Donato   myspace update
179
180
181
182
183
  

                  else {

                      this.hideFooter();

                      this.$.base_datalet_spin.remove();

                  }

035bbee3   Luigi Serra   Datalets and cont...
184
              },

17da8e08   Renato De Donato   hidden preview da...
185
  

035bbee3   Luigi Serra   Datalets and cont...
186
187
188
              /**

               * Set the domain url to show in the footer

               */

fb05b400   Renato De Donato   controllet 2.0, n...
189
190
191
  //            setDomain: function(url){

  //                this.$.domain.textContent = url;

  //            },

17da8e08   Renato De Donato   hidden preview da...
192
193
194
  

              hideFooter: function() {

                  this.$.base_datalet_container.innerHTML = "";

c94733d2   Renato De Donato   paper-card modify
195
                  this.$.base_datalet_container.style.margin = 0;

17da8e08   Renato De Donato   hidden preview da...
196
197
                  this.$.base_datalet_container.style.border = 0;

              }

2b65b828   isisadmin   base datalet fix
198
           });

73bcce88   luigser   COMPONENTS
199
200
      </script>

  </dom-module>