From c6b059604f5ff93784dc7c1991eb3547ee0cb449 Mon Sep 17 00:00:00 2001 From: "sqrd.max" Date: Fri, 10 May 2024 00:52:35 +0300 Subject: [PATCH] last changes have been made autocomplite and localstorage for directory tree works with bugs --- python/ccdb/webgui/__init__.py | 45 +++---- ...mple_direcotires.html => direcotires.html} | 0 .../{simple_tree.html => directory_tree.html} | 19 ++- python/ccdb/webgui/templates/doc.html | 26 +++- .../templates/{simple_logs.html => logs.html} | 0 python/ccdb/webgui/templates/simple.html | 20 --- python/ccdb/webgui/templates/simple_base.html | 69 ---------- .../ccdb/webgui/templates/test_request.html | 123 +++++++++--------- python/ccdb/webgui/templates/variations.html | 1 + .../{simple_versions.html => versions.html} | 0 10 files changed, 120 insertions(+), 183 deletions(-) rename python/ccdb/webgui/templates/{simple_direcotires.html => direcotires.html} (100%) rename python/ccdb/webgui/templates/{simple_tree.html => directory_tree.html} (89%) rename python/ccdb/webgui/templates/{simple_logs.html => logs.html} (100%) delete mode 100644 python/ccdb/webgui/templates/simple.html delete mode 100644 python/ccdb/webgui/templates/simple_base.html rename python/ccdb/webgui/templates/{simple_versions.html => versions.html} (100%) diff --git a/python/ccdb/webgui/__init__.py b/python/ccdb/webgui/__init__.py index ff2798e..2c932de 100644 --- a/python/ccdb/webgui/__init__.py +++ b/python/ccdb/webgui/__init__.py @@ -30,13 +30,13 @@ def dir_to_ul(directory, level=0): result = '\n' return result @@ -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' @@ -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/') def get_dir_info(dir_id): @@ -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/') def get_table_info(table_id): db: ccdb.AlchemyProvider = g.db @@ -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' @@ -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/') def versions(table_path): @@ -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(): @@ -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) diff --git a/python/ccdb/webgui/templates/simple_direcotires.html b/python/ccdb/webgui/templates/direcotires.html similarity index 100% rename from python/ccdb/webgui/templates/simple_direcotires.html rename to python/ccdb/webgui/templates/direcotires.html diff --git a/python/ccdb/webgui/templates/simple_tree.html b/python/ccdb/webgui/templates/directory_tree.html similarity index 89% rename from python/ccdb/webgui/templates/simple_tree.html rename to python/ccdb/webgui/templates/directory_tree.html index d6c6459..a0bede4 100644 --- a/python/ccdb/webgui/templates/simple_tree.html +++ b/python/ccdb/webgui/templates/directory_tree.html @@ -90,6 +90,10 @@ margin-bottom: 10px; } +.clickable { + cursor: pointer; +} +

{% block title %}Tables{% endblock %}

@@ -169,6 +173,13 @@

{% block title %}Tables{% endblock %}

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({ @@ -181,7 +192,7 @@

{% block title %}Tables{% endblock %}

tree.addClass("tree"); tree.find('li').has("ul").each(function () { var branch = $(this); - branch.prepend(""); + branch.prepend(""); branch.addClass('branch'); branch.on('click', function (e) { if (!$(e.target).is('a') && !$(e.target).is('button') && !$(e.target).closest('button').length) { @@ -189,6 +200,12 @@

{% block title %}Tables{% endblock %}

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(); diff --git a/python/ccdb/webgui/templates/doc.html b/python/ccdb/webgui/templates/doc.html index 3404466..a2251aa 100644 --- a/python/ccdb/webgui/templates/doc.html +++ b/python/ccdb/webgui/templates/doc.html @@ -6,13 +6,27 @@

Information

{% block content %}
+
-

- - Visit the Calibration Database GluEX Wiki Page - -

+ + +
+

GitHub Repository

- +

Jefferson Lab CCDB GitHub repository.

+
+ + +
+

Support & Issues

- +

GitHub Issues page.

+
+ + +
+

Documentation & Resources

- +

Calibration Database GluEX Wiki Page.

+
+
{% endblock %} diff --git a/python/ccdb/webgui/templates/simple_logs.html b/python/ccdb/webgui/templates/logs.html similarity index 100% rename from python/ccdb/webgui/templates/simple_logs.html rename to python/ccdb/webgui/templates/logs.html diff --git a/python/ccdb/webgui/templates/simple.html b/python/ccdb/webgui/templates/simple.html deleted file mode 100644 index 4e1837a..0000000 --- a/python/ccdb/webgui/templates/simple.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends 'simple_base.html' %} - -{% block header %} -

{% block title %}Data Timeline{% endblock %}

- -{% endblock %} - -{% block content %} - -

CCDB 2.0 GUI development is in progress...

- - - - - -{% endblock %} diff --git a/python/ccdb/webgui/templates/simple_base.html b/python/ccdb/webgui/templates/simple_base.html deleted file mode 100644 index 2a1d8c2..0000000 --- a/python/ccdb/webgui/templates/simple_base.html +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - {% block title %}CCDB Web GUI{% endblock %} - - - - - - - - - -
-
- {% block header %}{% endblock %} -
- {% for message in get_flashed_messages() %} -
{{ message }}
- {% endfor %} - - {% block content %}{% endblock %} -
- -
-
- {% block footer %}CCDB Calibration and Conditions database. Report a bug{% endblock %} -
-
- - {% block additional_scripts %} - - {% endblock %} - - diff --git a/python/ccdb/webgui/templates/test_request.html b/python/ccdb/webgui/templates/test_request.html index 3619411..ef60c2c 100644 --- a/python/ccdb/webgui/templates/test_request.html +++ b/python/ccdb/webgui/templates/test_request.html @@ -62,71 +62,72 @@

{% block title %}CCDB - Test Request{% endblock %}

- + + + tableNameInput.data("ui-autocomplete")._renderItem = function(ul, item) { + return $("") + .attr("data-value", item.value) + .append(item.label) + .appendTo(ul); + }; +}); + + +function combineRequest(event) +{ + console.log(event); + //type table + let type_table = document.getElementById('tableName').value; + if(!type_table) { + alert("Please specify type table"); + return false; + } + + //run number + let run = document.getElementById('runNumber').value + if(!run){ + alert("Please specify run number"); + return false; + } + //variation + let variation = document.getElementById('variationSelect').value; + + //now we have everything to build request + let request = type_table+":"+run +":"+ variation; + + //is there a date? + let date = document.getElementById('dateText').value; + if(date) request = request + ":" +date; + console.log(request) + + // //insert request value to our hidden input and return true + // console.log(request); + // // $("#requestHidden").val(request); + + let hidden = document.getElementById('requestHidden'); + hidden.setAttribute("value", request); + + return false; +} + + {% endblock %} \ No newline at end of file diff --git a/python/ccdb/webgui/templates/variations.html b/python/ccdb/webgui/templates/variations.html index 0e964db..178f0e5 100644 --- a/python/ccdb/webgui/templates/variations.html +++ b/python/ccdb/webgui/templates/variations.html @@ -39,6 +39,7 @@

{% block title %}Variations{% endblock %}

$('#variationsTable').DataTable({ "pagingType": "full_numbers", "order": [[1, "asc"]], + "pageLength": 100, "dom": "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" + "<'row'<'col-sm-12'tr>>" + "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", diff --git a/python/ccdb/webgui/templates/simple_versions.html b/python/ccdb/webgui/templates/versions.html similarity index 100% rename from python/ccdb/webgui/templates/simple_versions.html rename to python/ccdb/webgui/templates/versions.html