mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-10 08:38:28 +00:00
Draft of new organisation of the web interface. Usage of Flask's blueprint
This commit is contained in:
parent
da081bae42
commit
32906965d8
31 changed files with 139 additions and 421 deletions
|
@ -9,10 +9,12 @@ import time
|
||||||
import calendar
|
import calendar
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request
|
||||||
import flask
|
import flask
|
||||||
|
import importlib
|
||||||
import os
|
import os
|
||||||
|
from os.path import join
|
||||||
import sys
|
import sys
|
||||||
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/'))
|
sys.path.append(os.path.join(os.environ['AIL_BIN'], 'packages/'))
|
||||||
sys.path.append('./Flasks/')
|
sys.path.append('./modules/')
|
||||||
import Paste
|
import Paste
|
||||||
from Date import Date
|
from Date import Date
|
||||||
|
|
||||||
|
@ -25,15 +27,19 @@ cfg = Flask_config.cfg
|
||||||
Flask_config.app = Flask(__name__, static_url_path='/static/')
|
Flask_config.app = Flask(__name__, static_url_path='/static/')
|
||||||
app = Flask_config.app
|
app = Flask_config.app
|
||||||
|
|
||||||
# import routes and functions from modules
|
# dynamically import routes and functions from modules
|
||||||
import Flask_dashboard
|
for root, dirs, files in os.walk('modules/'):
|
||||||
import Flask_trendingcharts
|
for directory in dirs:
|
||||||
import Flask_trendingmodules
|
#if directory == 'templates':
|
||||||
import Flask_browsepastes
|
# continue
|
||||||
import Flask_sentiment
|
sys.path.append(join(root, directory))
|
||||||
import Flask_terms
|
for name in files:
|
||||||
import Flask_search
|
if name.startswith('Flask_') and name.endswith('.py'):
|
||||||
import Flask_showpaste
|
if name == 'Flask_config.py':
|
||||||
|
continue
|
||||||
|
name = name.strip('.py')
|
||||||
|
print('importing {}'.format(name))
|
||||||
|
importlib.import_module(name)
|
||||||
|
|
||||||
def list_len(s):
|
def list_len(s):
|
||||||
return len(s)
|
return len(s)
|
||||||
|
|
|
@ -1,100 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
# -*-coding:UTF-8 -*
|
|
||||||
|
|
||||||
'''
|
|
||||||
Flask functions and routes for the trending modules page
|
|
||||||
'''
|
|
||||||
import redis
|
|
||||||
import json
|
|
||||||
import flask
|
|
||||||
from flask import Flask, render_template, jsonify, request
|
|
||||||
|
|
||||||
import Paste
|
|
||||||
|
|
||||||
# ============ VARIABLES ============
|
|
||||||
import Flask_config
|
|
||||||
|
|
||||||
app = Flask_config.app
|
|
||||||
cfg = Flask_config.cfg
|
|
||||||
max_preview_char = Flask_config.max_preview_char
|
|
||||||
max_preview_modal = Flask_config.max_preview_modal
|
|
||||||
r_serv_db = Flask_config.r_serv_db
|
|
||||||
# ============ FUNCTIONS ============
|
|
||||||
|
|
||||||
def getPastebyType(server, module_name):
|
|
||||||
all_path = []
|
|
||||||
for path in server.smembers('WARNING_'+module_name):
|
|
||||||
all_path.append(path)
|
|
||||||
return all_path
|
|
||||||
|
|
||||||
|
|
||||||
def event_stream_getImportantPasteByModule(module_name):
|
|
||||||
index = 0
|
|
||||||
all_pastes_list = getPastebyType(r_serv_db, module_name)
|
|
||||||
for path in all_pastes_list:
|
|
||||||
index += 1
|
|
||||||
paste = Paste.Paste(path)
|
|
||||||
content = paste.get_p_content().decode('utf8', 'ignore')
|
|
||||||
content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
|
|
||||||
curr_date = str(paste._get_p_date())
|
|
||||||
curr_date = curr_date[0:4]+'/'+curr_date[4:6]+'/'+curr_date[6:]
|
|
||||||
data = {}
|
|
||||||
data["module"] = module_name
|
|
||||||
data["index"] = index
|
|
||||||
data["path"] = path
|
|
||||||
data["content"] = content[0:content_range]
|
|
||||||
data["linenum"] = paste.get_lines_info()[0]
|
|
||||||
data["date"] = curr_date
|
|
||||||
data["char_to_display"] = max_preview_modal
|
|
||||||
data["finished"] = True if index == len(all_pastes_list) else False
|
|
||||||
yield 'retry: 100000\ndata: %s\n\n' % json.dumps(data) #retry to avoid reconnection of the browser
|
|
||||||
|
|
||||||
# ============ ROUTES ============
|
|
||||||
|
|
||||||
@app.route("/browseImportantPaste/", methods=['GET'])
|
|
||||||
def browseImportantPaste():
|
|
||||||
module_name = request.args.get('moduleName')
|
|
||||||
return render_template("browse_important_paste.html")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/importantPasteByModule/", methods=['GET'])
|
|
||||||
def importantPasteByModule():
|
|
||||||
module_name = request.args.get('moduleName')
|
|
||||||
|
|
||||||
all_content = []
|
|
||||||
paste_date = []
|
|
||||||
paste_linenum = []
|
|
||||||
all_path = []
|
|
||||||
allPastes = getPastebyType(r_serv_db, module_name)
|
|
||||||
|
|
||||||
for path in allPastes[0:10]:
|
|
||||||
all_path.append(path)
|
|
||||||
paste = Paste.Paste(path)
|
|
||||||
content = paste.get_p_content().decode('utf8', 'ignore')
|
|
||||||
content_range = max_preview_char if len(content)>max_preview_char else len(content)-1
|
|
||||||
all_content.append(content[0:content_range].replace("\"", "\'").replace("\r", " ").replace("\n", " "))
|
|
||||||
curr_date = str(paste._get_p_date())
|
|
||||||
curr_date = curr_date[0:4]+'/'+curr_date[4:6]+'/'+curr_date[6:]
|
|
||||||
paste_date.append(curr_date)
|
|
||||||
paste_linenum.append(paste.get_lines_info()[0])
|
|
||||||
|
|
||||||
if len(allPastes) > 10:
|
|
||||||
finished = False
|
|
||||||
else:
|
|
||||||
finished = True
|
|
||||||
|
|
||||||
return render_template("important_paste_by_module.html",
|
|
||||||
moduleName=module_name,
|
|
||||||
all_path=all_path,
|
|
||||||
content=all_content,
|
|
||||||
paste_date=paste_date,
|
|
||||||
paste_linenum=paste_linenum,
|
|
||||||
char_to_display=max_preview_modal,
|
|
||||||
finished=finished)
|
|
||||||
|
|
||||||
@app.route("/_getImportantPasteByModule")
|
|
||||||
def getImportantPasteByModule():
|
|
||||||
module_name = request.args.get('moduleName')
|
|
||||||
return flask.Response(event_stream_getImportantPasteByModule(module_name), mimetype="text/event-stream")
|
|
||||||
|
|
||||||
|
|
|
@ -1,219 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
# -*-coding:UTF-8 -*
|
|
||||||
|
|
||||||
'''
|
|
||||||
Flask functions and routes for the trending modules page
|
|
||||||
'''
|
|
||||||
import redis
|
|
||||||
import datetime
|
|
||||||
import calendar
|
|
||||||
import flask
|
|
||||||
from flask import Flask, render_template, jsonify, request
|
|
||||||
|
|
||||||
import Paste
|
|
||||||
|
|
||||||
# ============ VARIABLES ============
|
|
||||||
import Flask_config
|
|
||||||
|
|
||||||
app = Flask_config.app
|
|
||||||
cfg = Flask_config.cfg
|
|
||||||
r_serv_corpus = Flask_config.r_serv_corpus
|
|
||||||
# ============ FUNCTIONS ============
|
|
||||||
|
|
||||||
def Corpus_getValueOverRange(word, startDate, num_day):
|
|
||||||
passed_days = 0
|
|
||||||
oneDay = 60*60*24
|
|
||||||
to_return = []
|
|
||||||
curr_to_return = 0
|
|
||||||
for timestamp in range(startDate, startDate - max(num_day)*oneDay, -oneDay):
|
|
||||||
value = r_serv_corpus.hget(timestamp, word)
|
|
||||||
curr_to_return += int(value) if value is not None else 0
|
|
||||||
for i in num_day:
|
|
||||||
if passed_days == i-1:
|
|
||||||
to_return.append(curr_to_return)
|
|
||||||
passed_days += 1
|
|
||||||
return to_return
|
|
||||||
|
|
||||||
|
|
||||||
# ============ ROUTES ============
|
|
||||||
|
|
||||||
@app.route("/corpus_management/")
|
|
||||||
def corpus_management():
|
|
||||||
TrackedCorpusSet_Name = "TrackedSetCorpusSet"
|
|
||||||
TrackedCorpusDate_Name = "TrackedCorpusDate"
|
|
||||||
|
|
||||||
today = datetime.datetime.now()
|
|
||||||
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
today_timestamp = calendar.timegm(today.timetuple())
|
|
||||||
|
|
||||||
track_list = []
|
|
||||||
track_list_values = []
|
|
||||||
track_list_num_of_paste = []
|
|
||||||
for tracked_corpus in r_serv_corpus.smembers(TrackedCorpusSet_Name):
|
|
||||||
track_list.append(tracked_corpus)
|
|
||||||
value_range = Corpus_getValueOverRange(tracked_corpus, today_timestamp, [1, 7, 31])
|
|
||||||
|
|
||||||
corpus_date = r_serv_corpus.hget(TrackedCorpusDate_Name, tracked_corpus)
|
|
||||||
|
|
||||||
set_paste_name = "tracked_" + tracked_corpus
|
|
||||||
track_list_num_of_paste.append(r_serv_corpus.scard(set_paste_name))
|
|
||||||
corpus_date = datetime.datetime.utcfromtimestamp(int(corpus_date)) if corpus_date is not None else "No date recorded"
|
|
||||||
value_range.append(corpus_date)
|
|
||||||
track_list_values.append(value_range)
|
|
||||||
|
|
||||||
|
|
||||||
return render_template("corpus_management.html", black_list=black_list, track_list=track_list, track_list_values=track_list_values, track_list_num_of_paste=track_list_num_of_paste)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_management_query_paste/")
|
|
||||||
def corpus_management_query_paste():
|
|
||||||
corpus = request.args.get('corpus')
|
|
||||||
TrackedCorpusSet_Name = "TrackedSetCorpusSet"
|
|
||||||
paste_info = []
|
|
||||||
|
|
||||||
set_paste_name = "tracked_" + corpus
|
|
||||||
track_list_path = r_serv_corpus.smembers(set_paste_name)
|
|
||||||
|
|
||||||
for path in track_list_path:
|
|
||||||
paste = Paste.Paste(path)
|
|
||||||
p_date = str(paste._get_p_date())
|
|
||||||
p_date = p_date[6:]+'/'+p_date[4:6]+'/'+p_date[0:4]
|
|
||||||
p_source = paste.p_source
|
|
||||||
p_encoding = paste._get_p_encoding()
|
|
||||||
p_size = paste.p_size
|
|
||||||
p_mime = paste.p_mime
|
|
||||||
p_lineinfo = paste.get_lines_info()
|
|
||||||
p_content = paste.get_p_content().decode('utf-8', 'ignore')
|
|
||||||
if p_content != 0:
|
|
||||||
p_content = p_content[0:400]
|
|
||||||
paste_info.append({"path": path, "date": p_date, "source": p_source, "encoding": p_encoding, "size": p_size, "mime": p_mime, "lineinfo": p_lineinfo, "content": p_content})
|
|
||||||
|
|
||||||
return jsonify(paste_info)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_management_query/")
|
|
||||||
def corpus_management_query():
|
|
||||||
TrackedCorpusDate_Name = "TrackedCorpusDate"
|
|
||||||
corpus = request.args.get('corpus')
|
|
||||||
|
|
||||||
today = datetime.datetime.now()
|
|
||||||
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
today_timestamp = calendar.timegm(today.timetuple())
|
|
||||||
value_range = corpus_getValueOverRange(corpus, today_timestamp, [1, 7, 31])
|
|
||||||
|
|
||||||
corpus_date = r_serv_corpus.hget(TrackedCorpusDate_Name, corpus)
|
|
||||||
|
|
||||||
corpus_date = datetime.datetime.utcfromtimestamp(int(corpus_date)) if corpus_date is not None else "No date recorded"
|
|
||||||
value_range.append(str(corpus_date))
|
|
||||||
return jsonify(value_range)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_management_action/", methods=['GET'])
|
|
||||||
def corpus_management_action():
|
|
||||||
TrackedCorpusSet_Name = "TrackedSetCorpusSet"
|
|
||||||
TrackedCorpusDate_Name = "TrackedCorpusDate"
|
|
||||||
|
|
||||||
today = datetime.datetime.now()
|
|
||||||
today = today.replace(microsecond=0)
|
|
||||||
today_timestamp = calendar.timegm(today.timetuple())
|
|
||||||
|
|
||||||
|
|
||||||
section = request.args.get('section')
|
|
||||||
action = request.args.get('action')
|
|
||||||
corpus = request.args.get('corpus')
|
|
||||||
if action is None or corpus is None:
|
|
||||||
return "None"
|
|
||||||
else:
|
|
||||||
if section == "followCorpus":
|
|
||||||
if action == "add":
|
|
||||||
r_serv_corpus.sadd(TrackedCorpusSet_Name, corpus.lower())
|
|
||||||
r_serv_corpus.hset(TrackedCorpusDate_Name, corpus, today_timestamp)
|
|
||||||
else:
|
|
||||||
r_serv_corpus.srem(TrackedCorpusSet_Name, corpus.lower())
|
|
||||||
else:
|
|
||||||
return "None"
|
|
||||||
|
|
||||||
to_return = {}
|
|
||||||
to_return["section"] = section
|
|
||||||
to_return["action"] = action
|
|
||||||
to_return["corpus"] = corpus
|
|
||||||
return jsonify(to_return)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_plot_tool/")
|
|
||||||
def corpus_plot_tool():
|
|
||||||
corpus = request.args.get('corpus')
|
|
||||||
if corpus is not None:
|
|
||||||
return render_template("corpus_plot_tool.html", corpus=corpus)
|
|
||||||
else:
|
|
||||||
return render_template("corpus_plot_tool.html", corpus="")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_plot_tool_data/")
|
|
||||||
def corpus_plot_tool_data():
|
|
||||||
oneDay = 60*60*24
|
|
||||||
range_start = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_start')))) if request.args.get('range_start') is not None else 0;
|
|
||||||
range_start = range_start.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
range_start = calendar.timegm(range_start.timetuple())
|
|
||||||
range_end = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_end')))) if request.args.get('range_end') is not None else 0;
|
|
||||||
range_end = range_end.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
range_end = calendar.timegm(range_end.timetuple())
|
|
||||||
corpus = request.args.get('corpus')
|
|
||||||
|
|
||||||
if corpus is None:
|
|
||||||
return "None"
|
|
||||||
else:
|
|
||||||
value_range = []
|
|
||||||
for timestamp in range(range_start, range_end+oneDay, oneDay):
|
|
||||||
value = r_serv_corpus.hget(timestamp, corpus)
|
|
||||||
curr_value_range = int(value) if value is not None else 0
|
|
||||||
value_range.append([timestamp, curr_value_range])
|
|
||||||
value_range.insert(0,corpus)
|
|
||||||
return jsonify(value_range)
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_plot_top/")
|
|
||||||
def corpus_plot_top():
|
|
||||||
return render_template("corpus_plot_top.html")
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/corpus_plot_top_data/")
|
|
||||||
def corpus_plot_top_data():
|
|
||||||
oneDay = 60*60*24
|
|
||||||
today = datetime.datetime.now()
|
|
||||||
today = today.replace(hour=0, minute=0, second=0, microsecond=0)
|
|
||||||
today_timestamp = calendar.timegm(today.timetuple())
|
|
||||||
|
|
||||||
set_day = "TopCorpusFreq_set_day_" + str(today_timestamp)
|
|
||||||
set_week = "TopCorpusFreq_set_week";
|
|
||||||
set_month = "TopCorpusFreq_set_month";
|
|
||||||
|
|
||||||
the_set = request.args.get('set')
|
|
||||||
num_day = int(request.args.get('num_day'))
|
|
||||||
if the_set is None:
|
|
||||||
return "None"
|
|
||||||
else:
|
|
||||||
to_return = []
|
|
||||||
if the_set == "TopCorpusFreq_set_day":
|
|
||||||
the_set += "_" + str(today_timestamp)
|
|
||||||
|
|
||||||
for corpus, tot_value in r_serv_corpus.zrevrangebyscore(the_set, '+inf', '-inf', withscores=True, start=0, num=20):
|
|
||||||
position = {}
|
|
||||||
position['day'] = r_serv_corpus.zrevrank(set_day, corpus)
|
|
||||||
position['day'] = position['day']+1 if position['day'] is not None else "<20"
|
|
||||||
position['week'] = r_serv_corpus.zrevrank(set_week, corpus)
|
|
||||||
position['week'] = position['week']+1 if position['week'] is not None else "<20"
|
|
||||||
position['month'] = r_serv_corpus.zrevrank(set_month, corpus)
|
|
||||||
position['month'] = position['month']+1 if position['month'] is not None else "<20"
|
|
||||||
value_range = []
|
|
||||||
for timestamp in range(today_timestamp, today_timestamp - num_day*oneDay, -oneDay):
|
|
||||||
value = r_serv_corpus.hget(timestamp, corpus)
|
|
||||||
curr_value_range = int(value) if value is not None else 0
|
|
||||||
value_range.append([timestamp, curr_value_range])
|
|
||||||
|
|
||||||
to_return.append([corpus, value_range, tot_value, position])
|
|
||||||
|
|
||||||
return jsonify(to_return)
|
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -130,7 +130,7 @@
|
||||||
$("#"+activePage).addClass("active");
|
$("#"+activePage).addClass("active");
|
||||||
|
|
||||||
var dataPath = 'credential';
|
var dataPath = 'credential';
|
||||||
$.get("{{ url_for('importantPasteByModule') }}"+"?moduleName="+dataPath, function(data, status){
|
$.get("{{ url_for('browsepastes.importantPasteByModule') }}"+"?moduleName="+dataPath, function(data, status){
|
||||||
$('#'+dataPath+'-tab').html(data);
|
$('#'+dataPath+'-tab').html(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -144,7 +144,7 @@ var loading_gif = "<img id='loading-gif-modal' class='img-center' src=\"{{url_fo
|
||||||
|
|
||||||
$('.nav-tabs a').on('shown.bs.tab', function(event){
|
$('.nav-tabs a').on('shown.bs.tab', function(event){
|
||||||
var dataPath = $(event.target).attr('data-attribute-name');
|
var dataPath = $(event.target).attr('data-attribute-name');
|
||||||
$.get("{{ url_for('importantPasteByModule') }}"+"?moduleName="+dataPath, function(data, status){
|
$.get("{{ url_for('browsepastes.importantPasteByModule') }}"+"?moduleName="+dataPath, function(data, status){
|
||||||
var currentTab = $('[name].active').children();
|
var currentTab = $('[name].active').children();
|
||||||
$('#'+previous_tab.attr('data-attribute-name')+'-tab').html(loading_gif);
|
$('#'+previous_tab.attr('data-attribute-name')+'-tab').html(loading_gif);
|
||||||
currentTab.removeClass( "active" );
|
currentTab.removeClass( "active" );
|
|
@ -13,10 +13,10 @@
|
||||||
{% for path in all_path %}
|
{% for path in all_path %}
|
||||||
<tr>
|
<tr>
|
||||||
<td> {{ i + 1 }}</td>
|
<td> {{ i + 1 }}</td>
|
||||||
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{path}}&num={{i+1}}">{{ path }}</a></td>
|
<td><a target="_blank" href="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{path}}&num={{i+1}}">{{ path }}</a></td>
|
||||||
<td>{{ paste_date[i] }}</td>
|
<td>{{ paste_date[i] }}</td>
|
||||||
<td>{{ paste_linenum[i] }}</td>
|
<td>{{ paste_linenum[i] }}</td>
|
||||||
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ content[i] }} "></span> <button type="button" class="btn-link" data-num="{{ i + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ i+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ content[i] }} "></span> <button type="button" class="btn-link" data-num="{{ i + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{ path }}&num={{ i+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% set i = i + 1 %}
|
{% set i = i + 1 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -47,7 +47,7 @@ function deploy_source() {
|
||||||
if(typeof(EventSource) !== "undefined" && typeof(source) !== "") {
|
if(typeof(EventSource) !== "undefined" && typeof(source) !== "") {
|
||||||
$("#load_more_json_button1").show();
|
$("#load_more_json_button1").show();
|
||||||
$("#load_more_json_button2").show();
|
$("#load_more_json_button2").show();
|
||||||
var source = new EventSource("{{ url_for('getImportantPasteByModule') }}"+"?moduleName="+moduleName);
|
var source = new EventSource("{{ url_for('browsepastes.getImportantPasteByModule') }}"+"?moduleName="+moduleName);
|
||||||
source.onmessage = function(event) {
|
source.onmessage = function(event) {
|
||||||
var feed = jQuery.parseJSON( event.data );
|
var feed = jQuery.parseJSON( event.data );
|
||||||
curr_numElem = parseInt($("#myTable_"+moduleName).attr('data-numElem'));
|
curr_numElem = parseInt($("#myTable_"+moduleName).attr('data-numElem'));
|
||||||
|
@ -93,10 +93,10 @@ function add_entries_X(to_add) {
|
||||||
elem_added++;
|
elem_added++;
|
||||||
search_table.row.add( [
|
search_table.row.add( [
|
||||||
feed.index,
|
feed.index,
|
||||||
"<a target=\"_blank\" href=\"{{ url_for('showsavedpaste') }}?paste="+feed.path+"&num="+feed.index+"\"> "+ feed.path +"</a>",
|
"<a target=\"_blank\" href=\"{{ url_for('showsavedpastes.showsavedpaste') }}?paste="+feed.path+"&num="+feed.index+"\"> "+ feed.path +"</a>",
|
||||||
feed.date,
|
feed.date,
|
||||||
feed.linenum,
|
feed.linenum,
|
||||||
"<p><span class=\"glyphicon glyphicon-info-sign\" data-toggle=\"tooltip\" data-placement=\"left\" title=\""+feed.content.replace(/\"/g, "\'").replace(/\r/g, "\'").replace(/\n/g, "\'")+"\"></span> <button type=\"button\" class=\"btn-link\" data-num=\""+feed.index+"\" data-toggle=\"modal\" data-target=\"#mymodal\" data-url=\"{{ url_for('showsavedpaste') }}?paste="+feed.path+"&num="+feed.index+"\" data-path=\""+feed.path+"\"><span class=\"fa fa-search-plus\"></span></button></p>"
|
"<p><span class=\"glyphicon glyphicon-info-sign\" data-toggle=\"tooltip\" data-placement=\"left\" title=\""+feed.content.replace(/\"/g, "\'").replace(/\r/g, "\'").replace(/\n/g, "\'")+"\"></span> <button type=\"button\" class=\"btn-link\" data-num=\""+feed.index+"\" data-toggle=\"modal\" data-target=\"#mymodal\" data-url=\"{{ url_for('showsavedpastes.showsavedpaste') }}?paste="+feed.path+"&num="+feed.index+"\" data-path=\""+feed.path+"\"><span class=\"fa fa-search-plus\"></span></button></p>"
|
||||||
] ).draw( false );
|
] ).draw( false );
|
||||||
$("#myTable_"+moduleName).attr('data-numElem', curr_numElem+1);
|
$("#myTable_"+moduleName).attr('data-numElem', curr_numElem+1);
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ $(document).ready(function(){
|
||||||
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var modal=$(this);
|
var modal=$(this);
|
||||||
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
var url = " {{ url_for('showsavedpastes.showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
||||||
last_clicked_paste = $(this).attr('data-num');
|
last_clicked_paste = $(this).attr('data-num');
|
||||||
$.get(url, function (data) {
|
$.get(url, function (data) {
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ $(document).ready(function(){
|
||||||
// On click, donwload all paste's content
|
// On click, donwload all paste's content
|
||||||
$("#load-more-button").on("click", function (event) {
|
$("#load-more-button").on("click", function (event) {
|
||||||
if (complete_paste == null) { //Donwload only once
|
if (complete_paste == null) { //Donwload only once
|
||||||
$.get("{{ url_for('getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
|
$.get("{{ url_for('showsavedpastes.getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
|
||||||
complete_paste = data;
|
complete_paste = data;
|
||||||
update_preview();
|
update_preview();
|
||||||
});
|
});
|
|
@ -8,7 +8,7 @@ import json
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
|
|
||||||
# ============ VARIABLES ============
|
# ============ VARIABLES ============
|
||||||
import Flask_config
|
import Flask_config
|
||||||
|
@ -17,6 +17,9 @@ app = Flask_config.app
|
||||||
cfg = Flask_config.cfg
|
cfg = Flask_config.cfg
|
||||||
r_serv = Flask_config.r_serv
|
r_serv = Flask_config.r_serv
|
||||||
r_serv_log = Flask_config.r_serv_log
|
r_serv_log = Flask_config.r_serv_log
|
||||||
|
|
||||||
|
dashboard = Blueprint('dashboard', __name__, template_folder='templates')
|
||||||
|
|
||||||
# ============ FUNCTIONS ============
|
# ============ FUNCTIONS ============
|
||||||
|
|
||||||
def event_stream():
|
def event_stream():
|
||||||
|
@ -51,18 +54,21 @@ def get_queues(r):
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/_logs")
|
@dashboard.route("/_logs")
|
||||||
def logs():
|
def logs():
|
||||||
return flask.Response(event_stream(), mimetype="text/event-stream")
|
return flask.Response(event_stream(), mimetype="text/event-stream")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/_stuff", methods=['GET'])
|
@dashboard.route("/_stuff", methods=['GET'])
|
||||||
def stuff():
|
def stuff():
|
||||||
return jsonify(row1=get_queues(r_serv))
|
return jsonify(row1=get_queues(r_serv))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/")
|
@dashboard.route("/")
|
||||||
def index():
|
def index():
|
||||||
default_minute = cfg.get("Flask", "minute_processed_paste")
|
default_minute = cfg.get("Flask", "minute_processed_paste")
|
||||||
threshold_stucked_module = cfg.getint("Module_ModuleInformation", "threshold_stucked_module")
|
threshold_stucked_module = cfg.getint("Module_ModuleInformation", "threshold_stucked_module")
|
||||||
return render_template("index.html", default_minute = default_minute, threshold_stucked_module=threshold_stucked_module)
|
return render_template("index.html", default_minute = default_minute, threshold_stucked_module=threshold_stucked_module)
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(dashboard)
|
|
@ -43,7 +43,7 @@
|
||||||
<div class="sidebar-collapse">
|
<div class="sidebar-collapse">
|
||||||
<ul class="nav" id="side-menu">
|
<ul class="nav" id="side-menu">
|
||||||
<li class="sidebar-search">
|
<li class="sidebar-search">
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
{% include 'searchbox.html' %}
|
{% include 'searchbox.html' %}
|
||||||
<!-- /input-group -->
|
<!-- /input-group -->
|
||||||
</li>
|
</li>
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="table-responsive", id="queueing" style="margin-top:10px; font-size: small;"></div>
|
<div class="table-responsive", id="queueing" style="margin-top:10px; font-size: small;"></div>
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -176,7 +176,7 @@
|
||||||
<!-- /#page-wrapper -->
|
<!-- /#page-wrapper -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script> var url_showSavedPath = "{{ url_for('showsavedpaste') }}"; </script>
|
<script> var url_showSavedPath = "{{ url_for('showsavedpastes.showsavedpaste') }}"; </script>
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='js/indexjavascript.js')}}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='js/indexjavascript.js')}}"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
|
@ -9,7 +9,7 @@ import json
|
||||||
import os
|
import os
|
||||||
import datetime
|
import datetime
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
|
|
||||||
import Paste
|
import Paste
|
||||||
from whoosh import index
|
from whoosh import index
|
||||||
|
@ -30,6 +30,8 @@ baseindexpath = os.path.join(os.environ['AIL_HOME'], cfg.get("Indexer", "path"))
|
||||||
indexRegister_path = os.path.join(os.environ['AIL_HOME'],
|
indexRegister_path = os.path.join(os.environ['AIL_HOME'],
|
||||||
cfg.get("Indexer", "register"))
|
cfg.get("Indexer", "register"))
|
||||||
|
|
||||||
|
searches = Blueprint('searches', __name__, template_folder='templates')
|
||||||
|
|
||||||
# ============ FUNCTIONS ============
|
# ============ FUNCTIONS ============
|
||||||
def get_current_index():
|
def get_current_index():
|
||||||
with open(indexRegister_path, "r") as f:
|
with open(indexRegister_path, "r") as f:
|
||||||
|
@ -84,7 +86,7 @@ def to_iso_date(timestamp):
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/search", methods=['POST'])
|
@searches.route("/search", methods=['POST'])
|
||||||
def search():
|
def search():
|
||||||
query = request.form['query']
|
query = request.form['query']
|
||||||
q = []
|
q = []
|
||||||
|
@ -144,7 +146,7 @@ def search():
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/get_more_search_result", methods=['POST'])
|
@searches.route("/get_more_search_result", methods=['POST'])
|
||||||
def get_more_search_result():
|
def get_more_search_result():
|
||||||
query = request.form['query']
|
query = request.form['query']
|
||||||
q = []
|
q = []
|
||||||
|
@ -193,3 +195,5 @@ def get_more_search_result():
|
||||||
return jsonify(to_return)
|
return jsonify(to_return)
|
||||||
|
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(searches)
|
|
@ -49,7 +49,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -113,10 +113,10 @@
|
||||||
{% for path in r %}
|
{% for path in r %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ loop.index0 + 1 }}</td>
|
<td>{{ loop.index0 + 1 }}</td>
|
||||||
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ loop.index0+1 }}"> {{ path }}</a></td>
|
<td><a target="_blank" href="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{ path }}&num={{ loop.index0+1 }}"> {{ path }}</a></td>
|
||||||
<td>{{ paste_date[loop.index0] }}</td>
|
<td>{{ paste_date[loop.index0] }}</td>
|
||||||
<td>{{ paste_size[loop.index0] }}</td>
|
<td>{{ paste_size[loop.index0] }}</td>
|
||||||
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ c[loop.index0] }}"></span> <button type="button" class="btn-link" data-num="{{ loop.index0 + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpaste') }}?paste={{ path }}&num={{ loop.index0+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
<td><p><span class="glyphicon glyphicon-info-sign" data-toggle="tooltip" data-placement="left" title="{{ c[loop.index0] }}"></span> <button type="button" class="btn-link" data-num="{{ loop.index0 + 1 }}" data-toggle="modal" data-target="#mymodal" data-url="{{ url_for('showsavedpastes.showsavedpaste') }}?paste={{ path }}&num={{ loop.index0+1 }}" data-path="{{ path }}"><span class="fa fa-search-plus"></span></button></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
$('#index_name').on('change', function() {
|
$('#index_name').on('change', function() {
|
||||||
var form = document.createElement('form');
|
var form = document.createElement('form');
|
||||||
form.setAttribute("method", 'post');
|
form.setAttribute("method", 'post');
|
||||||
form.setAttribute("action", "{{ url_for('search') }}");
|
form.setAttribute("action", "{{ url_for('searches.search') }}");
|
||||||
|
|
||||||
var input1 = document.createElement('input');
|
var input1 = document.createElement('input');
|
||||||
input1.setAttribute("type", "hidden");
|
input1.setAttribute("type", "hidden");
|
||||||
|
@ -202,16 +202,16 @@
|
||||||
|
|
||||||
function load_search_50_data() {
|
function load_search_50_data() {
|
||||||
var options = { query: query, page_offset: page_offset, index_name: $("#index_name").val() };
|
var options = { query: query, page_offset: page_offset, index_name: $("#index_name").val() };
|
||||||
$.post( "{{ url_for('get_more_search_result') }}", options).done(function( data ) {
|
$.post( "{{ url_for('searches.get_more_search_result') }}", options).done(function( data ) {
|
||||||
|
|
||||||
for(i=0; i<data.path_array.length; i++) {
|
for(i=0; i<data.path_array.length; i++) {
|
||||||
var curr_preview = data.preview_array[i].replace(/\"/g, "\'");
|
var curr_preview = data.preview_array[i].replace(/\"/g, "\'");
|
||||||
search_table.row.add( [
|
search_table.row.add( [
|
||||||
init_num_of_elements_in_table+((offset))+i+1,
|
init_num_of_elements_in_table+((offset))+i+1,
|
||||||
"<a target=\"_blank\" href=\"{{ url_for('showsavedpaste') }}?paste="+data.path_array[i]+"&num="+i+"\"> "+ data.path_array[i] +"</a>",
|
"<a target=\"_blank\" href=\"{{ url_for('showsavedpastes.showsavedpaste') }}?paste="+data.path_array[i]+"&num="+i+"\"> "+ data.path_array[i] +"</a>",
|
||||||
data.date_array[i],
|
data.date_array[i],
|
||||||
data.size_array[i],
|
data.size_array[i],
|
||||||
"<p><span class=\"glyphicon glyphicon-info-sign\" data-toggle=\"tooltip\" data-placement=\"left\" title=\""+curr_preview+"\"></span> <button type=\"button\" class=\"btn-link\" data-num=\""+i+"\" data-toggle=\"modal\" data-target=\"#mymodal\" data-url=\"{{ url_for('showsavedpaste') }}?paste="+data.path_array[i]+"&num="+i+"\" data-path=\""+data.path_array[i]+"\"><span class=\"fa fa-search-plus\"></span></button></p>"
|
"<p><span class=\"glyphicon glyphicon-info-sign\" data-toggle=\"tooltip\" data-placement=\"left\" title=\""+curr_preview+"\"></span> <button type=\"button\" class=\"btn-link\" data-num=\""+i+"\" data-toggle=\"modal\" data-target=\"#mymodal\" data-url=\"{{ url_for('showsavedpastes.showsavedpaste') }}?paste="+data.path_array[i]+"&num="+i+"\" data-path=\""+data.path_array[i]+"\"><span class=\"fa fa-search-plus\"></span></button></p>"
|
||||||
] ).draw( false );
|
] ).draw( false );
|
||||||
}
|
}
|
||||||
offset = offset + data.path_array.length;
|
offset = offset + data.path_array.length;
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
// On click, get html content from url and update the corresponding modal
|
// On click, get html content from url and update the corresponding modal
|
||||||
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
$("[data-toggle='modal']").off('click.openmodal').on("click.openmodal", function (event) {
|
||||||
var modal=$(this);
|
var modal=$(this);
|
||||||
var url = " {{ url_for('showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
var url = " {{ url_for('showsavedpastes.showpreviewpaste') }}?paste=" + $(this).attr('data-path') + "&num=" + $(this).attr('data-num');
|
||||||
last_clicked_paste = $(this).attr('data-num');
|
last_clicked_paste = $(this).attr('data-num');
|
||||||
$.get(url, function (data) {
|
$.get(url, function (data) {
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@
|
||||||
// On click, donwload all paste's content
|
// On click, donwload all paste's content
|
||||||
$("#load-more-button").off('click.download').on("click.download", function (event) {
|
$("#load-more-button").off('click.download').on("click.download", function (event) {
|
||||||
if (complete_paste == null) { //Donwload only once
|
if (complete_paste == null) { //Donwload only once
|
||||||
$.get("{{ url_for('getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
|
$.get("{{ url_for('showsavedpastes.getmoredata') }}"+"?paste="+$(modal).attr('data-path'), function(data, status){
|
||||||
complete_paste = data;
|
complete_paste = data;
|
||||||
update_preview();
|
update_preview();
|
||||||
});
|
});
|
|
@ -9,7 +9,7 @@ import datetime
|
||||||
import calendar
|
import calendar
|
||||||
from Date import Date
|
from Date import Date
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
|
|
||||||
import Paste
|
import Paste
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ app = Flask_config.app
|
||||||
cfg = Flask_config.cfg
|
cfg = Flask_config.cfg
|
||||||
r_serv_charts = Flask_config.r_serv_charts
|
r_serv_charts = Flask_config.r_serv_charts
|
||||||
r_serv_sentiment = Flask_config.r_serv_sentiment
|
r_serv_sentiment = Flask_config.r_serv_sentiment
|
||||||
|
|
||||||
|
sentiments = Blueprint('sentiments', __name__, template_folder='templates')
|
||||||
|
|
||||||
# ============ FUNCTIONS ============
|
# ============ FUNCTIONS ============
|
||||||
|
|
||||||
def get_date_range(num_day):
|
def get_date_range(num_day):
|
||||||
|
@ -34,12 +37,12 @@ def get_date_range(num_day):
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/sentiment_analysis_trending/")
|
@sentiments.route("/sentiment_analysis_trending/")
|
||||||
def sentiment_analysis_trending():
|
def sentiment_analysis_trending():
|
||||||
return render_template("sentiment_analysis_trending.html")
|
return render_template("sentiment_analysis_trending.html")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sentiment_analysis_getplotdata/", methods=['GET'])
|
@sentiments.route("/sentiment_analysis_getplotdata/", methods=['GET'])
|
||||||
def sentiment_analysis_getplotdata():
|
def sentiment_analysis_getplotdata():
|
||||||
# Get the top providers based on number of pastes
|
# Get the top providers based on number of pastes
|
||||||
oneHour = 60*60
|
oneHour = 60*60
|
||||||
|
@ -85,13 +88,13 @@ def sentiment_analysis_getplotdata():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sentiment_analysis_plot_tool/")
|
@sentiments.route("/sentiment_analysis_plot_tool/")
|
||||||
def sentiment_analysis_plot_tool():
|
def sentiment_analysis_plot_tool():
|
||||||
return render_template("sentiment_analysis_plot_tool.html")
|
return render_template("sentiment_analysis_plot_tool.html")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/sentiment_analysis_plot_tool_getdata/", methods=['GET'])
|
@sentiments.route("/sentiment_analysis_plot_tool_getdata/", methods=['GET'])
|
||||||
def sentiment_analysis_plot_tool_getdata():
|
def sentiment_analysis_plot_tool_getdata():
|
||||||
getProviders = request.args.get('getProviders')
|
getProviders = request.args.get('getProviders')
|
||||||
|
|
||||||
|
@ -134,4 +137,5 @@ def sentiment_analysis_plot_tool_getdata():
|
||||||
|
|
||||||
return jsonify(to_return)
|
return jsonify(to_return)
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(sentiments)
|
|
@ -45,7 +45,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
|
@ -98,7 +98,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
|
@ -7,7 +7,7 @@
|
||||||
import redis
|
import redis
|
||||||
import json
|
import json
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
|
|
||||||
import Paste
|
import Paste
|
||||||
|
|
||||||
|
@ -20,6 +20,9 @@ r_serv_pasteName = Flask_config.r_serv_pasteName
|
||||||
max_preview_char = Flask_config.max_preview_char
|
max_preview_char = Flask_config.max_preview_char
|
||||||
max_preview_modal = Flask_config.max_preview_modal
|
max_preview_modal = Flask_config.max_preview_modal
|
||||||
tlsh_to_percent = Flask_config.tlsh_to_percent
|
tlsh_to_percent = Flask_config.tlsh_to_percent
|
||||||
|
|
||||||
|
showsavedpastes = Blueprint('showsavedpastes', __name__, template_folder='templates')
|
||||||
|
|
||||||
# ============ FUNCTIONS ============
|
# ============ FUNCTIONS ============
|
||||||
|
|
||||||
def showpaste(content_range):
|
def showpaste(content_range):
|
||||||
|
@ -89,22 +92,20 @@ def showpaste(content_range):
|
||||||
|
|
||||||
return render_template("show_saved_paste.html", date=p_date, source=p_source, encoding=p_encoding, language=p_language, size=p_size, mime=p_mime, lineinfo=p_lineinfo, content=p_content, initsize=len(p_content), duplicate_list = p_duplicate_list, simil_list = p_simil_list, hashtype_list = p_hashtype_list, date_list=p_date_list)
|
return render_template("show_saved_paste.html", date=p_date, source=p_source, encoding=p_encoding, language=p_language, size=p_size, mime=p_mime, lineinfo=p_lineinfo, content=p_content, initsize=len(p_content), duplicate_list = p_duplicate_list, simil_list = p_simil_list, hashtype_list = p_hashtype_list, date_list=p_date_list)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/showsavedpaste/") #completely shows the paste in a new tab
|
@showsavedpastes.route("/showsavedpaste/") #completely shows the paste in a new tab
|
||||||
def showsavedpaste():
|
def showsavedpaste():
|
||||||
return showpaste(0)
|
return showpaste(0)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/showpreviewpaste/")
|
@showsavedpastes.route("/showpreviewpaste/")
|
||||||
def showpreviewpaste():
|
def showpreviewpaste():
|
||||||
num = request.args.get('num', '')
|
num = request.args.get('num', '')
|
||||||
return "|num|"+num+"|num|"+showpaste(max_preview_modal)
|
return "|num|"+num+"|num|"+showpaste(max_preview_modal)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/getmoredata/")
|
@showsavedpastes.route("/getmoredata/")
|
||||||
def getmoredata():
|
def getmoredata():
|
||||||
requested_path = request.args.get('paste', '')
|
requested_path = request.args.get('paste', '')
|
||||||
paste = Paste.Paste(requested_path)
|
paste = Paste.Paste(requested_path)
|
||||||
|
@ -112,3 +113,5 @@ def getmoredata():
|
||||||
to_return = p_content[max_preview_modal-1:]
|
to_return = p_content[max_preview_modal-1:]
|
||||||
return to_return
|
return to_return
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(showsavedpastes)
|
|
@ -71,7 +71,7 @@
|
||||||
<td>{{ hashtype_list[i] }}</td>
|
<td>{{ hashtype_list[i] }}</td>
|
||||||
<td>Similarity: {{ simil_list[i] }}%</td>
|
<td>Similarity: {{ simil_list[i] }}%</td>
|
||||||
<td>{{ date_list[i] }}</td>
|
<td>{{ date_list[i] }}</td>
|
||||||
<td><a target="_blank" href="{{ url_for('showsavedpaste') }}?paste={{ dup_path }}" id='dup_path'>{{ dup_path }}</a></td>
|
<td><a target="_blank" href="{{ url_for('showsavedpaste.showsavedpaste') }}?paste={{ dup_path }}" id='dup_path'>{{ dup_path }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% set i = i + 1 %}
|
{% set i = i + 1 %}
|
||||||
{% endfor %}
|
{% endfor %}
|
|
@ -8,7 +8,7 @@ import redis
|
||||||
import datetime
|
import datetime
|
||||||
import calendar
|
import calendar
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
import re
|
import re
|
||||||
import Paste
|
import Paste
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ app = Flask_config.app
|
||||||
cfg = Flask_config.cfg
|
cfg = Flask_config.cfg
|
||||||
r_serv_term = Flask_config.r_serv_term
|
r_serv_term = Flask_config.r_serv_term
|
||||||
|
|
||||||
|
terms = Blueprint('terms', __name__, template_folder='templates')
|
||||||
|
|
||||||
DEFAULT_MATCH_PERCENT = 50
|
DEFAULT_MATCH_PERCENT = 50
|
||||||
|
|
||||||
#tracked
|
#tracked
|
||||||
|
@ -53,7 +55,7 @@ def Term_getValueOverRange(word, startDate, num_day, per_paste=""):
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/terms_management/")
|
@terms.route("/terms_management/")
|
||||||
def terms_management():
|
def terms_management():
|
||||||
per_paste = request.args.get('per_paste')
|
per_paste = request.args.get('per_paste')
|
||||||
if per_paste == "1" or per_paste is None:
|
if per_paste == "1" or per_paste is None:
|
||||||
|
@ -131,7 +133,7 @@ def terms_management():
|
||||||
per_paste=per_paste)
|
per_paste=per_paste)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_management_query_paste/")
|
@terms.route("/terms_management_query_paste/")
|
||||||
def terms_management_query_paste():
|
def terms_management_query_paste():
|
||||||
term = request.args.get('term')
|
term = request.args.get('term')
|
||||||
paste_info = []
|
paste_info = []
|
||||||
|
@ -164,7 +166,7 @@ def terms_management_query_paste():
|
||||||
return jsonify(paste_info)
|
return jsonify(paste_info)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_management_query/")
|
@terms.route("/terms_management_query/")
|
||||||
def terms_management_query():
|
def terms_management_query():
|
||||||
TrackedTermsDate_Name = "TrackedTermDate"
|
TrackedTermsDate_Name = "TrackedTermDate"
|
||||||
BlackListTermsDate_Name = "BlackListTermDate"
|
BlackListTermsDate_Name = "BlackListTermDate"
|
||||||
|
@ -186,7 +188,7 @@ def terms_management_query():
|
||||||
return jsonify(value_range)
|
return jsonify(value_range)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_management_action/", methods=['GET'])
|
@terms.route("/terms_management_action/", methods=['GET'])
|
||||||
def terms_management_action():
|
def terms_management_action():
|
||||||
today = datetime.datetime.now()
|
today = datetime.datetime.now()
|
||||||
today = today.replace(microsecond=0)
|
today = today.replace(microsecond=0)
|
||||||
|
@ -254,7 +256,7 @@ def terms_management_action():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_plot_tool/")
|
@terms.route("/terms_plot_tool/")
|
||||||
def terms_plot_tool():
|
def terms_plot_tool():
|
||||||
term = request.args.get('term')
|
term = request.args.get('term')
|
||||||
if term is not None:
|
if term is not None:
|
||||||
|
@ -263,7 +265,7 @@ def terms_plot_tool():
|
||||||
return render_template("terms_plot_tool.html", term="")
|
return render_template("terms_plot_tool.html", term="")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_plot_tool_data/")
|
@terms.route("/terms_plot_tool_data/")
|
||||||
def terms_plot_tool_data():
|
def terms_plot_tool_data():
|
||||||
oneDay = 60*60*24
|
oneDay = 60*60*24
|
||||||
range_start = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_start')))) if request.args.get('range_start') is not None else 0;
|
range_start = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_start')))) if request.args.get('range_start') is not None else 0;
|
||||||
|
@ -293,14 +295,14 @@ def terms_plot_tool_data():
|
||||||
return jsonify(value_range)
|
return jsonify(value_range)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_plot_top/")
|
@terms.route("/terms_plot_top/")
|
||||||
def terms_plot_top():
|
def terms_plot_top():
|
||||||
per_paste = request.args.get('per_paste')
|
per_paste = request.args.get('per_paste')
|
||||||
per_paste = per_paste if per_paste is not None else 1
|
per_paste = per_paste if per_paste is not None else 1
|
||||||
return render_template("terms_plot_top.html", per_paste=per_paste)
|
return render_template("terms_plot_top.html", per_paste=per_paste)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/terms_plot_top_data/")
|
@terms.route("/terms_plot_top_data/")
|
||||||
def terms_plot_top_data():
|
def terms_plot_top_data():
|
||||||
oneDay = 60*60*24
|
oneDay = 60*60*24
|
||||||
today = datetime.datetime.now()
|
today = datetime.datetime.now()
|
||||||
|
@ -346,3 +348,5 @@ def terms_plot_top_data():
|
||||||
return jsonify(to_return)
|
return jsonify(to_return)
|
||||||
|
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(terms)
|
|
@ -71,7 +71,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
<script>
|
<script>
|
||||||
function reload_per_paste() {
|
function reload_per_paste() {
|
||||||
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
||||||
window.location.href = {{ url_for('terms_management') }}+"?per_paste="+checked;
|
window.location.href = {{ url_for('terms.terms_management') }}+"?per_paste="+checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
//console.log(data);
|
//console.log(data);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var the_modal=$(this);
|
var the_modal=$(this);
|
||||||
var url = "{{ url_for('terms_management_query_paste') }}?term=" + encodeURIComponent($(this).attr('data-term'));
|
var url = "{{ url_for('terms.terms_management_query_paste') }}?term=" + encodeURIComponent($(this).attr('data-term'));
|
||||||
$.getJSON(url, function (data) {
|
$.getJSON(url, function (data) {
|
||||||
if (data.length != 0) {
|
if (data.length != 0) {
|
||||||
var html_to_add = "";
|
var html_to_add = "";
|
||||||
|
@ -315,7 +315,7 @@
|
||||||
html_to_add += "<td>"+curr_data.size+"</td>";
|
html_to_add += "<td>"+curr_data.size+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.lineinfo[0]+"</td>";
|
html_to_add += "<td>"+curr_data.lineinfo[0]+"</td>";
|
||||||
html_to_add += "<td>"+curr_data.lineinfo[1]+"</td>";
|
html_to_add += "<td>"+curr_data.lineinfo[1]+"</td>";
|
||||||
html_to_add += "<td><div class=\"row\"><button class=\"btn btn-xs btn-default\" data-toggle=\"popover\" data-placement=\"left\" data-content=\""+curr_data.content.replace(/\"/g, "\'")+"\">Preview content</button><a target=\"_blank\" href=\"{{ url_for('showsavedpaste') }}?paste="+curr_data.path+"&num=0\"> <button type=\"button\" class=\"btn btn-xs btn-info\">Show Paste</button></a></div></td>";
|
html_to_add += "<td><div class=\"row\"><button class=\"btn btn-xs btn-default\" data-toggle=\"popover\" data-placement=\"left\" data-content=\""+curr_data.content.replace(/\"/g, "\'")+"\">Preview content</button><a target=\"_blank\" href=\"{{ url_for('showsavedpastes.showsavedpaste') }}?paste="+curr_data.path+"&num=0\"> <button type=\"button\" class=\"btn btn-xs btn-info\">Show Paste</button></a></div></td>";
|
||||||
|
|
||||||
html_to_add += "</tr>";
|
html_to_add += "</tr>";
|
||||||
}
|
}
|
||||||
|
@ -323,11 +323,11 @@
|
||||||
html_to_add += "</table>";
|
html_to_add += "</table>";
|
||||||
$("#mymodalbody").html(html_to_add);
|
$("#mymodalbody").html(html_to_add);
|
||||||
$("[data-toggle=popover]").popover();
|
$("[data-toggle=popover]").popover();
|
||||||
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
$("#button_show_plot").attr("href", "{{ url_for('terms.terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
||||||
$('#modal-table').DataTable();
|
$('#modal-table').DataTable();
|
||||||
} else {
|
} else {
|
||||||
$("#mymodalbody").html("No paste containing this term has been received yet.");
|
$("#mymodalbody").html("No paste containing this term has been received yet.");
|
||||||
$("#button_show_plot").attr("href", "{{ url_for('terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
$("#button_show_plot").attr("href", "{{ url_for('terms.terms_plot_tool')}}"+"?term="+the_modal.attr('data-term') );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -364,14 +364,14 @@ function perform_operation(){
|
||||||
|
|
||||||
if (curr_term != "") {
|
if (curr_term != "") {
|
||||||
console.log(data_to_send);
|
console.log(data_to_send);
|
||||||
$.get("{{ url_for('terms_management_action') }}", data_to_send, function(data, status){
|
$.get("{{ url_for('terms.terms_management_action') }}", data_to_send, function(data, status){
|
||||||
if(status == "success") {
|
if(status == "success") {
|
||||||
var json = data;
|
var json = data;
|
||||||
|
|
||||||
if(json.section == "followTerm") {
|
if(json.section == "followTerm") {
|
||||||
if(json.action == "add") {
|
if(json.action == "add") {
|
||||||
// query data
|
// query data
|
||||||
$.get("{{ url_for('terms_management_query') }}", { term: json.term, section: json.section }, function(data2, status){
|
$.get("{{ url_for('terms.terms_management_query') }}", { term: json.term, section: json.section }, function(data2, status){
|
||||||
var action_button = "<button class=\"btn-link btn-interaction\" data-toggle=\"tooltip\" data-placement=\"left\" title=\"Remove this term\" data-content=\"" + json.term + "\" data-section=\"followTerm\" data-action=\"delete\"><span class=\"glyphicon glyphicon-trash\"></span></button>"
|
var action_button = "<button class=\"btn-link btn-interaction\" data-toggle=\"tooltip\" data-placement=\"left\" title=\"Remove this term\" data-content=\"" + json.term + "\" data-section=\"followTerm\" data-action=\"delete\"><span class=\"glyphicon glyphicon-trash\"></span></button>"
|
||||||
table_track.row.add( [ json.term, data2[3], data2[0], data2[1], data2[2], 0, action_button ] ).draw( false );
|
table_track.row.add( [ json.term, data2[3], data2[0], data2[1], data2[2], 0, action_button ] ).draw( false );
|
||||||
perform_binding();
|
perform_binding();
|
||||||
|
@ -386,7 +386,7 @@ function perform_operation(){
|
||||||
}
|
}
|
||||||
} else if(json.section == "blacklistTerm"){
|
} else if(json.section == "blacklistTerm"){
|
||||||
if(json.action == "add") {
|
if(json.action == "add") {
|
||||||
$.get("{{ url_for('terms_management_query') }}", { term: json.term, section: json.section }, function(data2, status){
|
$.get("{{ url_for('terms.terms_management_query') }}", { term: json.term, section: json.section }, function(data2, status){
|
||||||
console.log(data2);
|
console.log(data2);
|
||||||
var action_button = "<button class=\"btn-link btn-interaction\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Remove this term\" data-content=\"" + json.term + "\" data-section=\"blacklistTerm\" data-action=\"delete\"><span class=\"glyphicon glyphicon-trash\"></span></button>"
|
var action_button = "<button class=\"btn-link btn-interaction\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Remove this term\" data-content=\"" + json.term + "\" data-section=\"blacklistTerm\" data-action=\"delete\"><span class=\"glyphicon glyphicon-trash\"></span></button>"
|
||||||
table_black.row.add( [ json.term, data2[3], action_button ] ).draw( false );
|
table_black.row.add( [ json.term, data2[3], action_button ] ).draw( false );
|
|
@ -46,7 +46,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -214,7 +214,7 @@ function plotData() {
|
||||||
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
||||||
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
||||||
|
|
||||||
$.getJSON("{{ url_for('terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term, per_paste: checked }, function(data, status){
|
$.getJSON("{{ url_for('terms.terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term, per_paste: checked }, function(data, status){
|
||||||
graph_data = [];
|
graph_data = [];
|
||||||
var to_plot = [];
|
var to_plot = [];
|
||||||
var curr_data = [];
|
var curr_data = [];
|
||||||
|
@ -252,7 +252,7 @@ function addData() {
|
||||||
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
||||||
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
||||||
|
|
||||||
$.getJSON("{{ url_for('terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term, per_paste: checked }, function(data, status){
|
$.getJSON("{{ url_for('terms.terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term, per_paste: checked }, function(data, status){
|
||||||
var curr_data = [];
|
var curr_data = [];
|
||||||
for(i=1; i<data.length; i++) {
|
for(i=1; i<data.length; i++) {
|
||||||
curr_data.push([data[i][0]*1000, data[i][1]]);
|
curr_data.push([data[i][0]*1000, data[i][1]]);
|
||||||
|
@ -273,7 +273,7 @@ function replot() {
|
||||||
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
||||||
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
||||||
|
|
||||||
promises.push($.getJSON("{{ url_for('terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term, per_paste: checked }, function(data, status){
|
promises.push($.getJSON("{{ url_for('terms.terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term, per_paste: checked }, function(data, status){
|
||||||
var curr_data = [];
|
var curr_data = [];
|
||||||
for(i=1; i<data.length; i++) {
|
for(i=1; i<data.length; i++) {
|
||||||
curr_data.push([data[i][0]*1000, data[i][1]]);
|
curr_data.push([data[i][0]*1000, data[i][1]]);
|
|
@ -47,7 +47,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -297,7 +297,7 @@
|
||||||
|
|
||||||
function reload_per_paste() {
|
function reload_per_paste() {
|
||||||
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
var checked = $("#per_paste").prop( "checked" ) ? 1 : 0;
|
||||||
window.location.href = {{ url_for('terms_plot_top') }}+"?per_paste="+checked;
|
window.location.href = {{ url_for('terms.terms_plot_top') }}+"?per_paste="+checked;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ var plot_month;
|
||||||
|
|
||||||
var promises = []; // Used to know when everything has been received
|
var promises = []; // Used to know when everything has been received
|
||||||
|
|
||||||
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today, num_day: 5, per_paste: per_paste }, function(data, status){
|
promises.push($.getJSON("{{ url_for('terms.terms_plot_top_data') }}", { set: set_today, num_day: 5, per_paste: per_paste }, function(data, status){
|
||||||
data.sort(function(a, b){return b[2]-a[2];});
|
data.sort(function(a, b){return b[2]-a[2];});
|
||||||
// Sort data
|
// Sort data
|
||||||
var table_today = $("#table-today")
|
var table_today = $("#table-today")
|
||||||
|
@ -398,7 +398,7 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week, num_day: 7, per_paste: per_paste }, function(data, status){
|
promises.push($.getJSON("{{ url_for('terms.terms_plot_top_data') }}", { set: set_week, num_day: 7, per_paste: per_paste }, function(data, status){
|
||||||
data.sort(function(a, b){return b[2]-a[2];});
|
data.sort(function(a, b){return b[2]-a[2];});
|
||||||
// Sort data
|
// Sort data
|
||||||
var table = $("#table-week")
|
var table = $("#table-week")
|
||||||
|
@ -438,7 +438,7 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week,
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month, num_day: 31, per_paste: per_paste }, function(data, status){
|
promises.push($.getJSON("{{ url_for('terms.terms_plot_top_data') }}", { set: set_month, num_day: 31, per_paste: per_paste }, function(data, status){
|
||||||
data.sort(function(a, b){return b[2]-a[2];});
|
data.sort(function(a, b){return b[2]-a[2];});
|
||||||
// Sort data
|
// Sort data
|
||||||
var table = $("#table-month")
|
var table = $("#table-month")
|
||||||
|
@ -507,7 +507,7 @@ function perform_operation(){
|
||||||
|
|
||||||
var data_to_send = { section: curr_section, action:"add", term: curr_term};
|
var data_to_send = { section: curr_section, action:"add", term: curr_term};
|
||||||
|
|
||||||
$.get("{{ url_for('terms_management_action') }}", data_to_send, function(data, status){
|
$.get("{{ url_for('terms.terms_management_action') }}", data_to_send, function(data, status){
|
||||||
if(status == "success") {
|
if(status == "success") {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ import redis
|
||||||
import datetime
|
import datetime
|
||||||
from Date import Date
|
from Date import Date
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
|
|
||||||
# ============ VARIABLES ============
|
# ============ VARIABLES ============
|
||||||
import Flask_config
|
import Flask_config
|
||||||
|
@ -16,6 +16,9 @@ import Flask_config
|
||||||
app = Flask_config.app
|
app = Flask_config.app
|
||||||
cfg = Flask_config.cfg
|
cfg = Flask_config.cfg
|
||||||
r_serv_charts = Flask_config.r_serv_charts
|
r_serv_charts = Flask_config.r_serv_charts
|
||||||
|
|
||||||
|
trendings = Blueprint('trendings', __name__, template_folder='templates')
|
||||||
|
|
||||||
# ============ FUNCTIONS ============
|
# ============ FUNCTIONS ============
|
||||||
|
|
||||||
def get_date_range(num_day):
|
def get_date_range(num_day):
|
||||||
|
@ -30,7 +33,7 @@ def get_date_range(num_day):
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/_progressionCharts", methods=['GET'])
|
@trendings.route("/_progressionCharts", methods=['GET'])
|
||||||
def progressionCharts():
|
def progressionCharts():
|
||||||
attribute_name = request.args.get('attributeName')
|
attribute_name = request.args.get('attributeName')
|
||||||
trending_name = request.args.get('trendingName')
|
trending_name = request.args.get('trendingName')
|
||||||
|
@ -53,21 +56,23 @@ def progressionCharts():
|
||||||
keyw_value = r_serv_charts.zrevrangebyscore(redis_progression_name, '+inf', '-inf', withscores=True, start=0, num=10)
|
keyw_value = r_serv_charts.zrevrangebyscore(redis_progression_name, '+inf', '-inf', withscores=True, start=0, num=10)
|
||||||
return jsonify(keyw_value)
|
return jsonify(keyw_value)
|
||||||
|
|
||||||
@app.route("/wordstrending/")
|
@trendings.route("/wordstrending/")
|
||||||
def wordstrending():
|
def wordstrending():
|
||||||
default_display = cfg.get("Flask", "default_display")
|
default_display = cfg.get("Flask", "default_display")
|
||||||
return render_template("Wordstrending.html", default_display = default_display)
|
return render_template("Wordstrending.html", default_display = default_display)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/protocolstrending/")
|
@trendings.route("/protocolstrending/")
|
||||||
def protocolstrending():
|
def protocolstrending():
|
||||||
default_display = cfg.get("Flask", "default_display")
|
default_display = cfg.get("Flask", "default_display")
|
||||||
return render_template("Protocolstrending.html", default_display = default_display)
|
return render_template("Protocolstrending.html", default_display = default_display)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/trending/")
|
@trendings.route("/trending/")
|
||||||
def trending():
|
def trending():
|
||||||
default_display = cfg.get("Flask", "default_display")
|
default_display = cfg.get("Flask", "default_display")
|
||||||
return render_template("Trending.html", default_display = default_display)
|
return render_template("Trending.html", default_display = default_display)
|
||||||
|
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(trendings)
|
|
@ -44,7 +44,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
|
@ -8,7 +8,7 @@ import redis
|
||||||
import datetime
|
import datetime
|
||||||
from Date import Date
|
from Date import Date
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request
|
from flask import Flask, render_template, jsonify, request, Blueprint
|
||||||
|
|
||||||
# ============ VARIABLES ============
|
# ============ VARIABLES ============
|
||||||
import Flask_config
|
import Flask_config
|
||||||
|
@ -16,6 +16,9 @@ import Flask_config
|
||||||
app = Flask_config.app
|
app = Flask_config.app
|
||||||
cfg = Flask_config.cfg
|
cfg = Flask_config.cfg
|
||||||
r_serv_charts = Flask_config.r_serv_charts
|
r_serv_charts = Flask_config.r_serv_charts
|
||||||
|
|
||||||
|
trendingmodules = Blueprint('trendingmodules', __name__, template_folder='templates')
|
||||||
|
|
||||||
# ============ FUNCTIONS ============
|
# ============ FUNCTIONS ============
|
||||||
|
|
||||||
# Iterate over elements in the module provided and return the today data or the last data
|
# Iterate over elements in the module provided and return the today data or the last data
|
||||||
|
@ -43,7 +46,7 @@ def get_date_range(num_day):
|
||||||
|
|
||||||
# ============ ROUTES ============
|
# ============ ROUTES ============
|
||||||
|
|
||||||
@app.route("/_moduleCharts", methods=['GET'])
|
@trendingmodules.route("/_moduleCharts", methods=['GET'])
|
||||||
def modulesCharts():
|
def modulesCharts():
|
||||||
keyword_name = request.args.get('keywordName')
|
keyword_name = request.args.get('keywordName')
|
||||||
module_name = request.args.get('moduleName')
|
module_name = request.args.get('moduleName')
|
||||||
|
@ -69,7 +72,7 @@ def modulesCharts():
|
||||||
return jsonify(member_set)
|
return jsonify(member_set)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/_providersChart", methods=['GET'])
|
@trendingmodules.route("/_providersChart", methods=['GET'])
|
||||||
def providersChart():
|
def providersChart():
|
||||||
keyword_name = request.args.get('keywordName')
|
keyword_name = request.args.get('keywordName')
|
||||||
module_name = request.args.get('moduleName')
|
module_name = request.args.get('moduleName')
|
||||||
|
@ -106,8 +109,10 @@ def providersChart():
|
||||||
return jsonify(member_set)
|
return jsonify(member_set)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/moduletrending/")
|
@trendingmodules.route("/moduletrending/")
|
||||||
def moduletrending():
|
def moduletrending():
|
||||||
return render_template("Moduletrending.html")
|
return render_template("Moduletrending.html")
|
||||||
|
|
||||||
|
|
||||||
|
# ========= REGISTRATION =========
|
||||||
|
app.register_blueprint(trendingmodules)
|
|
@ -36,7 +36,7 @@
|
||||||
<!-- /#side-menu -->
|
<!-- /#side-menu -->
|
||||||
</div>
|
</div>
|
||||||
<!-- /.sidebar-collapse -->
|
<!-- /.sidebar-collapse -->
|
||||||
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
<a href="{{ url_for('dashboard.index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.navbar-static-side -->
|
<!-- /.navbar-static-side -->
|
||||||
</nav>
|
</nav>
|
|
@ -1,22 +1,22 @@
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
<li id='page-index'><a href="{{ url_for('index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a></li>
|
<li id='page-index'><a href="{{ url_for('dashboard.index') }}"><i class="fa fa-dashboard fa-fw"></i> Dashboard</a></li>
|
||||||
<li id='page-trendingchart'><a href="{{ url_for('trending') }}"><i class="glyphicon glyphicon-stats"></i> Trending charts</a></li>
|
<li id='page-trendingchart'><a href="{{ url_for('trendings.trending') }}"><i class="glyphicon glyphicon-stats"></i> Trending charts</a></li>
|
||||||
<li id='page-modulestats'><a href="{{ url_for('moduletrending') }}"><i class="glyphicon glyphicon-stats"></i> Modules statistics</a></li>
|
<li id='page-modulestats'><a href="{{ url_for('trendingmodules.moduletrending') }}"><i class="glyphicon glyphicon-stats"></i> Modules statistics</a></li>
|
||||||
<li id='page-browse'><a href="{{ url_for('browseImportantPaste') }}"><i class="fa fa-search-plus "></i> Browse important pastes</a></li>
|
<li id='page-browse'><a href="{{ url_for('browsepastes.browseImportantPaste') }}"><i class="fa fa-search-plus "></i> Browse important pastes</a></li>
|
||||||
<li id='page-sentiment'><a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-heart"></i> Sentiment Analysis
|
<li id='page-sentiment'><a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-heart"></i> Sentiment Analysis
|
||||||
<span class="caret"></span></a>
|
<span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="{{ url_for('sentiment_analysis_trending') }}"><i class="fa fa-bar-chart-o"> </i> Sentiment trending</a></li>
|
<li><a href="{{ url_for('sentiments.sentiment_analysis_trending') }}"><i class="fa fa-bar-chart-o"> </i> Sentiment trending</a></li>
|
||||||
<li><a href="{{ url_for('sentiment_analysis_plot_tool') }}"><i class="fa fa-wrench"> </i> Sentiment plot Tool</a></li>
|
<li><a href="{{ url_for('sentiments.sentiment_analysis_plot_tool') }}"><i class="fa fa-wrench"> </i> Sentiment plot Tool</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li id='page-termsfrequency'><a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-eye"></i> Terms frequency
|
<li id='page-termsfrequency'><a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="fa fa-eye"></i> Terms frequency
|
||||||
<span class="caret"></span></a>
|
<span class="caret"></span></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="{{ url_for('terms_management') }}"><i class="fa fa-gear "> </i> Terms managements</a></li>
|
<li><a href="{{ url_for('terms.terms_management') }}"><i class="fa fa-gear "> </i> Terms managements</a></li>
|
||||||
<li><a href="{{ url_for('terms_plot_top') }}"><i class="glyphicon glyphicon-fire"> </i> Terms plot top</a></li>
|
<li><a href="{{ url_for('terms.terms_plot_top') }}"><i class="glyphicon glyphicon-fire"> </i> Terms plot top</a></li>
|
||||||
<li><a href="{{ url_for('terms_plot_tool') }}"><i class="fa fa-wrench"> </i> Terms plot tool</a></li>
|
<li><a href="{{ url_for('terms.terms_plot_tool') }}"><i class="fa fa-wrench"> </i> Terms plot tool</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in a new issue