Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin UI quality of life improvements #79

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
- '3.10'
- '3.11'
- '3.12'
- '3.13'

services:
mongodb:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
classifiers=[
"Programming Language :: Python",
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
"Topic :: Software Development :: Libraries :: Python Modules",
],
python_requires='>=3.8',
python_requires='>=3.9',
keywords='switches feature flipper pyramid pylons turbogears',
author='Kyle Adams',
author_email='[email protected]',
Expand Down
25 changes: 17 additions & 8 deletions switchboard/admin/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
p + p { text-indent: 1.5em; margin-top: -1.5em; }
/* more typography, Switchboard-specific (i.e., not from Typelate) */
.switchboard .sort { line-height: 2.16667rem; }
.switchboard input[type="search"] { margin-left: 1rem; }
.switchboard input[type="search"] { margin-left: 1rem; width: 25%; }
/* general */
#content { width: 80%; margin: 0 auto; }
.switchboard { margin-bottom: 2rem; margin-top: 132px; }
Expand Down Expand Up @@ -163,7 +163,7 @@
content: " ▾";
}
/* table */
.switchboard .switches { width: 100%; collapse; margin-bottom: 1.65rem; }
.switchboard .switches { width: 100%; collapse; margin-bottom: 1.65rem; display: flex; flex-direction: column;}
.switchboard .switches .switch { border-top: 1px solid #bbb; padding: 1.65rem 0; position: relative; }
.switchboard .switches .switch.overlayed { opacity: 0.6; }
.switchboard .switches .switch > div { vertical-align: top; overflow:hidden; }
Expand All @@ -174,10 +174,10 @@
.switchboard .switches .name small { color: #666; }
.switchboard .switches .description, .switchboard .switches .description p { margin-bottom: 0; }
/* statuses */
.switchboard .switches .status { text-align: right; width: 100%; position: absolute; right: 0; top: 1.65rem; }
.switchboard .switches .status { text-align: right; position: absolute; right: 0; top: 1.65rem; }
.switchboard .switches .status label { display: inline-block; font-weight: bold; color: #222; }
.switchboard .switches .status label:after { content: ':'; }
.switchboard .switches .status select, .switchboard input[type="search"] { width: 25%; }
.switchboard .switches .status select { width: 25em; }
.switchboard .switch[data-switch-status="1"] .status select { border-left: 10px solid #cc4036; }
.switchboard .switch[data-switch-status="2"] .status select { border-left: 10px solid #faa732; }
.switchboard .switch[data-switch-status="3"] .status select { border-left: 10px solid #5bb75b; }
Expand Down Expand Up @@ -842,24 +842,33 @@

$('input[type=search]').keyup(function () {
var query = $(this).val();
$('.switches .switch', $sb).removeClass('hidden');
$('.switches .switch', $sb).removeClass('hidden').css('order', 0);
if (!query) {
return;
}
$('.switches .switch', $sb).each(function (_, el) {
var $el = $(el);
var score = 0;
score += $el.attr('data-switch-key').score(query);
score += $el.attr('data-switch-label').score(query);
score += $el.attr('data-switch-key').score(query) * 10;
score += $el.attr('data-switch-label').score(query) * 5;
if ($el.attr('data-switch-description')) {
score += $el.attr('data-switch-description').score(query);
score += $el.attr('data-switch-description').score(query) * 5;
}
score += $('.conditions', $el).text().score(query);
if (score === 0) {
$el.addClass('hidden');
}
$el.css('order', Math.round(-score*1000)); // smallest first; convert to large ints
});
});

window.addEventListener("keydown", (e) => {
if (!$('input[type=search]').is(':focus') && (e.code === 'F3' || e.code === 'Slash' || ((e.ctrlKey || e.metaKey) && e.code === 'KeyF'))) {
e.preventDefault();
$('input[type=search]').focus();
}
});

function closer($message) {
function slideComplete() {
$(this).removeClass('active');
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py{38,39,310,311,312}
envlist = py{39,310,311,312,313}

[testenv]
commands = pytest {posargs}
Expand All @@ -20,4 +20,4 @@ commands =
# or use pytest-cov package?
coverage run -m pytest
# "codecov" needs xml format, not .coverage file:
coverage xml
coverage xml