- Changes to the list views - now using tabulator with filtering and sorting, client-side pagination, ...
- Adaptation of all list views in the app
This commit is contained in:
@@ -31,6 +31,10 @@ from .interaction_forms import (SpecialistForm, EditSpecialistForm, EditEveAIAge
|
||||
EditEveAIToolForm, ExecuteSpecialistForm,
|
||||
SpecialistMagicLinkForm, EditSpecialistMagicLinkForm)
|
||||
|
||||
from eveai_app.views.list_views.interaction_list_views import (get_specialists_list_view, get_assets_list_view,
|
||||
get_magic_links_list_view, get_chat_sessions_list_view)
|
||||
from eveai_app.views.list_views.list_view_utils import render_list_view
|
||||
|
||||
interaction_bp = Blueprint('interaction_bp', __name__, url_prefix='/interaction')
|
||||
|
||||
|
||||
@@ -56,17 +60,9 @@ def before_request():
|
||||
|
||||
@interaction_bp.route('/chat_sessions', methods=['GET', 'POST'])
|
||||
def chat_sessions():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
per_page = request.args.get('per_page', 10, type=int)
|
||||
|
||||
query = ChatSession.query.order_by(desc(ChatSession.session_start))
|
||||
|
||||
pagination = query.paginate(page=page, per_page=per_page, error_out=False)
|
||||
docs = pagination.items
|
||||
|
||||
rows = prepare_table_for_macro(docs, [('id', ''), ('session_id', ''), ('session_start', ''), ('session_end', '')])
|
||||
|
||||
return render_template('interaction/chat_sessions.html', rows=rows, pagination=pagination)
|
||||
# Get configuration and render the list view
|
||||
config = get_chat_sessions_list_view()
|
||||
return render_list_view('list_view.html', **config)
|
||||
|
||||
|
||||
@interaction_bp.route('/handle_chat_session_selection', methods=['POST'])
|
||||
@@ -288,45 +284,10 @@ def edit_specialist(specialist_id):
|
||||
@interaction_bp.route('/specialists', methods=['GET', 'POST'])
|
||||
@roles_accepted('Super User', 'Partner Admin', 'Tenant Admin')
|
||||
def specialists():
|
||||
# Get all specialists (no pagination needed for client-side)
|
||||
specialists_query = Specialist.query.order_by(Specialist.id)
|
||||
all_specialists = specialists_query.all()
|
||||
|
||||
# Prepare data for Tabulator
|
||||
specialists_data = []
|
||||
for specialist in all_specialists:
|
||||
specialists_data.append({
|
||||
'id': specialist.id,
|
||||
'name': specialist.name,
|
||||
'type': specialist.type,
|
||||
'type_version': specialist.type_version,
|
||||
'active': specialist.active
|
||||
})
|
||||
|
||||
# Column definitions
|
||||
columns = [
|
||||
{'title': 'ID', 'field': 'id', 'width': 80},
|
||||
{'title': 'Name', 'field': 'name'},
|
||||
{'title': 'Type', 'field': 'type'},
|
||||
{'title': 'Type Version', 'field': 'type_version'},
|
||||
{'title': 'Active', 'field': 'active', 'formatter': 'tickCross'}
|
||||
]
|
||||
|
||||
# Action definitions
|
||||
actions = [
|
||||
{'value': 'edit_specialist', 'text': 'Edit Specialist', 'class': 'btn-primary', 'requiresSelection': True},
|
||||
{'value': 'execute_specialist', 'text': 'Execute Specialist', 'class': 'btn-primary', 'requiresSelection': True},
|
||||
{'value': 'create_specialist', 'text': 'Register Specialist', 'class': 'btn-success', 'position': 'right', 'requiresSelection': False}
|
||||
]
|
||||
|
||||
# Initial sort configuration
|
||||
initial_sort = [{'column': 'id', 'dir': 'asc'}]
|
||||
|
||||
return render_template('interaction/specialists.html',
|
||||
specialists_data=specialists_data,
|
||||
columns=columns,
|
||||
actions=actions,
|
||||
initial_sort=initial_sort)
|
||||
# Get configuration and render the list view
|
||||
config = get_specialists_list_view()
|
||||
return render_list_view('list_view.html', **config)
|
||||
|
||||
|
||||
@interaction_bp.route('/handle_specialist_selection', methods=['POST'])
|
||||
@@ -763,19 +724,9 @@ def edit_specialist_magic_link(specialist_magic_link_id):
|
||||
@interaction_bp.route('/specialist_magic_links', methods=['GET', 'POST'])
|
||||
@roles_accepted('Super User', 'Partner Admin', 'Tenant Admin')
|
||||
def specialist_magic_links():
|
||||
page = request.args.get('page', 1, type=int)
|
||||
per_page = request.args.get('per_page', 10, type=int)
|
||||
|
||||
query = SpecialistMagicLink.query.order_by(SpecialistMagicLink.id)
|
||||
|
||||
pagination = query.paginate(page=page, per_page=per_page)
|
||||
the_specialist_magic_links = pagination.items
|
||||
|
||||
# prepare table data
|
||||
rows = prepare_table_for_macro(the_specialist_magic_links, [('id', ''), ('name', ''), ('magic_link_code', ''),])
|
||||
|
||||
# Render the catalogs in a template
|
||||
return render_template('interaction/specialist_magic_links.html', rows=rows, pagination=pagination)
|
||||
# Get configuration and render the list view
|
||||
config = get_magic_links_list_view()
|
||||
return render_list_view('list_view.html', **config)
|
||||
|
||||
|
||||
@interaction_bp.route('/handle_specialist_magic_link_selection', methods=['POST'])
|
||||
@@ -798,19 +749,15 @@ def handle_specialist_magic_link_selection():
|
||||
# Routes for Asset Management ---------------------------------------------------------------------
|
||||
@interaction_bp.route('/assets', methods=['GET', 'POST'])
|
||||
def assets():
|
||||
from eveai_app.views.list_views.assets_list_view import AssetsListView
|
||||
view = AssetsListView(
|
||||
model=EveAIAsset,
|
||||
template='interaction/assets.html',
|
||||
per_page=10
|
||||
)
|
||||
return view.get()
|
||||
config = get_assets_list_view()
|
||||
return render_list_view('list_view.html', **config)
|
||||
|
||||
|
||||
@interaction_bp.route('/handle_asset_selection', methods=['POST'])
|
||||
def handle_asset_selection():
|
||||
action = request.form.get('action')
|
||||
asset_id = request.form.get('selected_row')
|
||||
asset_identification = request.form.get('selected_row')
|
||||
asset_id = ast.literal_eval(asset_identification).get('value')
|
||||
|
||||
if action == 'edit_asset':
|
||||
return redirect(prefixed_url_for('interaction_bp.edit_asset', asset_id=asset_id))
|
||||
|
||||
Reference in New Issue
Block a user