Реализовал фильтрацию по паттернам

This commit is contained in:
saber-nyan 2019-05-17 22:22:09 +03:00
parent c5a6a4012e
commit 8faa5bdc45
No known key found for this signature in database
GPG Key ID: 7B069E9C295E6B4A
4 changed files with 31 additions and 8 deletions

View File

@ -58,7 +58,6 @@ export default {
} }
instance.post(`/packet/${this.streamId}`, { instance.post(`/packet/${this.streamId}`, {
fetchLatest: false,
direction: 'ASC', direction: 'ASC',
startingFrom: startsFrom, startingFrom: startsFrom,
pageSize: parseInt(this.$store.state.pageSize), pageSize: parseInt(this.$store.state.pageSize),

View File

@ -1,5 +1,6 @@
<template> <template>
<div class="dropdown-item" :style="'color:' + color"> <div class="dropdown-item" :style="'color:' + color"
@click="openPattern">
{{name}}: {{regex ? `/${value}/` : `'${value}'`}} {{name}}: {{regex ? `/${value}/` : `'${value}'`}}
<div class="float-right"> <div class="float-right">
<button @click.prevent.stop="deleteSelf()" class="btn btn-outline-danger btn-block btn-sm" type="button">x</button> <button @click.prevent.stop="deleteSelf()" class="btn btn-outline-danger btn-block btn-sm" type="button">x</button>
@ -9,11 +10,17 @@
<script> <script>
import axios from "axios"; import axios from "axios";
import $ from "jquery";
export default { export default {
name: "FlagPattern", name: "FlagPattern",
props: ['name', 'value', 'color', 'id', 'regex',], props: ['name', 'value', 'color', 'id', 'regex',],
methods: { methods: {
openPattern() {
this.$router.push({name: 'home', params: this.$route.params, query: {pId: this.id,},});
// $('.dropdown').trigger('hide.bs.dropdown')
$('.dropdown-toggle').dropdown('toggle')
},
deleteSelf() { deleteSelf() {
const instance = axios.create({ const instance = axios.create({
baseURL: this.$store.state.apiUrl, baseURL: this.$store.state.apiUrl,

View File

@ -35,24 +35,36 @@ export default {
const newStream = this.$data.streams[index - 1]; const newStream = this.$data.streams[index - 1];
if (!newStream) return; if (!newStream) return;
const newId = newStream.id; const newId = newStream.id;
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}}); this.$router.push({
name: 'home',
params: {servicePort: this.$props.servicePort, streamId: newId,},
});
} else if (e.key === 'ArrowDown') { } else if (e.key === 'ArrowDown') {
e.preventDefault(); e.preventDefault();
const index = this.$data.streams.findIndex(e => e.id === this.$props.streamId); const index = this.$data.streams.findIndex(e => e.id === this.$props.streamId);
const newStream = this.$data.streams[index + 1]; const newStream = this.$data.streams[index + 1];
if (!newStream) return; if (!newStream) return;
const newId = newStream.id; const newId = newStream.id;
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}}); this.$router.push({
name: 'home',
params: {servicePort: this.$props.servicePort, streamId: newId,},
});
} else if (e.key === 'Home') { } else if (e.key === 'Home') {
const newStream = this.$data.streams[0]; const newStream = this.$data.streams[0];
if (!newStream) return; if (!newStream) return;
const newId = newStream.id; const newId = newStream.id;
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}}); this.$router.push({
name: 'home',
params: {servicePort: this.$props.servicePort, streamId: newId,},
});
} else if (e.key === 'End') { } else if (e.key === 'End') {
const newStream = this.$data.streams[this.$data.streams.length - 1]; const newStream = this.$data.streams[this.$data.streams.length - 1];
if (!newStream) return; if (!newStream) return;
const newId = newStream.id; const newId = newStream.id;
this.$router.push({name: 'home', params: {servicePort: this.$props.servicePort, streamId: newId}}); this.$router.push({
name: 'home',
params: {servicePort: this.$props.servicePort, streamId: newId,},
});
} }
}, },
} }
@ -63,6 +75,11 @@ export default {
this.streams = []; this.streams = [];
this.$refs.infiniteLoading.stateChanger.reset(); this.$refs.infiniteLoading.stateChanger.reset();
}, },
'$route.query': function (query) {
console.debug('Sidebar.vue: query changed! new:', query);
this.streams = [];
this.$refs.infiniteLoading.stateChanger.reset();
},
}, },
methods: { methods: {
infiniteHandler($state) { infiniteHandler($state) {
@ -88,10 +105,10 @@ export default {
} }
instance.post(`/stream/${this.$props.servicePort || 'all'}`, { instance.post(`/stream/${this.$props.servicePort || 'all'}`, {
fetchLatest: false,
direction: 'DESC', direction: 'DESC',
startingFrom: startsFrom, startingFrom: startsFrom,
pageSize: parseInt(this.$store.state.pageSize), pageSize: parseInt(this.$store.state.pageSize),
pattern: this.$route.query.pId ? {id: this.$route.query.pId,} : null,
}).then(response => { }).then(response => {
const data = response.data; const data = response.data;
if (data.length === 0) return $state.complete(); if (data.length === 0) return $state.complete();

View File

@ -1,6 +1,6 @@
<template> <template>
<li class="nav-item"> <li class="nav-item">
<router-link class="nav-link" active-class="active" :to="{ name: 'home', params: { servicePort: servicePort, streamId: id} }"> <router-link class="nav-link" active-class="active" :to="{ name: 'home', params: { servicePort: servicePort, streamId: id}, query: $route.query }">
#{{id}} {{proto}}<br/> #{{id}} {{proto}}<br/>
{{new Date(startTime).toLocaleDateString('ru-RU', {month: '2-digit', day: '2-digit', hour:'2-digit', minute: '2-digit', second: '2-digit'})}} {{new Date(startTime).toLocaleDateString('ru-RU', {month: '2-digit', day: '2-digit', hour:'2-digit', minute: '2-digit', second: '2-digit'})}}
- {{new Date(endTime).toLocaleTimeString('ru-RU', {hour:'2-digit', minute: '2-digit', second: '2-digit'})}} - {{new Date(endTime).toLocaleTimeString('ru-RU', {hour:'2-digit', minute: '2-digit', second: '2-digit'})}}