mirror of
https://github.com/Av0idD4rk/packmate.git
synced 2026-10-24 18:29:26 +00:00
Add ability to delete patterns
This commit is contained in:
parent
cfdfc9e578
commit
db8370e40c
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,29 +1,14 @@
|
|||||||
.idea/**/workspace.xml
|
.idea
|
||||||
.idea/**/tasks.xml
|
|
||||||
.idea/**/dictionaries
|
|
||||||
.idea/**/shelf
|
|
||||||
.idea/**/dataSources/
|
|
||||||
.idea/**/dataSources.ids
|
|
||||||
.idea/**/dataSources.local.xml
|
|
||||||
.idea/**/sqlDataSources.xml
|
|
||||||
.idea/**/dynamic.xml
|
|
||||||
.idea/**/uiDesigner.xml
|
|
||||||
.idea/**/dbnavigator.xml
|
|
||||||
.idea/**/gradle.xml
|
|
||||||
.idea/**/libraries
|
|
||||||
cmake-build-debug/
|
cmake-build-debug/
|
||||||
cmake-build-release/
|
cmake-build-release/
|
||||||
.idea/**/mongoSettings.xml
|
|
||||||
*.iws
|
*.iws
|
||||||
out/
|
out/
|
||||||
.idea_modules/
|
.idea_modules/
|
||||||
atlassian-ide-plugin.xml
|
atlassian-ide-plugin.xml
|
||||||
.idea/replstate.xml
|
|
||||||
com_crashlytics_export_strings.xml
|
com_crashlytics_export_strings.xml
|
||||||
crashlytics.properties
|
crashlytics.properties
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
fabric.properties
|
fabric.properties
|
||||||
.idea/httpRequests
|
|
||||||
*.bak
|
*.bak
|
||||||
/.tgitconfig
|
/.tgitconfig
|
||||||
logs
|
logs
|
||||||
|
|||||||
@ -1,69 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<code_scheme name="Project" version="173">
|
|
||||||
<option name="LINE_SEPARATOR" value=" " />
|
|
||||||
<option name="FORMATTER_TAGS_ENABLED" value="true" />
|
|
||||||
<option name="SOFT_MARGINS" value="90,120" />
|
|
||||||
<CssCodeStyleSettings>
|
|
||||||
<option name="HEX_COLOR_UPPER_CASE" value="true" />
|
|
||||||
</CssCodeStyleSettings>
|
|
||||||
<JSCodeStyleSettings version="0">
|
|
||||||
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
||||||
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
||||||
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
||||||
</JSCodeStyleSettings>
|
|
||||||
<codeStyleSettings language="CSS">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="CoffeeScript">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="HTML">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="JavaScript">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="LESS">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="INDENT_SIZE" value="4" />
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="SASS">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="INDENT_SIZE" value="4" />
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="SCSS">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="INDENT_SIZE" value="4" />
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="Stylus">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="INDENT_SIZE" value="4" />
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="TypeScript">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
<codeStyleSettings language="XML">
|
|
||||||
<indentOptions>
|
|
||||||
<option name="USE_TAB_CHARACTER" value="true" />
|
|
||||||
</indentOptions>
|
|
||||||
</codeStyleSettings>
|
|
||||||
</code_scheme>
|
|
||||||
</component>
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<state>
|
|
||||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="DiscordProjectSettings">
|
|
||||||
<option name="show" value="true" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectNotificationSettings">
|
|
||||||
<option name="askShowProject" value="false" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="JavaScriptLibraryMappings">
|
|
||||||
<includedPredefinedLibrary name="Node.js Core" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="JavaScriptSettings">
|
|
||||||
<option name="languageLevel" value="ES6" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/packmate-frontend.iml" filepath="$PROJECT_DIR$/.idea/packmate-frontend.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$" />
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="SaveActionSettings">
|
|
||||||
<option name="actions">
|
|
||||||
<set>
|
|
||||||
<option value="activate" />
|
|
||||||
<option value="activateOnBatch" />
|
|
||||||
<option value="organizeImports" />
|
|
||||||
<option value="reformat" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CommitMessageInspectionProfile">
|
|
||||||
<profile version="1.0">
|
|
||||||
<inspection_tool class="GrazieCommit" enabled="true" level="TYPO" enabled_by_default="true" />
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
15
src/App.vue
15
src/App.vue
@ -100,10 +100,6 @@
|
|||||||
this.addPatternFromWs(parsed.value);
|
this.addPatternFromWs(parsed.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'DELETE_PATTERN': {
|
|
||||||
this.deletePatternFromWs(parsed.value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'COUNTERS_UPDATE': {
|
case 'COUNTERS_UPDATE': {
|
||||||
const data = parsed.value;
|
const data = parsed.value;
|
||||||
this.$store.commit('setCurrentPacketsCount', data.totalPackets);
|
this.$store.commit('setCurrentPacketsCount', data.totalPackets);
|
||||||
@ -171,10 +167,15 @@
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
addPatternFromWs(pattern) {
|
addPatternFromWs(pattern) {
|
||||||
|
const foundIndex = this.$store.state.patterns.findIndex(el => el.id === pattern.id);
|
||||||
|
if (foundIndex === -1) {
|
||||||
this.$store.commit('addPattern', pattern);
|
this.$store.commit('addPattern', pattern);
|
||||||
},
|
return;
|
||||||
deletePatternFromWs(id) {
|
}
|
||||||
this.$store.commit('setPatterns', this.$store.state.patterns.filter(o => o.id !== id));
|
|
||||||
|
let newPatterns = this.$store.state.patterns.slice();
|
||||||
|
newPatterns.splice(foundIndex, 1, pattern);
|
||||||
|
this.$store.commit('setPatterns', newPatterns);
|
||||||
},
|
},
|
||||||
togglePatternFromWs(id, enabled) {
|
togglePatternFromWs(id, enabled) {
|
||||||
this.$store.state.patterns.forEach(pattern => {
|
this.$store.state.patterns.forEach(pattern => {
|
||||||
|
|||||||
@ -124,6 +124,7 @@
|
|||||||
}, {}); // Array to object
|
}, {}); // Array to object
|
||||||
let offset = 0;
|
let offset = 0;
|
||||||
this.packet.matches
|
this.packet.matches
|
||||||
|
.filter(match => !patterns[match.patternId].deleted)
|
||||||
.sort((a, b) => a.startPosition - b.startPosition)
|
.sort((a, b) => a.startPosition - b.startPosition)
|
||||||
.forEach(match => {
|
.forEach(match => {
|
||||||
const pattern = patterns[match.patternId];
|
const pattern = patterns[match.patternId];
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
<b-dropdown-item-button @click.stop.prevent="resetPatternSelection">
|
<b-dropdown-item-button @click.stop.prevent="resetPatternSelection">
|
||||||
<strong>All streams</strong>
|
<strong>All streams</strong>
|
||||||
</b-dropdown-item-button>
|
</b-dropdown-item-button>
|
||||||
<b-dropdown-item-button v-for="pattern in this.$store.state.patterns"
|
<b-dropdown-item-button v-for="pattern in existingPatterns"
|
||||||
:key="pattern.id" @click.stop.prevent="openPattern(pattern)"
|
:key="pattern.id" @click.stop.prevent="openPattern(pattern)"
|
||||||
:class="{ 'ignore-pattern' : pattern.actionType === 'IGNORE' }">
|
:class="{ 'ignore-pattern' : pattern.actionType === 'IGNORE' }">
|
||||||
|
|
||||||
@ -36,16 +36,22 @@
|
|||||||
<i class="fas fa-backward"></i>
|
<i class="fas fa-backward"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button v-if="pattern.enabled" type="button" class="btn btn-outline-danger btn-sm"
|
<button v-if="pattern.enabled" type="button" class="btn btn-outline-danger btn-sm mr-1"
|
||||||
@click.stop.prevent="togglePattern(pattern)"
|
@click.stop.prevent="togglePattern(pattern)"
|
||||||
title="Stop matching streams with this pattern">
|
title="Stop matching streams with this pattern">
|
||||||
<i class="fas fa-pause"></i>
|
<i class="fas fa-pause"></i>
|
||||||
</button>
|
</button>
|
||||||
<button v-else type="button" class="btn btn-outline-success btn-sm"
|
<button v-else type="button" class="btn btn-outline-success btn-sm mr-1"
|
||||||
@click.stop.prevent="togglePattern(pattern)"
|
@click.stop.prevent="togglePattern(pattern)"
|
||||||
title="Start matching streams with this pattern again">
|
title="Start matching streams with this pattern again">
|
||||||
<i class="fas fa-play"></i>
|
<i class="fas fa-play"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-outline-danger btn-sm"
|
||||||
|
@click.stop.prevent="deletePattern(pattern)"
|
||||||
|
title="Permanently delete this pattern">
|
||||||
|
<i class="fas fa-trash"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</b-dropdown-item-button>
|
</b-dropdown-item-button>
|
||||||
</b-dropdown>
|
</b-dropdown>
|
||||||
@ -56,6 +62,11 @@
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.updatePatterns();
|
this.updatePatterns();
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
existingPatterns: function () {
|
||||||
|
return this.$store.state.patterns.filter(p => !p.deleted)
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getSearchTypeValue(searchType, value) {
|
getSearchTypeValue(searchType, value) {
|
||||||
if (searchType === 'REGEX') return `/${value}/`;
|
if (searchType === 'REGEX') return `/${value}/`;
|
||||||
@ -113,7 +124,7 @@
|
|||||||
togglePattern(pattern) {
|
togglePattern(pattern) {
|
||||||
const enabled = !pattern.enabled;
|
const enabled = !pattern.enabled;
|
||||||
console.debug('Toggling pattern', pattern);
|
console.debug('Toggling pattern', pattern);
|
||||||
this.$http.post(`pattern/${pattern.id}/`, null, {
|
this.$http.post(`pattern/${pattern.id}/enable`, null, {
|
||||||
params: {
|
params: {
|
||||||
enabled,
|
enabled,
|
||||||
},
|
},
|
||||||
@ -130,6 +141,21 @@
|
|||||||
console.error('Failed to toggle pattern', e);
|
console.error('Failed to toggle pattern', e);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
deletePattern(pattern) {
|
||||||
|
console.debug('Deleting pattern', pattern);
|
||||||
|
|
||||||
|
this.$http.delete(`pattern/${pattern.id}`, null)
|
||||||
|
.then(() => {
|
||||||
|
console.debug('Done deleting pattern');
|
||||||
|
this.$emit('patternAddComplete');
|
||||||
|
}).catch(e => {
|
||||||
|
this.$bvToast.toast(`Failed to delete pattern: ${e}`, {
|
||||||
|
title: 'Error',
|
||||||
|
variant: 'danger',
|
||||||
|
});
|
||||||
|
console.error('Failed to delete pattern', e);
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-if="stream.userAgentHash"><br/>UA: {{ stream.userAgentHash }}</template>
|
<template v-if="stream.userAgentHash"><br/>UA: {{ stream.userAgentHash }}</template>
|
||||||
<br/>
|
<br/>
|
||||||
<span v-for="pattern in stream.foundPatterns"
|
<span v-for="pattern in notDeletedFoundPatterns"
|
||||||
:key="pattern.id"
|
:key="pattern.id"
|
||||||
:style="`color: ${pattern.color};`">
|
:style="`color: ${pattern.color};`">
|
||||||
{{ pattern.name }}
|
{{ pattern.name }}
|
||||||
@ -44,6 +44,9 @@
|
|||||||
shouldShowServiceName: function () {
|
shouldShowServiceName: function () {
|
||||||
return this.$route?.params?.servicePort === undefined;
|
return this.$route?.params?.servicePort === undefined;
|
||||||
},
|
},
|
||||||
|
notDeletedFoundPatterns: function () {
|
||||||
|
return this.stream.foundPatterns.filter(p => !p.deleted);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user