Skip to content

Commit

Permalink
4.2 final
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisclark committed Apr 26, 2024
1 parent 154be27 commit d0398c2
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 44 deletions.
4 changes: 2 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Change Log
This document records all notable changes to `django-sql-explorer <https://github.com/chrisclark/django-sql-explorer>`_.
This project adheres to `Semantic Versioning <https://semver.org/>`_.

`4.2.0b1`_ (2024-04-25)
`4.2.0`_ (2024-04-26)
===========================
* `#609`_: Tracking should be opt-in and not use the SECRET_KEY
* `#610`_: Import error (sql_metadata) with 4.1 version
* `#612`_: Accessing the database during app initialization
* Regex-injection vulnerability
* Better anonymization for telemetry
* Improved assistant UI

`4.1.0`_ (2024-04-23)
===========================
Expand Down
4 changes: 2 additions & 2 deletions explorer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"major": 4,
"minor": 2,
"patch": 0,
"releaselevel": "beta",
"serial": 1
"releaselevel": "final",
"serial": 0
}


Expand Down
25 changes: 0 additions & 25 deletions explorer/src/js/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ function getErrorMessage() {
return errorElement ? errorElement.textContent.trim() : null;
}

function assistantSearchFocus() {
document.getElementById("search_assistant_tables").focus();
}

export function setUpAssistant(expand = false) {

const error = getErrorMessage();
Expand Down Expand Up @@ -71,27 +67,6 @@ export function setUpAssistant(expand = false) {
console.error('Error retrieving JSON schema:', error);
});

const checkbox = document.getElementById('include_other_tables');
const additionalTableContainer = document.getElementById('additional_table_container');
const assistantInputWrapper = document.getElementById('assistant_input_wrapper');

function showHideExtraTables(checked) {
if (checked) {
additionalTableContainer.classList.remove('d-none');
assistantInputWrapper.classList.remove('col-12');
assistantInputWrapper.classList.add('col-9');
assistantSearchFocus();
} else {
additionalTableContainer.classList.add('d-none');
assistantInputWrapper.classList.remove('col-9');
assistantInputWrapper.classList.add('col-12');
}
}
checkbox.addEventListener('change', function() {
showHideExtraTables(this.checked);
});
showHideExtraTables(checkbox.checked);

document.getElementById('id_assistant_input').addEventListener('keydown', function(event) {
if ((event.ctrlKey || event.metaKey) && (event.key === 'Enter')) {
event.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion explorer/src/scss/assistant.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#additional_table_container {
overflow-y: auto;
max-height: 120px;
max-height: 10rem;
}

#assistant_input_parent {
Expand Down
2 changes: 1 addition & 1 deletion explorer/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

def instance_identifier():
from explorer.models import ExplorerValue
key = "explorer_instance_identifier"
key = "explorer_instance_uuid"
r = cache.get(key)
if not r:
r = ExplorerValue.objects.get_uuid()
Expand Down
20 changes: 7 additions & 13 deletions explorer/templates/explorer/assistant.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,33 @@
<div id="assistant_collapse" class="accordion-collapse collapse" aria-labelledby="assistant_accordion_header" data-bs-parent="#assistant_accordion">
<div class="accordion-body">
<div class="row assistant_input_parent">
<div class="mt-3 col-12" id="assistant_input_wrapper">
<div class="mt-3 col-8" id="assistant_input_wrapper">
<textarea
class="form-control mb-4" id="id_assistant_input"
name="sql_assistant" rows="3" placeholder="What do you need help with?"></textarea>
name="sql_assistant" rows="5" placeholder="What do you need help with?"></textarea>
<label for="id_assistant_input" class="form-label d-none" id="id_assistant_input_label">Assistant prompt</label>
<div id="id_error_help_message" class="d-none text-secondary small">
Hit "Ask Assistant" to try and fix the issue. The assistant is automatically aware of error messages & context.
</div>
</div>
<div id="additional_table_container" class="d-none col-3">
<div id="additional_table_container" class="col-4">
<input id="search_assistant_tables" class="search" placeholder="{% trans "Search Tables" %}" />
<a class="small text-secondary" style="cursor: pointer; text-decoration: none;"
data-bs-toggle="tooltip" data-bs-placement="top"
data-bs-title="SQL Assistant builds a prompt with your query, your request, relevant schema (tables referenced in your query) and sample data from those tables. You can optionally include other tables (schema + data sample) that you'd like SQL Assistant to know about.">(?)</a>
<label for="search_assistant_tables" class="d-none" id="search_assistant_tables_label">Search tables</label>
<div id="table-list" class="list"></div>
</div>
</div>

<div class="row">
<div class="col-6">
<div class="form-check form-check-inline">
<input type="checkbox" class="form-check-input" name="assistant-include-other-tables" id="include_other_tables" autocomplete="off">
<label class="form-check-label" for="include_other_tables">Include Other Tables (<a class="small text-secondary" style="cursor: pointer;"
data-bs-toggle="tooltip" data-bs-placement="top"
data-bs-title="SQL Assistant builds a prompt with your query, your request, relevant schema (tables referenced in your query) and sample data from those tables. You can optionally include other tables (schema + data sample) that you'd like SQL Assistant to know about.">?</a>)</label>
</div>
</div>
<div class="col-6 text-end">
<div class="col-12 text-center">
<div class="btn-group" role="group">
<button type="button" class="btn btn-outline-primary" id="ask_assistant_btn">Ask Assistant</button>
</div>
</div>
</div>


<div id="response_block" class="position-relative d-none">
<div class="mt-3 p-2 pt-4 rounded-2 border bg-light">
<div id="assistant_response"></div>
Expand Down

0 comments on commit d0398c2

Please sign in to comment.