import React, { Component } from 'react'
import classnames from 'classnames'
import { RequestUtils, ResponseUtils } from '../../flow/utils.js'
import { formatSize, formatTimeDelta } from '../../utils.js'
export function TLSColumn({ flow }) {
return (
|
)
}
TLSColumn.headerClass = 'col-tls'
TLSColumn.headerName = ''
export function IconColumn({ flow }) {
return (
|
)
}
IconColumn.headerClass = 'col-icon'
IconColumn.headerName = ''
IconColumn.getIcon = flow => {
if (!flow.response) {
return 'resource-icon-plain'
}
var contentType = ResponseUtils.getContentType(flow.response) || ''
// @todo We should assign a type to the flow somewhere else.
if (flow.response.status_code === 304) {
return 'resource-icon-not-modified'
}
if (300 <= flow.response.status_code && flow.response.status_code < 400) {
return 'resource-icon-redirect'
}
if (contentType.indexOf('image') >= 0) {
return 'resource-icon-image'
}
if (contentType.indexOf('javascript') >= 0) {
return 'resource-icon-js'
}
if (contentType.indexOf('css') >= 0) {
return 'resource-icon-css'
}
if (contentType.indexOf('html') >= 0) {
return 'resource-icon-document'
}
return 'resource-icon-plain'
}
export function PathColumn({ flow }) {
let err;
if(flow.error){
if (flow.error.msg === "Connection killed"){
err =
} else {
err =
}
}
return (
{flow.request.is_replay && (
)}
{flow.intercepted && (
)}
{err}
{RequestUtils.pretty_url(flow.request)}
|
)
}
PathColumn.headerClass = 'col-path'
PathColumn.headerName = 'Path'
export function MethodColumn({ flow }) {
return (
{flow.request.method} |
)
}
MethodColumn.headerClass = 'col-method'
MethodColumn.headerName = 'Method'
export function StatusColumn({ flow }) {
let color = 'darkred';
if (flow.response !== null && 100 <= flow.response.status_code && flow.response.status_code < 200) {
color = 'green'
}
else if (flow.response !== null && 200 <= flow.response.status_code && flow.response.status_code < 300) {
color = 'darkgreen'
}
else if (flow.response !== null && 300 <= flow.response.status_code && flow.response.status_code < 400) {
color = 'lightblue'
}
else if (flow.response !== null && 400 <= flow.response.status_code && flow.response.status_code < 500) {
color = 'lightred'
}
else if (flow.response !== null && 500 <= flow.response.status_code && flow.response.status_code < 600) {
color = 'lightred'
}
return (
{flow.response && flow.response.status_code} |
)
}
StatusColumn.headerClass = 'col-status'
StatusColumn.headerName = 'Status'
export function SizeColumn({ flow }) {
return (
{formatSize(SizeColumn.getTotalSize(flow))} |
)
}
SizeColumn.getTotalSize = flow => {
let total = flow.request.contentLength
if (flow.response) {
total += flow.response.contentLength || 0
}
return total
}
SizeColumn.headerClass = 'col-size'
SizeColumn.headerName = 'Size'
export function TimeColumn({ flow }) {
return (
{flow.response ? (
formatTimeDelta(1000 * (flow.response.timestamp_end - flow.request.timestamp_start))
) : (
'...'
)}
|
)
}
TimeColumn.headerClass = 'col-time'
TimeColumn.headerName = 'Time'
export default [
TLSColumn,
IconColumn,
PathColumn,
MethodColumn,
StatusColumn,
SizeColumn,
TimeColumn,
]