rbbt-rest 1.6.2 → 1.6.3
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/misc.rb +10 -0
- data/lib/rbbt/rest/workflow/jobs.rb +8 -7
- data/share/views/compass/app.sass +278 -3
- data/share/views/compass/base/color.sass +66 -0
- data/share/views/compass/blocks.sass +0 -0
- data/share/views/compass/mixins/_blocks.sass +76 -80
- data/share/views/compass/mixins/_compass.sass +0 -0
- data/share/views/compass/mixins/_hide.sass +76 -1
- data/share/views/compass/table.sass +142 -0
- data/share/views/compass/variables/colors.sass +7 -0
- data/share/views/compass/variables/sizes.sass +5 -0
- data/share/views/entity_partials/action_card.haml +5 -5
- data/share/views/entity_partials/action_controller.haml +31 -33
- data/share/views/entity_partials/entity_card.haml +28 -27
- data/share/views/entity_partials/entity_list_card.haml +30 -42
- data/share/views/entity_partials/entity_map_card.haml +35 -43
- data/share/views/entity_partials/list_container.haml +6 -6
- data/share/views/layout.haml +53 -59
- data/share/views/layout/coda.haml +1 -0
- data/share/views/layout/doctype.haml +8 -0
- data/share/views/layout/footer.haml +36 -10
- data/share/views/layout/header.haml +47 -0
- data/share/views/layout/top_menu.haml +27 -13
- data/share/views/partials/form.haml +4 -4
- data/share/views/partials/table.haml +2 -1
- data/share/views/partials/table/column.haml +8 -9
- data/share/views/partials/table/files.haml +2 -2
- data/share/views/partials/table/filters.haml +16 -16
- data/share/views/partials/table/page.haml +9 -15
- data/share/views/public/js/ng-favourites.js +13 -0
- data/share/views/public/js/rbbt.aesthetics.js +51 -0
- data/share/views/public/js/rbbt.entity.js +62 -0
- data/share/views/public/js/rbbt.entity_list.js +54 -0
- data/share/views/public/js/rbbt.entity_map.js +52 -0
- data/share/views/public/js/rbbt.favourites.js +286 -0
- data/share/views/public/js/rbbt.favourites.js.old +195 -0
- data/share/views/public/js/rbbt.js +40 -0
- data/share/views/public/js/rbbt.knowledge_base.js +24 -0
- data/share/views/public/js/rbbt.page.js +32 -0
- data/share/views/public/js/rbbt/actions.js +15 -14
- data/share/views/public/js/rbbt/table.js +6 -4
- data/share/views/tools/cytoscape.haml +310 -0
- data/share/views/tools/protein_tool.haml +383 -0
- data/share/views/tools/protein_tool/controls.haml +315 -0
- metadata +23 -2
@@ -0,0 +1,195 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
rbbt.favourites = {};
|
4
|
+
|
5
|
+
var fav_module = rbbt.favourites;
|
6
|
+
|
7
|
+
fav_module.update_favourite_entities = function(){
|
8
|
+
return m.request({method: 'GET', url: '/favourite_entities'}).then(function(data){
|
9
|
+
fav_module.favourite_entities = {}
|
10
|
+
for (type in data){
|
11
|
+
var type_data = data[type]
|
12
|
+
fav_module.favourite_entities[type] = {}
|
13
|
+
for (entity in type_data){
|
14
|
+
var info = type_data[entity]
|
15
|
+
info.id = entity
|
16
|
+
info.type = type
|
17
|
+
fav_module.favourite_entities[type][entity] = new Entity(info)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return data
|
21
|
+
})
|
22
|
+
}
|
23
|
+
|
24
|
+
fav_module.update_favourite_lists = function(){
|
25
|
+
return m.request({method: 'GET', url: '/favourite_entity_lists'}).then(function(data){
|
26
|
+
fav_module.favourite_lists = {}
|
27
|
+
for (type in data){
|
28
|
+
var type_data = data[type]
|
29
|
+
fav_module.favourite_lists[type] = {}
|
30
|
+
for (i in type_data){
|
31
|
+
var list = type_data[i]
|
32
|
+
info = {}
|
33
|
+
info.id = list
|
34
|
+
info.type = type
|
35
|
+
fav_module.favourite_lists[type][list] = new EntityList(info)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return data
|
39
|
+
}) //.then(fav_module.update_list_selects)
|
40
|
+
}
|
41
|
+
|
42
|
+
fav_module.update_favourites = function(){
|
43
|
+
return fav_module.update_favourite_entities().then(fav_module.update_favourite_lists)
|
44
|
+
}
|
45
|
+
|
46
|
+
fav_module.isFavourite_entity = function(entity){
|
47
|
+
var favourites = fav_module.favourite_entities
|
48
|
+
return favourites[entity.type] !== undefined && favourites[entity.type][entity.id] !== undefined
|
49
|
+
}
|
50
|
+
|
51
|
+
fav_module.isFavourite_list = function(list){
|
52
|
+
var favourites = fav_module.favourite_lists
|
53
|
+
return favourites[list.type] !== undefined && favourites[list.type][list.id] !== undefined
|
54
|
+
}
|
55
|
+
|
56
|
+
fav_module.toggleFavourite_entity = function(){
|
57
|
+
var entity = rbbt.page.entity();
|
58
|
+
|
59
|
+
if (fav_module.isFavourite_entity(entity)){
|
60
|
+
rbbt.post({url: '/remove_favourite_entity/' + entity.type + '/' + entity.id}).then(fav_module.update)
|
61
|
+
}else{
|
62
|
+
rbbt.post({url: '/add_favourite_entity/' + entity.type + '/' + entity.id, data: entity.info}).then(fav_module.update)
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
fav_module.toggleFavourite_list = function(){
|
67
|
+
var list = rbbt.page.list();
|
68
|
+
|
69
|
+
if (fav_module.isFavourite_list(list)){
|
70
|
+
rbbt.post({url: '/remove_favourite_entity_list/' + list.type + '/' + list.id}).then(fav_module.update)
|
71
|
+
}else{
|
72
|
+
rbbt.post({url: '/add_favourite_entity_list/' + list.type + '/' + list.id}).then(fav_module.update)
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
fav_module.toggleFavourite = function(){
|
77
|
+
if (! rbbt.page.entity())
|
78
|
+
if (! rbbt.page.list())
|
79
|
+
return
|
80
|
+
else
|
81
|
+
fav_module.toggleFavourite_list()
|
82
|
+
else
|
83
|
+
fav_module.toggleFavourite_entity()
|
84
|
+
}
|
85
|
+
|
86
|
+
//{{{ VIEWS
|
87
|
+
|
88
|
+
fav_module.star_view = function(){
|
89
|
+
if (! rbbt.page.entity())
|
90
|
+
if (! rbbt.page.list())
|
91
|
+
return
|
92
|
+
else
|
93
|
+
return m('i.icon.star', {class: (fav_module.isFavourite_list(rbbt.page.list()) ? 'favourite' : 'not_favourite')})
|
94
|
+
else
|
95
|
+
return m('i.icon.star', {class: (fav_module.isFavourite_entity(rbbt.page.entity()) ? 'favourite' : 'not_favourite')})
|
96
|
+
}
|
97
|
+
|
98
|
+
fav_module.draw_favourite_menu = function(){
|
99
|
+
var favourites = fav_module.favourite_entities
|
100
|
+
var types = Object.keys(favourites)
|
101
|
+
|
102
|
+
return m('.ui.menu',
|
103
|
+
m('.ui.dropdown.item', [
|
104
|
+
m('i.icon.dropdown'),
|
105
|
+
'Entities',
|
106
|
+
m('.menu', types.map(function(type, index){
|
107
|
+
var _type = favourites[type]
|
108
|
+
var entities = Object.keys(_type)
|
109
|
+
|
110
|
+
return m('.ui.dropdown.item', [
|
111
|
+
m('i.icon.dropdown'),
|
112
|
+
type,
|
113
|
+
m('.menu', entities.map(function(entity, index){ url = _type[entity].url(); return m('a.item', {href: url}, _type[entity].name) }))
|
114
|
+
]);
|
115
|
+
}))
|
116
|
+
])
|
117
|
+
)
|
118
|
+
}
|
119
|
+
|
120
|
+
fav_module.draw_favourite_list_menu = function(){
|
121
|
+
var favourites = fav_module.favourite_lists
|
122
|
+
var types = Object.keys(favourites)
|
123
|
+
|
124
|
+
return m('.ui.menu',
|
125
|
+
m('.ui.dropdown.item', [
|
126
|
+
m('i.icon.dropdown'),
|
127
|
+
'Lists',
|
128
|
+
m('.menu', types.map(function(type, index){
|
129
|
+
var _type = favourites[type]
|
130
|
+
var lists = Object.keys(_type)
|
131
|
+
|
132
|
+
return m('.ui.dropdown.item', [
|
133
|
+
m('i.icon.dropdown'),
|
134
|
+
type,
|
135
|
+
m('.menu', lists.map(function(lists, index){ url = _type[lists].url(); return m('a.item', {href: url}, _type[lists].name) }))
|
136
|
+
]);
|
137
|
+
}))
|
138
|
+
])
|
139
|
+
)
|
140
|
+
}
|
141
|
+
fav_module.view = function(){
|
142
|
+
m.render($('#top_menu > .favourite')[0], [
|
143
|
+
m('.item.pointer', {onclick: fav_module.toggleFavourite}, fav_module.star_view()),
|
144
|
+
m('.item', {style: 'padding: 0px'}, fav_module.draw_favourite_menu()),
|
145
|
+
m('.item', {style: 'padding: 0px'}, fav_module.draw_favourite_list_menu())
|
146
|
+
])
|
147
|
+
}
|
148
|
+
|
149
|
+
fav_module.update = function(){
|
150
|
+
fav_module.update_favourites().then(fav_module.view).then(function(){ $('.dropdown:not([tabindex])').dropdown()})
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
fav_module._update_list_select= function(select, type, lists){
|
155
|
+
if (select.attr('attr-allow-empty') == 'true'){
|
156
|
+
var option = $('<option value="none" class="loaded">none</option>')
|
157
|
+
select.append(option);
|
158
|
+
}
|
159
|
+
|
160
|
+
var selected = null;
|
161
|
+
|
162
|
+
if (select.attr('attr-selected') != undefined ){
|
163
|
+
selected = select.attr('attr-selected');
|
164
|
+
}
|
165
|
+
|
166
|
+
$.each(lists, function(name, elems){
|
167
|
+
var option = null;
|
168
|
+
var name = elems
|
169
|
+
if (selected == null || name != selected){
|
170
|
+
option = $('<option attr-entity_type="' + type + '" class="automatic_load" value="' + name.id + '">' + name.id + '</option>');
|
171
|
+
}else{
|
172
|
+
option = $('<option attr-entity_type="' + type + '" class="automatic_load" selected=selected value="' + name.id + '">' + name.id + '</option>');
|
173
|
+
}
|
174
|
+
select.append(option);
|
175
|
+
return true
|
176
|
+
})
|
177
|
+
},
|
178
|
+
|
179
|
+
fav_module.update_list_selects= function(){
|
180
|
+
$('select.favourite_lists').find('option.automatic_load').remove()
|
181
|
+
|
182
|
+
$.each(fav_module.favourite_lists, function(type, lists){
|
183
|
+
$('select.favourite_lists[type=' + type + ']').each(function(){
|
184
|
+
var select = $(this);
|
185
|
+
fav_module._update_list_select(select, type, lists);
|
186
|
+
})
|
187
|
+
$('select.favourite_lists[type=All]').each(function(){
|
188
|
+
var select = $(this);
|
189
|
+
select.append($('<option class="automatic_load ui" disabled>'+ type +'</option>'));
|
190
|
+
fav_module._update_list_select(select, type, lists);
|
191
|
+
})
|
192
|
+
});
|
193
|
+
}
|
194
|
+
|
195
|
+
fav_module.update()
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
rbbt.post = function(params){
|
3
|
+
var req_params = {config: rbbt.post.asFormUrlEncoded, serialize: rbbt.post.serialize_data, method: 'POST'}
|
4
|
+
for (key in params)
|
5
|
+
req_params[key] = params[key]
|
6
|
+
|
7
|
+
return m.request(req_params)
|
8
|
+
}
|
9
|
+
|
10
|
+
rbbt.post.serialize_data = function(obj) {
|
11
|
+
var str = [];
|
12
|
+
for(var p in obj)
|
13
|
+
if (obj.hasOwnProperty(p)) {
|
14
|
+
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
15
|
+
}
|
16
|
+
|
17
|
+
return str.join("&");
|
18
|
+
}
|
19
|
+
|
20
|
+
rbbt.post.asFormUrlEncoded = function(xhr){
|
21
|
+
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
|
22
|
+
}
|
23
|
+
|
24
|
+
rbbt.log = function(obj){
|
25
|
+
console.log(obj)
|
26
|
+
}
|
27
|
+
|
28
|
+
rbbt.LS = {}
|
29
|
+
|
30
|
+
rbbt.LS.load = function(key){
|
31
|
+
var content = localStorage[key]
|
32
|
+
if (content === undefined)
|
33
|
+
return undefined
|
34
|
+
else
|
35
|
+
return JSON.parse(content)
|
36
|
+
}
|
37
|
+
|
38
|
+
rbbt.LS.store = function(key, value){
|
39
|
+
localStorage[key] = JSON.stringify(value)
|
40
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
var KB = rbbt.knowledge_base = {}
|
3
|
+
|
4
|
+
KB.children = function(database, entity){
|
5
|
+
var url = '/kb/user/' + database + '/children/' + entity.id
|
6
|
+
url = add_parameter(url, '_format', 'json')
|
7
|
+
return m.request({url: url, method: "GET", type: Entity})
|
8
|
+
}
|
9
|
+
|
10
|
+
KB.parents = function(database, entity){
|
11
|
+
var url = '/kb/user/' + database + '/parents/' + entity.id
|
12
|
+
url = add_parameter(url, '_format', 'json')
|
13
|
+
return m.request({url: url, method: "GET", type: Entity})
|
14
|
+
}
|
15
|
+
|
16
|
+
Entity.prototype.children = function(database){
|
17
|
+
return KB.children(database, this)
|
18
|
+
}
|
19
|
+
|
20
|
+
Entity.prototype.parents = function(database){
|
21
|
+
return KB.parents(database, this)
|
22
|
+
}
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
rbbt.page = {};
|
3
|
+
rbbt.page.entity = function(){
|
4
|
+
var card = $('.entity_card')
|
5
|
+
if (card.length == 0) return false
|
6
|
+
|
7
|
+
var entity = card.attr('data-entity')
|
8
|
+
var type = card.attr('data-entity-type')
|
9
|
+
var format = card.attr('data-entity-format')
|
10
|
+
var info = card.attr('data-entity-info')
|
11
|
+
var id = card.attr('data-entity-id')
|
12
|
+
return new Entity({id: id, code: entity, type: type, format: format, info: JSON.parse(info)})
|
13
|
+
}
|
14
|
+
|
15
|
+
rbbt.page.list = function(){
|
16
|
+
var card = $('.entity_list_card')
|
17
|
+
if (card.length == 0) return false
|
18
|
+
|
19
|
+
var list = card.attr('data-list')
|
20
|
+
var type = card.attr('data-list-type')
|
21
|
+
return new EntityList({id: list, type: type})
|
22
|
+
}
|
23
|
+
|
24
|
+
rbbt.page.map = function(){
|
25
|
+
var card = $('.entity_map_card')
|
26
|
+
if (card.length == 0) return false
|
27
|
+
|
28
|
+
var map = card.attr('data-map')
|
29
|
+
var type = card.attr('data-type')
|
30
|
+
var column = card.attr('data-column')
|
31
|
+
return new EntityMap({id: map, type: type, column: column})
|
32
|
+
}
|
@@ -71,7 +71,7 @@ $.widget("rbbt.action_controller", {
|
|
71
71
|
var tool = this
|
72
72
|
var controller = tool.element;
|
73
73
|
|
74
|
-
controller.on('click', '> .
|
74
|
+
controller.on('click', '> .action_menu .button', function(e){ tool._activate_action(this); return false});
|
75
75
|
controller.on('click', '> .controls > .reload', function(e){ tool._reload_action(this); return false});
|
76
76
|
controller.on('click', '> .controls > .parameters', function(e){ tool._display_parameters(this); return false});
|
77
77
|
controller.on('click', '> .controls > .description', function(e){ tool._display_description(this); return false});
|
@@ -84,11 +84,11 @@ $.widget("rbbt.action_controller", {
|
|
84
84
|
|
85
85
|
this.options.controller = controller
|
86
86
|
this.options.action_controls = controller.find('> .controls')
|
87
|
-
this.options.action_list = controller.find('> .
|
87
|
+
this.options.action_list = controller.find('> .action_menu')
|
88
88
|
|
89
89
|
this.options.complete = function(jqXHR, textStatus){
|
90
90
|
var action_controller = tool.options.controller
|
91
|
-
var action_list_item = action_controller.find('.
|
91
|
+
var action_list_item = action_controller.find('.action_menu > .loading, .action_menu > .active')
|
92
92
|
var action_div = action_controller.next('.action_loader');
|
93
93
|
|
94
94
|
if (jqXHR.status == 202){
|
@@ -98,14 +98,14 @@ $.widget("rbbt.action_controller", {
|
|
98
98
|
var response = $(jqXHR.responseText)
|
99
99
|
var stat = response.find('span.status').html()
|
100
100
|
var message = response.find('.step_messages li:first').html()
|
101
|
+
var progress = response.find('.step.progress')
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
action_div.html("<span class='loading ui message'>Loading [" + stat + ": " + message + "] ...</span>");
|
106
|
-
};
|
103
|
+
text = [$('<div class="header">').html(stat), $('<div class="content">').html(message)]
|
104
|
+
action_controller.find('> .progress').html("").append(text).append(progress);
|
105
|
+
update_rbbt()
|
107
106
|
}
|
108
107
|
}else{
|
108
|
+
action_controller.find('> .progress').html("");
|
109
109
|
action_controller.removeClass('loading').removeClass('disabled');
|
110
110
|
action_list_item.removeClass('loading').removeClass('disabled');
|
111
111
|
|
@@ -142,7 +142,7 @@ $.widget("rbbt.action_controller", {
|
|
142
142
|
|
143
143
|
_activate_action: function(e){
|
144
144
|
var action_list_item = $(e)
|
145
|
-
var action_list = action_list_item.parent('.
|
145
|
+
var action_list = action_list_item.parent('.action_menu');
|
146
146
|
var link = action_list_item.find('> a')
|
147
147
|
link = action_list_item
|
148
148
|
|
@@ -165,14 +165,14 @@ $.widget("rbbt.action_controller", {
|
|
165
165
|
|
166
166
|
_unpin_parameters: function(){
|
167
167
|
var controller = $(this.element)
|
168
|
-
var action = controller.find('.
|
168
|
+
var action = controller.find('.action_menu .active a').first().html()
|
169
169
|
this.options.saved[action] = undefined
|
170
170
|
controller.find('> .controls > .pin').removeClass('saved')
|
171
171
|
},
|
172
172
|
|
173
173
|
_pin_parameters: function(){
|
174
174
|
var controller = $(this.element)
|
175
|
-
var action = $(this.element).find('.
|
175
|
+
var action = $(this.element).find('.action_menu .active a').first().html()
|
176
176
|
var loader = $(this.element).next('.action_loader').first();
|
177
177
|
this.options.saved[action] = loader.attr('form-params')
|
178
178
|
controller.find('> .controls > .pin').addClass('saved')
|
@@ -180,7 +180,7 @@ $.widget("rbbt.action_controller", {
|
|
180
180
|
},
|
181
181
|
|
182
182
|
_toggle_pin: function(){
|
183
|
-
var action = $(this.element).find('.
|
183
|
+
var action = $(this.element).find('.action_menu .active a').first().html()
|
184
184
|
|
185
185
|
if (this.options.saved[action] != undefined){
|
186
186
|
this._unpin_parameters();
|
@@ -212,7 +212,8 @@ $.widget("rbbt.action_controller", {
|
|
212
212
|
|
213
213
|
|
214
214
|
_reload_action: function(e){
|
215
|
-
if(
|
215
|
+
if($(e).hasClass('disabled')){ return false}
|
216
|
+
console.log(1)
|
216
217
|
var action_list_item = $(e);
|
217
218
|
var action_list = action_list_item.parent('.controls');
|
218
219
|
var action_controller = action_list.parent('.action_controller');
|
@@ -264,7 +265,7 @@ $.widget("rbbt.action_controller", {
|
|
264
265
|
_load_action: function(link){
|
265
266
|
var action_list_item = link.parent('.button');
|
266
267
|
action_list_item = link
|
267
|
-
var action_list = action_list_item.parent('.
|
268
|
+
var action_list = action_list_item.parent('.action_menu');
|
268
269
|
var action_controller = action_list.parents('.action_controller').first();
|
269
270
|
var action_div = action_controller.next('.action_loader');
|
270
271
|
var href = link.attr('href')
|
@@ -59,6 +59,7 @@ $.widget("rbbt.table", {
|
|
59
59
|
$.scrollTo(table.find('tfoot'), {axis : 'y', offset: {top: - window.innerHeight + 100 }});
|
60
60
|
}else{ complete() }
|
61
61
|
if (tool.options.ellipsis !== undefined && ! $(table).hasClass('no_js')){
|
62
|
+
console.log($(table).hasClass('no_js'))
|
62
63
|
tool._fix_long_table_cells(5);
|
63
64
|
}
|
64
65
|
});
|
@@ -98,7 +99,7 @@ $.widget("rbbt.table", {
|
|
98
99
|
|
99
100
|
//{{{ Pagination
|
100
101
|
//
|
101
|
-
table.on('click', 'tfoot > tr > th > .table_pagination > .num
|
102
|
+
table.on('click', 'tfoot > tr > th > .table_pagination > .num:not(.active)', function(link){
|
102
103
|
var link = $(this)
|
103
104
|
|
104
105
|
var stat = tool._status()
|
@@ -108,7 +109,7 @@ $.widget("rbbt.table", {
|
|
108
109
|
return false
|
109
110
|
})
|
110
111
|
|
111
|
-
table.on('click', 'tfoot > tr > th > .table_pagination > .arrow
|
112
|
+
table.on('click', 'tfoot > tr > th > .table_pagination > .arrow.prev', function(link){
|
112
113
|
var stat = tool._status()
|
113
114
|
|
114
115
|
if (stat.num > 1){ stat.num = stat.num - 1 }
|
@@ -118,9 +119,9 @@ $.widget("rbbt.table", {
|
|
118
119
|
return false
|
119
120
|
})
|
120
121
|
|
121
|
-
table.on('click', 'tfoot > tr > th > .table_pagination > .arrow
|
122
|
+
table.on('click', 'tfoot > tr > th > .table_pagination > .arrow.next', function(evt){
|
122
123
|
var stat = tool._status();
|
123
|
-
var last = parseInt($(this).parents('.table_pagination').first().find('.num').last().
|
124
|
+
var last = parseInt($(this).parents('.table_pagination').first().find('a.num').last().html())
|
124
125
|
|
125
126
|
if (stat.num < last){ stat.num = stat.num + 1 }
|
126
127
|
|
@@ -275,6 +276,7 @@ $.widget("rbbt.table", {
|
|
275
276
|
url = add_parameter(url, '_format', 'map')
|
276
277
|
if (undefined != filter){ url = add_parameter(url, '_filter', escape(filter)) }
|
277
278
|
|
279
|
+
console.log(url)
|
278
280
|
modal.modal('show_url', url)
|
279
281
|
return false
|
280
282
|
});
|
@@ -0,0 +1,310 @@
|
|
1
|
+
- id = "rand" << (rand * 1000).to_i.to_s unless defined? id and not (id.nil? or id.empty?)
|
2
|
+
- id = Misc.snake_case(id)
|
3
|
+
- static = false unless defined? static and not static.nil?
|
4
|
+
- knowledge_base = nil unless defined? knowledge_base and not knowledge_base.nil?
|
5
|
+
- kb_name = 'user' unless defined? kb_name and not kb_name.nil?
|
6
|
+
|
7
|
+
= link_css '/stylesheets/cytoscape'
|
8
|
+
|
9
|
+
- syndications = {}
|
10
|
+
- databases = []
|
11
|
+
- cytoscape.knowledge_base.all_databases.each do |database|
|
12
|
+
- database = database.to_s
|
13
|
+
- name, synd = database.split("@")
|
14
|
+
- if synd
|
15
|
+
- syndications[synd] ||= []
|
16
|
+
- syndications[synd] << database
|
17
|
+
- else
|
18
|
+
- databases << database
|
19
|
+
|
20
|
+
:sass
|
21
|
+
.tab.content
|
22
|
+
position: relative
|
23
|
+
.cytoscape_tool.fixable.preload(id=id)
|
24
|
+
|
25
|
+
.controls.ui.top.attached.tabular.menu
|
26
|
+
.ui.item(data-tab='Close')
|
27
|
+
%i.icon.close
|
28
|
+
.ui.item(data-tab='Edges') Edges
|
29
|
+
.ui.item(data-tab='Entities') Entities
|
30
|
+
.ui.item(data-tab='Aesthetics') Aesthetics
|
31
|
+
.ui.item(data-tab='Help') Help
|
32
|
+
.ui.tab.bottom.attached.very.basic.segment.content(data-tab='Close')
|
33
|
+
.ui.tab.bottom.attached.segment.content(data-tab='Edges')
|
34
|
+
.database_edges
|
35
|
+
|
36
|
+
%h5 Add edges between entities
|
37
|
+
.action_parameters
|
38
|
+
%form.action_parameter_form
|
39
|
+
- if databases.any?
|
40
|
+
.input.multiple.database
|
41
|
+
- databases.each do |database|
|
42
|
+
- name, *rest = database.split "@"
|
43
|
+
%span.cchoice
|
44
|
+
%label(for="database[#{database}]")=name
|
45
|
+
%input(id="database[#{database}]" type="checkbox" value="true" name="database[#{database}]")
|
46
|
+
- if syndications.any?
|
47
|
+
%dl.rbbt_tabs.subtle(style="margin:1em")
|
48
|
+
- syndications.each do |synd, databases|
|
49
|
+
%dt.next=synd
|
50
|
+
%dd
|
51
|
+
.input.database.multiple
|
52
|
+
- databases.each do |database|
|
53
|
+
- name, *rest = database.split "@"
|
54
|
+
%span.choice
|
55
|
+
%label(for="database[#{database}]")=name
|
56
|
+
%input(id="database[#{database}]" type="checkbox" value="true" name="database[#{database}]")
|
57
|
+
|
58
|
+
.input.submit
|
59
|
+
%input(type="submit")
|
60
|
+
|
61
|
+
.ui.tab.bottom.attached.segment.content(data-tab='Entities')
|
62
|
+
.add_gene_list
|
63
|
+
%h5 Add entities from a list
|
64
|
+
= action_parameters nil, {:klass => ''}, :action => '#' do
|
65
|
+
- input :entities, :select, "Entities to add", nil, :html_options => {:class => 'favourite_lists', :type => 'All'}
|
66
|
+
|
67
|
+
.database_neighbours
|
68
|
+
%h5 Add neighbours of entities
|
69
|
+
.action_parameters.ui.raised.segment
|
70
|
+
%form.ui.form
|
71
|
+
.field.input.select.database
|
72
|
+
%label knowledgebase
|
73
|
+
%select(type="All" name="database")
|
74
|
+
- databases.each do |database|
|
75
|
+
- name, *rest = database.split "@"
|
76
|
+
%option(value=database)=name
|
77
|
+
- syndications.each do |synd, databases|
|
78
|
+
%option(disabled=true)=synd
|
79
|
+
- databases.each do |database|
|
80
|
+
- name, *rest = database.split "@"
|
81
|
+
%option(value=database)=name
|
82
|
+
.field.submit
|
83
|
+
%input.ui.submit.button(type="submit")
|
84
|
+
|
85
|
+
.ui.tab.bottom.attached.segment.content(data-tab='Aesthetics')
|
86
|
+
.maps
|
87
|
+
%h5 Map entity aesthetic
|
88
|
+
= action_parameters nil, {:klass => ''}, :action => '#' do
|
89
|
+
- input :elem, :select, "Type of element", :nodes, :select_options => [:nodes, :edges]
|
90
|
+
- input :aesthetic, :select, "Aesthetic to map to", :opacity, :select_options => [:shape, :size, :color, :opacity, :borderWidth]
|
91
|
+
- input :field, :string, "Attribute to map", 'id', :select_options => {:textarea => "Use textarea"}, :html_options => {:class => 'favourite_maps', :type => 'All'}
|
92
|
+
- input :map, :select, "Select map to use", nil, :select_options => {:textarea => "Use textarea"}, :html_options => {:class => 'favourite_maps', :type => 'All'}
|
93
|
+
- input :map_tsv, :text, "Map", nil, :no_file => true
|
94
|
+
|
95
|
+
.select_gene_list
|
96
|
+
%h5 Highlight entities from a list
|
97
|
+
= action_parameters nil, {:klass => ''}, :action => '#' do
|
98
|
+
- input :entities, :select, "Genes to add", nil, :html_options => {:class => 'favourite_lists', :type => 'All'}
|
99
|
+
|
100
|
+
.ui.tab.bottom.attached.segment.content(data-tab='Help')
|
101
|
+
|
102
|
+
:documentation
|
103
|
+
|
104
|
+
### Edges
|
105
|
+
|
106
|
+
You can connect your nodes using any of the databases in the `knowledgebase`.
|
107
|
+
This is configured in the `Edges` menu: check the databases you want to use,
|
108
|
+
if none is selected (by default) all of them are used.
|
109
|
+
|
110
|
+
### Entities
|
111
|
+
|
112
|
+
The network comes preloaded with a list of entities (nodes), but you
|
113
|
+
can remove them or add new ones. To remove them use the context menu
|
114
|
+
(right-click over cytoscape window); you can remove one node, or the
|
115
|
+
selected list of nodes.
|
116
|
+
|
117
|
+
Adding nodes can be done using the `Entity` menu. You can add entities from
|
118
|
+
your `favourite` lists or add the neighbours of your entities using any of
|
119
|
+
the databases in the `knowledgebase`.
|
120
|
+
|
121
|
+
### Aesthetics
|
122
|
+
|
123
|
+
Use the `Aesthetics` menu to change how your network looks. This can
|
124
|
+
help represent different sources of information. For now it works only
|
125
|
+
on nodes. You can change the value of different aesthetics, like
|
126
|
+
color, border width, size, shape, and opacity. You can `map` these
|
127
|
+
aesthetics to favourite `Entity Maps`, or use a custom mapping
|
128
|
+
in-place, as a space-separated TSV file (see example below). The
|
129
|
+
mappings can consider the identity of the node (type `id` in `field`;
|
130
|
+
default) or the type of node (type `entity_type` in `field`). For
|
131
|
+
instance:
|
132
|
+
|
133
|
+
aesthetic: color
|
134
|
+
field: entity_type
|
135
|
+
map: use_textarea
|
136
|
+
map_tsv:
|
137
|
+
GOTerm red
|
138
|
+
KeggPathway blue
|
139
|
+
Gene yellow
|
140
|
+
|
141
|
+
Another example use is to gather the `mutation/protein size` column on
|
142
|
+
the `COSMIC Overview` analysis bellow, and map it to the `opacity`
|
143
|
+
aesthetic of the genes (using the `id` as `field`).
|
144
|
+
|
145
|
+
.window.fixed_size(id="#{id}_window")
|
146
|
+
|
147
|
+
|
148
|
+
:deferjs
|
149
|
+
var cytoscape_id = '##{id}';
|
150
|
+
|
151
|
+
require_js(['/js/cytoscape/js/src/AC_OETags.js', '/js/cytoscape/js/src/cytoscapeweb.js', '/js/cytoscape'], function(){
|
152
|
+
|
153
|
+
$('.preload').removeClass('preload')
|
154
|
+
|
155
|
+
var tool = $(cytoscape_id).cytoscape_tool({
|
156
|
+
knowledge_base: '#{kb_name}',
|
157
|
+
namespace: '#{cytoscape.namespace}',
|
158
|
+
entities: #{cytoscape.entities.to_json},
|
159
|
+
network: #{cytoscape.network.to_json},
|
160
|
+
aesthetics: #{cytoscape.aesthetics.to_json},
|
161
|
+
|
162
|
+
node_click: function(event){
|
163
|
+
var target = event.target;
|
164
|
+
|
165
|
+
for (var i in target.data){
|
166
|
+
var variable_name = i;
|
167
|
+
var variable_value = target.data[i];
|
168
|
+
}
|
169
|
+
|
170
|
+
for (var i in target.data) {
|
171
|
+
var variable_name = i;
|
172
|
+
var variable_value = target.data[i];
|
173
|
+
}
|
174
|
+
|
175
|
+
var url = target.data.url;
|
176
|
+
|
177
|
+
$('#modal').modal('show_url', url, undefined, function(){
|
178
|
+
$('#modal').find(' > .header > .title').attr('entity', target.data.id).attr('type', target.data.entity_type)
|
179
|
+
})
|
180
|
+
return(false)
|
181
|
+
},
|
182
|
+
|
183
|
+
edge_click: function(event){
|
184
|
+
var target = event.target;
|
185
|
+
for (var i in target.data){
|
186
|
+
var variable_name = i;
|
187
|
+
var variable_value = target.data[i];
|
188
|
+
}
|
189
|
+
|
190
|
+
var pair = [target.data.source, target.data.target].join("~")
|
191
|
+
tool.cytoscape_tool('show_info', "user", target.data.database, pair);
|
192
|
+
|
193
|
+
return(false)
|
194
|
+
}
|
195
|
+
|
196
|
+
});
|
197
|
+
|
198
|
+
require_js('/js/controls/context_menu', function(){
|
199
|
+
cytoscape_context_menu(tool)
|
200
|
+
})
|
201
|
+
|
202
|
+
require_js('/js/controls/placement', function(){
|
203
|
+
cytoscape_placement(tool)
|
204
|
+
})
|
205
|
+
|
206
|
+
require_js('/js/controls/save', function(){
|
207
|
+
cytoscape_save(tool)
|
208
|
+
})
|
209
|
+
|
210
|
+
|
211
|
+
///////////////////////////////////
|
212
|
+
//{{{ NETWORK INIT
|
213
|
+
|
214
|
+
tool.cytoscape_tool('draw');
|
215
|
+
|
216
|
+
//////////////////////////////////////////////////////////////////
|
217
|
+
//{{{ Controls
|
218
|
+
|
219
|
+
$('.cytoscape_tool .database_edges input[type=submit]').click(function(){
|
220
|
+
var form =$(this).parents('form').first()
|
221
|
+
var inputs = form.find('.input.database.multiple')
|
222
|
+
var databases = $.map(inputs.find('input[type=checkbox]:checked'), function(e){
|
223
|
+
return $(e).attr('name').match(/\[(.*)\]/)[1];
|
224
|
+
})
|
225
|
+
|
226
|
+
tool.cytoscape_tool('set_edges', databases)
|
227
|
+
tool.cytoscape_tool('draw');
|
228
|
+
|
229
|
+
return false;
|
230
|
+
})
|
231
|
+
|
232
|
+
$('.cytoscape_tool .database_neighbours input[type=submit]').click(function(){
|
233
|
+
var databases = $.map($(this).parents('form').first().find('.input.database').find('input[type=checkbox]:checked'), function(e){
|
234
|
+
return $(e).attr('name').match(/\[(.*)\]/)[1];
|
235
|
+
})
|
236
|
+
var option = $(this).closest('form').find('select').find('option:selected');
|
237
|
+
var database = option.attr('value')
|
238
|
+
|
239
|
+
tool.cytoscape_tool('add_neighbours', database)
|
240
|
+
tool.cytoscape_tool('draw');
|
241
|
+
|
242
|
+
return false;
|
243
|
+
})
|
244
|
+
|
245
|
+
|
246
|
+
$('.cytoscape_tool .add_gene_list input[type=submit]').click(function(){
|
247
|
+
var option = $(this).closest('form').find('select.favourite_lists').find('option:selected');
|
248
|
+
var type = option.attr('attr-entity_type')
|
249
|
+
var list_id = $(this).parents('form').first().find('select').val();
|
250
|
+
var list = list_entities(type, list_id);
|
251
|
+
var info = list_info(type, list_id);
|
252
|
+
|
253
|
+
tool.cytoscape_tool('add_entities', type, list)
|
254
|
+
tool.cytoscape_tool('draw');
|
255
|
+
|
256
|
+
return false;
|
257
|
+
})
|
258
|
+
|
259
|
+
$('.cytoscape_tool .select_gene_list input[type=submit]').click(function(){
|
260
|
+
var option = $(this).closest('form').find('select.favourite_lists').find('option:selected');
|
261
|
+
var type = option.attr('attr-entity_type')
|
262
|
+
var list_id = $(this).parents('form').first().find('select').val();
|
263
|
+
var list = list_entities(type, list_id);
|
264
|
+
|
265
|
+
tool.cytoscape_tool('select_entities', list)
|
266
|
+
|
267
|
+
return false;
|
268
|
+
})
|
269
|
+
|
270
|
+
$('.cytoscape_tool .maps input[type=submit]').click(function(){
|
271
|
+
var form = $(this).closest('form')
|
272
|
+
|
273
|
+
|
274
|
+
var elem = form.first().find('div.input.elem select').val();
|
275
|
+
var map_id = form.first().find('div.input.map select').val();
|
276
|
+
var field = form.first().find('div.input.field input').val();
|
277
|
+
var map_content = form.first().find('div.input.map_tsv textarea').val();
|
278
|
+
var option = form.first().find('div.input.map option:selected');
|
279
|
+
var type = option.attr('attr-entity_type')
|
280
|
+
var column = form.first().find('div.input.map select').find('option:selected').attr('attr-column');
|
281
|
+
var aesthetic = form.first().find('div.input.aesthetic select').val();
|
282
|
+
|
283
|
+
var map;
|
284
|
+
|
285
|
+
if (map_id == 'textarea'){
|
286
|
+
map_content = "#: :type=:single#:sep=/\\s/#:identifiers=Hsa/jan2013\n" + map_content
|
287
|
+
rbbt_job('TSVWorkflow', 'to_json', {tsv: map_content}, function(data){
|
288
|
+
var map = JSON.parse(data)
|
289
|
+
tool.cytoscape_tool('aesthetic', elem, aesthetic, map, field)
|
290
|
+
tool.cytoscape_tool('draw')
|
291
|
+
})
|
292
|
+
}else{
|
293
|
+
entity_map(type, column, map_id, function(map){
|
294
|
+
tool.cytoscape_tool('aesthetic', elem, aesthetic, map, field)
|
295
|
+
tool.cytoscape_tool('draw')
|
296
|
+
});
|
297
|
+
}
|
298
|
+
|
299
|
+
return false;
|
300
|
+
})
|
301
|
+
})
|
302
|
+
:javascript
|
303
|
+
$('.item[data-tab]').tab()
|
304
|
+
$('.item[data-tab=Close]').click(function(item){
|
305
|
+
var tool = $(this).parents('.cytoscape_tool').first()
|
306
|
+
tool.find('.tab.active, .item.active').removeClass('active')
|
307
|
+
return false
|
308
|
+
})
|
309
|
+
|
310
|
+
|