Skip to content

Commit 3e02e1c

Browse files
author
Daniel Herzog
committed
Added expand / collapse for request and response sections; Styling
1 parent 3655318 commit 3e02e1c

File tree

4 files changed

+55
-39
lines changed

4 files changed

+55
-39
lines changed

src/network/network_details_templates.js

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,49 @@ templates._request = function(request, is_last, do_raw)
141141
// A request that's followed by another one, without a response in between,
142142
// is not shown in network-details. It will mostly mean it was retried internally
143143
// and didn't go on the network.
144-
if (!is_last && !request.was_responded_to)
145-
return [];
144+
var is_relevant = is_last && request.was_responded_to;
145+
146+
var expanded = window.settings.network_logger.get("expand-requests");
147+
var show_headline = is_relevant;
148+
var show_headers = is_relevant && expanded;
149+
var show_body = show_headers;
146150

147151
return [
148-
templates._request_headers(request, do_raw),
149-
templates._request_body(request, do_raw)
152+
show_headline ? this._headline(false, expanded) : [],
153+
show_headers ? templates._request_headers(request, do_raw) : [],
154+
show_body ? templates._request_body(request, do_raw) : []
150155
];
151156
};
152157

153158
templates._response = function(response, is_last, do_raw)
154159
{
160+
var expanded = window.settings.network_logger.get("expand-responses");
161+
var show_headline = response.logger_entry_touched_network;
162+
var show_headers = expanded && response.logger_entry_touched_network;
163+
var show_body = expanded;
164+
155165
return [
156-
this._response_headers(response, do_raw),
157-
this._response_body(response, do_raw, is_last)
166+
show_headline ? this._headline(true, expanded) : [],
167+
show_headers ? this._response_headers(response, do_raw) : [],
168+
show_body ? this._response_body(response, do_raw, is_last) : []
158169
];
159170
};
160171

172+
templates._headline = function(is_response, is_unfolded)
173+
{
174+
return [
175+
"div",
176+
["input",
177+
"type", "button",
178+
"class", is_unfolded ? "unfolded" : ""
179+
],
180+
is_response ? ui_strings.S_NETWORK_REQUEST_DETAIL_RESPONSE_TITLE
181+
: ui_strings.S_NETWORK_REQUEST_DETAIL_REQUEST_TITLE,
182+
"handler", "toggle-expand-request-response",
183+
"class", "header"
184+
].concat(is_response ? ["data-is-response", "data-is-response"] : []);
185+
};
186+
161187
templates._header_token_templ = function(state, token)
162188
{
163189
var TYPE = 0;
@@ -187,8 +213,6 @@ templates._token_receiver = function(tokens, token_type, token)
187213

188214
templates._request_headers = function(req, do_raw)
189215
{
190-
var headline = ["h2", ui_strings.S_NETWORK_REQUEST_DETAIL_REQUEST_TITLE];
191-
192216
if (do_raw)
193217
{
194218
if (req.request_headers_raw)
@@ -204,12 +228,10 @@ templates._request_headers = function(req, do_raw)
204228
var state_holder = new cls.HTTPHeaderTokenizer.TokenStateholder(data_spec_firstline_tokens);
205229
var map_func = this._header_token_templ.bind(this, state_holder);
206230
return [
207-
headline,
208231
this._pre(req.header_tokens.map(map_func))
209232
];
210233
}
211234
return [
212-
headline,
213235
ui_strings.S_NETWORK_REQUEST_NO_HEADERS_LABEL
214236
];
215237
}
@@ -243,17 +265,12 @@ templates._request_headers = function(req, do_raw)
243265
}
244266
}
245267
return [
246-
headline,
247268
ret
248269
];
249270
};
250271

251272
templates._response_headers = function(resp, do_raw)
252273
{
253-
if (!resp.logger_entry_touched_network)
254-
return [];
255-
256-
var headline = ["h2", ui_strings.S_NETWORK_REQUEST_DETAIL_RESPONSE_TITLE];
257274
if (do_raw)
258275
{
259276
if (!resp.header_tokens)
@@ -269,12 +286,10 @@ templates._response_headers = function(resp, do_raw)
269286
var state_holder = new cls.HTTPHeaderTokenizer.TokenStateholder(data_spec_firstline_tokens);
270287
var map_func = this._header_token_templ.bind(this, state_holder);
271288
return [
272-
headline,
273289
this._pre(resp.header_tokens.map(map_func))
274290
];
275291
}
276292
return [
277-
headline,
278293
ui_strings.S_NETWORK_REQUEST_NO_HEADERS_LABEL
279294
];
280295
}
@@ -301,7 +316,6 @@ templates._response_headers = function(resp, do_raw)
301316
}
302317

303318
return [
304-
headline,
305319
ret
306320
];
307321
};

src/network/network_style.css

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@
277277
{
278278
overflow: auto;
279279
height: 100%;
280-
padding-left: 10px;
280+
padding-left: 5px;
281281
box-sizing: border-box;
282282
}
283283

284-
.height-holder
284+
.height-holder /* todo: probably merge me with entry-details */
285285
{
286286
height: 100%;
287287
width: 100%;
@@ -384,20 +384,8 @@
384384
padding: 10px 0 5px 0;
385385
}
386386

387-
.network-details-container h2 {
388-
font-weight: normal;
389-
font-size: 11px;
390-
padding: 0;
391-
margin: 10px -10px;
392-
padding-left: 10px;
393-
394-
line-height: 20px;
395-
background-color: #e9e9e9;
396-
background-image: -o-linear-gradient(-90deg,
397-
rgba(255, 255, 255, 0.85) 0,
398-
rgba(255, 255, 255, 0.45) 100%);
399-
background-image: linear-gradient(rgba(255, 255, 255, 0.85) 0,
400-
rgba(255, 255, 255, 0.45) 100%);
387+
.network-details-container div.header {
388+
margin: 0 -5px; /* todo: 10px -5px looks better to me but is inconsistent with dom panel headers */
401389
}
402390

403391
.entry-details > h2:first-child,

src/network/network_view.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,15 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
650650
}
651651
}.bind(this);
652652

653+
this._on_toggle_expand_request_response_bound = function(event)
654+
{
655+
var KEY = event.target.dataset.isResponse ? "expand-responses" : "expand-requests";
656+
var set_active = !settings.network_logger.get(KEY);
657+
settings.network_logger.set(KEY, set_active);
658+
this.needs_instant_update = true;
659+
this.update();
660+
}.bind(this);
661+
653662
/*
654663
// Todo: currently can't have the setting-changing context menu only on this container
655664
this._on_toggle_raw_mode_bound = function(event)
@@ -680,7 +689,7 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
680689
eh.click["select-network-viewmode"] = this._on_select_network_viewmode_bound;
681690
eh.click["type-filter-network-view"] = this._on_change_type_filter_bound;
682691
eh.click["profiler-mode-switch"] = this._on_toggle_network_profiler_bound;
683-
692+
eh.click["toggle-expand-request-response"] = this._on_toggle_expand_request_response_bound;
684693
eh.click["close-incomplete-warning"] = this._on_close_incomplete_warning_bound;
685694

686695
ActionHandlerInterface.apply(this);
@@ -718,7 +727,9 @@ cls.NetworkLog.create_ui_widgets = function()
718727
"network-profiler-mode": false,
719728
"detail-view-left-pos": 120,
720729
"track-content": true,
721-
"view-raw": false
730+
"view-raw": false,
731+
"expand-requests": true,
732+
"expand-responses": true
722733
},
723734
// key-label map
724735
{

src/ui-style/debugger_style.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,15 +404,17 @@ styles
404404
padding: 0 5px;
405405
}
406406

407-
header
407+
header,
408+
div.header
408409
{
409410
padding: 2px;
410411
background-color: #fff;
411412
border-bottom: 1px solid #fff;
412413
border-bottom-color: #ccc;
413414
}
414415

415-
container > div > header
416+
container > div > header,
417+
div.header
416418
{
417419
line-height: 20px;
418420
background-color: #e9e9e9;
@@ -433,7 +435,8 @@ category header:hover input
433435
opacity: 1;
434436
}
435437

436-
header input
438+
header input,
439+
.header input
437440
{
438441
background: transparent url('../ui-images/icons/icon_arrow_right.png') scroll no-repeat 50% 100%;
439442
border: none;

0 commit comments

Comments
 (0)