Commit 3de02848 authored by delanoe's avatar delanoe

Merge remote-tracking branch 'origin/c24b-testing-help' into testing-help

parents abeab3b8 029d48d6
......@@ -151,6 +151,9 @@ INDEXED_HYPERDATA = {
# },
}
# user parameters----------------------------------------
USER_LANG = ["fr", "en"]
# resources ---------------------------------------------
def get_resource(sourcetype):
......
......@@ -61,7 +61,9 @@ class User(Base):
"""check if a given node is owned by the user"""
return (node.user_id == self.id) or \
node.id in (contact.id for contact in self.contacts())
def get_params(self, username=None):
print(self.__dict__.items())
return self.hyperdata
class Contact(Base):
__tablename__ = 'contacts'
......
......@@ -3,6 +3,7 @@ from django.conf.urls import url
from . import nodes
from . import projects
from . import corpora
from . import users
from . import ngrams
from . import metrics
from . import ngramlists
......@@ -90,6 +91,6 @@ urlpatterns = [ url(r'^nodes$' , nodes.NodeListResource.as_view()
, url(r'^ngramlists/maplist$' , ngramlists.MapListGlance.as_view() )
# fast access to maplist, similarly formatted for termtable
, url(r'^user/parameters/$', users.UserParameters.as_view())
]
from .api import * #notamment APIView, check_rights, format_response
from gargantext.util.http import *
from django.core.exceptions import *
from collections import defaultdict
from gargantext.util.toolchain import *
import copy
from gargantext.util.db import session
class UserParameters(APIView):
'''API endpoint that represent the parameters of the user'''
def get(self, request):
node_user = session.query(Node).filter(Node.user_id == request.user.id, Node.typename== "USER").first()
if node_user is None:
return Response({"detail":"Not Found"}, status=HTTP_404)
else:
#context = format_response(node_user, )
return Response(node_user.hyperdata)
def put(self, request):
if request.user.id is None:
raise TypeError("This API request must come from an authenticated user.")
else:
# we query among the nodes that belong to this user
user = cache.User[request.user.id]
node_user = session.query(Node).filter(Node.user_id == user.id, Node.typename== "USER").first()
if node_user is None:
return Response({"detail":"Not Allowed"}, status=HTTP_401_UNAUTHORIZED)
for k, v in request.data.items():
node_user.hyperdata[k] = v
# setattr(node_user.hyperdata, k, v)
# print(node_user.hyperdata)
node_user.save_hyperdata()
session.add(node_user)
session.commit()
node_user = session.query(Node).filter(Node.user_id == user.id, Node.typename== "USER").first()
print(node_user.hyperdata)
return Response({"detail":"Updated user parameters", "hyperdata": node_user.hyperdata}, status=HTTP_202_ACCEPTED)
......@@ -2,8 +2,10 @@ from django.contrib.auth import authenticate, login, logout
from django.core.urlresolvers import reverse_lazy
from django.views.generic import FormView
from django.shortcuts import redirect
from gargantext.util.db import session
from gargantext.models.users import User
from django import forms
from gargantext.models import Node, User
from gargantext.views.pages.projects import overview
......@@ -21,6 +23,23 @@ class LoginView(FormView):
if user is not None and user.is_active:
login(self.request, user)
node_user = session.query(Node).filter(Node.user_id == user.id, Node.typename== "USER").first()
#user hasn't been found inside Node table
#create it from auth table => node table
if node_user is None:
node_user = Node(
typename = 'USER',
#in node = > name
#in user = > username
name = user.name,
user_id = user.id,
)
node_user.hyperdata = {"language":"fr"}
session.add(node_user)
session.commit()
return super(LoginView, self).form_valid(form)
else:
return self.form_invalid(form)
......
from gargantext.util.http import *
from gargantext.util.db import *
from gargantext.util.db_cache import cache
from gargantext.models import *
from gargantext.constants import *
from gargantext.settings import *
from datetime import datetime
from gargantext.util.http import *
from gargantext.util.db import *
from gargantext.util.db_cache import cache
from gargantext.models import *
from gargantext.constants import *
from gargantext.settings import *
from datetime import datetime
from .main import get_user_params
from gargantext.constants import USER_LANG
def _get_user_project_corpus(request, project_id, corpus_id):
"""Helper method to get a corpus, knowing the project's and corpus' ID.
......@@ -28,7 +28,6 @@ def docs_by_titles(request, project_id, corpus_id):
authorized, user, project, corpus = _get_user_project_corpus(request, project_id, corpus_id)
if not authorized:
return HttpResponseForbidden()
source_type = corpus.resources()[0]['type']
# response!
return render(
......@@ -41,7 +40,9 @@ def docs_by_titles(request, project_id, corpus_id):
'corpus': corpus,
'resourcename' : get_resource(source_type)['name'],
'view': 'titles',
'user': request.user
'user': request.user,
'user_parameters': get_user_params(user),
'languages': USER_LANG
},
)
......@@ -57,10 +58,10 @@ def docs_by_sources(request, project_id, corpus_id):
# and the project just for project.id in corpusBannerTop
project = cache.Node[project_id]
user = cache.User[request.user.id]
source_type = corpus.resources()[0]['type']
# rendered page : sources.html
return render(
template_name = 'pages/corpora/sources.html',
request = request,
......@@ -70,7 +71,10 @@ def docs_by_sources(request, project_id, corpus_id):
'project': project,
'corpus' : corpus,
'resourcename' : get_resource(source_type)['name'],
'view': 'sources'
'user': request.user,
'user_parameters': get_user_params(user),
'view': 'sources',
'languages': USER_LANG
},
)
......@@ -86,10 +90,10 @@ def docs_by_authors(request, project_id, corpus_id):
# and the project just for project.id in corpusBannerTop
project = cache.Node[project_id]
user = cache.User[request.user.id]
source_type = corpus.resources()[0]['type']
# rendered page : sources.html
node_user = get_node_user(user)
return render(
template_name = 'pages/corpora/authors.html',
request = request,
......@@ -99,7 +103,10 @@ def docs_by_authors(request, project_id, corpus_id):
'project': project,
'corpus' : corpus,
'resourcename' : get_resource(source_type)['name'],
'view': 'authors'
'view': 'authors',
'user': request.user,
'user_parameters': node_user.hyperdata,
'languages': USER_LANG
},
)
......@@ -111,7 +118,6 @@ def analytics(request, project_id, corpus_id):
return HttpResponseForbidden()
source_type = corpus.resources()[0]['type']
# response!
return render(
template_name = 'pages/analytics/histories.html',
......@@ -123,6 +129,8 @@ def analytics(request, project_id, corpus_id):
'corpus': corpus,
'resourcename' : get_resource(source_type)['name'],
'view': 'analytics',
'user': request.user
'user': request.user,
'user_parameters': get_user_params(user),
'languages': USER_LANG
},
)
......@@ -81,4 +81,3 @@ class AuthenticationForm(forms.Form):
def get_user(self):
return self.user_cache
from gargantext.util.http import *
from gargantext.util.http import *
from gargantext.util.db import session
from gargantext.models import Node, User
import datetime
from gargantext.util.generators import paragraphs, credits
from gargantext.constants import USER_LANG
def get_user_node(user):
if user is not None:
node_user = session.query(Node).filter(Node.user_id == user.id, Node.typename== "USER").first()
return node_user
else:
return None
def get_user_params(user):
node_user = get_user_node(user)
if node_user is not None:
return node_user.hyperdata
return {}
def home(request):
'''Home describes the platform.
......@@ -19,12 +32,15 @@ def home(request):
'paragraph_gargantua': paragraphs.gargantua(),
'paragraph_lorem' : paragraphs.lorem(),
'paragraph_tutoreil': paragraphs.tutoreil(),
'languages': USER_LANG,
'user_parameters': get_user_params(request.user)
},
)
def about(request):
'''About Gargantext, its team and sponsors
'''
return render(
template_name = 'pages/main/about.html',
request = request,
......@@ -35,6 +51,8 @@ def about(request):
'institutions': credits.institutions(),
'labos': credits.labs(),
'grants': credits.grants(),
'user_parameters': get_user_params(request.user),
'languages': USER_LANG,
},
)
......@@ -50,11 +68,13 @@ def robots(request):
def maintenance(request):
'''Gargantext out of service
'''
user_node = get_user_node(request.user)
return render(
template_name = 'pages/main/maintenance.html',
request = request,
context = {
'user': request.user,
'date': datetime.datetime.now(),
'user_parameters': get_user_params(request.user)
},
)
......@@ -4,7 +4,7 @@ from gargantext.util.db_cache import cache
from gargantext.util.files import upload
from gargantext.models import *
from gargantext.constants import *
from .main import get_user_params
from gargantext.util.scheduling import scheduled
from gargantext.util.toolchain import parse_extract_indexhyperdata
......@@ -13,6 +13,19 @@ from collections import defaultdict
from django.utils.translation import ugettext_lazy
import re
def get_node_user(user):
node_user = session.query(Node).filter(Node.user_id == user.id, Node.typename == "USER").first()
if node_user is None:
node_user = Node(user_id = user.id,
typename = 'USER',
name = user.name,
)
#default language for now is 'fr'
node_user.hyperdata["language"] = "fr"
session.add(node_user)
session.commit()
print(node_user.hyperdata)
return node_user
@requires_auth
def overview(request):
......@@ -22,7 +35,8 @@ def overview(request):
'''
user = cache.User[request.user.id]
print(user)
node_user = get_node_user(user)
# If POST method, creates a new project...
if request.method == 'POST':
name = str(request.POST['name'])
......@@ -31,6 +45,8 @@ def overview(request):
user_id = user.id,
typename = 'PROJECT',
name = name,
parent_id = node_user.id,
)
session.add(new_project)
session.commit()
......@@ -51,6 +67,8 @@ def overview(request):
# projects owned by the user
'number': user_projects.count(),
'projects': user_projects,
'user_parameters': get_user_params(request.user),
'languages': USER_LANG,
# projects owned by the user's contacts
'common_users': (contact for contact, projects in contacts_projects),
'common_projects': sum((projects for contact, projects in contacts_projects), []),
......@@ -90,7 +108,8 @@ def project(request, project_id):
# security check
project = session.query(Node).filter(Node.id == project_id).first()
user = cache.User[request.user.id]
node_user = get_node_user(user)
if project is None:
raise Http404()
if not user.owns(project):
......@@ -168,8 +187,11 @@ def project(request, project_id):
template_name = 'pages/projects/wait.html',
request = request,
context = {
'form': NewCorpusForm,
'user': request.user,
'user_parameters': get_user_params(request.user),
'languages': USER_LANG,
'date': datetime.now(),
'project': project,
'donut': donut,
......@@ -189,6 +211,8 @@ def project(request, project_id):
template_name = 'pages/projects/project.html',
request = request,
context = {
'user_parameters': get_user_params(request.user),
"languages": USER_LANG,
'form': NewCorpusForm,
'user': request.user,
'date': datetime.now(),
......
......@@ -3,8 +3,11 @@ from gargantext.util.db import session
from gargantext.util.db_cache import cache
from gargantext.models import Node
from gargantext.constants import get_resource
from gargantext.constants import USER_LANG
from .main import get_user_params
from datetime import datetime
@requires_auth
def ngramtable(request, project_id, corpus_id):
'''
......@@ -32,7 +35,6 @@ def ngramtable(request, project_id, corpus_id):
corpora_infos = corpora_infos_q.all()
source_type = corpus.resources()[0]['type']
# rendered page : terms.html
return render(
template_name = 'pages/corpora/terms.html',
......@@ -48,6 +50,9 @@ def ngramtable(request, project_id, corpus_id):
# for the CSV import modal
'importroute': "/api/ngramlists/import?onto_corpus=%i"% corpus.id,
'corporainfos' : corpora_infos
'corporainfos' : corpora_infos,
#user params
'user_parameters': get_user_params(request.user),
'languages': USER_LANG
},
)
......@@ -4,8 +4,9 @@ from gargantext.util.db_cache import cache
from gargantext.models import *
from gargantext.constants import *
from gargantext.settings import *
from gargantext.constants import USER_LANG
from datetime import datetime
from gargantext.views.pages.main import get_user_params
@requires_auth
def explorer(request, project_id, corpus_id):
......@@ -19,9 +20,10 @@ def explorer(request, project_id, corpus_id):
# we pass our corpus
corpus = cache.Node[corpus_id]
# security check
user = cache.User[request.user.id]
node_user = get_node_user(user)
if corpus is None:
raise Http404()
if not user.owns(corpus):
......@@ -46,6 +48,8 @@ def explorer(request, project_id, corpus_id):
'corpus' : corpus ,
'maplist_id': maplist_id ,
'view' : 'graph' ,
'user_parameters': get_user_params(request.user),
'languages': USER_LANG
},
)
......@@ -61,6 +65,7 @@ def myGraphs(request, project_id, corpus_id):
'''
user = cache.User[request.user.id]
# we pass our corpus
corpus = cache.Node[corpus_id]
......@@ -99,6 +104,8 @@ def myGraphs(request, project_id, corpus_id):
'corpus' : corpus,
'view' : 'myGraph',
'coocs' : coocs,
'coocs_count' : coocs_count
'coocs_count' : coocs_count,
'user_parameters': get_user_params(request.user),
'languages': USER_LANG,
},
)
......@@ -580,6 +580,9 @@ function Main_test(Data) {
$(".dynatable-record-count").insertAfter(".imadiv")
$(".dynatable-pagination-links").insertAfter(".imadiv")
$('<div class="imadiv"></div>').insertAfter("#my-ajax-table")
$(".dynatable-record-count").insertAfter(".imadiv")
$(".dynatable-pagination-links").insertAfter(".imadiv")
// binds a custom filter to our 'doubleSearch' via dynatable.queries.functions
MyTable.data('dynatable').queries
.functions['doubleSearch'] = function(record,searchString) {
......
......@@ -2025,7 +2025,7 @@ function MainTableAndCharts( ngdata , initial , filtersParams, callerLabel) {
+ '</th>'+"\n" ;
// main name and score columns
div_table += "\t"+"\t"+'<th data-dynatable-column="name">Terms</th>'+"\n";
div_table += "\t"+"\t"+'<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Score</th>'+"\n";
div_table += "\t"+"\t"+'<th id="score_column_id" data-dynatable-sorts="score" data-dynatable-column="score">Occurences (nb)</th>'+"\n";
div_table += "\t"+"\t"+'</th>'+"\n";
div_table += "\t"+'</tr>'+"\n";
div_table += "\t"+'</thead>'+"\n";
......@@ -2376,6 +2376,10 @@ function MainTableAndCharts( ngdata , initial , filtersParams, callerLabel) {
$(".dynatable-record-count").insertAfter(".imadiv")
$(".dynatable-pagination-links").insertAfter(".imadiv")
$('<div class="imadiv"></div>').insertAfter("#my-ajax-table")
$(".dynatable-record-count").insertAfter(".imadiv")
$(".dynatable-pagination-links").insertAfter(".imadiv")
// restore chart filters
if (typeof(filtersParams.from) != 'undefined'
&& typeof(filtersParams.to) != 'undefined'
......
......@@ -482,6 +482,9 @@ function Main_test( data , initial) {
$(".dynatable-record-count").insertAfter(".imadiv")
$(".dynatable-pagination-links").insertAfter(".imadiv")
$('<div class="imadiv"></div>').insertAfter("#my-ajax-table")
$(".dynatable-record-count").insertAfter(".imadiv")
$(".dynatable-pagination-links").insertAfter(".imadiv")
console.log("After table 3")
return "OK"
......
This diff is collapsed.
......@@ -169,8 +169,16 @@ $(document).on('keyup keydown', function(e){
var att_c = AttsDict_sorted[i].value;
var the_method = "clustersBy"
if(att_s.indexOf("clust")>-1) the_method = "colorsBy"
div_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "color")\'>By '+att_s+'('+att_c+')'+'</a></li>'
pr('<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "color")\'>By '+att_s+'('+att_c+')'+'</a></li>')
var method_label = att_s
if (att_s == "clust_default"){
method_label = "default";
}
else if (att_s == "clust_louvain"){
method_label = "community (louvain)"
}
div_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "color")\'>By '+method_label+'</a></li>'
// pr('<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "color")\'>By '+att_s+'('+att_c+')'+'</a></li>')
}
div_info += ' </ul>'
div_info += ' </li>'
......@@ -217,11 +225,12 @@ $(document).on('keyup keydown', function(e){
var att_c = AttsDict_sorted[i].value;
var the_method = "clustersBy"
if(att_s.indexOf("clust")>-1) the_method = "colorsBy"
div_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "size")\'>By '+att_s+'('+att_c+')'+'</a></li>'
pr('<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "size")\'>By '+att_s+'('+att_c+')'+'</a></li>')
console.log(att_s)
div_info += '<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "size")\'>By '+att_s+'</a></li>'
// pr('<li><a href="#" onclick=\''+the_method+'("'+att_s+'" , "size")\'>By '+att_s+'</a></li>')
}
div_info += '<li><a href="#" onclick=\''+"clustersBy"+'("default" , "size")\'>By '+"default"+'('+AttsDict_sorted[0].value+')'+'</a></li>'
console.log('<li><a href="#" onclick=\''+"clustersBy"+'("default" , "size")\'>By '+"default"+'('+AttsDict_sorted[0].value+')'+'</a></li>' )
div_info += '<li><a href="#" onclick=\''+"clustersBy"+'("default" , "size")\'>By '+"default"+'</a></li>'
//console.log('<li><a href="#" onclick=\''+"clustersBy"+'("default" , "size")\'>By '+"default"+'('+AttsDict_sorted[0].value+')'+'</a></li>' )
div_info += ' </ul>'
div_info += ' </li>'
......@@ -995,24 +1004,29 @@ function getTips(){
param='';
text =
"<br>"+
"Basic Interactions:"+
"<ul>"+
"<li>Click on a node to select/unselect and get its information. In case of multiple selection, the button unselect clears all selections.</li>"+
"<li>The switch button switch allows to change the view type.</li>"+
"</ul>"+
"<br>"+
"Graph manipulation:"+
"<ul>"+
"<center><b>Graph Explorer </b></center>"+
"<ul><b>Basic Interactions:</b>"+
"<li>With the mouse selector, click on a node to select/unselect and get its contextual information. Associated terms, neighbours and the first 5 documents will appears in this window.</li>"+
"<li>In case of node selection(simple or multiple), the button <button class='delete'>Delete</button> clears all the active selections.</li>"+
"<!--<li>You can search a specific term in the search bar: <div id='search_input_group' class='input-group input-group-sm'><span class='input-group-btn'><button id='searchbutton' title='Search the topic in the map' class='btn btn-info' type='button'><span class='glyphicon glyphicon-search'></span></button></span><input id='searchinput' type='text' class='form-control' placeholder='Search' /></li>-->"+
"</ul>"+
"<ul><b>Graph manipulation:</b>"+
"<li>Link and node sizes indicate their strength.</li>"+
"<li>To fold/unfold the graph (keep only strong links or weak links), use the 'edges filter' sliders.</li>"+
"<li>To select a more of less specific area of the graph, use the 'nodes filter' slider.</li>"+
"<li>To fold/unfold the graph (keep only strong links or weak links), use the 'edges filter' slider:</li> <img src='/static/img/slider_edges.png'/>"+
"<li>To select a more of less specific area of the graph, use the 'nodes filter' slider :</li><img src='/static/img/slider_nodes.png'/>"+
"<li>To change size of label (proportionnal to their strenght) use the 'label size slider':</li> <img src='/static/img/slider_label.png'/>"+
"<li>Change cluster coloration using a different algorithm in the options<img class='float: right' src='/static/img/slider_color.png'/></li> "+
"<li>Change size of cluster using the options <img class='float: right' src='/static/img/slider_size.png'/></li>"+
"</ul>"+
"<br>"+
"Micro/Macro view:"+
"<ul>"+
"<li>To explore the neighborhood of a selection, either double click on the selected nodes, either click on the macro/meso level button. Zoom out in meso view return to macro view.</li>"+
"<li>Click on the 'all nodes' tab below to view the full clickable list of nodes.</li>"+
"<ul><b>Micro/Macro view:</b>"+
"<a style='float: right;' class='btn-xs' href='' id='lensButton'></a>"+
"<li>To center the graph, click on the center button. </li>"+
"<li>To explore the neighborhood of a selection, double click on the selected nodes</li>"+
"<a style='float: right;' class='btn-xs' href='' id='zoomPlusButton'></a>"+
"<a style='float: right;' class='btn-xs' href='' id='zoomMinusButton'></a>"+
"<li>You can explore the graph using the slider and the macro/mesolevel button.</li>"+
"<a style='float:right;' href='#' id='edgesButton'> </a>"+
"<li>Recalculate the clusters of your graph using the edge button</li>"+
"</ul>";
$("#tab-container").hide();
......
......@@ -80,13 +80,14 @@
</a></li> -->
<!-- TODO fix: category0 -> category1 switching -->
<li class='basicitem'><a>
<li id="filter_graph" class='basicitem help'><a>
<!-- Create a subgraph -->
<ul id="category0" class="nav">
<li><small>Nodes</small> <div id="slidercat0nodesweight" class="settingslider"></div></li>
<li><small>Edges</small> <div id="slidercat0edgesweight" class="settingslider"></div></li>
</ul>
</a></li>
<!-- <li class='basicitem'><a>
Compare<br>
......
......@@ -6,7 +6,7 @@
{% load staticfiles %}
<div class="container">
<h3>
<h3 class="help" id="filter_analytics">
<span class="glyphicon glyphicon-hand-right" aria-hidden="true"></span>
Filter your documents with terms and watch histories (you can compare all your corpora).
</h3>
......@@ -96,7 +96,7 @@
<auto-complete source="getNgrams($query)"></auto-complete>
</tags-input ng-model="tags">
</li>
<!-- filter hyperdata
<!-- filter hyperdata
<li>
<ul>
<li ng-repeat="hyperdata in hyperdataList">
......
{% extends "pages/menu.html" %}
{% extends "pages/menu.html"}
{% block css %}
{% load staticfiles %}
......@@ -87,5 +87,5 @@
<!-- custom-lib for dynatable.js and dc.js -->
<script type="text/javascript" src="{% static "lib/gargantext/Authors_dyna_chart_and_table.js" %}"></script>
<script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script>
{% endblock %}
{% extends "pages/menu.html" %}
{% extends "pages/menu.html"%}
{% load staticfiles %}
{% block css %}
{% load staticfiles %}
<link rel="stylesheet" href="{% static "lib/bootstrap/3.0.2/bootstrap.css" %}">
<script type="text/javascript" src="{% static "lib/jquery/1.11.1/jquery.min.js" %}"></script>
<script type="text/javascript" src="{% static "lib/gargantext/garganrest.js" %}"></script>
......@@ -193,7 +193,7 @@
<script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script>
<script type="text/javascript">
// initial vars
......
{% extends "pages/menu.html" %}
{% block css %}
{% extends "pages/menu.html"%}
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static "lib/bootstrap/3.0.2/bootstrap.css" %}">
{% block css %}
<link rel="stylesheet" type="text/css" href="{% static "lib/d3/dc.css"%}"/>
<link rel="stylesheet" type="text/css" href="{% static "lib/jquery/dynatable/jquery.dynatable.css"%}"/>
<link rel="stylesheet" type="text/css" href="{% static "lib/gargantext/tables.css"%}"/>
<link rel="stylesheet" type="text/css" href="{% static "lib/gargantext/charts.css"%}"/>
......@@ -21,19 +20,7 @@
<div class="container">
<div class="col-md-3 col-md-offset-2">
<div id="monthly-move-chart">
<center>
Select a frequency group in the chart with blue bars to zoom in
<p align="center">
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p>
<!-- <p style="font-size:70%">
<b>x</b>: amount of documents for the source
<b>y</b>: number of sources with that amount
</p> -->
<div class="clearfix"></div>
</center>
</div>
<div class="bs-callout">
<div class="row">
......@@ -47,7 +34,26 @@
</center>
<br>
</div>
</div>
<div id="monthly-move-chart" class="bs-callout">
<center>
<p id="sources_time" class="help">
Select a frequency group in the chart with blue bars to zoom in </p>
<p align="center">
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p>
<!-- <p style="font-size:70%">
<b>x</b>: amount of documents for the source
<b>y</b>: number of sources with that amount
-->
</p>
<div class="clearfix"></div>
</center>
</div>
</div>
</div>
</div>
......@@ -87,5 +93,5 @@
<!-- custom-lib for dynatable.js and dc.js -->
<script type="text/javascript" src="{% static "lib/gargantext/Sources_dyna_chart_and_table.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% endblock %}
......@@ -78,15 +78,7 @@ em {
<div class="container">
<div class="col-md-3 col-md-offset-2">
<div id="monthly-move-chart">
<center>
Select a score/frequency range in the chart with blue bars to zoom in
<p align="center">
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p>
<div class="clearfix"></div>
</center>
</div>
<div class="bs-callout">
<div class="row">
......@@ -101,9 +93,21 @@ em {
<br>
</div>
</div>
</div>
</div>
<div id="monthly-move-chart" class="bs-callout">
<center>
<p id="terms_time" class="help">Select a score/frequency range in the chart with blue bars to zoom in <p>
<p align="center">
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a></p>
<div class="clearfix"></div>
</center>
</div>
</div>
</div>
</div>
<div class="container">
<!-- (values set by js) caching our DB ids (handy for list update commands) -->
<input type="hidden" id="mainlist_id" value=""></input>
......@@ -136,12 +140,13 @@ em {
</button>
</div>
<!-- see in javascript function queries.functions['my_state_filter'] -->
<div class="pull-right" style="margin-top:2.1em;padding-left:1em;">
<div id="filter_terms" class="pull-right help" style="margin-top:2.1em;padding-left:1em;">
<select id="picklistmenu" name="my_state_filter">
<option value='reset'>All lists</option>
<option value='0'>Candidates terms</option>
<option value='reset'>All terms</option>
<!-- <option value='1' selected="selected">Map terms only</option> -->
<option value='1'>Map terms</option>
<option value='0'>Other terms</option>
<option value='2'>Stop terms</option>
</select>
<select id="picktermtype" name="my_termtype_filter" style="margin-left:1em;">
......@@ -457,7 +462,7 @@ function listmergeCsvPost(theFile){
}
};
</script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% endblock %}
{% extends "pages/menu.html" %}
{% extends "pages/menu.html"%}
{% load staticfiles %}
{% block css %}
......@@ -19,30 +19,38 @@
<div class="container">
<div class="col-md-3 col-md-offset-2">
<div id="monthly-move-chart">
<center>
Select a time range in the chart with blue bars to zoom in
<p align="center">
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a>
</p>
<div class="clearfix"></div>
</center>
</div>
<div class="bs-callout">
<div class="row">
<div id="monthly-volume-chart"></div>
</div>
</div>
<div class="bs-callout">
<div class="row">
<div id="monthly-volume-chart"></div>
<div class="row">
<div id="monthly-move-chart">
<center>
<p class="help" id="titles_time">Select a time range in the chart with blue bars to zoom in </p>
<p align="center">
<!--<a class="btn btn-xs btn-default" role="button" href="/chart/corpus/{{ corpus.id }}/data.csv">Save</a>-->
<a class="btn btn-xs btn-default" href="javascript:volumeChart.filterAll();dc.redrawAll();">Reset</a>
</p>
<div class="clearfix"></div>
</center>
</div>
</div>
<div id="content_loader">
<br>
<center>
<img width="10%" src="{% static "img/ajax-loader.gif"%}"></img>
</center>
<br>
</div>
</div>
<div id="content_loader">
<br>
<center>
<img width="10%" src="{% static "img/ajax-loader.gif"%}"></img>
</center>
<br>
</div>
</div>
</div>
</div>
......@@ -77,7 +85,7 @@
</input>
</span>
<span class="glyphicon glyphicon-filter" aria-hidden="true"></span>
<select id="docFilter" name="docFilter">
<select id="docFilter" name="docFilter" class="help">
<option value="filter_all">All</option>
<option value="filter_favs">Favorite documents</option>
<option value="filter_dupl_all">Duplicates (title, date &amp; src)</option>
......@@ -102,5 +110,5 @@
<!-- custom-lib for dynatable.js and dc.js -->
<script type="text/javascript" src="{% static "lib/gargantext/Docs_dyna_chart_and_table.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% endblock %}
......@@ -96,3 +96,4 @@
{% endblock %}
<script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script>
......@@ -5,7 +5,7 @@
<script type="text/javascript" src="{% static "lib/jquery/1.11.1/jquery.min.js" %}"></script>
<link rel="stylesheet" type="text/css" href="{% static "lib/bootstrap/3.0.2/bootstrap.css" %}">
<link rel="stylesheet" type="text/css" href="{% static "lib/gargantext/menu.css"%}"/>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% block css %}
{% endblock %}
......@@ -68,6 +68,8 @@
{% endif %}
</ul>
<ul class="nav navbar-nav pull-right">
<li class="dropdown">
<a href="#" role="button" class="dropdown-toggle navbar-text" data-toggle="dropdown" title="That is your username">
......@@ -102,7 +104,30 @@
{% endif %}
</ul>
</li>
{% if user.is_authenticated %}
<li class="nav-item dropdown lang">
<a class="nav-link dropdown-toggle" id="lang" data-lang="{{user_parameters.language}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img value="{{user_parameters.language}}" src="/static/img/{{user_parameters.language}}.png" width="25%"/>
<span class="label">{{user_parameters.language}}</span>
<i class="caret"></i>
</a>
<ul class="dropdown-menu" aria-labelledby="lang">
{% for lang in languages %}
{% if lang != user_parameters.language %}
<li class="dropdown-item new_lang">
<a class="new_lang" data-lang="{{lang}}"><img value="{{user_parameters.language}}" src="/static/img/{{lang}}.png" width="25%"/> <span>{{lang}}</span> </a></li>
{% endif %}
{% endfor %}
</ul>
</li>
{% endif %}
</ul>
</div>
</div>
{% if corpus %}
......@@ -209,6 +234,7 @@
{% if view != "graph" %}
<div class="container theme-showcase">
<div class="jumbotron" style="margin-bottom:0">
<br>
<br>
<br>
<div class="row">
......@@ -222,7 +248,10 @@
</div>
<!-- export button -->
<div class="col-md-6">
{% if view == 'terms' %}
<a id="export_terms" class="help btn pull-right">
</a>
<a class="btn btn-primary exportbtn pull-right" role="button"
href="/api/ngramlists/export?corpus={{corpus.id}}"
title="Export terms table in CSV">
......@@ -230,14 +259,11 @@
</a>
{% elif view == 'titles' %}
{% elif view == 'titles' %}
<a href="http://gitlab.iscpif.fr/humanities/gargantext/wikis/faq/exportImport" class="pull-right btn btn-lg">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
<a id="export_corpus" class="help btn pull-right">
</a>
<a class="btn btn-primary exportbtn pull-right" role="button"
href="/api/nodes?parent_id={{corpus.id}}&types[]=DOCUMENT&pagination_limit=100000&formated=csv"
title="Export full corpus in CSV">
......@@ -252,6 +278,18 @@
{% else %}
<!-- TODO export source table -->
<!-- <a id="export_sources" class="help">
</a> -->
<!-- <a id="export_sources" class="help btn btn-primary exportbtn pull-right" role="button"
href="/api/nodes?parent_id={{corpus.id}}&types[]=DOCUMENT&pagination_limit=100000&formated=csv"
title="Export full corpus in CSV">
Export sources &nbsp;
<span class="glyphicon glyphicon-download" aria-hidden="true"></span>
</a><span class="help" id="export_sources"> -->
{% endif %}
</div>
</div>
......@@ -387,8 +425,9 @@
<script type="text/javascript" src="{% static "lib/gargantext/garganrest.js" %}"></script>
<!-- Graph renaming (load after garganrest)-->
<script type="text/javascript" src="{% static "lib/gargantext/graph_renamer.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
{% endif %}
<script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script>
{% if debug == False %}
<!-- Piwik -->
......
{% if list_corpora %}
{% for key, corpora in list_corpora.items %}
<h2>
<div class="row">
<div class="col-md-1 content"></div>
<span class="glyphicon glyphicon-cd" aria-hidden="true"></span>
{{ key }}
</h2>
{% for corpus in corpora %}
<div id="corpus_{{corpus.id}}">
<div class="row">
<h4>
<div class="col-md-1 content"></div>
<div class="col-md-5 content">
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}">
<span class="glyphicon glyphicon-file" aria-hidden="true"></span>
{{corpus.name}}, {{ corpus.count }} documents {{ corpus.status_message }}
</a>
</div>
<div class="col-md-3 content">
<!-- -->
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<a href="/projects/{{project.id}}/corpora/{{corpus.id}}" title="View the corpus">
<button type="button" class="btn btn-default" aria-label="Left Align">
<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
</button>
</a>
<button type="button" class="btn btn-default yopla" data-container="body" data-toggle="popover" data-placement="bottom" data-trigger="focus"
data-content="
<ul>
<li
onclick=&quot;
garganrest.metrics.update({{corpus.id}}, function(){alert('The corpus ({{corpus.name|escapejs}}) was updated')});
&quot;>
<a href='#'>Recalculate ngram metrics</a> <br/> (can take a little while)
</li>
</ul>
">
<span class="glyphicon glyphicon-repeat" aria-hidden="true"
title='Recalculate ngram scores and similarities'></span>
</button>
{% endif %}
<!-- TODO: delete non seulement si state.complete mais aussi si state.error -->
<button type="button" class="btn btn-default" data-container="body" data-toggle="popover" data-placement="bottom"
data-content="
<ul>
<li
onclick=&quot;
garganrest.nodes.delete({{corpus.id}}, function(){$('#corpus_'+{{corpus.id}}).remove()});
$(this).parent().parent().remove();
&quot;>
<a href='#'>Delete this</a>
</li>
</ul>
">
<span class="glyphicon glyphicon-trash" aria-hidden="true"
title='Delete this corpus'></span>
</button>
{% endifequal %}
{% endfor %}
</div>
<div class="col-md-3 content">
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
{% else %}
{% if state.error %}
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
{{ state.error }}
{% else %}
<div class="progress">
<div class=" progress-bar progress-bar-striped
progress-bar-success
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
<span>
Upload
</span>
</div>
{% for state in corpus.hyperdata.statuses %}
<div class=" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 20%">
<span>
{{ state.action }}
{% if not state.complete %}
Processing
{% endif %}
</span>
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endifequal %}
{% endfor %}
</div>
<div class="col-md-1 content"></div>
</h4>
</div>
</div>
{% endfor %}
{% endfor %}
{% endif %}
<div class="modal fade" id="stack1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Query to PubMed</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
<input id="daquery" type="text" class="input-lg" data-tabindex="2">
<a onclick="getGlobalResults();" class="btn">Scan</a>
<div id="results"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button onclick="doTheQuery();" disabled id="id_thebutton" type="button" class="btn btn-primary">Explore a sample!</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal -->
<div class="modal fade" id="addcorpus" tabindex="-1" role="dialog" aria-labelledby="myModalLabel2" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Add a Corpus <a href="https://gogs.iscpif.fr/humanities/faq_gargantext/wiki/FAQ#import--export-a-dataset">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
</a>
</h3>
</div>
<div class="modal-body">
<!-- FAQ -->
<form id="id_form" enctype="multipart/form-data" action="/projects/{{project.id}}/" method="post">
{% csrf_token %}
<table cellpadding="5">
{% for field in form %}
<tr>
<th>{{field.label_tag}}</th>
<td>
{{ field.errors }}
{{ field }}
{% if field.name == 'name' %}
<span onclick="getGlobalResults(this);" id="scanpubmed"></span>
<div id="theresults"></div>
{% endif %}
</td>
</tr>
{% endfor %}
<tr>
<th></th>
<td>
<div id="pubmedcrawl" style="visibility: hidden;">
Do you have a file already? &nbsp;
<input type="radio" id="file_yes" name="file1" onclick="FileOrNotFile(this.value);" class="file1" value="true" checked> Yes </input>
<input type="radio" id="file_no" name="file1" onclick="FileOrNotFile(this.value);" class="file1" value="false"> No </input>
</div>
</td>
</tr>
</table>
</form>
<div class="modal-footer">
<!-- <div id="pubmedcrawl" align="right" style="visibility: hidden;"><a data-toggle="modal" href="#stack1">&#10142; Query directly in PubMed</a></div> -->
<button type="button" class="btn btn-default" data-dismiss="modal">
<span class="glyphicon glyphicon-remove" aria-hidden="true" ></span>
Close
</button>
<button onclick='bringDaNoise();' id="submit_thing" disabled class="btn btn-primary" >
<span class="glyphicon glyphicon-ok" aria-hidden="true" ></span>
Process this!
</button><span id="simpleloader"></span>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- Modal -->
<div id="wait" class="modal fade">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h2 class="modal-title"><h2><span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span> Uploading corpus...</h2>
</div>
<div class="modal-body">
<h5>
Your file has been uploaded !
Gargantext need some time to eat it.
Duration depends on the size of the dish.
</h5>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Continue on Gargantext</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
This diff is collapsed.
This diff is collapsed.
......@@ -49,11 +49,12 @@
</div>
<div class="col-md-3"></div>
<div class="col-md-5">
<p>
<p id="project" class="help">
<br>
<button id="add" type="button" class="btn btn-primary btn-lg" data-container="body" data-toggle="popover" data-placement="bottom">
<button id="add" type="button" class="btn btn-primary btn-lg help" data-container="body" data-toggle="popover" data-placement="bottom">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
Add a new project
</button>
<div id="popover-content" class="hide">
<div id="createForm" class="form-group">
......@@ -182,7 +183,9 @@
</style>
<script type="text/javascript" src="{% static "lib/gargantext/garganrest_projects.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
<script type="text/javascript">
getProjects();
// $(document).on("input#inoutName").bind('keypress', function(e) {
// if(e.keyCode==13){
......
......@@ -11,6 +11,7 @@
<link rel="stylesheet" href="{% static "lib/morris/morris.css" %}">
<script src="{% static "lib/raphael/raphael-min.js"%}"></script>
<style type="text/css">
.ui-autocomplete {
z-index: 5000;
......@@ -53,9 +54,10 @@
{% if donut %}
<div id="hero-donut" style="height: 200px;"></div>
{% endif %}
<center>
<a data-toggle="modal" href="#addcorpus">
<a data-toggle="modal" href="#addcorpus" >
<button
type="button"
class="btn btn-primary btn-lg"
......@@ -66,8 +68,12 @@
<span class="glyphicon glyphicon-plus" aria-hidden="true" ></span>
Add a corpus
</button>
<p class="help" id="corpus-btn"></p>
</a>
</center>
</p>
</div>
</div>
......@@ -256,8 +262,7 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Add a Corpus <a href="http://gitlab.iscpif.fr/humanities/gargantext/wikis/faq/exportImport">
<span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span>
<h3 id="corpus" class="help">Add a Corpus
</a>
</h3>
</div>
......@@ -331,6 +336,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/javascript" src="{% static "lib/jquery/1.11.2/jquery-ui.js" %}"></script>
<!-- <script type="text/javascript" src="{% static "lib/gargantext/help.js" %}"></script> -->
<script type="text/javascript">
var corporaDivs = document.getElementsByClassName('corpusElt')
......
{% for state in corpus.hyperdata.statuses %}
{% ifequal state.action "Workflow" %}
{% if state.complete %}
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
{% else %}
{% if state.error %}
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
{{ state.error }}
{% else %}
<div class="progress">
{% for state in corpus.hyperdata.statuses %}
{% if state.action != "Workflow" %}
<div class=" progress-bar progress-bar-striped
{% if state.complete %}
progress-bar-success
{% else %}
active
{% endif %}
"
role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 25%">
<span>
{{ state.action }}
{% if state.complete %}
Ok
{% else %}
Processing
{% endif %}
</span>
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endif %}
{% endifequal %}
{% endfor %}
function manageStatus(statuses){
status_bar = ""
status_bar += '<div class="progress">'
statuses.forEach(function (status){
if (status["action"] == "Workflow"){
if (status["complete"]){
status_bar += '<span class="glyphicon glyphicon-ok pull-right" aria-hidden="true"></span></div>'
return status_bar;
};
else if (status["error"]) {
status_bar += '<span class="glyphicon glyphicon-exclamation-sign pull-right" aria-hidden="true"></span></div>'
return status_bar;
};
else{
};
};
else{
status_bar +='<div class=" progress-bar progress-bar-striped'
if (status["complete"]){
status_bar +='progress-bar-sucess'
};
else{
status_bar +='active'
};
status_bar+= '" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 25%"> <span>'
if (status["action"]){
if (status["complete"]){
status_bar+= " OK </span></div>"
};
else{
status_bar+= " Processing </span>"
};
}
});
}
}
})
status_bar+="</div>"
return status_bar
};
console.log(errors)
errors.forEach(function(err) {
div = err[0].split(" ")
logs = []
logs.push(div[0])
if (err[1] == false)
{
alert(div[0])
//$(div[0]).parent().addClass("alert danger error");
$(div[0]).next(div[1]).collapse("show");
//$(div[0]).find(div[1]).collapse("show")
}
else
{
$("<span class='glyphicon glyphicon-ok' aria-hidden='true'>").appendTo(div[0])
}
});
return errors
};
function checkInput(source){
if (source.val().length > 0){
return true
}
else {
return false
}
}
function checkSourceFormat(){
source = $("select#source").find(':selected')
if (source.val() != '') {
console.log(source)
source_data = source.data("format")
alert(source_data)
formats = source_data.split(',');
alert(formats);
extension = $("#file").val().substr( (filename.lastIndexOf('.') +1) );
if ($.inArray(extension, formats) == -1){
//$("span.format").collapse("show");
return false;
}
else{
//$("span.format").collapse("hide");
return true;
}
}
return true
}
function checkFileSize(filesize, max_size){
if (filesize > max_size){
return true
}
else{
return false
}
};
//ADD CORPUS FORM
// //source
// $('#source').change(function() {
// $("#source").next("span.required").collapse("hide");
// source_type = $('#source').find(":selected");
// var formats = source_type.data("format").split(',');
// if (formats.length == 0){
// $("#source").next("span.required").collapse("show");
//
// }
// else{
// $("#source").next("span.required").collapse("hide");
// }
// });
// //file
// var max_size = parseInt($('#file').data("max-size"));
// $('#file').change(function() {
// var filesize = parseInt(this.files[0].size);
// if( filesize > max_size){
// alert("Upload file can't exceed 1 Mo because Gargantext would have an indigestion. Consult the special diet of Gargantext in our FAQ")
// $("#file").empty();
// };
// });
//
//
// });
$("#create").bind("click",function(){
var method = $('#radioBtn').find('a.active').data("title");
errors = checkForm()
if (has_error == "true"){
alert("Invalid Form");
}
else{
alert("OK")
//if (checkFileExtension() == true){
//preparePost(method, form)
//}
}
});
/////////////////FORM VALIDATION
function checkFilename(filename){
if (filename == ""){
$("#filename").next("span.required").collapse("show");
return false;
}
else{
$("#file").next("span.required").collapse("hide");
return true;
}
};
function checkFileSize(filesize, max_size){
if (filesize > max_size){
$("span.size").collapse("show");
}
else{
$("span.size").collapse("hide");
}
};
function checkFileExtension(){
filename = $('#file').val()
source_type = $('#source').find(":selected");
if (filename != "" && source_type.val() !== "0"){
fextension = filename.substr( (filename.lastIndexOf('.') +1) );
var formats = source_type.data("format").split(',');
if ($.inArray(extension, formats) == -1){
$("span.format").collapse("show");
return false;
}
else{
$("span.format").collapse("hide");
return true;
}
}
};
//name
$("span.error").collapse("hide");
$('#name').on('input', function() {
var input=$(this);
var is_name=input.val();
if ( is_name.length < 0){
$("#name").next("span.required").collapse("show");
$("form-group#name").addClass("error");
}
else {
$("#name").next("span").collapse("hide");
}
});
//source
$('#source').change(function() {
$("#source").next("span.required").collapse("hide");
source_type = $('#source').find(":selected");
var formats = source_type.data("format").split(',');
if (formats.length == 0){
$("#source").next("span.required").collapse("show");
}
else{
$("#source").next("span.required").collapse("hide");
}
});
//file
var max_size = parseInt($('#file').data("max-size"));
$('#file').change(function() {
$('#name span').collapse("hide");
var input=$(this);
var filename= input.val()
var filesize = parseInt(this.files[0].size);
checkFileSize(filesize, max_size);
});
//console.log("ERRORS?,)
$("#create").bind("click",function(){
var method = $('#radioBtn').find('a.active').data("title");
has_error = $("span.error").hasClass("collapse in");
if (has_error == "true"){
alert("Invalid Form");
}
else{
if (checkFileExtension() == true){
//preparePost(method, form)
}
}
});
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