rbbt-rest 1.8.137 → 1.8.143

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/rest/common/cache.rb +12 -5
  3. data/lib/rbbt/rest/common/misc.rb +15 -0
  4. data/lib/rbbt/rest/entity/rest.rb +8 -2
  5. data/share/views/compass/card_templates.sass +14 -0
  6. data/share/views/compass/layout.sass +2 -0
  7. data/share/views/compass/misc.sass +2 -0
  8. data/share/views/entity_partials/action_controller.haml +1 -1
  9. data/share/views/entity_partials/entity_card.haml +20 -3
  10. data/share/views/entity_partials/entity_list_card.haml +9 -0
  11. data/share/views/job_result/array.haml +4 -1
  12. data/share/views/layout/footer.haml +2 -15
  13. data/share/views/partials/footers/bsc.haml +3 -3
  14. data/share/views/partials/tabs.haml +15 -12
  15. data/share/views/public/js/app.js +13 -0
  16. data/share/views/public/js/helpers/helpers.js +2 -2
  17. data/share/views/public/js/rbbt.basic.js +2 -2
  18. data/share/views/public/js/rbbt.plots/rbbt.plots.graph.adapters.js +33 -11
  19. data/share/views/public/js/rbbt.plots/rbbt.plots.graph.js +20 -2
  20. data/share/views/public/js/rbbt/actions.js +21 -12
  21. data/share/views/public/plugins/cytoscapejs/cytoscape.js +1 -0
  22. data/share/views/public/plugins/cytoscapejs/cytoscape.min.js +22 -56
  23. data/share/views/public/plugins/cytoscapejs/cytoscape.umd.js +32290 -0
  24. data/share/views/public/plugins/js-cookie/js/js.cookie.js +83 -65
  25. data/share/views/tools/nvd3.haml +3 -2
  26. data/share/views/tools/nvd3/chart.haml +6 -1
  27. metadata +3 -5
  28. data/share/views/main.haml +0 -0
  29. data/share/views/public/plugins/cytoscapejs/cytoscape.js +0 -24578
  30. data/share/views/public/plugins/cytoscapejs/cytoscape.js.map +0 -1
  31. data/share/views/public/plugins/cytoscapejs/cytoscape.min.js.map +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 260f3dfac0e66e1895ed7aea67d5a07e91b4e3b47f009278b36eee79e419107e
4
- data.tar.gz: 74d2cb800b8c8f72a2fcfccb5e16386c051e1474029de057d2f81a817f009518
3
+ metadata.gz: b6fed7211306df3aec52b9f2e1417c6ce42134377d8a48dabe12b9afde64835f
4
+ data.tar.gz: a93c9017255ff8495cda997bbccd816e9ee4fb01eb7023e8436454593b628c7e
5
5
  SHA512:
6
- metadata.gz: 987251d8d2d028fabdd77337bb25c34219361f77087b0d60b6210fbbd2b9c7c7ec724fd377d7a5baf887b1f2512f5138314718df72419e2986df5975e0381940
7
- data.tar.gz: e18031687205f914cc169b42472edbf9c237b9e3d0747bb8517027584ca2d26e41f4ec6203ec96c5a62b5483f16e2c81415a22648bfd2eeee76af6fa0fadaf2d
6
+ metadata.gz: c4b013bb24c9061c734cc1b8851457f614c799a73d08454d99d15e468a0771ad5da9d548416f3aa1ba810d34f36b34eeee2bc3e0d582e073a6cc83100afc10f7
7
+ data.tar.gz: d7c81039ebcdcf20d0d4ff8284cee946f47b1fbf6e2ae0680ee8d2ec60c6aa23c8efa8fff09cffd8a64f0b5d4e1c96e1869d895dbdbb61b244cbbe35f0bb0d0d
@@ -128,7 +128,7 @@ module RbbtRESTHelpers
128
128
 
129
129
  halt 200, hash.to_json
130
130
  when "table"
131
- halt 200, tsv2html(fragment_file)
131
+ halt_html tsv2html(fragment_file)
132
132
  when "json"
133
133
  content_type "application/json"
134
134
  halt 200, tsv_process(load_tsv(fragment_file).first).to_json
@@ -153,6 +153,7 @@ module RbbtRESTHelpers
153
153
  header "Location", Entity::REST.entity_list_url(list_id, type)
154
154
  url = Entity::REST.entity_list_url(list_id, type)
155
155
  url = url + '?_layout=false' unless @layout
156
+ url = URI.encode(url)
156
157
  redirect to(url)
157
158
  when "map"
158
159
  raw_tsv, tsv_options = load_tsv(fragment_file)
@@ -174,12 +175,12 @@ module RbbtRESTHelpers
174
175
  Entity::Map.save_map(type.to_s, column, map_id, tsv, user)
175
176
  url = Entity::REST.entity_map_url(map_id, type, column)
176
177
  url = url + '?_layout=false' unless @layout
178
+ url = URI.encode(url)
177
179
  redirect to(url)
178
180
  when "excel"
179
181
  require 'rbbt/tsv/excel'
180
182
  tsv, tsv_options = load_tsv(fragment_file)
181
183
  tsv = tsv_process(tsv)
182
- content_type "text/html"
183
184
  data = nil
184
185
  excel_file = TmpFile.tmp_file
185
186
  tsv.excel(excel_file, :sort_by => @excel_sort_by, :sort_by_cast => @excel_sort_by_cast, :name => true, :remove_links => true)
@@ -233,6 +234,8 @@ data = NULL
233
234
  rescue
234
235
  end
235
236
  end
237
+ else
238
+ txt = nil
236
239
  end
237
240
 
238
241
  if mime
@@ -241,10 +244,14 @@ data = NULL
241
244
  content_type "text/plain"
242
245
  end
243
246
 
244
- if File.exists? fragment_file
245
- send_file fragment_file
247
+ if mime && mime.to_s.include?("text/html")
248
+ halt_html txt || Open.read(fragment_file)
246
249
  else
247
- halt 200, Open.read(fragment_file)
250
+ if File.exists?(fragment_file)
251
+ send_file fragment_file
252
+ else
253
+ halt 200, Open.read(fragment_file)
254
+ end
248
255
  end
249
256
  end
250
257
  elsif Open.exists?(fragment_file + '.error')
@@ -298,6 +298,21 @@ module RbbtRESTHelpers
298
298
  FileUtils.ln_s(path, dest)
299
299
  "/permalink/#{ id }"
300
300
  end
301
+
302
+ def fix_html(html)
303
+ if html !~ /^\s*<html/i
304
+ "<html><meta charset=#{html.encoding.to_s}/><body>" + html + "<body/><html/>"
305
+ else
306
+ html
307
+ end
308
+ end
309
+
310
+ def halt_html(html, response = 200)
311
+ content_type "text/html; charset=#{html.encoding.to_s}"
312
+ html = fix_html html
313
+ halt response, html
314
+ end
315
+
301
316
  end
302
317
 
303
318
  require 'haml'
@@ -14,11 +14,11 @@ module Entity
14
14
  #{{{ MISC
15
15
 
16
16
  def self.clean_element(elem)
17
- elem.gsub('/', '-..-').gsub("|", '-...-').gsub('%', 'o-o').gsub('[','(.-(').gsub(']',').-)')
17
+ elem.gsub('&', '--AND--').gsub('/', '-..-').gsub("|", '-...-').gsub('%', 'o-o').gsub('[','(.-(').gsub(']',').-)')
18
18
  end
19
19
 
20
20
  def self.restore_element(elem)
21
- CGI.unescape(CGI.unescape(elem.gsub('-..-', '/').gsub('-...-', '|').gsub('o-o', '%').gsub('(.-(','[').gsub(').-)',']')))
21
+ CGI.unescape(CGI.unescape(elem.gsub('--AND--', '&').gsub('-..-', '/').gsub('-...-', '|').gsub('o-o', '%').gsub('(.-(','[').gsub(').-)',']')))
22
22
  end
23
23
 
24
24
  def self.setup(mod)
@@ -146,6 +146,12 @@ module Entity
146
146
  rescue
147
147
  text = self
148
148
  end
149
+
150
+ begin
151
+ attributes[:title] ||= self.respond_to?(:title)? self.title || self : self
152
+ rescue
153
+ end
154
+
149
155
  attributes[:title] = text if attributes[:title].nil?
150
156
 
151
157
  Misc.html_tag('a', text, attributes)
@@ -1,4 +1,13 @@
1
1
 
2
+ .action_controller
3
+ display:flex !important
4
+ & > .action_progress
5
+ flex-width: 100%
6
+ & > .ui.buttons > .button
7
+ flex-height: 3em
8
+ & > .ui.buttons.controls > .button
9
+ max-height: 3em
10
+
2
11
  .action_parameters, .filter_controls
3
12
  form
4
13
  &:after
@@ -41,3 +50,8 @@
41
50
  width: 7em !important
42
51
 
43
52
 
53
+ .card_sidebar, .card_sidebar > *, .card_sidebar > * > *
54
+ text-overflow: ellipsis
55
+ overflow-x: auto
56
+ max-width: 100%
57
+
@@ -2,6 +2,8 @@
2
2
  .preload *
3
3
  +animation-duration(0s !important)
4
4
 
5
+ html, body
6
+ scroll-padding-top: 60px
5
7
  body
6
8
  background: none repeat scroll 0% 0% #F7F7F7
7
9
  margin: 0 !important
@@ -286,6 +286,8 @@ dl.flex_dl
286
286
  flex-basis: 20%
287
287
  text-align: right
288
288
  padding-right: 2em
289
+ max-width: 20%
290
+ text-overflow: ellipsis
289
291
  & > dd
290
292
  flex-basis: 80%
291
293
  flex-grow: 1
@@ -39,6 +39,6 @@
39
39
  = entity.action_link action, text, params.merge(:class => 'ui item button')
40
40
  - last_resource = resource
41
41
 
42
- .action_progress.ui.info.message
42
+ .action_progress.ui.info.message
43
43
 
44
44
  .action_loader.ui.very.basic.segment<
@@ -2,36 +2,53 @@
2
2
  - entity_id = "entity__" + entity.id
3
3
  - default = entity.respond_to?(:default)? entity.default || entity.to_s : entity.to_s
4
4
 
5
+ :sass
6
+ .card_sidebar, .card_sidebar > *, .card_sidebar > * > *
7
+ text-overflow: ellipsis
8
+ overflow-x: auto
9
+ max-width: 100%
5
10
 
6
11
  .entity_card.ui.grid(data-entity=entity data-entity-id=default data-entity-type="#{entity.base_type}" data-entity-format="#{entity.respond_to?(:format) ? entity.format : ""}" data-entity-info="#{entity.info.to_json}")
7
12
  /-- card_sidebar --
8
- .ui.four.wide.column.vertical.card_sidebar.menu
13
+ .ui.four.wide.column.vertical.card_sidebar.menu.hidden
14
+ - empty = true
9
15
  - if card.sections.any?
16
+ - empty = false
10
17
  %h3 Sections
11
18
  - card.sections.each do |name,section|
12
19
  %a.item(href="##{Misc.snake_case(name)}")= Misc.humanize(name)
13
- %a.item(href="#entity_actions") Entity actions
20
+ - if card.action_controller
21
+ %a.item(href="#entity_actions") Entity actions
14
22
 
15
23
  - info = card.entity.info
24
+ - info.delete :annotation_types
16
25
  - if info.any? or card.meta or card.list_container
17
- %h3 Meta data
18
26
  .meta
19
27
  - if info.any?
28
+ %h3 Meta data
20
29
  .entity_info
21
30
  = hash2dl(info)
22
31
 
23
32
  - case card.meta
24
33
  - when nil
25
34
  - when Hash
35
+ - empty = false
26
36
  = hash2dl(card.meta)
27
37
  - when Proc
38
+ - empty = false
28
39
  = fragment :meta, &card.meta
29
40
 
30
41
  - if card.list_container
42
+ - empty = false
31
43
  %h3 Related lists
32
44
  .list_container
33
45
  = list_container_render(card.list_container)
34
46
 
47
+ - if ! empty
48
+ .show_opened
49
+ - else
50
+ .delete_empty
51
+
35
52
 
36
53
  .ui.twelve.wide.column.content
37
54
  .ui.header.basic.segment
@@ -3,7 +3,9 @@
3
3
 
4
4
  .entity_list_card.ui.grid(id="#{ list_id.gsub(/\s/,'_') }_card" data-list=list_id data-list-type="#{list.base_type}")
5
5
  .ui.four.wide.column.vertical.card_sidebar.menu.hidden
6
+ - empty = true
6
7
  - if card.sections.any?
8
+ - empty = false
7
9
  %h3 Sections
8
10
  - card.sections.each do |name,section|
9
11
  %a.item(href="##{Misc.snake_case(name)}")= Misc.humanize(name)
@@ -22,7 +24,10 @@
22
24
  %a.edit_list.ui.button(href="#") Edit
23
25
 
24
26
  - info = card.list.info
27
+ - info.delete :annotation_types
28
+ - info.delete :annotated_array
25
29
  - if info.any? or card.meta or card.list_container
30
+ - empty = false
26
31
  /-- sidebar --
27
32
  %h3 Meta data
28
33
  .meta
@@ -55,10 +60,14 @@
55
60
  %li= link
56
61
 
57
62
  - if card.list_container
63
+ - empty = false
58
64
  %h3 Related lists
59
65
  .list_container
60
66
  = list_container_render(card.list_container)
61
67
 
68
+ - if ! empty
69
+ .show_opened
70
+
62
71
  .ui.twelve.wide.column.content
63
72
  .ui.header.basic.segment
64
73
  .content
@@ -1,4 +1,7 @@
1
1
  %ul
2
2
  - result.each do |elem|
3
- %li= elem
3
+ - if elem.respond_to?(:link)
4
+ %li= elem.link
5
+ - else
6
+ %li= elem
4
7
 
@@ -37,24 +37,11 @@
37
37
  a
38
38
  width: 100%
39
39
 
40
- .ui.segment.stackable.bottom.attached.grid.three.column
40
+ .ui.segment.stackable.bottom.attached.grid.two.column
41
41
  .ui.column
42
42
  = partial_render('partials/footers/bsc')
43
+ -#
43
44
  .ui.column
44
45
  = partial_render('partials/footers/ntnu')
45
46
  .ui.column
46
47
  = partial_render('partials/footers/cnio')
47
- -#.ui.segment
48
- .image
49
- %a(href="http://www.cnio.es/")
50
- %img(src="/file/cnio.png" height='115px' width='241px')
51
- .content
52
- .ui.header
53
- CNIO. Centro Nacional de Investigaciones Oncologicas (Spanish National Cancer Research Center)
54
- .description
55
- %span.group Structural Computational Biology Group
56
- %br/
57
- %span.address C/ Melchor Fernandez Almagro, 3, E-28029 Madrid
58
- .meta.contact
59
- %span.who miguel.vazquez
60
- %span.where cnio.es
@@ -2,19 +2,19 @@
2
2
  %a(href="http://www.bsc.es/")
3
3
  %img(src="/file/bsc.svg")
4
4
  .content
5
- .ui.header
5
+ -#.ui.header
6
6
  :sass
7
7
  span.bsc
8
8
  font-weight: bold
9
9
  span.cns
10
10
  font-style: italic
11
11
  font-weight: normal
12
-
12
+ -#
13
13
  %span.bsc Barcelona Supercomputing Center
14
14
  %span.cns Centro Nacional de Supercomputaci&oacute;n
15
15
 
16
16
  .description
17
- %span.group Genome Informatics Unit
17
+ %span.group Genome Informatics Unit. Life sciences Department.
18
18
  %span.address Nexus II Building. C/ Jordi Girona, 29. 08034 Barcelona (Spain)
19
19
 
20
20
  .meta.contact
@@ -2,23 +2,26 @@
2
2
  - id = "tab_menu_" + rand(1000).to_s unless defined? id and not id.nil?
3
3
  - active = false unless defined? active and not active.nil?
4
4
  - active = headers.first if TrueClass === active
5
- .ui.top.attached.tabular.stackable.menu(id=id)
5
+ .tabs(id=id)
6
+ .ui.top.attached.tabular.stackable.menu
7
+ - headers.each do |header|
8
+ - code = codes[header] ||= Misc.digest([header, id]*"-")
9
+ - tab_active = (active and active == header) ? 'active' : ''
10
+ .ui.item(data-tab=code class=tab_active)= header
11
+
6
12
  - headers.each do |header|
7
- - code = codes[header] ||= Misc.digest([header, id]*"-")
13
+ - code = codes[header]
14
+ - next if content[header].nil?
8
15
  - tab_active = (active and active == header) ? 'active' : ''
9
- .ui.item(data-tab=code class=tab_active)= header
10
-
11
- - headers.each do |header|
12
- - code = codes[header]
13
- - next if content[header].nil?
14
- - tab_active = (active and active == header) ? 'active' : ''
15
- .ui.tab.bottom.attached.segment.content(data-tab=code class=tab_active)
16
- = content[header]
16
+ .ui.tab.bottom.attached.segment.content(data-tab=code class=tab_active)
17
+ = content[header]
17
18
 
18
19
  :deferjs
19
- $("##{id} > .item[data-tab]").tab()
20
+ //$("##{id} > .item[data-tab]").tab()
21
+
22
+ $("##{id} > .menu > .item[data-tab]").tab({"context": "##{id}"})
20
23
 
21
- $('##{id} > .item[data-tab=close]').click(function(item){
24
+ $('##{id} > .menu > .item[data-tab=close]').click(function(item){
22
25
  var tool = $(this).parents('.cytoscape_tool').first()
23
26
  tool.find('.tab.active, .item.active').removeClass('active')
24
27
  return false
@@ -39,6 +39,19 @@ if (typeof user === 'undefined') user = 'none'
39
39
 
40
40
  $(function(){
41
41
 
42
+ register_dom_update('.card_sidebar > .show_opened', function(elem){
43
+ elem.parent('.card_sidebar').removeClass('hidden')
44
+ elem.remove()
45
+ })
46
+
47
+ register_dom_update('.card_sidebar > .delete_empty', function(elem){
48
+ console.log('delete')
49
+ elem.parent('.card_sidebar').siblings('.content').find('.controls > .card_sidebar_open').remove()
50
+ elem.parent('.card_sidebar').remove()
51
+ })
52
+
53
+
54
+
42
55
  register_dom_update('.reload_workflow', function(elem){
43
56
  elem.click(function(){
44
57
  console.log('WR')
@@ -48,11 +48,11 @@ function remove_parameter(url, parameter){
48
48
  }
49
49
 
50
50
  function clean_element(elem){
51
- return elem.replace(/\//g, '-..-').replace(/%/g,'o-o').replace(/\[/g,'(.-(').replace(/\]/g,').-)')
51
+ return elem.replace('&','--AND--').replace(/\//g, '-..-').replace(/%/g,'o-o').replace(/\[/g,'(.-(').replace(/\]/g,').-)')
52
52
  }
53
53
 
54
54
  function restore_element(elem){
55
- return unescape(elem.replace(/-\.\.-/g, '/').replace(/o-o/g,'%')).replace(/\(\.-\(/g,'[').replace(/\)\.-\)/g,']');
55
+ return unescape(elem.replace('--AND--','&').replace(/-\.\.-/g, '/').replace(/o-o/g,'%')).replace(/\(\.-\(/g,'[').replace(/\)\.-\)/g,']');
56
56
  }
57
57
 
58
58
  function parse_parameters(params){
@@ -160,7 +160,7 @@ rbbt.post = function(url, data, params){
160
160
  // Cookies
161
161
 
162
162
  rbbt.set_cookie = function(name,value){
163
- Cookies.set(name, value)
163
+ Cookies.set(name, value, { sameSite: 'strict'})
164
164
  }
165
165
 
166
166
  rbbt.get_cookie = function(name){
@@ -171,7 +171,7 @@ rbbt.get_cookie = function(name){
171
171
  }
172
172
 
173
173
  rbbt.remove_cookie = function(name){
174
- Cookies.remove(name)
174
+ Cookies.remove(name, { sameSite: 'strict'})
175
175
  }
176
176
 
177
177
  // LocalStorage
@@ -66,6 +66,7 @@ rbbt.plots.graph.build_cytoscapejs = function(graph_model){
66
66
  forArray(model.edges, function(edge){
67
67
  var clean = clean_hash(edge)
68
68
  if (undefined === clean.id) clean.id = clean.code
69
+ clean.id = clean.code + "@" + clean.database
69
70
  edges.push({data: clean})
70
71
  })
71
72
 
@@ -100,6 +101,10 @@ rbbt.plots.graph.view_cytoscapejs = function(graph_model, elem, style, layout, e
100
101
  style: { 'shape': 'data(shape)' }
101
102
  },
102
103
 
104
+ {
105
+ selector: 'edge',
106
+ style: { 'curve-style': 'bezier'}
107
+ },
103
108
  {
104
109
  selector: 'edge[color]',
105
110
  style: { 'line-color': 'data(color)',
@@ -113,18 +118,35 @@ rbbt.plots.graph.view_cytoscapejs = function(graph_model, elem, style, layout, e
113
118
  selector: 'edge[width]',
114
119
  style: { 'width': 'data(width)'}
115
120
  },
116
- {
117
- selector: 'edge[target-arrow-shape]',
118
- style: { 'target-arrow-shape': 'data(target-arrow-shape)'}
119
- },
120
- {
121
- selector: 'edge[target-arrow-color]',
122
- style: { 'target-arrow-color': 'data(target-arrow-color)'}
123
- }
121
+ //{
122
+ // selector: 'edge[target-arrow-shape]',
123
+ // style: { 'target-arrow-shape': 'data(target-arrow-shape)'}
124
+ //},
125
+ //{
126
+ // selector: 'edge[target-arrow-color]',
127
+ // style: { 'target-arrow-color': 'data(target-arrow-color)'}
128
+ //}
124
129
 
125
130
  ]
126
131
 
127
- var default_layout = { name: 'cose' }
132
+ var default_layout = {
133
+ name: 'cose',
134
+ idealEdgeLength: 100,
135
+ nodeOverlap: 20,
136
+ refresh: 20,
137
+ fit: true,
138
+ padding: 30,
139
+ randomize: false,
140
+ componentSpacing: 100,
141
+ nodeRepulsion: 400000,
142
+ edgeElasticity: 100,
143
+ nestingFactor: 5,
144
+ gravity: 80,
145
+ numIter: 1000,
146
+ initialTemp: 200,
147
+ coolingFactor: 0.95,
148
+ minTemp: 1.0
149
+ }
128
150
 
129
151
  if (undefined === style) style = default_style
130
152
  if (undefined === layout) layout = default_layout
@@ -139,6 +161,7 @@ rbbt.plots.graph.view_cytoscapejs = function(graph_model, elem, style, layout, e
139
161
  container: elem,
140
162
  elements: cy_model.elements,
141
163
  style: style,
164
+ layout: layout,
142
165
  }
143
166
 
144
167
  if (undefined !== extra) forHash(extra, function(k,v){ cy_params[k,v] })
@@ -147,7 +170,7 @@ rbbt.plots.graph.view_cytoscapejs = function(graph_model, elem, style, layout, e
147
170
 
148
171
  cy.layout(layout)
149
172
 
150
- cy.one('layoutready', function(){
173
+ cy.one('layoutstop', function(){
151
174
  deferred.resolve(this)
152
175
  })
153
176
  })
@@ -238,7 +261,6 @@ rbbt.plots.graph.update_cytoscape = function(graph_model, elem){
238
261
 
239
262
  rbbt.plots.graph.view_d3js_graph = function(graph_model, elem, node_obj){
240
263
  rbbt.plots.graph.update(graph_model).then(function(updated_model){
241
- console.log(updated_model)
242
264
  var dataset = rbbt.plots.graph.build_d3(updated_model)
243
265
 
244
266
  if (undefined === node_obj){