Commit 120b24454727f38aa9014128321e13eb29f7cf3c
1 parent
4148147e
Exists in
master
and in
111 other branches
epntap grids: check URLs, tooltip the cell content, improve style
Showing
2 changed files
with
55 additions
and
24 deletions
Show diff stats
js/app/views/EpnTapUI.js
... | ... | @@ -203,10 +203,26 @@ Ext.define('App.util.Format', { |
203 | 203 | 'prettify': function(data) { |
204 | 204 | return data.charAt(0).toUpperCase() + data.replace(/_/g, ' ').substr(1).toLowerCase(); |
205 | 205 | }, |
206 | + 'url': function(data) { | |
207 | + var url_pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol | |
208 | + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|'+ // domain name | |
209 | + '((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address | |
210 | + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path | |
211 | + '(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string | |
212 | + '(\\#[-a-z\\d_]*)?$','i'); // fragment locator | |
213 | + return url_pattern.test(data) ? data : null; | |
214 | + }, | |
215 | + 'cell': function(content, tooltip=null, tooltipTitle='') { | |
216 | + content = content ? content : '-'; | |
217 | + if(tooltip !== '') { | |
218 | + var ttAttr = " data-qtitle='" + tooltipTitle + "' data-qtip='" + (tooltip ? tooltip : content) + "'"; | |
219 | + } | |
220 | + return "<div class=epntap_cell " + ttAttr + ">" + content + "</div>"; | |
221 | + }, | |
206 | 222 | |
207 | 223 | // Services grid |
208 | 224 | |
209 | - 'serviceTooltip': function(value, data) { | |
225 | + 'serviceTooltip': function(data) { | |
210 | 226 | for (var key in data) { |
211 | 227 | if(typeof data[key] == 'string' && data[key] != '') { |
212 | 228 | data[key] = data[key].replace(/'/g, ''').replace(/"/g, '"'); |
... | ... | @@ -223,10 +239,10 @@ Ext.define('App.util.Format', { |
223 | 239 | details += '<li><b>' + Ext.util.Format.prettify(colums[key]) + '</b>: ' + val + '</li>'; |
224 | 240 | } |
225 | 241 | } |
226 | - return Ext.String.format("<div data-qtitle='{0}' data-qtip='{1}<ul>{2}</ul>'>{0}</div>", value, info, details); | |
242 | + return info + '<ul>' + details + '</ul>'; | |
227 | 243 | }, |
228 | 244 | 'service.text': function(data, metadata, record) { |
229 | - return Ext.util.Format.serviceTooltip(data, record.data); | |
245 | + return Ext.util.Format.cell(data, Ext.util.Format.serviceTooltip(record.data), data); | |
230 | 246 | }, |
231 | 247 | 'service.number': function(data, metadata, record) { |
232 | 248 | value = '' + data; |
... | ... | @@ -237,36 +253,37 @@ Ext.define('App.util.Format', { |
237 | 253 | } else if(data >= 1000) { |
238 | 254 | value = (data/1000).toPrecision(3) + 'k'; |
239 | 255 | } |
240 | - return Ext.util.Format.serviceTooltip(value, record.data); | |
256 | + return Ext.util.Format.cell(value, Ext.util.Format.serviceTooltip(record.data), record.data.short_name); | |
241 | 257 | }, |
242 | 258 | |
243 | 259 | // Granules grid |
244 | 260 | |
245 | - 'granuleTooltip': function(value, data) { | |
246 | - for (var key in data) { | |
247 | - if(typeof data[key] == 'string' && data[key] != '') { | |
248 | - data[key] = data[key].replace(/'/g, ''').replace(/"/g, '"'); | |
249 | - } | |
250 | - } | |
251 | - var tooltip = '<img src="' + data.thumbnail_url + '">'; | |
252 | - return Ext.String.format("<div data-qtitle='' data-qtip='{0}'>{1}</div>", tooltip, value); | |
253 | - }, | |
254 | 261 | 'granule.text': function(data, metadata, record) { |
255 | - return Ext.util.Format.granuleTooltip('<p style="white-space: normal;">' + data + '</p>', record.data); | |
262 | + return Ext.util.Format.cell(data); | |
256 | 263 | }, |
257 | 264 | 'granule.link': function(data, metadata, record) { |
258 | - return Ext.util.Format.granuleTooltip('<a style="font-size:150%" target="_blank" href="' + data + '">🗗</a>', record.data); | |
265 | + var icon_b64 = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgaGVpZ2h0PSIxMDI0IiB3aWR0aD0iNzY4IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik02NDAgNzY4SDEyOFYyNTcuOTA1OTk5OTk5OTk5OTVMMjU2IDI1NlYxMjhIMHY3NjhoNzY4VjU3Nkg2NDBWNzY4ek0zODQgMTI4bDEyOCAxMjhMMzIwIDQ0OGwxMjggMTI4IDE5Mi0xOTIgMTI4IDEyOFYxMjhIMzg0eiIvPjwvc3ZnPg=='; | |
266 | + var icon = '<img width="15px height="15px" src="' + icon_b64 + '">'; | |
267 | + url = Ext.util.Format.url(data); | |
268 | + if(url) { | |
269 | + txt = '<a style="font-size:150%" target="_blank" href="' + url + '">' + icon + '</a>'; | |
270 | + } | |
271 | + return Ext.util.Format.cell(txt, url); | |
259 | 272 | }, |
260 | 273 | 'granule.img': function(data, metadata, record) { |
261 | - return Ext.util.Format.granuleTooltip('<img width="40px height="40px" src="' + data + '">', record.data); | |
274 | + img_url = Ext.util.Format.url(data); | |
275 | + if(img_url) { | |
276 | + icon = '<img style="max-width:100%; max-height:100%" alt="-" src="' + img_url + '">'; | |
277 | + img = '<img style="max-width:200px; max-height:200px" alt="-" src="' + img_url + '">'; | |
278 | + } | |
279 | + return Ext.util.Format.cell(icon, img); | |
262 | 280 | }, |
263 | 281 | 'granule.type': function(data, metadata, record) { |
264 | 282 | var productTypeDict = Ext.data.StoreManager.lookup('productTypesStore').data.map; |
265 | - return Ext.util.Format.granuleTooltip('<p>' + productTypeDict[data].data.name + '</p>', record.data); | |
283 | + return Ext.util.Format.cell(productTypeDict[data].data.name); | |
266 | 284 | }, |
267 | 285 | 'granule.size': function(data, metadata, record) { |
268 | 286 | var size = parseInt(data); |
269 | - var txt = ''; | |
270 | 287 | if (isNaN(size)) { |
271 | 288 | } else if (size >= 1024*1024) { |
272 | 289 | txt = (size/(1024*1024)).toPrecision(3) + 'Go'; |
... | ... | @@ -275,11 +292,11 @@ Ext.define('App.util.Format', { |
275 | 292 | } else { |
276 | 293 | txt = size + 'Ko'; |
277 | 294 | } |
278 | - return Ext.util.Format.granuleTooltip('<p>' + txt + '</p>', record.data); | |
295 | + return Ext.util.Format.cell(txt); | |
279 | 296 | }, |
280 | 297 | 'granule.proc_lvl': function(data, metadata, record) { |
281 | 298 | var levels = {1: 'Raw', 2: 'Edited', 3: 'Calibrated', 4: 'Resampled', 5: 'Derived', 6: 'Ancillary'}; |
282 | - return Ext.util.Format.granuleTooltip((data in levels) ? '<p>' + levels[data] + '</p>' : '<em>' + data + '</em>', record.data); | |
299 | + return Ext.util.Format.cell((data in levels) ? levels[data] : '<em>' + data + '</em>'); | |
283 | 300 | }, |
284 | 301 | 'granule.date': function(data, metadata, record) { |
285 | 302 | if(isNaN(data)) { |
... | ... | @@ -292,7 +309,8 @@ Ext.define('App.util.Format', { |
292 | 309 | var D = Math.floor((h % 153) / 5) + 1; |
293 | 310 | var M = ((Math.floor(h / 153) + 2) % 12) + 1; |
294 | 311 | var Y = Math.floor(e / 1461) - 4716 + Math.floor((12 + 2 - M) / 12); |
295 | - return Ext.util.Format.granuleTooltip('<p>' + Ext.Date.format(new Date(Y, M-1, D), 'Y/m/d') + '</p>', record.data); | |
312 | + var date = new Date(Y, M-1, D); | |
313 | + return Ext.util.Format.cell(Ext.Date.format(date, 'Y/m/d'), Ext.Date.format(date, 'F j, Y, g:i a')); | |
296 | 314 | }, |
297 | 315 | 'granule.format': function(data, metadata, record) { |
298 | 316 | var mimetypeDict = { |
... | ... | @@ -343,7 +361,7 @@ Ext.define('App.util.Format', { |
343 | 361 | 'video/quicktime': 'mov', |
344 | 362 | 'video/x-msvideo': 'avi' |
345 | 363 | }; |
346 | - return Ext.util.Format.granuleTooltip((data in mimetypeDict) ? '<p>' + mimetypeDict[data] + '</p>' : '<em>' + data + '</em>', record.data); | |
364 | + return Ext.util.Format.cell((data in mimetypeDict) ? '<p>' + mimetypeDict[data] + '</p>' : '<em>' + data + '</em>'); | |
347 | 365 | } |
348 | 366 | }); |
349 | 367 | |
... | ... | @@ -593,6 +611,7 @@ Ext.define('amdaUI.EpnTapUI', { |
593 | 611 | createServicesGrid: function() { |
594 | 612 | return { |
595 | 613 | xtype: 'grid', |
614 | + cls: 'epntap_grid', | |
596 | 615 | id: 'epnTapServicesGrid', |
597 | 616 | title: 'Services', |
598 | 617 | store: Ext.data.StoreManager.lookup('servicesStore'), |
... | ... | @@ -640,6 +659,7 @@ Ext.define('amdaUI.EpnTapUI', { |
640 | 659 | createGranulesGrid: function() { |
641 | 660 | return { |
642 | 661 | xtype: 'grid', |
662 | + cls: 'epntap_grid', | |
643 | 663 | id: 'epnTapGranulesGrid', |
644 | 664 | title: 'Granules', |
645 | 665 | store: Ext.data.StoreManager.lookup('granulesStore'), |
... | ... |
js/resources/css/amda.css
... | ... | @@ -489,10 +489,21 @@ p + p { |
489 | 489 | opacity: 1.0 !important; |
490 | 490 | } |
491 | 491 | |
492 | -.disabled_row { | |
492 | +.epntap_grid .disabled_row { | |
493 | 493 | color: gray; |
494 | 494 | } |
495 | 495 | |
496 | -.error_row { | |
496 | +.epntap_grid .error_row { | |
497 | 497 | color: IndianRed; |
498 | 498 | } |
499 | + | |
500 | +.epntap_grid td, .epntap_grid .x-grid-cell-inner { | |
501 | + padding: 0px; | |
502 | +} | |
503 | + | |
504 | +.epntap_cell { | |
505 | + padding: 4px; | |
506 | + /*width: 100%; | |
507 | + height: 100%;*/ | |
508 | + white-space: normal; | |
509 | +} | |
499 | 510 | \ No newline at end of file |
... | ... |