File tree 7 files changed +32
-6
lines changed
templates/debug_toolbar/panels 7 files changed +32
-6
lines changed Original file line number Diff line number Diff line change @@ -8,13 +8,15 @@ style: package-lock.json
8
8
flake8
9
9
npx eslint --ignore-path .gitignore --fix .
10
10
npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS )
11
+ ! grep -r ' \(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
11
12
12
13
style_check : package-lock.json
13
14
isort -c .
14
15
black --target-version=py36 --check .
15
16
flake8
16
17
npx eslint --ignore-path .gitignore .
17
18
npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS )
19
+ ! grep -r ' \(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
18
20
19
21
example :
20
22
python example/manage.py migrate --noinput
Original file line number Diff line number Diff line change 601
601
# djDebug .djdt-width-60 {
602
602
width : 60% ;
603
603
}
604
+ # djDebug .djdt-max-height-100 {
605
+ max-height : 100% ;
606
+ }
604
607
# djDebug .djdt-highlighted {
605
608
background-color : lightgrey;
606
609
}
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ const djdt = {
44
44
inner . previousElementSibling . remove ( ) ; // Remove AJAX loader
45
45
inner . innerHTML = data . content ;
46
46
$$ . executeScripts ( data . scripts ) ;
47
+ $$ . applyStyles ( inner ) ;
47
48
} ) ;
48
49
}
49
50
}
Original file line number Diff line number Diff line change @@ -32,6 +32,26 @@ const $$ = {
32
32
document . head . appendChild ( el ) ;
33
33
} ) ;
34
34
} ,
35
+ applyStyles ( container ) {
36
+ /*
37
+ * Given a container element, apply styles set via data-djdt-styles attribute.
38
+ * The format is data-djdt-styles="styleName1:value;styleName2:value2"
39
+ * The style names should use the CSSStyleDeclaration camel cased names.
40
+ */
41
+ container
42
+ . querySelectorAll ( "[data-djdt-styles]" )
43
+ . forEach ( function ( element ) {
44
+ const styles = element . dataset . djdtStyles || "" ;
45
+ styles . split ( ";" ) . forEach ( function ( styleText ) {
46
+ const styleKeyPair = styleText . split ( ":" ) ;
47
+ if ( styleKeyPair . length === 2 ) {
48
+ const name = styleKeyPair [ 0 ] . trim ( ) ;
49
+ const value = styleKeyPair [ 1 ] . trim ( ) ;
50
+ element . style [ name ] = value ;
51
+ }
52
+ } ) ;
53
+ } ) ;
54
+ } ,
35
55
} ;
36
56
37
57
function ajax ( url , init ) {
Original file line number Diff line number Diff line change 3
3
{{ refresh_form }}
4
4
< button class ="refreshHistory "> Refresh</ button >
5
5
</ form >
6
- < table style =" max-height: 100%; ">
6
+ < table class =" djdt- max-height- 100 ">
7
7
< thead >
8
8
< tr >
9
9
< th > {% trans "Time" %}</ th >
Original file line number Diff line number Diff line change 14
14
{% for call in func_list %}
15
15
< tr class ="{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %} " id ="profilingMain_{{ call.id }} ">
16
16
< td >
17
- < div style =" padding-left :{{ call.indent }}px ">
17
+ < div data-djdt-styles =" paddingLeft :{{ call.indent }}px ">
18
18
{% if call.has_subfuncs %}
19
19
< button type ="button " class ="djProfileToggleDetails djToggleSwitch " data-toggle-name ="profilingMain " data-toggle-id ="{{ call.id }} "> -</ button >
20
20
{% else %}
Original file line number Diff line number Diff line change 2
2
< ul >
3
3
{% for alias, info in databases %}
4
4
< li >
5
- < strong > < span class ="djdt-color " style =" background-color :rgb({{ info.rgb_color|join:', ' }}) "> </ span > {{ alias }}</ strong >
5
+ < strong > < span class ="djdt-color " data-djdt-styles =" backgroundColor :rgb({{ info.rgb_color|join:', ' }}) "> </ span > {{ alias }}</ strong >
6
6
{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %}
7
7
{% if info.similar_count %}
8
8
{% blocktrans with count=info.similar_count trimmed %}
40
40
< tbody >
41
41
{% for query in queries %}
42
42
< tr class ="{% if query.is_slow %} djDebugRowWarning{% endif %} " id ="sqlMain_{{ forloop.counter }} ">
43
- < td > < span class ="djdt-color " style =" background-color :rgb({{ query.rgb_color|join:', '}}) "> </ span > </ td >
43
+ < td > < span class ="djdt-color " data-djdt-styles =" backgroundColor :rgb({{ query.rgb_color|join:', '}}) "> </ span > </ td >
44
44
< td class ="djdt-toggle ">
45
45
< button type ="button " class ="djToggleSwitch " data-toggle-name ="sqlMain " data-toggle-id ="{{ forloop.counter }} "> +</ button >
46
46
</ td >
47
47
< td >
48
48
< div class ="djDebugSql "> {{ query.sql|safe }}</ div >
49
49
{% if query.similar_count %}
50
50
< strong >
51
- < span class ="djdt-color " style =" background-color :{{ query.similar_color }} "> </ span >
51
+ < span class ="djdt-color " data-djdt-styles =" backgroundColor :{{ query.similar_color }} "> </ span >
52
52
{% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %}
53
53
</ strong >
54
54
{% endif %}
55
55
{% if query.duplicate_count %}
56
56
< strong >
57
- < span class ="djdt-color " style =" background-color :{{ query.duplicate_color }} "> </ span >
57
+ < span class ="djdt-color " data-djdt-styles =" backgroundColor :{{ query.duplicate_color }} "> </ span >
58
58
{% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %}
59
59
</ strong >
60
60
{% endif %}
You can’t perform that action at this time.
0 commit comments