Commit 9e1ea42d authored by Yannick Chudy's avatar Yannick Chudy

pusher + options, botapadapi

parent 76ee1598
.PHONY: install docker-build docker-push docker-pull
install:
mkdir -p ./static/images/
pip install -r requirements.txt
......@@ -9,6 +11,20 @@ install:
cd ./static && unzip master.zip
npm install jade --save
jade:
@echo "\n ---------------------------"
@echo " * Building flask templates"
@echo " ---------------------------\n"
#cd ./templates && pypugjs *.jade
cd ./templates && node ../node_modules/jade/bin/jade.js -P *.jade
docker-build:
@echo "\n --------------------"
......
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from flask import request, jsonify
import igraph
from reliure.types import GenericType, Text, Numeric, Boolean
from reliure.web import ReliureAPI, EngineView, ComponentView, RemoteApi
from reliure.pipeline import Optionable, Composable
from reliure.engine import Engine
from cello.graphs import export_graph, IN, OUT, ALL
from cello.graphs.prox import ProxSubgraph, ProxExtract
from cello.layout import export_layout
from cello.clustering import export_clustering
from pdgapi.explor import ComplexQuery, AdditiveNodes, NodeExpandQuery, export_graph, layout_api, clustering_api
def explore_engine(graphdb):
""" Prox engine """
# setup
engine = Engine("graph")
engine.graph.setup(in_name="request", out_name="graph")
## Search
@Composable
def get_graph(query, **kwargs):
gid = query['graph']
graph = graphdb.get_graph(gid)
return graph
@Composable
def subgraph(query, cut=50, weighted=True, length=3, mode=ALL, add_loops=False, ):
graph = get_graph(query)
uuids = { v['uuid'] : v.index for v in graph.vs }
pz = [ q for q in query['units']]
pz = [ uuids[p] for p in pz ]
extract = ProxExtract()
vs = []
for u in pz:
s = extract(graph, pzeros=[u], weighted=weighted,mode=mode, cut=cut, length=length)
vs = vs + s.keys()
return graph.subgraph(vs)
from cello.graphs.transform import VtxAttr
searchs = []
for k,w,l,m,n in [
(u"Search", True, 3, OUT,30 ), ]:
search = Optionable("GraphSearch")
search._func = subgraph
search.add_option("weighted", Boolean(default=w))
search.add_option("add_loops", Boolean(default=True, help="add loops on vertices"))
search.add_option("mode", Numeric(choices=[ IN, OUT, ALL], default=m, help="edge directions"))
search.add_option("length", Numeric( vtype=int, min=1, default=l))
search.add_option("cut", Numeric( vtype=int, min=2, default=n))
search |= VtxAttr(color=[(45, 200, 34), ])
search |= VtxAttr(type=1)
search.name = k
searchs.append(search)
sglobal = Composable(get_graph) | ProxSubgraph()
sglobal.name = "Global"
searchs.append(sglobal)
engine.graph.set( *searchs )
return engine
def explore_api(engines, graphdb):
#explor_api = explor.explore_api("xplor", graphdb, engines)
api = ReliureAPI("xplor",expose_route=False)
# prox search returns graph only
view = EngineView(explore_engine(graphdb))
view.set_input_type(ComplexQuery())
view.add_output("request", ComplexQuery())
view.add_output("graph", export_graph, id_attribute='uuid')
api.register_view(view, url_prefix="explore")
# prox expand returns [(node,score), ...]
view = EngineView(engines.expand_prox_engine(graphdb))
view.set_input_type(NodeExpandQuery())
view.add_output("scores", lambda x:x)
api.register_view(view, url_prefix="expand_px")
# additive search
view = EngineView(engines.additive_nodes_engine(graphdb))
view.set_input_type(AdditiveNodes())
view.add_output("graph", export_graph, id_attribute='uuid' )
api.register_view(view, url_prefix="additive_nodes")
#layout
api = layout_api(engines, api)
#clustering
api = clustering_api(engines, api)
return api
\ No newline at end of file
This diff is collapsed.
......@@ -681,8 +681,9 @@ Cello.Doc = Backbone.Model.extend({
Cello.get(this, 'otype');
Cello.get(this, 'value');
Cello.set(this, 'value', function(val){
_this.validate(val);
_this.set('value', val);
var _val = _this.validate(val);
if (_this.value != _val)
_this.set('value', _val);
});
// check data
Cello.assert(this.name !== null, "Option should have a name");
......@@ -700,12 +701,25 @@ Cello.Doc = Backbone.Model.extend({
/** Validate one value
*/
_validate_one: function(val){
parse: function(val){
if (this.otype) {
if(this.otype.type === "Boolean"){
val = [true, "true", "True", "TRUE", "1", "yes"].indexOf(val) >= 0;
//console.log(this.otype.type, val);
val = [1, true, "true", "True", "TRUE", "1", "yes"].indexOf(val) >= 0;
}
if(this.otype.vtype === "float"){
val = parseFloat(val);
}
if(this.otype.vtype === "int"){
val = parseInt(val);
}
}
return val;
},
/** Validate one value
*/
_validate_one: function(val){
val = this.parse(val)
// check enum
var choices = this.otype.choices;
if(choices && _.indexOf(choices, val) < 0){
......@@ -721,8 +735,7 @@ Cello.Doc = Backbone.Model.extend({
validate: function(val){
var _this = this;
// TODO; run validators !
var multi = _this.otype.multi;
if(multi){
if(this.is_multi()){
var nval = [];
_.each(val, function(one_val){
nval.push(_this._validate_one(one_val));
......
This diff is collapsed.
......@@ -543,14 +543,12 @@ var GvizShortcuts = function(gviz){ return [
],
[
'+', "increase vertex size", function(){
gviz.user_vtx_size = Math.min(25, gviz.user_vtx_size + 1 );
gviz.request_animation();
gviz.increase_vertex_size();
}
],
[
'-', "decrease vertex size", function(){
gviz.user_vtx_size = Math.max(-5, gviz.user_vtx_size - 1 );
gviz.request_animation();
gviz.decrease_vertex_size();
}
],
[
......@@ -595,12 +593,12 @@ var GvizShortcuts = function(gviz){ return [
],
[
'd', "increases autorotate speed", function(){
gviz.controls.autoRotateSpeed += 0.001;
gviz.controls.autoRotateSpeed = gviz.controls.autoRotateSpeed * 1.5;
}
],
[
's', "decreases autorotate speed", function(){
gviz.controls.autoRotateSpeed -= 0.001;
gviz.controls.autoRotateSpeed = gviz.controls.autoRotateSpeed / 1.5;
}
],
[
......@@ -1046,12 +1044,15 @@ App.Base = Backbone.View.extend({
if ( routes.explore ){
var explore = Engine({url: routes.explore.url});
explore.register_input("request", app.models.query);
app.listenTo( Backbone,"engine:explore", function(params){
app.models.query.reset_from_models(params)
explore.play();
});
app.listenTo(explore, 'play:success', app.explore_reset);
app.engines.explore = explore;
}
// Starred engine
......
This diff is collapsed.
......@@ -930,9 +930,9 @@ gviz.DEFAULTS = {
show_text : true,
show_images : true,
background_color : 0xFF11FF,
user_font_size : 0, // range -5,5
user_vtx_size : 0, // range -5,5
background_color : 0xAAAAAA,
user_font_size : 3, //[0, 25]
user_vtx_size : 1, //
initial_size : 10, //
initial_z : 1400,
......@@ -1596,6 +1596,26 @@ gviz.ThreeViz = Backbone.View.extend({
}
},
increase_vertex_size : function(){
this.user_vtx_size = Math.min(25 , this.user_vtx_size * 1.5 );
this.request_animation(100);
},
decrease_vertex_size : function(){
this.user_vtx_size = Math.max(0.1 , this.user_vtx_size / 1.5 );
this.request_animation(100);
},
increase_font_size : function(){
this.user_font_size = Math.min(25, this.user_font_size + 1 );
this.request_animation(100);
},
decrease_font_size : function(){
this.user_font_size = Math.max(-5, this.user_font_size - 1 );
this.request_animation(100);
},
collapse : function(delay, easing, complete){
/**
* tween back vertices and edges to 0
......@@ -1968,7 +1988,7 @@ gviz.ThreeVizHelpers = {
wnode_scale : function(vtx){
var v = vtx.get('SIZE'); // [0,1]
return ( 3 + this.user_vtx_size ) * v ;
return ( this.user_vtx_size ) * v ;
},
// optimizations
......@@ -2155,8 +2175,10 @@ gviz.ThreeVizHelpers = {
y = 0,
text_width = 0, //compute the text width
paddingX = material.textPaddingX | 0,
paddingY1 = (material.textPaddingY | 0) + ((text_lines.length-1) * -12)/text_lines.length + 9 * (i);
userPaddingX = material.textPaddingX | 0,
userPaddingY = material.textPaddingY | 0,
paddingX = 0, paddingY = 0;
var fontsize = 1;
_.each(text_lines[i], function (token){
......@@ -2218,8 +2240,8 @@ gviz.ThreeVizHelpers = {
var text_height = dimension.actualBoundingBoxDescent - dimension.actualBoundingBoxAscent;
//update of padding
var xi = x + paddingRelX;
var yi = y - paddingY - (i)*( paddingRelY + (text_height | 0));
var xi = x + userPaddingX + paddingRelX;
var yi = y - userPaddingY - paddingY - (i)*( paddingRelY + (text_height | 0));
/* : TODO : text background */
//maxX = Math.max(maxX, dimension.width + letter_width/2);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -19,6 +19,34 @@
background: #127777;
}
#keb {
min-width:350px;
}
#keb .close{
background: #EEE;
text-align:right;
padding: 4px ;
}
#keb {
min-width:350px;
}
#keb .close{
background: #EEE;
text-align:right;
padding: 4px ;
}
a.ui.active.refresh.button {
position:absolute;
right: 56px;
bottom: 22px;
}
.masthead.segment {
min-height: 700px;
padding: 5px;
......@@ -152,6 +180,8 @@
top: 176px;
}
#menu .divider { margin:3px }
.nofoot #menu {
top: 24px;
}
......@@ -168,7 +198,7 @@
text-align:left;
width:100%;
height:calc(100%);
height:100%;
}
#viz {
......@@ -183,7 +213,7 @@
margin:12px;
}
.nofoot #labels {
bottom: -30px;
//bottom: -30px;
}
.markdown {
position:absolute;
......@@ -210,6 +240,10 @@
</head>
<body>
<!-- Page Contents-->
<div id="keb" style="background:#FAFAFA" class="ui left vertical sidebar">
<div class="close"><a class="ui link icon"><i class="close icon"></i></a></div>
<padagraph-gviz-control></padagraph-gviz-control>
</div>
<div class="pusher">
<div class="ui inverted vertical center aligned segment">{% if footer %}
<div class="ui text container">
......@@ -299,15 +333,18 @@
<script data-main="{{static_host}}/static/main" src="{{static_host}}/static/require.js"></script>
<link rel="import" href="{{static_host}}/static/padagraph-gviz-min.html">
<div id="gviz" class="{{ 'nofoot' if not footer else '' }}">
<padagraph-gviz-json routes="{{routes}}" data="{{data}}">
<padagraph-gviz-json sync="{{sync}}" routes="{{routes}}" data="{{data}}">
<padagraph-gviz options="{{options}}">
<div id="viz"></div>
<padagraph-model-popup id="gvizpopup"></padagraph-model-popup>
<div id="menu" class="ui icon vertical borderless menu">
<div id="menu" class="ui icon borderless vertical menu">
<padagraph-collection-filter mode="node" asitem="asitem"></padagraph-collection-filter>
<padagraph-collection-filter mode="edge" asitem="asitem"></padagraph-collection-filter>
<div class="ui divider"> </div>
<padagraph-engine-control engine="layout" asitem="asitem"></padagraph-engine-control>
<padagraph-engine-control engine="clustering" asitem="asitem"></padagraph-engine-control>
<padagraph-engine-control engine="explore" asitem="asitem"></padagraph-engine-control>
<div class="ui divider"></div><a id="keb_settings" class="ui item"><i class="settings icon"></i></a>
</div>
<div id="labels">
<padagraph-labels-control></padagraph-labels-control>
......@@ -316,10 +353,40 @@
</padagraph-gviz-json>
<script>
e = document.getElementById('gviz');
e.style.height = ( window.innerHeight - 62 )+ "px";
e.style.height = ( window.innerHeight - 32 )+ "px";
document.querySelector('padagraph-gviz-json').addEventListener('engines-complete', function (e) {
console.log(e.detail.app); // true
var app = e.detail.app;
var engines = [];
var app_engines = {
'explore':app.engines.explore,
'layout':app.engines.layout,
'clustering':app.engines.clustering,
};
for (var k in app_engines){
var engine = app_engines[k]
engine.name = k;
engines.push(engine);
}
var keb = document.createElement("padagraph-keb")
keb.engines = engines;
$("#keb")
.sidebar('setting', 'dimPage', false)
.sidebar('setting', 'transition', 'overlay')
$("#keb").append(keb)
$("#keb .close").click( ()=>{ $("#keb").sidebar('hide') } )
$("#keb_settings").click( ()=>{ $("#keb").sidebar('show') } )
})
</script>
</div>{% if graphurl %} <a href="{{graphurl}}" class="ui active right floated button">refresh</a>
</div>{% if graphurl %} <a href="{{graphurl}}" class="ui active refresh button">refresh</a>
<!--a.ui.active.primary.button(href="{{padurl}}") edit-->{% endif %}
</div>{% elif error %}
<div class="ui text container">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment