Skip to content

Commit 9702d99

Browse files
author
Daniel Herzog
committed
Added separate wrapping setting; Added temp buttons for raw and wrap; Removed context menu option; Fixed name-value tables in details view; Fixed headers to stretch to full width; Cleanup
1 parent 59af4fa commit 9702d99

File tree

4 files changed

+84
-61
lines changed

4 files changed

+84
-61
lines changed

src/network/network_details_templates.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ templates._pre = function(content)
1313
return ["pre", content, "class", "mono"];
1414
};
1515

16-
templates.details = function(entry, left_val, do_raw)
16+
templates.details = function(entry, left_val, do_raw, do_wrap)
1717
{
1818
return (
1919
["div",
@@ -23,15 +23,17 @@ templates.details = function(entry, left_val, do_raw)
2323
"handler", "resize-request-detail"
2424
],
2525
["div",
26-
this._details_headline(entry),
27-
this._details_content(entry, do_raw),
26+
["div",
27+
this._details_headline(entry),
28+
this._details_content(entry, do_raw),
29+
"class", "table-cell"
30+
],
2831
"data-object-id", String(entry.id),
2932
"class", "entry-details"
30-
// Todo: currently can't have the setting-changing context menu only on this container
31-
// ,"data-menu", "network-logger-details"
3233
]
3334
],
34-
"class", "network-details-container" + (do_raw? "" : " parsed"),
35+
"class", "network-details-container" +
36+
(do_wrap ? " network-details-container-wrap" : ""),
3537
"style", "left:" + left_val + "px"]
3638
);
3739
};
@@ -170,7 +172,7 @@ templates._header_token_templ = function(state, token)
170172
{
171173
if (token[TYPE] === cls.HTTPHeaderTokenizer.types.NAME)
172174
{
173-
attrs.extend(["data-spec", "http#" + token[STR].trim()]);
175+
attrs.extend(["data-spec", "http#" + token[STR].trim(), "data-tooltip", "network-header-tooltip"]);
174176
}
175177
else if (token[TYPE] === cls.HTTPHeaderTokenizer.types.FIRST_LINE_PART)
176178
{
@@ -245,18 +247,20 @@ templates._request_headers = function(req, do_raw)
245247
return templates._pre(ret);
246248
};
247249

250+
templates._reduce_tokens = function(map_func, previous_val, current_val, index){
251+
if (index == 1)
252+
previous_val = map_func(previous_val);
253+
return previous_val.concat(map_func(current_val));
254+
};
255+
248256
templates.headers_tonkenized = function(tokens, data_spec_firstline_tokens)
249257
{
250258
var state_holder = new cls.HTTPHeaderTokenizer.TokenStateholder(data_spec_firstline_tokens);
251259
var map_func = this._header_token_templ.bind(this, state_holder);
252-
var token_templates = tokens.reduce(function(previous_val, current_val, index){
253-
if (index == 1)
254-
previous_val = map_func(previous_val);
255-
return previous_val.concat(map_func(current_val));
256-
});
260+
var token_templates = tokens.reduce(this._reduce_tokens.bind(this, map_func));
257261
token_templates.push(state_holder.str_buffer);
258262
return token_templates;
259-
}
263+
};
260264

261265
templates._response_headers = function(resp, do_raw)
262266
{
@@ -363,10 +367,10 @@ templates._request_body = function(req, do_raw)
363367
}
364368
else if (req.request_body.mimeType.startswith("application/x-www-form-urlencoded"))
365369
{
366-
var url_enc_template = [];
370+
var url_enc_template;
367371
if (do_raw)
368372
{
369-
url_enc_template.push(req.request_body.content.stringData);
373+
url_enc_template = req.request_body.content.stringData;
370374
}
371375
else
372376
{
@@ -380,7 +384,7 @@ templates._request_body = function(req, do_raw)
380384
);
381385
rows.extend(parts.map(this.param_cells));
382386
var table = ["table", rows];
383-
url_enc_template.push(table);
387+
url_enc_template = table;
384388
}
385389
ret = url_enc_template;
386390
}

src/network/network_style.css

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
}
199199

200200
/* Network log / Detail view */
201-
.network_logger .close-request-detail,
202201
.network_logger .close_incomplete_warning
203202
{
204203
width: 15px;
@@ -213,7 +212,6 @@
213212
position: absolute;
214213
}
215214

216-
.network_logger .close-request-detail::before,
217215
.network_logger .close_incomplete_warning::before
218216
{
219217
content: "";
@@ -223,21 +221,13 @@
223221
background: transparent url("../ui-images/icons/icon_close_tab_small.png") 50% 50% no-repeat;
224222
}
225223

226-
.network_logger .close-request-detail:active,
227224
.network_logger .close_incomplete_warning:active
228225
{
229226
background-color: rgba(0, 0, 0, 0.28);
230227
box-shadow: 0 1px #fff,
231228
inset 0 1px 1px rgba(0, 0, 0, 0.15),
232229
inset 0 0 4px rgba(0, 0, 0, 0.05);
233230
}
234-
.close-request-detail
235-
{
236-
display: inline-block;
237-
position: absolute;
238-
right: 7px;
239-
top: 7px;
240-
}
241231

242232
.network_logger .close_incomplete_warning
243233
{
@@ -254,11 +244,6 @@
254244
cursor: col-resize;
255245
}
256246

257-
.network-details-container .close-request-detail:active
258-
{
259-
background-color: #cacaca;
260-
}
261-
262247
.network-details-container
263248
{
264249
position: absolute;
@@ -282,17 +267,27 @@
282267
overflow: auto;
283268
}
284269

270+
.network-details-container .table-cell
271+
{
272+
display: table-cell;
273+
}
274+
275+
.network-details-container-wrap .table-cell
276+
{
277+
display: block;
278+
}
279+
285280
.method-and-url
286281
{
287282
white-space: pre;
288283
}
289284

290-
.parsed .method-and-url
285+
.network-details-container-wrap .method-and-url
291286
{
292287
word-wrap: break-word;
293288
}
294289

295-
.network_logger .header-token-type-first_line_part
290+
.network-details-container .header-token-type-first_line_part
296291
{
297292
font-weight: bold;
298293
}
@@ -321,14 +316,21 @@
321316
margin: 0;
322317
}
323318

324-
.parsed pre,
325-
.parsed p,
326-
.parsed td
319+
.network-details-container-wrap pre,
320+
.network-details-container-wrap p,
321+
.network-details-container-wrap td
327322
{
328323
word-wrap: break-word;
324+
white-space: pre;
329325
}
330326

331-
.parsed .entry-details img {
327+
.network-details-container-wrap td
328+
{
329+
/* not entirely sure why only pre-wrap helps here */
330+
white-space: pre-wrap;
331+
}
332+
333+
.network-details-container-wrap img {
332334
width: 100%;
333335
}
334336

@@ -342,10 +344,19 @@
342344
border-collapse: collapse;
343345
}
344346

347+
.network-details-container table
348+
{
349+
width: 1px;
350+
}
351+
352+
.network-details-container-wrap table
353+
{
354+
width: 100%;
355+
}
356+
345357
.network-details-container td,
346358
.network-details-container th
347359
{
348-
padding: 0 5px 0 0;
349360
vertical-align: top;
350361
}
351362

@@ -355,7 +366,8 @@
355366
white-space: nowrap;
356367
}
357368

358-
.network-details-container th:first-child
369+
.network-details-container th:first-child,
370+
.network-details-container td:first-child
359371
{
360372
width: 20%;
361373
padding-right: 30px;
@@ -379,12 +391,6 @@
379391
margin: 0 0 0 -5px; /* todo: 10px 0 10px -5px; looks better to me but is inconsistent with dom panel headers */
380392
}
381393

382-
.entry-details > h2:first-child,
383-
.entry-details tbody:first-child tr:first-child h2
384-
{
385-
margin-top: 0;
386-
}
387-
388394
.network_logger .network-main-container .sortable-table .network-graph-column
389395
{
390396
line-height: 0;
@@ -457,6 +463,7 @@
457463
.network-tooltip-container table
458464
{
459465
border-collapse: collapse;
466+
width: 100%;
460467
}
461468

462469
.network-tooltip-container td

src/network/network_view.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
9999
var left_val = settings.network_logger.get("detail-view-left-pos");
100100
left_val = Math.min(left_val, window.innerWidth - MINIMUM_DETAIL_WIDTH);
101101
var do_raw = settings.network_logger.get("view-raw");
102-
return templates.network.details(entry, left_val, do_raw);
102+
var do_wrap = settings.network_logger.get("wrap-detail-view");
103+
return templates.network.details(entry, left_val, do_raw, do_wrap);
103104
};
104105

105106
this._render_click_to_fetch_view = function(container)
@@ -525,9 +526,7 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
525526

526527
this._on_header_tooltip_bound = function(evt, target)
527528
{
528-
// Probably make a template do the work. Need to know raw or parsed though, or probably only do it
529-
// on the parsed headers.
530-
529+
// console.log("_on_header_tooltip_bound", evt, target);
531530
}.bind(this);
532531

533532
this._update_mono_lineheight = function()
@@ -691,15 +690,6 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
691690
this.update();
692691
}.bind(this);
693692

694-
/*
695-
// Todo: currently can't have the setting-changing context menu only on this container
696-
this._on_toggle_raw_mode_bound = function(event)
697-
{
698-
var KEY = "view-raw";
699-
settings.network_logger.set(KEY, !settings.network_logger.get(KEY));
700-
}.bind(this);
701-
*/
702-
703693
var eh = window.eventHandlers;
704694

705695
eh.click["select-network-request"] = this._on_clicked_request_bound;
@@ -760,6 +750,7 @@ cls.NetworkLog.create_ui_widgets = function()
760750
"detail-view-left-pos": 120,
761751
"track-content": true,
762752
"view-raw": false,
753+
"wrap-detail-view": true,
763754
"expand-requests": true,
764755
"expand-responses": true
765756
},
@@ -768,12 +759,12 @@ cls.NetworkLog.create_ui_widgets = function()
768759
"pause": ui_strings.S_TOGGLE_PAUSED_UPDATING_NETWORK_VIEW,
769760
"network-profiler-mode": ui_strings.S_BUTTON_SWITCH_TO_NETWORK_PROFILER,
770761
"track-content": ui_strings.S_NETWORK_CONTENT_TRACKING_SETTING_TRACK_LABEL,
771-
"view-raw": ui_strings.S_NETWORK_RAW_VIEW_LABEL
762+
"view-raw": ui_strings.S_NETWORK_RAW_VIEW_LABEL,
763+
"wrap-detail-view": ui_strings.S_NETWORK_WRAP_LINES_LABEL
772764
},
773765
// settings map
774766
{
775-
checkboxes: ["track-content", "view-raw"],
776-
contextmenu: ["view-raw"]
767+
checkboxes: ["track-content"]
777768
},
778769
// templates
779770
{
@@ -874,6 +865,24 @@ cls.NetworkLog.create_ui_widgets = function()
874865
],
875866
handler: "profiler-mode-switch"
876867
},
868+
{
869+
type: UI.TYPE_SWITCH,
870+
items: [
871+
{
872+
key: "network_logger.view-raw",
873+
icon: "view-raw"
874+
}
875+
]
876+
},
877+
{
878+
type: UI.TYPE_SWITCH,
879+
items: [
880+
{
881+
key: "network_logger.wrap-detail-view",
882+
icon: "wrap-detail-view"
883+
}
884+
]
885+
},
877886
{
878887
type: UI.TYPE_INPUT,
879888
items: [

src/ui-strings/ui_strings-en.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,9 @@ ui_strings.S_NETWORK_N_BYTE_BODY = "Request body of %s bytes";
12631263
/* DESC: Name of networks raw-view setting, shows requests and responses raw instead of parsed */
12641264
ui_strings.S_NETWORK_RAW_VIEW_LABEL = "Show raw requests and responses";
12651265

1266+
/* DESC: Name of networks wrap-lines setting */
1267+
ui_strings.S_NETWORK_WRAP_LINES_LABEL = "Wrap long lines";
1268+
12661269
/* DESC: Name of entry in Network Log, used in summary at the end */
12671270
ui_strings.S_NETWORK_REQUEST = "Request";
12681271

0 commit comments

Comments
 (0)