rbbt-rest 1.7.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59c0ed2d456a49f6418d29a6264603d9975f739d
4
- data.tar.gz: 3886dd197d5d6b6ea33f471c3edca6397fc682ae
3
+ metadata.gz: 83b8b9094b9af4834099ecf4ccd86eef7b611a8e
4
+ data.tar.gz: 3b66884ff196078ceb9e743cc3904b60baa74794
5
5
  SHA512:
6
- metadata.gz: 58719858ad8424352f9ba49bded0b74e8d466e1d382aba478366e02e646a2fd807e43b2617ac5a4f3d8c4518c0f96841242d82a2d11b45b9d18bc424fe7b058b
7
- data.tar.gz: 40ba3da4b639c982216228cf61f5286543ceb7d5aa335617154ccc3a9b3b6be145b67f5fcace57971cf866a51c9ecd6d3653082f4f7e9a018a21bebfb4fb539a
6
+ metadata.gz: a97a9160d62382ae1e786a2f63e261da90b484d16367eeb7322721611e7d4d9c76c6555fad0ec959a8c64e5ae4ae95b2ef82673d3252f388c75c8c14585e7cad
7
+ data.tar.gz: 698cd1bae789d6f3ebb4126889961e02c319f66f3721045fef3af97c1a25e00c9cad03ce789278ffa9c5408c1eefb4036468e2f6c5228e1da7ac024076186d0d
@@ -45,7 +45,7 @@ module RbbtRESTHelpers
45
45
  path = locate_javascript(file.split("/")[2..-1] * "/")
46
46
  end
47
47
 
48
- Open.read(path)
48
+ "//FILE: #{ File.basename(path) }\n" + Open.read(path)
49
49
  } * "\n"
50
50
 
51
51
  FileUtils.mkdir_p File.dirname(filename) unless File.exists? File.dirname(filename)
@@ -305,6 +305,7 @@ module Sinatra
305
305
  target = kb.target(database)
306
306
  source_type = kb.source_type(database)
307
307
  target_type = kb.target_type(database)
308
+ fields = kb.fields(database)
308
309
  source_entity_options = kb.entity_options_for source_type
309
310
  target_entity_options = kb.entity_options_for target_type
310
311
 
@@ -315,6 +316,7 @@ module Sinatra
315
316
  :target_type => target_type,
316
317
  :source_entity_options => source_entity_options,
317
318
  :target_entity_options => target_entity_options,
319
+ :fields => fields,
318
320
  }
319
321
 
320
322
  halt 200, info.to_json
@@ -394,10 +394,11 @@ body
394
394
  .flex-wrap
395
395
  flex-wrap: wrap
396
396
 
397
- .action_parameters
398
- transform: translateX(-0.9em)
399
- width: calc(100% + 2 * 0.9em)
400
- margin-bottom: 1.8em !important
397
+ .ui.segment
398
+ .action_parameters
399
+ transform: translateX(-0.9em)
400
+ width: calc(100% + 2 * 0.9em)
401
+ margin-bottom: 1.8em !important
401
402
 
402
403
 
403
404
  #top_menu
@@ -30,14 +30,22 @@
30
30
  requirejs.config({baseUrl: '/js-find'})
31
31
 
32
32
 
33
+
34
+ -# JQUERY JS
33
35
  - %w(jquery-2.1.1 jquery.cookie jquery.form).each do |jquery_file|
34
36
  - record_js File.join('/plugins/jquery/js/', jquery_file)
35
37
 
36
38
  - record_js '/plugins/jquery-ui/js/jquery-ui-1.8.14.custom.min.js'
37
39
  - record_js '/plugins/jquery.tablesorter/jquery.tablesorter.min.js'
38
40
  - record_js '/plugins/jquery.scrollTo/jquery.scrollTo'
41
+
42
+ -# SEMANTIC UI JS
39
43
  - record_js '/plugins/semantic-ui/dist/semantic.min.js'
44
+
45
+ -# OTHER
40
46
  - record_js '/plugins/FileSaver/js/FileSaver.js'
47
+
48
+ -# VISUALIZATION JS
41
49
  - record_js '/plugins/color-js/color.js'
42
50
  - record_js '/plugins/d3js/js/d3js.min.js'
43
51
  - record_js '/plugins/nvd3/js/nv.d3.js'
@@ -45,6 +53,8 @@
45
53
  - record_js '/plugins/cola/js/cola.js'
46
54
  - record_js '/plugins/mithril-node-render/js/index.js'
47
55
 
56
+
57
+
48
58
  - %w(helpers _md5 _ajax_replace _ellipsis).each do |file|
49
59
  - record_js "/js-find/#{ file }"
50
60
 
@@ -52,7 +62,10 @@
52
62
  - %w(dom_update fragment actions table list map reveal).each do |file|
53
63
  - record_js "/js-find/rbbt/#{ file }"
54
64
 
55
- - %w(rbbt rbbt.basic rbbt.exception rbbt.job rbbt.page rbbt.entity rbbt.entity_list rbbt.entity_map rbbt.views rbbt.favourites rbbt.knowledge_base rbbt.aesthetics rbbt.plots rbbt.modal).each do |file|
65
+ - %w(rbbt rbbt.basic rbbt.exception rbbt.job rbbt.page rbbt.entity rbbt.entity_list rbbt.entity_map rbbt.views rbbt.favourites rbbt.modal).each do |file|
66
+ - record_js "/js-find/#{ file }"
67
+
68
+ - %w(rbbt.knowledge_base rbbt.aesthetics rbbt.plots).each do |file|
56
69
  - record_js "/js-find/#{ file }"
57
70
 
58
71
  - record_js "/js-find/app"
@@ -2,16 +2,6 @@ rbbt.aesthetics = {LS_key: "rbbt.aesthetics"}
2
2
 
3
3
  var aes_module = rbbt.aesthetics
4
4
 
5
- aes_module.load = function(){
6
- this.aesthetics = rbbt.LS.load(this.LS_key)
7
- if (undefined === this.aesthetics)
8
- this.aesthetics = []
9
- }.bind(aes_module)
10
-
11
- aes_module.store = function(){
12
- rbbt.LS.store(this.LS_key, this.aesthetics)
13
- }.bind(aes_module)
14
-
15
5
  aes_module.map_aesthetic = function(aes, mapper, map_obj){
16
6
  switch(mapper){
17
7
  case false:
@@ -28,6 +18,100 @@ aes_module.map_aesthetic = function(aes, mapper, map_obj){
28
18
  }
29
19
  }
30
20
 
21
+ aes_module.get_list_property = function(list, rule, result) {
22
+ promise = list.property(rule.property, rule.args)
23
+
24
+ if (undefined === rule.extract){
25
+ return promise.then(result, rbbt.exception.report)
26
+ }else{
27
+ var extract = rule.extract
28
+ return promise.then(function(v){return v.map(extract)}).then(result, rbbt.exception.report)
29
+ }
30
+ }
31
+
32
+ aes_module.get_list_workflow_job = function(list, rule, result) {
33
+ promise = rbbt.job(rule.workflow, rule.task, rule.args,true)
34
+
35
+ if (undefined === rule.extract){
36
+ return promise.then(result, rbbt.exception.report)
37
+ }else{
38
+ var extract = rule.extract
39
+ return m.sync([list.get(), promise]).then(function(res){
40
+ list_info = res[0]
41
+ data = res[1]
42
+ return list_info.entities.map(function(e){ return extract.call(null, data, e) })
43
+ }).then(result, rbbt.exception.report)
44
+ }
45
+ }
46
+
47
+ aes_module.get_list_knowledge_base = function(list, rule, result) {
48
+ var db_code
49
+ var promise
50
+ if (rule.parents){
51
+ var db_code = [rule.parents, rule.knowledge_base].join("@")
52
+ promise = rbbt.knowledge_base.list_parents(db_code, list)
53
+ }
54
+
55
+ if (rule.children){
56
+ var db_code = [rule.children, rule.knowledge_base].join("@")
57
+ promise = rbbt.knowledge_base.list_children(db_code, list)
58
+ }
59
+
60
+ if (rule.field){
61
+ promise = m.sync([promise,rbbt.knowledge_base.database_info(db_code)]).then(function(res){
62
+ var data = res[0]
63
+ var db_info = res[1]
64
+ var fields = db_info.fields
65
+ var field_pos = fields.indexOf(rule.field)
66
+
67
+ if (field_pos < 0){
68
+ var msg = "Field not found: " + rule.field + ". Options: " + fields.join(", ")
69
+ throw new Error(msg)
70
+ }
71
+
72
+ var matches = {}
73
+ forHash(data, function(key, values){
74
+ var source = values[0]
75
+ var target = values[1]
76
+ if (matches[source] === undefined) matches[source] = {}
77
+ matches[source][target] = values[field_pos+2]
78
+ })
79
+ return matches
80
+ })
81
+
82
+ }else{
83
+ promise = promise.then(function(data){
84
+ var matches = {}
85
+ forHash(data, function(key, values){
86
+ var source = values[0]
87
+ var target = values[1]
88
+ if (matches[source] === undefined) matches[source] = {}
89
+ matches[source][target] = values.slice(2)
90
+ })
91
+ return matches
92
+ })
93
+ }
94
+
95
+ if (undefined === rule.extract){
96
+ return m.sync([list.get(), promise]).then(function(res){
97
+ var list_info = res[0]
98
+ var data = res[1]
99
+ return list_info.entities.map(function(e){ return data[e] })
100
+ }).then(result, function(r){rbbt.exception.report(r[1])})
101
+ }
102
+ else{
103
+ var extract = rule.extract
104
+ return m.sync([list.get(), promise]).then(function(res){
105
+ var list_info = res[0]
106
+ var data = res[1]
107
+ return list_info.entities.map(function(e){
108
+ return extract.call(null, data, e)
109
+ })
110
+ }).then(result, function(r){rbbt.exception.report(r[1])})
111
+ }
112
+
113
+ }
114
+
31
115
  aes_module.get_list_aesthetics = function(list, rules) {
32
116
  var result = {}
33
117
  var promises = []
@@ -35,73 +119,29 @@ aes_module.get_list_aesthetics = function(list, rules) {
35
119
  var mappers = {}
36
120
 
37
121
  if (undefined === rules) rules = this.aesthetics
122
+
38
123
  forArray(rules, function(rule){
39
124
  var aes = rule.aes
40
125
  result[aes] = m.prop()
41
126
  mappers[aes] = rule.mapper
42
127
 
43
- var args = rule.args
44
- var extract = rule.extract
45
-
46
128
  var promise
47
129
 
48
130
  if (rule.property){
49
- promise = list.property(rule.property, args)
50
-
51
- if (undefined === extract){
52
- promises.push(promise.then(result[aes], rbbt.exception.report))
53
- }else{
54
- promises.push(promise.then(function(v){return v.map(extract)}).then(result[aes], rbbt.exception.report))
55
- }
131
+ promises.push(aes_module.get_list_property(list, rule, result[aes]))
56
132
  }
57
133
 
58
134
  if (rule.workflow){
59
- promise = rbbt.job(rule.workflow, rule.task, args,true)
60
- if (undefined === extract){
61
- promises.push(promise.then(result[aes], rbbt.exception.report))
62
- }else{
63
- promises.push(m.sync([list.get(), promise]).then(function(res){
64
- list_info = res[0]
65
- data = res[1]
66
- return list_info.entities.map(function(e){ return extract.call(null, data, e) })
67
- }).then(result[aes], rbbt.exception.report))
68
- }
135
+ promises.push(aes_module.get_list_workflow_job(list, rule, result[aes]))
69
136
  }
70
137
 
71
138
  if (rule.knowledge_base){
72
- if (rule.parents)
73
- promise = rbbt.knowledge_base.list_parents([rule.parents, rule.knowledge_base].join("@"), list)
74
- if (rule.children)
75
- promise = rbbt.knowledge_base.list_children([rule.children, rule.knowledge_base].join("@"), list)
76
-
77
- promise = promise.then(function(data){
78
- var matches = {}
79
- forHash(data, function(key, values){
80
- var source = values[0]
81
- var target = values[1]
82
- if (matches[source] === undefined) matches[source] = {}
83
- matches[source][target] = values.slice(2)
84
- })
85
- return matches
86
- })
87
-
88
- if (undefined === extract){
89
- promises.push(m.sync([list.get(), promise]).then(function(res){
90
- list_info = res[0]
91
- data = res[1]
92
- return list_info.entities.map(function(e){ return data[e] })
93
- }).then(result[aes]))
94
- }else{
95
- promises.push(m.sync([list.get(), promise]).then(function(res){
96
- list_info = res[0]
97
- data = res[1]
98
- return list_info.entities.map(function(e){ return extract.call(null, data, e) })
99
- }).then(result[aes]))
100
- }
139
+ promises.push(aes_module.get_list_knowledge_base(list, rule, result[aes]))
101
140
  }
102
141
  })
103
142
 
104
143
  var mapped_result = {}
144
+
105
145
  m.sync(promises).then(function(){
106
146
  forHash(result, function(aes, values){
107
147
  var mapper = mappers[aes]
@@ -113,55 +153,40 @@ aes_module.get_list_aesthetics = function(list, rules) {
113
153
  return deferred.promise
114
154
  }
115
155
 
156
+ //{{{ HELPERS
157
+ aes_module.column_aes = function(aes, column){
158
+ var column_aes = {label: column}
159
+ forHash(aes, function(key, values){
160
+ var m
161
+ if (m = key.match(/^column-(.*)/)){
162
+ var clean_key = m[1]
163
+ if (undefined === values)
164
+ column_aes[clean_key] = undefined
165
+ else
166
+ column_aes[clean_key] = values[column]
167
+ }
168
+ })
169
+ return column_aes
170
+ }
171
+
172
+ //{{{ STORE, LOAD, ADD and APPLY
173
+
174
+ aes_module.store = function(){
175
+ rbbt.LS.store(this.LS_key, this.aesthetics)
176
+ }.bind(aes_module)
177
+
178
+ aes_module.load = function(){
179
+ this.aesthetics = rbbt.LS.load(this.LS_key)
180
+ if (undefined === this.aesthetics)
181
+ this.aesthetics = []
182
+ }.bind(aes_module)
183
+
116
184
  aes_module.add = function(rule){
117
185
  aes_module.aesthetics.push(rule)
118
186
  aes_module.aesthetics = unique(aes_module.aesthetics)
119
187
  aes_module.store()
120
188
  }
121
189
 
122
- aes_module.apply = function(){
123
- }
124
-
125
- //aes_module.add = function(selector, aes, value){
126
- // var mod = this
127
- // if (typeof selector == 'function'){
128
- // return selector.then(function(_selector){
129
- // mod.aesthetics.push({selector: _selector, aes: aes, value: value})
130
- // })
131
- // }else{
132
- // this.aesthetics.push({selector: selector, aes: aes, value: value})
133
- // }
134
- //}
135
- //
136
- //aes_module.clear_aesthetic = function(aes){
137
- // var data_key = 'data-aes-' + aesthetic.aes
138
- //
139
- // $('[' + data_key + ']').attr(data_key, 'none')
140
- //}
141
- //
142
- //aes_module.apply_aesthetic = function(aesthetic){
143
- //
144
- // if (typeof aesthetic.selector == "string"){
145
- // targets = $(aesthetic.selector)
146
- // }else{
147
- // var items = aesthetic.selector
148
- // if (typeof items[0] == 'object') items = $.map(items, function(i){return i.id})
149
- // targets = $('.entity').filter(function(index){
150
- // var id = $(this).attr('data-entity-id')
151
- // return items.indexOf(id) >= 0
152
- // })
153
- // }
154
- //
155
- // var data_key = 'data-aes-' + aesthetic.aes
156
- // targets.attr(data_key, aesthetic.value)
157
- //}
158
- //
159
- //aes_module.apply = function(aesthetic){
160
- // if (undefined === aesthetic)
161
- // aes_module.aesthetics.map(aes_module.apply_aesthetic)
162
- // else
163
- // aes_module.apply_aesthetic(aesthetic)
164
- //}
165
- //
190
+ aes_module.apply = function(){ }
166
191
 
167
192
  aes_module.load()
@@ -14,9 +14,9 @@ var EntityList = function(data){
14
14
  }
15
15
 
16
16
  this.get = function(){
17
- var url = this.url()
18
- url = add_parameter(url, '_format', 'json')
19
17
  if (undefined === this.entities && ! this.loading){
18
+ var url = this.url()
19
+ url = add_parameter(url, '_format', 'json')
20
20
  list = this
21
21
  this.loading = m.request({url: url, method: 'GET'}).then(this.entities).then(function(x){ list.loading = undefined; return x})
22
22
  return this.loading
@@ -68,14 +68,13 @@ var EntityList = function(data){
68
68
  var db_key = [database, knowledgebase].join("@")
69
69
  return rbbt.knowledge_base.list_subset(db_key, this)
70
70
  }
71
-
72
-
73
71
  }
74
72
 
73
+ //{{{ FAVOURITES
75
74
  var FavouriteLists = function(by_type){
76
- for (type in by_type){
77
- this[type] = by_type[type]
78
- }
75
+ for (type in by_type){
76
+ this[type] = by_type[type]
77
+ }
79
78
  }
80
79
 
81
80
  FavouriteLists.get = function(){
@@ -5,9 +5,10 @@ rbbt.exception.null = function(variable, text){
5
5
  }
6
6
 
7
7
  rbbt.exception.report = function(err){
8
+ console.log(err)
8
9
  console.log("Error: " + err)
9
10
  var stack = err.stack
10
- console.log(stack)
11
+ if(undefined === stack) stack = "No stack trace"
11
12
  if (rbbt.modal){
12
13
  stack = "<ul><li>" + stack.replace(/\n/g, '</li><li>') + '<li/></ul>'
13
14
  stack = stack.replace(/<li><li\/>/g,'').replace(/<li>(.*?)@(.*?):(\d+:\d+)<\/li>/g, '<li>$2<span style="font-weight:bold">$3</span><br/><em>$1</em></li>')
@@ -1,17 +1,23 @@
1
1
  var KB = rbbt.knowledge_base = {}
2
2
 
3
- KB.children = function(database, entity){
4
- var id = undefined
5
- if (typeof entity == 'string'){ id = entity}else{id = entity.id}
6
- var url = '/kb/user/' + database + '/children/' + id
7
- url = add_parameter(url, '_format', 'json')
8
- return m.request({url: url, method: "GET", type: Entity})
9
- }
3
+ //KB.children = function(database, entity){
4
+ // var id = undefined
5
+ // if (typeof entity == 'string'){ id = entity}else{id = entity.id}
6
+ // var url = '/knowledge_base/user/' + database + '/children/' + id
7
+ // url = add_parameter(url, '_format', 'json')
8
+ // return m.request({url: url, method: "GET", type: Entity})
9
+ //}
10
+ //
11
+ //KB.parents = function(database, entity){
12
+ // var url = '/knowledge_base/user/' + database + '/parents/' + entity.id
13
+ // url = add_parameter(url, '_format', 'json')
14
+ // return m.request({url: url, method: "GET", type: Entity})
15
+ //}
10
16
 
11
- KB.parents = function(database, entity){
12
- var url = '/kb/user/' + database + '/parents/' + entity.id
17
+ KB.database_info = function(database){
18
+ var url = '/knowledge_base/user/' + database + '/info'
13
19
  url = add_parameter(url, '_format', 'json')
14
- return m.request({url: url, method: "GET", type: Entity})
20
+ return m.request({url: url, method: "GET"})
15
21
  }
16
22
 
17
23
  KB.list_parents = function(database, list){
@@ -1,7 +1,20 @@
1
1
  rbbt.page = {};
2
2
 
3
+ rbbt.page.path = function(){
4
+ return window.location.pathname;
5
+ }
6
+
7
+ rbbt.page.path_parts = function(path){
8
+ if (undefined === path) path = rbbt.page.path()
9
+
10
+ var parts = path.split("/")
11
+ if (parts[0] == "") parts.shift()
12
+
13
+ return parts
14
+ }
15
+
3
16
  rbbt.page.type = function(path){
4
- if (undefined === path){ path = window.location.pathname; }
17
+ if (undefined === path) path = rbbt.page.path()
5
18
 
6
19
  if (path.match(/^\/entity\//)){ return "entity"; }
7
20
  if (path.match(/^\/entity_action\//)){ return "entity_action"; }
@@ -25,11 +38,22 @@ rbbt.page.entity = function(){
25
38
 
26
39
  rbbt.page.list = function(){
27
40
  var card = $('.entity_list_card')
28
- if (card.length == 0) return false
29
-
30
- var list = card.attr('data-list')
31
- var type = card.attr('data-list-type')
32
- return new EntityList({id: list, type: type})
41
+
42
+ if (card.length > 0){
43
+ var list = card.attr('data-list')
44
+ var type = card.attr('data-list-type')
45
+ return new EntityList({id: list, type: type})
46
+ }
47
+
48
+ if (rbbt.page.type() == 'entity_list_action'){
49
+ var parts = rbbt.page.path_parts()
50
+ var type = parts[1]
51
+ var list = parts[3]
52
+ console.log(list)
53
+ return new EntityList({id: list, type: type})
54
+ }
55
+
56
+ return false
33
57
  }
34
58
 
35
59
  rbbt.page.map = function(){
@@ -58,85 +82,3 @@ rbbt.page.map_link = function(type, column, id){
58
82
  return a
59
83
  }
60
84
 
61
- //{{{ OLD
62
- //function rbbt.page_entity(path){
63
- // if (undefined === path){ path = window.location.pathname; }
64
- //
65
- // switch(page_type(path)){
66
- // case "entity":
67
- // return restore_element(path.split('?')[0].split("/")[3]);
68
- // default:
69
- // return undefined
70
- // }
71
- //}
72
- //
73
- //function rbbt.page_entity_list(path){
74
- // if (undefined === path){ path = window.location.pathname; }
75
- //
76
- // switch(page_type(path)){
77
- // case "entity_list":
78
- // return restore_element(path.split('?')[0].split("/")[3]);
79
- // default:
80
- // return undefined
81
- // }
82
- //}
83
- //
84
- //function rbbt.page_entity_map(path){
85
- // if (undefined === path){ path = window.location.pathname; }
86
- //
87
- // switch(page_type(path)){
88
- // case "entity_map":
89
- // return restore_element(path.split('?')[0].split("/")[4]);
90
- // default:
91
- // return undefined
92
- // }
93
- //}
94
- //
95
- //function rbbt.page_entity_map_column(path){
96
- // if (undefined === path){ path = window.location.pathname; }
97
- //
98
- // switch(page_type(path)){
99
- // case "entity_map":
100
- // return restore_element(path.split("/")[3]);
101
- // default:
102
- // return undefined
103
- // }
104
- //}
105
- //
106
- //function rbbt.page_entity_type(path){
107
- // if (undefined === path){ path = window.location.pathname; }
108
- // var entity_type;
109
- //
110
- // switch(page_type(path)){
111
- // case "entity":
112
- // case "entity_list":
113
- // case "entity_action":
114
- // case "entity_list_action":
115
- // case "entity_map":
116
- // return restore_element(path.split("/")[2]);
117
- // break;
118
- // }
119
- // return undefined;
120
- //}
121
- //
122
- //function rbbt.page_entity_base_type(path){
123
- // return page_entity_type(path).split(":")[0]
124
- //}
125
- //
126
- //function rbbt.page_entity_format(path){
127
- // return page_entity_type(path).split(":")[1]
128
- //}
129
- //
130
- //function rbbt.page_entity_info(path){
131
- // var params;
132
- // if (undefined === path){
133
- // params = window.location.search;
134
- // }else{
135
- // params = path.split('?')[1]
136
- // }
137
- // return parse_parameters(params)
138
- //}
139
- //
140
- ////{{{ Link generators
141
- //
142
-
@@ -78,7 +78,7 @@ rbbt.plots.list_plot = function(list, rules, create_obj){
78
78
  rbbt.log("Loading")
79
79
  return m('.ui.basic.segment.plot.loading', "Loading")
80
80
  }else{
81
- rbbt.log("Wrap")
81
+ rbbt.log("Drawing")
82
82
  return m('.ui.basic.segment.plot', objs)
83
83
  }
84
84
  }
@@ -100,7 +100,6 @@ rbbt.plots.list_plot = function(list, rules, create_obj){
100
100
 
101
101
  //{{{ PLOTS
102
102
 
103
-
104
103
  //{{{ FORCE LAYOUT
105
104
 
106
105
  rbbt.plots.force_layout = function(graph){
@@ -136,7 +135,7 @@ rbbt.plots.association_network = function(nodes, associations){
136
135
  var target = value[1]
137
136
  var source_index = indices[source]
138
137
  var target_index = indices[target]
139
- links.push({source: source_index, target: target_index, id: key})
138
+ links.push({source: source_index, target: target_index, id: key, values: value})
140
139
  })
141
140
 
142
141
  return links
@@ -151,23 +150,27 @@ rbbt.plots.basic_rules = function(study){
151
150
  rules.push({aes:'description', property: 'long_name'})
152
151
  rules.push({aes:'highlight', property: 'significant_in_study', args:study})
153
152
  rules.push({aes:'order', property: 'damage_bias_in_study', args:study})
154
- rules.push({aes:'color_class', workflow: 'GEO', task: 'differential', args:{threshold: 0.05, dataset: 'GSE13507', to_gene: true, main:"/Primary/", contrast: "/ontrol/"}, extract: function(result, entity){
155
- if (undefined === result[entity]) return ""
156
- var pvalue = result[entity][result[entity].length-1]
157
- if (pvalue > 0 && pvalue < 0.05){
158
- return "green"
159
- }else{
160
- if (pvalue < 0 && pvalue > -0.05){
161
- return "red"
162
- }else{
163
- return ""
164
- }
165
- }
153
+ rules.push({aes:'color_class', workflow: 'GEO', task: 'differential',
154
+ args:{threshold: 0.05, dataset: 'GSE13507', to_gene: true, main:"/Primary/", contrast: "/ontrol/"},
155
+ extract: function(result, entity){
156
+ if (undefined === result[entity]) return ""
157
+ var pvalue = result[entity][result[entity].length-1]
158
+ if (pvalue > 0 && pvalue < 0.05){
159
+ return "green"
160
+ }else{
161
+ if (pvalue < 0 && pvalue > -0.05){
162
+ return "red"
163
+ }else{
164
+ return ""
165
+ }
166
+ }
166
167
  }})
167
- rules.push({aes:'color', workflow: 'GEO', task: 'differential', mapper: 'sign-gradient', args:{threshold: 0.05, dataset: 'GSE13507', to_gene: true, main:"/Primary/", contrast: "/ontrol/"}, extract: function(result, entity){
168
- if (undefined === result[entity]) return ""
169
- var pvalue = result[entity][result[entity].length-1]
170
- return pvalue_score(pvalue)
168
+ rules.push({aes:'color', workflow: 'GEO', task: 'differential', mapper: 'sign-gradient',
169
+ args:{threshold: 0.05, dataset: 'GSE13507', to_gene: true, main:"/Primary/", contrast: "/ontrol/"},
170
+ extract: function(result, entity){
171
+ if (undefined === result[entity]) return ""
172
+ var pvalue = result[entity][result[entity].length-1]
173
+ return pvalue_score(pvalue)
171
174
  }})
172
175
 
173
176
  return rules
@@ -295,11 +298,13 @@ rbbt.plots.d3js_group_graph = function(graph, object){
295
298
  .nodes(graph.nodes)
296
299
  .links(graph.links)
297
300
  .groups(graph.groups)
298
- .start()
301
+ .start(0,0,0)
299
302
 
300
- for(i=0; i<1000; i++) force.tick()
303
+ rbbt.log("force:warmup")
304
+ for(i=0; i<100; i++) force.tick()
305
+ rbbt.log("force:warmup done")
301
306
 
302
- var stop = true
307
+ var stop = false
303
308
  var e
304
309
  if (stop) e = 'end'
305
310
  else e = 'tick'
@@ -318,7 +323,10 @@ rbbt.plots.d3js_group_graph = function(graph, object){
318
323
  .attr("width", function (d) { return d.bounds.width() - pad/2; })
319
324
  .attr("height", function (d) { return d.bounds.height() - pad/2; });
320
325
 
321
- if (stop) svgPanZoom(object)
326
+ if (stop){
327
+ rbbt.log("force:panZoom")
328
+ svgPanZoom(object, {minZoom: 0, maxZoom: 1000})
329
+ }
322
330
  })
323
331
 
324
332
  var group = svg.selectAll(".group")
@@ -331,23 +339,40 @@ rbbt.plots.d3js_group_graph = function(graph, object){
331
339
  group.append('title').text(function(d){return d.name})
332
340
  var link = svg.selectAll(".link").data(graph.links).enter()
333
341
  .append("line").attr("class", "link")
334
- .style("stroke-width", 5)
342
+ .style("stroke-width", 7)
343
+ .style("stroke", function(l){
344
+ if (l.type && l.type == 'move')
345
+ return 'green'
346
+ else
347
+ return 'gray'
348
+ })
349
+ .style("stroke-dasharray", function(l){
350
+ if (l.type && l.type == 'move')
351
+ return '20,10,5,5,10'
352
+ else
353
+ return undefined
354
+ })
335
355
 
336
356
  var node = svg.selectAll(".node").data(graph.nodes).enter()
337
- .append("foreignObject").attr("class", "node")
338
- .attr('width',xsize)
339
- .attr('height',ysize).html(function(d){ return mrender(rbbt.plots.card_obj(d)) })
357
+ .append("foreignObject").attr("class", "node").attr('width',xsize).attr('height',ysize)
358
+ .html(function(d){ return mrender(rbbt.plots.card_obj(d)) })
340
359
  .call(force.drag)
341
360
 
342
-
361
+ //var node = svg.selectAll(".node").data(graph.nodes).enter()
362
+ // .append("rect").attr("class", "node")
363
+ // .attr('height', ysize)
364
+ // .attr('width', xsize)
365
+ // .attr('fill', 'white')
366
+ // .call(force.drag)
343
367
 
344
368
  if (stop){
345
369
  force.stop()
346
370
  }else{
347
- svgPanZoom(object)
371
+ rbbt.log("force:panZoom")
372
+ svgPanZoom(object, {minZoom: 0, maxZoom: 1000})
348
373
  }
349
374
 
350
- rbbt.log("force:panZoom")
375
+ rbbt.log("force:done")
351
376
  }
352
377
 
353
378
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-06 00:00:00.000000000 Z
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake