rbbt-rest 1.7.19 → 1.7.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rbbt/rest/common/cache.rb +13 -1
- data/lib/rbbt/rest/common/misc.rb +4 -2
- data/lib/rbbt/rest/common/users.rb +5 -0
- data/lib/rbbt/rest/entity.rb +2 -1
- data/lib/rbbt/rest/knowledge_base.rb +5 -2
- data/lib/rbbt/rest/knowledge_base/helpers.rb +9 -0
- data/lib/rbbt/rest/main.rb +2 -0
- data/share/views/compass/app.sass +6 -0
- data/share/views/layout/header.haml +8 -4
- data/share/views/public/js/helpers/defer.js +11 -9
- data/share/views/public/js/helpers/helpers.js +23 -5
- data/share/views/public/js/rbbt.basic.js +32 -1
- data/share/views/public/js/rbbt.entity.basic.js +41 -17
- data/share/views/public/js/rbbt.knowledge_base.js +60 -9
- data/share/views/public/js/rbbt.page.js +0 -1
- data/share/views/public/js/rbbt.plots/rbbt.plots.aes.js +195 -0
- data/share/views/public/js/{rbbt.aesthetics.js → rbbt.plots/rbbt.plots.aesthetics.js} +0 -0
- data/share/views/public/js/rbbt.plots/rbbt.plots.basic.js +2 -0
- data/share/views/public/js/rbbt.plots/rbbt.plots.graph.adapters.js +216 -0
- data/share/views/public/js/rbbt.plots/rbbt.plots.graph.js +138 -0
- data/share/views/public/js/rbbt.plots/rbbt.plots.graph.kb.js +72 -0
- data/share/views/public/js/{rbbt.plots.js → rbbt.plots/rbbt.plots.list.js} +1 -4
- data/share/views/public/js/rbbt/actions.js +0 -1
- data/share/views/public/plugins/js-cookie/js/js.cookie.js +145 -0
- data/share/views/public/plugins/mithril/js/mithril.js +1819 -833
- metadata +10 -5
- data/share/views/public/js/rbbt.aes_plots.js +0 -381
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.
|
4
|
+
version: 1.7.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -369,8 +369,6 @@ files:
|
|
369
369
|
- share/views/public/js/helpers/_md5.js
|
370
370
|
- share/views/public/js/helpers/defer.js
|
371
371
|
- share/views/public/js/helpers/helpers.js
|
372
|
-
- share/views/public/js/rbbt.aes_plots.js
|
373
|
-
- share/views/public/js/rbbt.aesthetics.js
|
374
372
|
- share/views/public/js/rbbt.basic.js
|
375
373
|
- share/views/public/js/rbbt.entity.basic.js
|
376
374
|
- share/views/public/js/rbbt.entity.js
|
@@ -383,7 +381,13 @@ files:
|
|
383
381
|
- share/views/public/js/rbbt.knowledge_base.js
|
384
382
|
- share/views/public/js/rbbt.modal.js
|
385
383
|
- share/views/public/js/rbbt.page.js
|
386
|
-
- share/views/public/js/rbbt.plots.js
|
384
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.aes.js
|
385
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.aesthetics.js
|
386
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.basic.js
|
387
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.graph.adapters.js
|
388
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.graph.js
|
389
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.graph.kb.js
|
390
|
+
- share/views/public/js/rbbt.plots/rbbt.plots.list.js
|
387
391
|
- share/views/public/js/rbbt.views.js
|
388
392
|
- share/views/public/js/rbbt/actions.js
|
389
393
|
- share/views/public/js/rbbt/dom_update.js
|
@@ -1176,6 +1180,7 @@ files:
|
|
1176
1180
|
- share/views/public/plugins/jquery/js/jquery-2.1.4.js
|
1177
1181
|
- share/views/public/plugins/jquery/js/jquery.cookie.js
|
1178
1182
|
- share/views/public/plugins/jquery/js/jquery.form.js
|
1183
|
+
- share/views/public/plugins/js-cookie/js/js.cookie.js
|
1179
1184
|
- share/views/public/plugins/mithril-node-render/js/index.js
|
1180
1185
|
- share/views/public/plugins/mithril/js/mithril.js
|
1181
1186
|
- share/views/public/plugins/mithril/js/mithril.min.js
|
@@ -1,381 +0,0 @@
|
|
1
|
-
rbbt.plots.aes = {}
|
2
|
-
|
3
|
-
rbbt.plots.aes.get_properties = function(list, rules){
|
4
|
-
if (undefined === rules) rules == []
|
5
|
-
if (undefined === list.properties) list.properties = {}
|
6
|
-
var promises = []
|
7
|
-
forArray(rules, function(rule){
|
8
|
-
var name = rule.name
|
9
|
-
var extract = rule.extract
|
10
|
-
|
11
|
-
if (rule.entity_type && rule.entity_type != list.type) return
|
12
|
-
|
13
|
-
if (rule.info){
|
14
|
-
var property = rule.property
|
15
|
-
var deferred = m.deferred()
|
16
|
-
var entry = rule.info
|
17
|
-
if (undefined === name) name = entry
|
18
|
-
|
19
|
-
var value = list.info[entry]
|
20
|
-
if (undefined === value && entry == 'type') value = list.type
|
21
|
-
if (undefined === value && entry == 'code') value = list.codes
|
22
|
-
|
23
|
-
deferred.resolve(value)
|
24
|
-
promise = deferred.promise
|
25
|
-
}
|
26
|
-
|
27
|
-
if (rule.value){
|
28
|
-
var property = rule.property
|
29
|
-
var deferred = m.deferred()
|
30
|
-
deferred.resolve(rule.value)
|
31
|
-
promise = deferred.promise
|
32
|
-
}
|
33
|
-
|
34
|
-
if (rule.property){
|
35
|
-
var property = rule.property
|
36
|
-
var args = rule.args
|
37
|
-
if (undefined === name) name = property
|
38
|
-
promise = rbbt.entity_array.property(list.codes, list.type, list.info, property, args)
|
39
|
-
if (extract){ promise = promise.then(function(res){ return res.map(extract)}) }
|
40
|
-
}
|
41
|
-
|
42
|
-
if (rule.workflow){
|
43
|
-
var workflow = rule.workflow
|
44
|
-
var task = rule.task
|
45
|
-
var args = rule.args
|
46
|
-
if (undefined === name) name = task
|
47
|
-
promise = rbbt.job(workflow, task, args, true)
|
48
|
-
if (extract){ promise = promise.then(function(res){ return list.codes.map(function(code){return extract.call(null, res, code)}) } )}
|
49
|
-
}
|
50
|
-
|
51
|
-
if (rule.parents || rule.children){
|
52
|
-
var kb_type
|
53
|
-
var database
|
54
|
-
if (rule.parents){
|
55
|
-
kb_type = 'parent'
|
56
|
-
var database = rule.parents
|
57
|
-
if (undefined === name) name = database
|
58
|
-
|
59
|
-
promise = rbbt.entity_array.parents(list.codes, list.type, database)
|
60
|
-
}else{
|
61
|
-
kb_type = 'children'
|
62
|
-
var database = rule.children
|
63
|
-
if (undefined === name) name = database
|
64
|
-
|
65
|
-
promise = rbbt.entity_array.children(list.codes, list.type, database)
|
66
|
-
}
|
67
|
-
|
68
|
-
if (rule.field){
|
69
|
-
promise = m.sync([promise,rbbt.knowledge_base.database_info(database)]).then(function(res){
|
70
|
-
var data = res[0]
|
71
|
-
var db_info = res[1]
|
72
|
-
var fields = db_info.fields
|
73
|
-
var field_pos = fields.indexOf(rule.field)
|
74
|
-
|
75
|
-
if (field_pos < 0){
|
76
|
-
var msg = "Field not found: " + rule.field + ". Options: " + fields.join(", ")
|
77
|
-
throw new Error(msg)
|
78
|
-
}
|
79
|
-
|
80
|
-
var matches = {}
|
81
|
-
forHash(data, function(key, values){
|
82
|
-
var source = values[0]
|
83
|
-
var target = values[1]
|
84
|
-
if (matches[source] === undefined) matches[source] = {}
|
85
|
-
matches[source][target] = values[field_pos+2]
|
86
|
-
})
|
87
|
-
return matches
|
88
|
-
})
|
89
|
-
}else{
|
90
|
-
promise = promise.then(function(data){
|
91
|
-
var matches = {}
|
92
|
-
forHash(data, function(key, values){
|
93
|
-
var source = values[0]
|
94
|
-
var target = values[1]
|
95
|
-
if (matches[source] === undefined) matches[source] = {}
|
96
|
-
matches[source][target] = values.slice(2)
|
97
|
-
})
|
98
|
-
return matches
|
99
|
-
})
|
100
|
-
}
|
101
|
-
|
102
|
-
if (extract){
|
103
|
-
promise = promise.then(function(matches){
|
104
|
-
return list.codes.map(function(e){
|
105
|
-
return extract.call(null, matches, e)
|
106
|
-
})
|
107
|
-
})
|
108
|
-
}
|
109
|
-
else{
|
110
|
-
promise = promise.then(function(matches){
|
111
|
-
return list.codes.map(function(e){ return matches[e] })
|
112
|
-
})
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
promises.push(promise.then(function(res){list.properties[name] = res}))
|
117
|
-
})
|
118
|
-
|
119
|
-
return m.sync(promises)
|
120
|
-
}
|
121
|
-
|
122
|
-
rbbt.plots.aes.set_aes = function(list, aes_rules){
|
123
|
-
if (undefined === list.aes) list.aes = {}
|
124
|
-
forArray(aes_rules, function(rule){
|
125
|
-
|
126
|
-
if (rule.entity_type && rule.entity_type != list.type) return
|
127
|
-
|
128
|
-
|
129
|
-
var name = rule.name
|
130
|
-
var aes = rule.aes
|
131
|
-
var mapper = rule.mapper
|
132
|
-
var mapper_obj = rule.mapper_obj
|
133
|
-
var property = list.properties[name]
|
134
|
-
|
135
|
-
if (rule.value){
|
136
|
-
list.aes[aes] = rule.value
|
137
|
-
return
|
138
|
-
}
|
139
|
-
|
140
|
-
if (undefined === property && list.info[name]) property = list.info[name]
|
141
|
-
if (undefined === property && name == 'type') property = list.type
|
142
|
-
if (undefined === property && name == 'code') property = list.codes
|
143
|
-
if (undefined === property) return
|
144
|
-
|
145
|
-
list.aes[aes] = aes_module.map_aesthetic(property, mapper, mapper_obj)
|
146
|
-
})
|
147
|
-
}
|
148
|
-
|
149
|
-
rbbt.plots.aes.update_aes = function(graph_model){
|
150
|
-
var data_promises = []
|
151
|
-
forHash(graph_model.entities, function(type, list){
|
152
|
-
data_promises.push(
|
153
|
-
|
154
|
-
rbbt.plots.aes.get_properties(list, graph_model.rules).
|
155
|
-
then(function(){
|
156
|
-
rbbt.plots.aes.set_aes(list, graph_model.aes_rules)
|
157
|
-
})
|
158
|
-
|
159
|
-
)
|
160
|
-
})
|
161
|
-
|
162
|
-
forHash(graph_model.associations, function(db, list){
|
163
|
-
data_promises.push(
|
164
|
-
|
165
|
-
rbbt.plots.aes.get_properties(list, graph_model.edge_rules).
|
166
|
-
then(function(){
|
167
|
-
rbbt.plots.aes.set_aes(list, graph_model.edge_aes_rules)
|
168
|
-
})
|
169
|
-
|
170
|
-
)
|
171
|
-
})
|
172
|
-
return m.sync(data_promises)
|
173
|
-
}
|
174
|
-
|
175
|
-
//{{{ SUBSET
|
176
|
-
rbbt.plots.aes.subset = function(db,source,target){
|
177
|
-
var promise = rbbt.entity_array.subset(db,source,target)
|
178
|
-
var db_info = KB.database_info(db)
|
179
|
-
return m.sync([promise,db_info]).then(function(d){
|
180
|
-
var associations = d[0]
|
181
|
-
var info = d[1]
|
182
|
-
var fields = ['source', 'target'].concat(info.fields)
|
183
|
-
|
184
|
-
var edges = {}
|
185
|
-
edges.codes = []
|
186
|
-
edges.database = db
|
187
|
-
edges.source_type = info.source
|
188
|
-
edges.target_type = info.target
|
189
|
-
edges.source_info = info.source_entity_options
|
190
|
-
edges.target_info = info.target_entity_options
|
191
|
-
edges.info = {}
|
192
|
-
edges.info.database = db
|
193
|
-
edges.properties = {}
|
194
|
-
edges.aes = {}
|
195
|
-
|
196
|
-
for (i in fields)
|
197
|
-
edges.info[fields[i]] = []
|
198
|
-
|
199
|
-
forHash(associations, function(code, values){
|
200
|
-
edges.codes.push(code)
|
201
|
-
for(i in values){
|
202
|
-
var field = fields[i]
|
203
|
-
var value = values[i]
|
204
|
-
edges.info[field].push(value)
|
205
|
-
}
|
206
|
-
})
|
207
|
-
|
208
|
-
edges.aes['source'] = edges.info['source']
|
209
|
-
edges.aes['target'] = edges.info['target']
|
210
|
-
edges.aes['database'] = db
|
211
|
-
|
212
|
-
return edges
|
213
|
-
})
|
214
|
-
}
|
215
|
-
|
216
|
-
//{{{ CONSOLIDATION
|
217
|
-
|
218
|
-
rbbt.plots.aes.consolidate_list = function(list){
|
219
|
-
var nodes = []
|
220
|
-
|
221
|
-
var codes = list.codes
|
222
|
-
var info = list.info
|
223
|
-
var aes = list.aes
|
224
|
-
var properties = list.properties
|
225
|
-
|
226
|
-
for (i in codes){
|
227
|
-
var node = {}
|
228
|
-
node.code = codes[i]
|
229
|
-
forHash(aes, function(name, values){
|
230
|
-
var value
|
231
|
-
if (typeof values == 'object') value = values[i]
|
232
|
-
else value = values
|
233
|
-
node[name] = value
|
234
|
-
})
|
235
|
-
nodes.push(node)
|
236
|
-
}
|
237
|
-
|
238
|
-
return nodes
|
239
|
-
}
|
240
|
-
|
241
|
-
rbbt.plots.aes.consolidate_associations = function(list, database){
|
242
|
-
var edges = []
|
243
|
-
forHash(list,function(code, values){
|
244
|
-
var edge = {}
|
245
|
-
var source_code = values[0]
|
246
|
-
var target_code = values[1]
|
247
|
-
|
248
|
-
edge.source = source_code
|
249
|
-
edge.target = target_code
|
250
|
-
edge.database = database
|
251
|
-
|
252
|
-
edges.push(edge)
|
253
|
-
})
|
254
|
-
|
255
|
-
return edges
|
256
|
-
}
|
257
|
-
|
258
|
-
rbbt.plots.aes.consolidate_associations = function(list){
|
259
|
-
var nodes = []
|
260
|
-
|
261
|
-
var codes = list.codes
|
262
|
-
var info = list.info
|
263
|
-
var aes = list.aes
|
264
|
-
var properties = list.properties
|
265
|
-
var values = list.properties
|
266
|
-
|
267
|
-
for (i in codes){
|
268
|
-
var node = {}
|
269
|
-
node.code = codes[i]
|
270
|
-
forHash(aes, function(name, values){
|
271
|
-
var value
|
272
|
-
if (typeof values == 'object') value = values[i]
|
273
|
-
else value = values
|
274
|
-
node[name] = value
|
275
|
-
})
|
276
|
-
nodes.push(node)
|
277
|
-
}
|
278
|
-
|
279
|
-
return nodes
|
280
|
-
}
|
281
|
-
|
282
|
-
rbbt.plots.aes.consolidate = function(graph_model){
|
283
|
-
var model = {}
|
284
|
-
|
285
|
-
var nodes = []
|
286
|
-
|
287
|
-
forHash(graph_model.entities, function(type, list){
|
288
|
-
var list_nodes = rbbt.plots.aes.consolidate_list(list)
|
289
|
-
for (i in list_nodes) nodes.push(list_nodes[i])
|
290
|
-
})
|
291
|
-
|
292
|
-
var edges = []
|
293
|
-
forHash(graph_model.associations, function(database, list){
|
294
|
-
var list_edges = rbbt.plots.aes.consolidate_associations(list,database)
|
295
|
-
for (i in list_edges) edges.push(list_edges[i])
|
296
|
-
})
|
297
|
-
|
298
|
-
model.nodes = nodes
|
299
|
-
model.edges = edges
|
300
|
-
|
301
|
-
return model
|
302
|
-
}
|
303
|
-
|
304
|
-
//}}} CONSOLIDATION
|
305
|
-
|
306
|
-
|
307
|
-
rbbt.plots.aes.build_d3 = function(graph_model){
|
308
|
-
|
309
|
-
var model = rbbt.plots.aes.consolidate(graph_model)
|
310
|
-
|
311
|
-
var node_index = {}
|
312
|
-
for (i=0; i< model.nodes.length; i++) node_index[model.nodes[i].code] = i
|
313
|
-
|
314
|
-
for (i=0; i< model.edges.length; i++){
|
315
|
-
var edge = model.edges[i]
|
316
|
-
edge.source = node_index[edge.source]
|
317
|
-
edge.target = node_index[edge.target]
|
318
|
-
}
|
319
|
-
|
320
|
-
model.links = model.edges
|
321
|
-
model.edges = undefined
|
322
|
-
model.node_index = node_index
|
323
|
-
|
324
|
-
return model
|
325
|
-
}
|
326
|
-
|
327
|
-
rbbt.plots.aes.build_cytoscape = function(graph_model){
|
328
|
-
var model = rbbt.plots.aes.consolidate(graph_model)
|
329
|
-
|
330
|
-
var dataSchema = {nodes: [], edges:[]}
|
331
|
-
|
332
|
-
var node_vars = {}
|
333
|
-
for (i in model.nodes){
|
334
|
-
for (p in model.nodes[i]){
|
335
|
-
if (undefined !== model.nodes[i][p])
|
336
|
-
node_vars[p] = typeof model.nodes[i][p]
|
337
|
-
}
|
338
|
-
}
|
339
|
-
for (p in node_vars){
|
340
|
-
dataSchema.nodes.push({name: p, type: node_vars[p]})
|
341
|
-
}
|
342
|
-
|
343
|
-
node_vars = {}
|
344
|
-
for (i in model.edges){
|
345
|
-
for (p in model.edges[i]){
|
346
|
-
if (undefined !== model.edges[i][p])
|
347
|
-
node_vars[p] = typeof model.edges[i][p]
|
348
|
-
}
|
349
|
-
}
|
350
|
-
for (p in node_vars){
|
351
|
-
dataSchema.edges.push({name: p, type: node_vars[p]})
|
352
|
-
}
|
353
|
-
|
354
|
-
var cy_model = {}
|
355
|
-
cy_model.dataSchema = dataSchema
|
356
|
-
cy_model.data = model
|
357
|
-
|
358
|
-
return cy_model
|
359
|
-
}
|
360
|
-
|
361
|
-
rbbt.plots.aes.build_cytoscapejs = function(graph_model){
|
362
|
-
var model = rbbt.plots.aes.consolidate(graph_model)
|
363
|
-
|
364
|
-
var nodes = []
|
365
|
-
forArray(model.nodes, function(node){
|
366
|
-
nodes.push({data: node})
|
367
|
-
})
|
368
|
-
|
369
|
-
console.log(model.edges)
|
370
|
-
var edges = []
|
371
|
-
forArray(model.edges, function(edge){
|
372
|
-
edges.push({data: edge})
|
373
|
-
})
|
374
|
-
|
375
|
-
var cy_model = {}
|
376
|
-
cy_model.elements = {nodes: nodes, edges: edges}
|
377
|
-
|
378
|
-
console.log(cy_model)
|
379
|
-
return cy_model
|
380
|
-
}
|
381
|
-
|