File tree Expand file tree Collapse file tree 7 files changed +32
-6
lines changed
templates/debug_toolbar/panels Expand file tree Collapse file tree 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
88 flake8
99 npx eslint --ignore-path .gitignore --fix .
1010 npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS )
11+ ! grep -r ' \(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1112
1213style_check : package-lock.json
1314 isort -c .
1415 black --target-version=py36 --check .
1516 flake8
1617 npx eslint --ignore-path .gitignore .
1718 npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS )
19+ ! grep -r ' \(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1820
1921example :
2022 python example/manage.py migrate --noinput
Original file line number Diff line number Diff line change 601601# djDebug .djdt-width-60 {
602602 width : 60% ;
603603}
604+ # djDebug .djdt-max-height-100 {
605+ max-height : 100% ;
606+ }
604607# djDebug .djdt-highlighted {
605608 background-color : lightgrey;
606609}
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ const djdt = {
4444 inner . previousElementSibling . remove ( ) ; // Remove AJAX loader
4545 inner . innerHTML = data . content ;
4646 $$ . executeScripts ( data . scripts ) ;
47+ $$ . applyStyles ( inner ) ;
4748 } ) ;
4849 }
4950 }
Original file line number Diff line number Diff line change @@ -32,6 +32,26 @@ const $$ = {
3232 document . head . appendChild ( el ) ;
3333 } ) ;
3434 } ,
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+ } ,
3555} ;
3656
3757function ajax ( url , init ) {
Original file line number Diff line number Diff line change 33 {{ refresh_form }}
44 < button class ="refreshHistory "> Refresh</ button >
55</ form >
6- < table style =" max-height: 100%; ">
6+ < table class =" djdt- max-height- 100 ">
77 < thead >
88 < tr >
99 < th > {% trans "Time" %}</ th >
Original file line number Diff line number Diff line change 1414 {% for call in func_list %}
1515 < tr class ="{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %} " id ="profilingMain_{{ call.id }} ">
1616 < td >
17- < div style =" padding-left :{{ call.indent }}px ">
17+ < div data-djdt-styles =" paddingLeft :{{ call.indent }}px ">
1818 {% if call.has_subfuncs %}
1919 < button type ="button " class ="djProfileToggleDetails djToggleSwitch " data-toggle-name ="profilingMain " data-toggle-id ="{{ call.id }} "> -</ button >
2020 {% else %}
Original file line number Diff line number Diff line change 22< ul >
33 {% for alias, info in databases %}
44 < 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 >
66 {{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %}
77 {% if info.similar_count %}
88 {% blocktrans with count=info.similar_count trimmed %}
4040 < tbody >
4141 {% for query in queries %}
4242 < 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 >
4444 < td class ="djdt-toggle ">
4545 < button type ="button " class ="djToggleSwitch " data-toggle-name ="sqlMain " data-toggle-id ="{{ forloop.counter }} "> +</ button >
4646 </ td >
4747 < td >
4848 < div class ="djDebugSql "> {{ query.sql|safe }}</ div >
4949 {% if query.similar_count %}
5050 < 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 >
5252 {% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %}
5353 </ strong >
5454 {% endif %}
5555 {% if query.duplicate_count %}
5656 < 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 >
5858 {% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %}
5959 </ strong >
6060 {% endif %}
You can’t perform that action at this time.
0 commit comments