Skip to content

Commit

Permalink
all site works. except ensure_dirs_loaded()
Browse files Browse the repository at this point in the history
  • Loading branch information
sqrd-max committed May 8, 2024
1 parent 10d734f commit 7026a4a
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 285 deletions.
47 changes: 12 additions & 35 deletions python/ccdb/webgui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,6 @@ def print_app_functions(app):
print()


def render_dir_info(directory):
"""
Render HTML for directory information using Flask and Jinja2.
:param directory: Directory object
:type directory: ccdb.model.Directory
"""

return render_template('objects_dir_info.html', dir=directory)


def render_table_info(table):
"""
Render HTML for table information using Flask and Jinja2.
:param table: Table object
:type table: ccdb.TypeTable
"""
return render_template('objects_table_info.html', table=table)


def dir_to_ul(directory, level=0):
"""
:param directory: Directory
Expand All @@ -51,13 +30,13 @@ def dir_to_ul(directory, level=0):

result = '<ul>\n'
for sub_dir in directory.sub_dirs:
result += f'<li><span>{sub_dir.name}</span> <button onclick="showDirInfo({sub_dir.id})">Info</button>'
result += f'<li><span>{sub_dir.name}</span> <button onclick="showDirInfo({sub_dir.id})">&#128712;</button>'
result += dir_to_ul(sub_dir, level + 1)
result += '</li>\n'

for table in directory.type_tables:
table_url = url_for('versions', table_path=table.path)
result += f'<li><a href="{table_url}">{table.name}</a> <button onclick="showTableInfo({table.id})">Info</button></li>\n'
result += f'<li><a href="{table_url}">{table.name}</a> <button onclick="showTableInfo({table.id})">&#128712;</button></li>\n'

result += '</ul>\n'
return result
Expand Down Expand Up @@ -131,21 +110,22 @@ def directory_tree():
@app.route('/get-dir-info/<int:dir_id>')
def get_dir_info(dir_id):
db: ccdb.AlchemyProvider = g.db
try:
directory = db.get_directory_by_id(dir_id)
return render_template('objects_dir_info.html', directory=directory)
except ObjectIsNotFoundInDbError:
directory = db.get_directory_by_id(dir_id)
if not directory:
return jsonify({"error": "Directory not found"}), 404
return render_template('objects_dir_info.html', directory=directory)



@app.route('/get-table-info/<int:table_id>')
def get_table_info(table_id):
db: ccdb.AlchemyProvider = g.db
try:
table = db.get_type_table_by_id(table_id)
return render_template('objects_table_info.html', table=table)
except ObjectIsNotFoundInDbError:
table = db.get_type_table_by_id(table_id)
if not table:
return jsonify({"error": "Table not found"}), 404
return render_template('objects_table_info.html', table=table)



@app.route('/vars')
def variations():
Expand Down Expand Up @@ -219,7 +199,7 @@ def show_request():

# get request from web form

# str_request = "/test/test_vars/test_table:0:default:2012-10-30_23-48-41"
#str_request = "/test/test_vars/test_table:0:default:2012-10-30_23-48-41"

# parse request and prepare time
request = parse_request(str_request)
Expand Down Expand Up @@ -307,9 +287,6 @@ def download_request():

return result




# THIS IS FOR FUTURE
# ====================================================================
# from ccdb.webgui.data_timeline import bp as time_line_bp
Expand Down
80 changes: 36 additions & 44 deletions python/ccdb/webgui/templates/objects_dir_info.html
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
{% macro modal_directory_info(directory) %}
<div class="modal fade" id="directoryInfoModal" tabindex="-1" aria-labelledby="directoryInfoModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="directoryInfoModalLabel">{{ directory.name }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<table class="table">
<tbody>
<tr>
<th scope="row">DB ID</th>
<td>{{ directory.id }}</td>
</tr>
<tr>
<th scope="row">Full path</th>
<td>{{ directory.path }}</td>
</tr>
<tr>
<th scope="row">Created</th>
<td>{{ directory.created.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
<tr>
<th scope="row">Modified</th>
<td>{{ directory.modified.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
<tr>
<th scope="row">Author</th>
<td>{{ directory.author_id }}</td>
</tr>
<tr>
<th scope="row">Comment</th>
<td>{{ directory.comment }}</td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<h5 class="modal-title w-100 text-center" id="directoryInfoModalLabel">Directory name: {{ directory.name }}</h5>
</div>
<div class="modal-body">
<table class="table">
<tbody>
<tr>
<th scope="row">DB ID</th>
<td>{{ directory.id }}</td>
</tr>
<tr>
<th scope="row">Full path</th>
<td>{{ directory.path }}</td>
</tr>
<tr>
<th scope="row">Created</th>
<td>{{ directory.created.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
<tr>
<th scope="row">Modified</th>
<td>{{ directory.modified.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
<tr>
<th scope="row">Author</th>
<td>{{ directory.author_id }}</td>
</tr>
<tr>
<th scope="row">Comment</th>
<td>{{ directory.comment }}</td>
</tr>
</tbody>
</table>
</div>
</div>
{% endmacro %}



46 changes: 34 additions & 12 deletions python/ccdb/webgui/templates/objects_table_info.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
@require(id, name, path, created, modified, author, comment)

<span class="file"><a href="versions?table=@path" class="table_link">@name</a>&nbsp;&nbsp;<a class="tree_link object_more_info" rel="Table @name">?</a></span>
<div style="display: none">
<table>
<tr style="color: gray"><td style="width:auto">DB ID:</td><td style="width: 100%">:&nbsp;&nbsp;&nbsp;@id</td></tr>
<tr><td style="font-weight: bolder">Full path </td><td>:&nbsp;&nbsp;&nbsp; @path</td></tr>
<tr><td>Created </td><td>:&nbsp;&nbsp;&nbsp; @created</td></tr>
<tr><td>Modified </td><td>:&nbsp;&nbsp;&nbsp; @modified</td></tr>
<tr><td>Author </td><td>:&nbsp;&nbsp;&nbsp; @author</td></tr>
<tr><td>Comment </td><td>:&nbsp;&nbsp;&nbsp; @comment</td></tr>
<div class="modal-header">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
<h5 class="modal-title w-100 text-center" id="tableInfoModalLabel">Table name: {{ table.name }}</h5>
</div>
<div class="modal-body">
<table class="table">
<tbody>
<tr>
<th scope="row">DB ID</th>
<td>{{ table.id }}</td>
</tr>
<tr>
<th scope="row">Full path</th>
<td>{{ table.path }}</td>
</tr>
<tr>
<th scope="row">Created</th>
<td>{{ table.created.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
<tr>
<th scope="row">Modified</th>
<td>{{ table.modified.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
<tr>
<th scope="row">Author</th>
<td>{{ table.author }}</td>
</tr>
<tr>
<th scope="row">Comment</th>
<td>{{ table.comment }}</td>
</tr>
</tbody>
</table>
</div>
</div>

Loading

0 comments on commit 7026a4a

Please sign in to comment.