Skip to content

Commit c4da371

Browse files
antgonzaElDeveloper
authored andcommitted
update vis-network (#2969)
* update vis-network * improve sizes * add cython to conda create -q --yes -n qiita * fix job creation in JS * fix #2554 * improving position * focus on new job [skip ci] * addressing @ElDeveloper comments
1 parent 157c4f1 commit c4da371

File tree

8 files changed

+103
-69
lines changed

8 files changed

+103
-69
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ before_install:
2121
install:
2222
# install a few of the dependencies that pip would otherwise try to install
2323
# when intalling scikit-bio
24-
- travis_retry conda create -q --yes -n qiita python=3.6 pip libgfortran numpy nginx
24+
- travis_retry conda create -q --yes -n qiita python=3.6 pip libgfortran numpy nginx cython
2525
- source activate qiita
2626
- pip install -U pip
2727
- 'echo "backend: Agg" > ~/matplotlibrc'

qiita_pet/static/js/networkVue.js

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -713,22 +713,12 @@ Vue.component('processing-graph', {
713713
**/
714714
addJobNodeToGraph: function(job_info) {
715715
let vm = this;
716-
// Fun fact - although it seems counterintuitive, in vis.Network we
717-
// first need to add the edge and then we can add the node. It doesn't
718-
// make sense, but it is how it works
719-
$(job_info.inputs).each(function(){
720-
vm.edges_ds.add({id: vm.edges_ds.length + 1, from: this, to: job_info.id});
721-
});
722-
var node_info = vm.colorScheme.in_construction;
723-
vm.nodes_ds.add({id: job_info.id, shape: node_info['shape'], group: "job", shape: 'dot', label: formatNodeLabel(job_info.label), color: node_info, status: 'in_construction'});
724-
$(job_info.outputs).each(function(){
725-
var out_name = this[0];
726-
var out_type = this[1];
727-
var n_id = job_info.id + ":" + out_name;
728-
vm.edges_ds.add({id: vm.edges_ds.length + 1, from: job_info.id, to: n_id });
729-
vm.nodes_ds.add({id: n_id, shape: 'dot', label: formatNodeLabel(out_name + "\n(" + out_type + ")"), group: "type", name: out_name, type: out_type});
730-
});
731-
vm.network.redraw();
716+
717+
vm.new_job_info = {
718+
job_id: job_info.id,
719+
scale: vm.network.getScale()
720+
}
721+
vm.updateGraph();
732722
},
733723

734724
/**
@@ -753,10 +743,11 @@ Vue.component('processing-graph', {
753743
edges: vm.edges_ds
754744
};
755745
var options = {
746+
autoResize: true,
756747
clickToUse: true,
757748
nodes: {
758749
font: {
759-
size: 16,
750+
size: 15,
760751
color: '#000000'
761752
},
762753
size: 13,
@@ -766,10 +757,13 @@ Vue.component('processing-graph', {
766757
color: 'grey'
767758
},
768759
layout: {
760+
randomSeed: 1,
761+
improvedLayout: true,
769762
hierarchical: {
770763
direction: "LR",
771-
sortMethod: "directed",
772-
levelSeparation: 260
764+
sortMethod : 'directed',
765+
levelSeparation: 190,
766+
shakeTowards: 'roots'
773767
}
774768
},
775769
interaction: {
@@ -794,6 +788,15 @@ Vue.component('processing-graph', {
794788
};
795789

796790
vm.network = new vis.Network(container, data, options);
791+
vm.network.on("stabilized", function (params) {
792+
if (vm.new_job_info !== null){
793+
vm.network.focus(vm.new_job_info["job_id"], {
794+
scale: vm.new_job_info["scale"]
795+
});
796+
vm.new_job_info = null;
797+
}
798+
});
799+
797800
vm.network.on("click", function (properties) {
798801
var ids = properties.nodes;
799802
if (ids.length == 0) {
@@ -974,11 +977,16 @@ Vue.component('processing-graph', {
974977
// data in a way that Vis.Network likes it
975978
// Format edge list data
976979
for(var i = 0; i < data.edges.length; i++) {
980+
// forcing a string
981+
data.edges[i][0] = data.edges[i][0].toString()
982+
data.edges[i][1] = data.edges[i][1].toString()
977983
vm.edges.push({from: data.edges[i][0], to: data.edges[i][1], arrows:'to'});
978984
}
979985
// Format node list data
980986
for(var i = 0; i < data.nodes.length; i++) {
981987
var node_info = vm.colorScheme[data.nodes[i][4]];
988+
// forcing a string
989+
data.nodes[i][2] = data.nodes[i][2].toString()
982990
vm.nodes.push({id: data.nodes[i][2], shape: node_info['shape'], label: formatNodeLabel(data.nodes[i][3]), type: data.nodes[i][1], group: data.nodes[i][0], color: node_info, status: data.nodes[i][4]});
983991
if (data.nodes[i][1] === 'job') {
984992
job_status = data.nodes[i][4];
@@ -1084,6 +1092,7 @@ Vue.component('processing-graph', {
10841092
**/
10851093
mounted() {
10861094
let vm = this;
1095+
vm.new_job_info = null;
10871096
// This initialPoll is used ONLY if the graph doesn't exist yet
10881097
vm.initialPoll = false;
10891098
// This variable is used to show the update countdown on the interface

qiita_pet/static/vendor/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Qiita relies on the following JavaScript libraries:
1212
- [tag-it.js](http://aehlke.github.io/tag-it/).
1313
- [underscore.js](http://underscorejs.org/).
1414
- [vis.js](http://visjs.org/).
15+
- [vis-network.js](https://unpkg.com/browse/vis-network@6.5.2)
1516
- [vue.js](https://vuejs.org).
1617
- [ol.js](https://openlayers.org/).
1718
- [platform.js](https://github.com/bestiejs/platform.js).

qiita_pet/static/vendor/css/vis-network.min.css

100755100644
Lines changed: 43 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qiita_pet/static/vendor/js/vis-network.min.js

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

qiita_pet/static/vendor/js/vis.min.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

qiita_pet/templates/sitebase.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
2121
<head>
2222
<title>{{portal_styling.title}}</title>
23+
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/vis-network.min.css" type="text/css">
2324
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery-ui.min.css" type="text/css">
2425
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery-ui.structure.min.css" type="text/css">
2526
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery-ui.theme.min.css" type="text/css">
@@ -29,8 +30,6 @@
2930
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/chosen.css" type="text/css">
3031
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.min.css" type="text/css">
3132
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/css/style.css" type="text/css">
32-
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/vis.min.css" type="text/css">
33-
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/vis-network.min.css" type="text/css">
3433
{% if portal_styling.custom_css %}
3534
<style type="text/css">
3635
{% raw portal_styling.custom_css %}
@@ -45,7 +44,7 @@
4544
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.plugin.natural.js" type="text/javascript"></script>
4645
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/vue.min.js"></script>
4746
<script src="{% raw qiita_config.portal_dir %}/static/js/qiita.js"></script>
48-
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/vis.min.js"></script>
47+
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/vis-network.min.js"></script>
4948
<script type="text/javascript" src="{% raw qiita_config.portal_dir %}/static/vendor/js/platform.js"></script>
5049
<script type="text/javascript" src="{% raw qiita_config.portal_dir %}/static/js/networkVue.js"></script>
5150
<script type="text/javascript" src="{% raw qiita_config.portal_dir %}/static/js/sampleTemplateVue.js"></script>

qiita_pet/templates/study_base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% set study_title_msg = study_title.replace('"', '\\"') %}
55
<link rel="stylesheet" src="{% raw qiita_config.portal_dir %}/static/vendor/css/vis.min.css" type="text/css">
66
<link rel="stylesheet" src="{% raw qiita_config.portal_dir %}/static/vendor/css/vis-network.min.css" type="text/css">
7-
<script type="text/javascript" src="{% raw qiita_config.portal_dir %}/static/vendor/js/vis.min.js"></script>
7+
<script type="text/javascript" src="{% raw qiita_config.portal_dir %}/static/vendor/js/vis-network.min.js"></script>
88
<script type="text/javascript">
99
function validate_delete_study_text() {
1010
if ($("#study-alias").val() == "{% raw study_title_msg %}") {

0 commit comments

Comments
 (0)