2024-11-19 14:58:40 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*-coding:UTF-8 -*
|
|
|
|
|
|
|
|
'''
|
|
|
|
Blueprint Flask: crawler splash endpoints: dashboard, onion crawler ...
|
|
|
|
'''
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2024-11-27 15:10:44 +00:00
|
|
|
import time
|
2024-11-19 14:58:40 +00:00
|
|
|
|
2024-11-27 15:10:44 +00:00
|
|
|
import json # TODO REMOVE ME
|
|
|
|
|
|
|
|
from flask import render_template, Response, request, Blueprint
|
2024-11-27 13:17:22 +00:00
|
|
|
from flask_login import login_required, current_user
|
2024-11-19 14:58:40 +00:00
|
|
|
|
|
|
|
# Import Role_Manager
|
|
|
|
from Role_Manager import login_admin, login_read_only
|
|
|
|
|
|
|
|
sys.path.append(os.environ['AIL_BIN'])
|
|
|
|
##################################
|
|
|
|
# Import Project packages
|
|
|
|
##################################
|
|
|
|
from lib import ail_stats
|
|
|
|
|
2024-11-27 15:10:44 +00:00
|
|
|
# TODO STATS
|
|
|
|
# from lib import ail_updates
|
2024-11-19 14:58:40 +00:00
|
|
|
|
|
|
|
# ============ BLUEPRINT ============
|
2024-11-27 15:10:44 +00:00
|
|
|
dashboard = Blueprint('dashboard', __name__, template_folder=os.path.join(os.environ['AIL_FLASK'], 'templates/dashboard'))
|
2024-11-19 14:58:40 +00:00
|
|
|
|
|
|
|
# ============ VARIABLES ============
|
|
|
|
bootstrap_label = ['primary', 'success', 'danger', 'warning', 'info']
|
|
|
|
|
|
|
|
# ============ FUNCTIONS ============
|
2024-11-27 15:10:44 +00:00
|
|
|
|
|
|
|
# ============= ROUTES ==============
|
|
|
|
|
|
|
|
@dashboard.route("/", methods=['GET'])
|
2024-11-19 14:58:40 +00:00
|
|
|
@login_required
|
|
|
|
@login_read_only
|
2024-11-27 15:10:44 +00:00
|
|
|
def index():
|
2024-11-27 13:17:22 +00:00
|
|
|
user_org = current_user.get_org()
|
|
|
|
user_id = current_user.get_user_id()
|
2024-11-19 14:58:40 +00:00
|
|
|
nb_objects = ail_stats.get_nb_objs_dashboard()
|
|
|
|
feeders_dashboard = ail_stats.get_feeders_dashboard_full()
|
2024-11-27 14:26:07 +00:00
|
|
|
crawlers_stats = ail_stats.get_crawlers_stats()
|
2024-11-27 13:17:22 +00:00
|
|
|
trackers = ail_stats.get_tracked_objs_dashboard(user_org, user_id)
|
|
|
|
tagged_objs = ail_stats.get_tagged_objs_dashboard()
|
2024-11-27 15:10:44 +00:00
|
|
|
return render_template("dashboard.html", feeders_dashboard=feeders_dashboard,
|
2024-11-27 13:17:22 +00:00
|
|
|
nb_objects=nb_objects, trackers=trackers, tagged_objs=tagged_objs,
|
2024-11-27 14:26:07 +00:00
|
|
|
bootstrap_label=bootstrap_label, crawlers_stats=crawlers_stats)
|