Skip to content

Commit

Permalink
last changes have been made
Browse files Browse the repository at this point in the history
autocomplite and localstorage for directory tree works with bugs
  • Loading branch information
sqrd-max committed May 9, 2024
1 parent 3108d01 commit c6b0596
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 183 deletions.
45 changes: 19 additions & 26 deletions python/ccdb/webgui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,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})">&#128712;</button>'
result += f'<li><span class="clickable">{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})">&#128712;</button></li>\n'
result += f'<li><a class="clickable" href="{table_url}">{table.name}</a> <button onclick="showTableInfo({table.id})">&#128712;</button></li>\n'

result += '</ul>\n'
return result
Expand Down Expand Up @@ -79,21 +79,18 @@ def directories():
db.get_root_directory()

# Render a template with the directories
return render_template("simple_direcotires.html", dirs_by_path=db.dirs_by_path)
return render_template("direcotires.html", dirs_by_path=db.dirs_by_path)

@app.route('/')
def index():
return render_template(
"dash_base.html",
app_name="Material Dashboard with Bokeh embedded in Flask",
app_description="This Dashboard is served by a Bokeh server embedded in Flask.",
app_icon="timeline"
)

@app.route('/doc')
def documentation():
return render_template("doc.html")
# @app.route('/')
# def index():
# return render_template(
# "dash_base.html",
# app_name="Material Dashboard with Bokeh embedded in Flask",
# app_description="This Dashboard is served by a Bokeh server embedded in Flask.",
# app_icon="timeline"
# )

@app.route('/')
@app.route('/tree')
def directory_tree():
# Get ccdb Alchemy provider from flask global state 'g'
Expand All @@ -105,7 +102,7 @@ def directory_tree():
# Generate html code of directory tree
html_tree = dir_to_ul(root_dir, level=0)

return render_template("simple_tree.html", html_tree=html_tree)
return render_template("directory_tree.html", html_tree=html_tree, dirs_by_path=db.dirs_by_path)

@app.route('/get-dir-info/<int:dir_id>')
def get_dir_info(dir_id):
Expand All @@ -115,8 +112,6 @@ def get_dir_info(dir_id):
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
Expand All @@ -125,8 +120,6 @@ def get_table_info(table_id):
return jsonify({"error": "Table not found"}), 404
return render_template('objects_table_info.html', table=table)



@app.route('/vars')
def variations():
# Get ccdb Alchemy provider from flask global state 'g'
Expand All @@ -143,7 +136,11 @@ def log_records():

records = db.get_log_records(1000)

return render_template("simple_logs.html", records=records)
return render_template("logs.html", records=records)

@app.route('/doc')
def documentation():
return render_template("doc.html")

@app.route('/versions/<path:table_path>')
def versions(table_path):
Expand All @@ -162,7 +159,7 @@ def versions(table_path):
except ccdb.errors.ObjectIsNotFoundInDbError as e:
return render_template("error.html", message=str(e), table_path=table_path), 404

return render_template("simple_versions.html", assignments=assignments, table_path=table_path)
return render_template("versions.html", assignments=assignments, table_path=table_path)

@app.route('/test_request')
def test_request():
Expand Down Expand Up @@ -197,10 +194,6 @@ def show_request():
run_range = ""
comment = ""

# get request from web form

#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)
assert isinstance(request, ParseRequestResult)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
margin-bottom: 10px;
}

.clickable {
cursor: pointer;
}

</style>

<h1 class="text-center my-4">{% block title %}Tables{% endblock %}</h1>
Expand Down Expand Up @@ -169,6 +173,13 @@ <h1 class="text-center my-4">{% block title %}Tables{% endblock %}</h1>
closedClass: 'bi-folder',
fileClass: 'bi-table'
});

$('#tree2').find('.branch').each(function() {
var branch = $(this);
if (localStorage.getItem('branch-' + branch.index()) === 'open') {
branch.children('.indicator').click();
}
});
});

$.fn.extend({
Expand All @@ -181,14 +192,20 @@ <h1 class="text-center my-4">{% block title %}Tables{% endblock %}</h1>
tree.addClass("tree");
tree.find('li').has("ul").each(function () {
var branch = $(this);
branch.prepend("<i class='indicator bi " + closedClass + "'></i>");
branch.prepend("<i class='indicator bi " + closedClass + "'></i>");
branch.addClass('branch');
branch.on('click', function (e) {
if (!$(e.target).is('a') && !$(e.target).is('button') && !$(e.target).closest('button').length) {
var icon = $(this).children('i:first');
icon.toggleClass(openedClass + " " + closedClass);
$(this).children().children().toggle();
e.stopPropagation();

if (icon.hasClass(openedClass)) {
localStorage.setItem('branch-' + $(this).index(), 'open');
} else {
localStorage.removeItem('branch-' + $(this).index());
}
}
});
branch.children().children().toggle();
Expand Down
26 changes: 20 additions & 6 deletions python/ccdb/webgui/templates/doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ <h1 class="mt-4 mb-4 text-center" style="font-size: 2.5rem;">Information</h1>

{% block content %}
<div class="container mt-5">
<div class="card">
<div class="card-body" style="font-size: 1.25rem;">
<p>
<a target="_blank" href="https://halldweb1.jlab.org/wiki/index.php/Calibration_Database"
class="btn btn-primary text-white" style="text-decoration: none;">
Visit the Calibration Database GluEX Wiki Page
</a>
</p>

<!-- GitHub Link -->
<div class="row">
<h4 class="col-auto">GitHub Repository</h4>-
<p class="col-auto"><a href="https://github.com/JeffersonLab/ccdb" target="_blank">Jefferson Lab CCDB GitHub repository</a>.</p>
</div>

<!-- GitHub Issues Link -->
<div class="row">
<h4 class="col-auto">Support & Issues</h4>-
<p class="col-auto"><a href="https://github.com/JeffersonLab/ccdb/issues" target="_blank">GitHub Issues page</a>.</p>
</div>

<!-- Wiki Link -->
<div class="row">
<h4 class="col-auto">Documentation & Resources</h4>-
<p class="col-auto"><a href="https://halldweb1.jlab.org/wiki/index.php/Calibration_Database" target="_blank">Calibration Database GluEX Wiki Page</a>.</p>
</div>
</div>
</div>
</div>
{% endblock %}
File renamed without changes.
20 changes: 0 additions & 20 deletions python/ccdb/webgui/templates/simple.html

This file was deleted.

69 changes: 0 additions & 69 deletions python/ccdb/webgui/templates/simple_base.html

This file was deleted.

Loading

0 comments on commit c6b0596

Please sign in to comment.