|
1 | 1 | <!-- |
2 | | - - Copyright 2014-2019 the original author or authors. |
| 2 | + - Copyright 2014-2020 the original author or authors. |
3 | 3 | - |
4 | 4 | - Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | - you may not use this file except in compliance with the License. |
|
105 | 105 | </template> |
106 | 106 |
|
107 | 107 | <script> |
108 | | - import subscribing from '@/mixins/subscribing'; |
109 | | - import Instance from '@/services/instance'; |
110 | | - import {concatMap, timer} from '@/utils/rxjs'; |
111 | | - import debounce from 'lodash/debounce'; |
112 | | - import mapKeys from 'lodash/mapKeys'; |
113 | | - import moment from 'moment'; |
114 | | - import {VIEW_GROUP} from '../../index'; |
115 | | - import sbaTracesChart from './traces-chart'; |
116 | | - import sbaTracesList from './traces-list'; |
| 108 | + import subscribing from '@/mixins/subscribing'; |
| 109 | + import Instance from '@/services/instance'; |
| 110 | + import {concatMap, timer} from '@/utils/rxjs'; |
| 111 | + import debounce from 'lodash/debounce'; |
| 112 | + import mapKeys from 'lodash/mapKeys'; |
| 113 | + import moment from 'moment'; |
| 114 | + import {VIEW_GROUP} from '../../index'; |
| 115 | + import sbaTracesChart from './traces-chart'; |
| 116 | + import sbaTracesList from './traces-list'; |
117 | 117 |
|
118 | | - const addToFilter = (oldFilter, addedFilter) => |
| 118 | + const addToFilter = (oldFilter, addedFilter) => |
119 | 119 | !oldFilter |
120 | 120 | ? addedFilter |
121 | 121 | : (val, key) => oldFilter(val, key) && addedFilter(val, key); |
|
127 | 127 | Object.assign(this, trace); |
128 | 128 | this.timestamp = moment(timestamp); |
129 | 129 | this.request = {...request, headers: normalize(request.headers)}; |
130 | | - this.response = {...response, headers: normalize(response.headers)}; |
| 130 | + this.response = response ? {...response, headers: normalize(response.headers)} : null; |
131 | 131 | } |
132 | 132 |
|
133 | 133 | get key() { |
134 | 134 | return `${this.timestamp.valueOf()}-${this.request.method}-${this.request.uri}`; |
135 | 135 | } |
136 | 136 |
|
137 | 137 | get contentLength() { |
138 | | - const contentLength = this.response.headers['content-length'] && this.response.headers['content-length'][0]; |
| 138 | + const contentLength = this.response && this.response.headers['content-length'] && this.response.headers['content-length'][0]; |
139 | 139 | if (contentLength && /^\d+$/.test(contentLength)) { |
140 | 140 | return parseInt(contentLength); |
141 | 141 | } |
142 | 142 | return null; |
143 | 143 | } |
144 | 144 |
|
145 | 145 | get contentType() { |
146 | | - const contentType = this.response.headers['content-type'] && this.response.headers['content-type'][0]; |
| 146 | + const contentType = this.response && this.response.headers['content-type'] && this.response.headers['content-type'][0]; |
147 | 147 | if (contentType) { |
148 | 148 | const idx = contentType.indexOf(';'); |
149 | 149 | return idx >= 0 ? contentType.substring(0, idx) : contentType; |
|
156 | 156 | } |
157 | 157 |
|
158 | 158 | isSuccess() { |
159 | | - return this.response.status <= 399 |
| 159 | + return this.response && this.response.status <= 399 |
160 | 160 | } |
161 | 161 |
|
162 | 162 | isClientError() { |
163 | | - return this.response.status >= 400 && this.response.status <= 499 |
| 163 | + return this.response && this.response.status >= 400 && this.response.status <= 499 |
164 | 164 | } |
165 | 165 |
|
166 | 166 | isServerError() { |
167 | | - return this.response.status >= 500 && this.response.status <= 599 |
| 167 | + return this.response && this.response.status >= 500 && this.response.status <= 599 |
168 | 168 | } |
169 | 169 | } |
170 | 170 |
|
|
0 commit comments