Virtual List added for history section.

This commit is contained in:
izerozlu
2019-08-27 13:33:31 +03:00
parent dabb7c370a
commit 515ea7e83d

View File

@@ -199,6 +199,7 @@
<script> <script>
import VirtualList from 'vue-virtual-scroll-list' import VirtualList from 'vue-virtual-scroll-list'
import section from "../components/section";
const statusCategories = [ const statusCategories = [
{name: 'informational', statusCodeRegex: new RegExp(/[1][0-9]+/), className: 'info-response'}, {name: 'informational', statusCodeRegex: new RegExp(/[1][0-9]+/), className: 'info-response'},
@@ -223,14 +224,11 @@
const findStatusGroup = responseStatus => statusCategories.find(status => status.statusCodeRegex.test(responseStatus)); const findStatusGroup = responseStatus => statusCategories.find(status => status.statusCodeRegex.test(responseStatus));
import section from "../components/section";
export default { export default {
components: { components: {
'pw-section': section, 'pw-section': section,
VirtualList VirtualList
}, },
data () { data () {
return { return {
method: 'GET', method: 'GET',
@@ -301,12 +299,13 @@
key, key,
value value
}) => `${key}=${encodeURIComponent(value)}`).join('&') }) => `${key}=${encodeURIComponent(value)}`).join('&')
return result == '' ? '' : `?${result}` return result === '' ? '' : `?${result}`
} }
}, },
methods: { methods: {
findEntryStatus(entry){ findEntryStatus(entry){
return findStatusGroup(entry.status); let foundStatusGroup = findStatusGroup(entry.status);
return foundStatusGroup || {className: ''};
}, },
deleteHistory(entry) { deleteHistory(entry) {
this.history.splice(this.history.indexOf(entry), 1) this.history.splice(this.history.indexOf(entry), 1)
@@ -332,19 +331,6 @@
if (this.$refs.response.$el.classList.contains('hidden')) { if (this.$refs.response.$el.classList.contains('hidden')) {
this.$refs.response.$el.classList.toggle('hidden') this.$refs.response.$el.classList.toggle('hidden')
} }
let now = new Date();
const n = now.toLocaleTimeString()
this.history = [{
millis: now.getTime(),
time: n,
method: this.method,
url: this.url,
path: this.path
}, ...this.history]
window.localStorage.setItem('history', JSON.stringify(this.history))
if (this.$refs.response.classList.contains('hidden')) {
this.$refs.response.classList.toggle('hidden')
}
this.$refs.response.$el.scrollIntoView({ this.$refs.response.$el.scrollIntoView({
behavior: 'smooth' behavior: 'smooth'
}) })