From 622d32fa45e6223d1b163dab33e240c9402ff359 Mon Sep 17 00:00:00 2001 From: Patrick Jentsch Date: Tue, 21 Mar 2023 10:50:29 +0100 Subject: [PATCH] UI enhancements --- app/admin/routes.py | 32 ++++++++-- app/templates/_sidenav.html.j2 | 11 ++-- app/templates/admin/admin.html.j2 | 11 ++++ app/templates/admin/corpora.html.j2 | 23 +++++++ app/templates/admin/user.html.j2 | 91 +++++++++++++++++----------- app/templates/main/dashboard.html.j2 | 55 +++++++++-------- app/templates/users/profile.html.j2 | 16 +++-- app/users/routes.py | 2 +- 8 files changed, 163 insertions(+), 78 deletions(-) create mode 100644 app/templates/admin/admin.html.j2 create mode 100644 app/templates/admin/corpora.html.j2 diff --git a/app/admin/routes.py b/app/admin/routes.py index 15ff0d9f..b2d0643b 100644 --- a/app/admin/routes.py +++ b/app/admin/routes.py @@ -1,9 +1,9 @@ -from flask import flash, redirect, render_template, url_for +from flask import flash, redirect, render_template, request, url_for from flask_breadcrumbs import register_breadcrumb from app import db, hashids -from app.models import Role, User, UserSettingJobStatusMailNotificationLevel -from app.users.forms import EditNotificationSettingsForm -from app.users.forms import EditProfileSettingsForm +from app.models import Corpus, Role, User, UserSettingJobStatusMailNotificationLevel +from app.settings.forms import EditNotificationSettingsForm +from app.settings.forms import EditProfileSettingsForm from . import bp from .forms import AdminEditUserForm from app.users.utils import ( @@ -15,7 +15,21 @@ from app.users.utils import ( @bp.route('') @register_breadcrumb(bp, '.', 'admin_panel_settingsAdministration') def index(): - return redirect(url_for('.users')) + return render_template( + 'admin/admin.html.j2', + title='Administration' + ) + + +@bp.route('/corpora') +@register_breadcrumb(bp, '.corpora', 'Corpora') +def corpora(): + corpora = [x.to_json_serializeable(backrefs=True) for x in Corpus.query.all()] + return render_template( + 'admin/corpora.html.j2', + corpora=corpora, + title='Corpora' + ) @bp.route('/users') @@ -33,7 +47,13 @@ def users(): @register_breadcrumb(bp, '.users.entity', '', dynamic_list_constructor=user_dlc) def user(user_id): user = User.query.get_or_404(user_id) - return render_template('admin/user.html.j2', title='User', user=user) + return render_template('admin/user.html.j2', title=user.username, user=user) + + +@bp.route('/users//dashboard') +@register_breadcrumb(bp, '.users.entity.dashboard', 'Dashboard', endpoint_arguments_constructor=user_eac) +def user_dashboard(user_id): + return render_template('main/dashboard.html.j2', title='Dashboard') @bp.route('/users//edit', methods=['GET', 'POST']) diff --git a/app/templates/_sidenav.html.j2 b/app/templates/_sidenav.html.j2 index 5157e262..5f6f6482 100644 --- a/app/templates/_sidenav.html.j2 +++ b/app/templates/_sidenav.html.j2 @@ -48,13 +48,16 @@
  • Account
  • settingsSettings
  • Log out
  • - {% if current_user.can('ADMINISTRATE') or current_user.can('USE_API') %} -
  • - {% endif %} {% if current_user.can('ADMINISTRATE') %} -
  • admin_panel_settingsAdministration
  • +
  • +
  • Administration
  • +
  • ICorpora
  • +
  • JJobs
  • +
  • groupUsers
  • {% endif %} {% if current_user.can('USE_API') %} +
  • +
  • API
  • apiAPI
  • {% endif %} diff --git a/app/templates/admin/admin.html.j2 b/app/templates/admin/admin.html.j2 new file mode 100644 index 00000000..d00adf58 --- /dev/null +++ b/app/templates/admin/admin.html.j2 @@ -0,0 +1,11 @@ +{% extends "base.html.j2" %} + +{% block page_content %} +
    +
    +
    +

    {{ title }}

    +
    +
    +
    +{% endblock page_content %} diff --git a/app/templates/admin/corpora.html.j2 b/app/templates/admin/corpora.html.j2 new file mode 100644 index 00000000..99fcc661 --- /dev/null +++ b/app/templates/admin/corpora.html.j2 @@ -0,0 +1,23 @@ +{% extends "base.html.j2" %} + +{% block page_content %} +
    +

    {{ title }}

    + +
    +
    +
    +
    +
    +
    + +{% endblock page_content %} + +{% block scripts %} +{{ super() }} + +{% endblock scripts %} diff --git a/app/templates/admin/user.html.j2 b/app/templates/admin/user.html.j2 index e3864e75..30f7c084 100644 --- a/app/templates/admin/user.html.j2 +++ b/app/templates/admin/user.html.j2 @@ -3,52 +3,49 @@ {% block page_content %}
    -
    +
    +

     

    + user-image +
    +

    {{ title }}

    + {{ user.role.name }} + {{ 'confirmed' if user.confirmed else 'unconfirmed' }} +

    {{ user.about_me }}

    -
    -

    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,

    - arrow_backBack to Users +
     
    + + -
    +
    - User information
    • Username: {{ user.username }}
    • Email: {{ user.email }}
    • Id: {{ user.id }}
    • Hashid: {{ user.hashid }}
    • Member since: {{ user.member_since }}
    • -
    • Confirmed status: {{ user.confirmed }}
    • Last seen: {{ user.last_seen }}
    • -
    • Permissions as Int: {{ user.role.permissions }}
    • -
    • Role: {{ user.role.name }}
    • -
    • Permissions: -
        - {% for permission in ['ADMINISTRATE', 'CONTRIBUTE', 'USE_API'] %} -
      • - -
      • - {% endfor %} -
      -
    -
    -

    Corpora

    +
    @@ -56,8 +53,7 @@
    -
    -

    Jobs

    +
    @@ -65,12 +61,7 @@
    -
    -

    Contributions

    -
    - -
    -

    SpaCy NLP Pipeline Models

    +
    @@ -78,8 +69,7 @@
    -
    -

    Tesseract OCR Pipeline Models

    +
    @@ -99,8 +89,35 @@

    Do you really want to delete the user {{ user.username }}? All associated data will be permanently deleted!

    {% endblock modals %} + + +{% block scripts %} +{{ super() }} + +{% endblock scripts %} diff --git a/app/templates/main/dashboard.html.j2 b/app/templates/main/dashboard.html.j2 index 0b8e6f31..54f91eaa 100644 --- a/app/templates/main/dashboard.html.j2 +++ b/app/templates/main/dashboard.html.j2 @@ -8,8 +8,11 @@
    -

    My Corpora

    +

    My Corpora

    Create a corpus to interactively perform linguistic analysis.

    +
    + +
    @@ -22,7 +25,7 @@
    -

    My Jobs

    +

    My Jobs

    A job is the execution of a service provided by nopaque. You can create any number of jobs and let them be processed simultaneously. We @@ -32,6 +35,9 @@ next step.

    Where is my Job data? Don't worry, please read this news entry

    +
    + +
    @@ -43,34 +49,35 @@
    -

    My Contributions

    -
    -
    - -
    - Tesseract OCR Pipeline Models -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    +

    My Contributions

    +
    + +
    +
    + +
    + Tesseract OCR Pipeline Models +

    Here you can see and edit the models that you have created. You can also create new models.

    +
    -
    -
    - -
    - SpaCy NLP Pipeline Models -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    +
    +
    + +
    + SpaCy NLP Pipeline Models +

    Here you can see and edit the models that you have created. You can also create new models.

    +
    -
    -
    - -
    - Transkribus HTR Pipeline Models -

    Here you can see and edit the models that you have created. You can also create new models.

    -
    +
    +
    + +
    + Transkribus HTR Pipeline Models +

    Here you can see and edit the models that you have created. You can also create new models.

    diff --git a/app/templates/users/profile.html.j2 b/app/templates/users/profile.html.j2 index 895fba82..6e02a42c 100644 --- a/app/templates/users/profile.html.j2 +++ b/app/templates/users/profile.html.j2 @@ -18,10 +18,14 @@
    +

    {{ user.username }}

    + {% if user.role.name != 'User' %} + {{ user.role.name }} + {% endif %} {% if user.is_public %} -

    {{ user.username }}

    + Public Profile {% else %} -

    {{ user.username }}

    + Private Profile {% endif %}
    @@ -34,10 +38,10 @@


    {% if user.about_me %} -
    +
    About me

    {{ user.about_me }}

    -
    + {% endif %}
    @@ -80,8 +84,8 @@ {% endif %}


    - {% if current_user.is_authenticated and current_user.hashid == user.id %} - Edit profile + {% if current_user.hashid == user.id %} + Edit profile {% endif %}
    diff --git a/app/users/routes.py b/app/users/routes.py index 0bf8eb1d..5d51e81f 100644 --- a/app/users/routes.py +++ b/app/users/routes.py @@ -42,7 +42,7 @@ def user(user_id): last_seen=last_seen, member_since=member_since, own_public_corpora=own_public_corpora, - user=user.to_json_serializeable(), + user=user, user_id=user_id, title=user.username )