mirror of
https://github.com/Av0idD4rk/packmate.git
synced 2026-10-23 15:31:00 +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/**/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
|
||||
.idea
|
||||
cmake-build-debug/
|
||||
cmake-build-release/
|
||||
.idea/**/mongoSettings.xml
|
||||
*.iws
|
||||
out/
|
||||
.idea_modules/
|
||||
atlassian-ide-plugin.xml
|
||||
.idea/replstate.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
.idea/httpRequests
|
||||
*.bak
|
||||
/.tgitconfig
|
||||
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>
|
||||
17
src/App.vue
17
src/App.vue
@ -100,10 +100,6 @@
|
||||
this.addPatternFromWs(parsed.value);
|
||||
break;
|
||||
}
|
||||
case 'DELETE_PATTERN': {
|
||||
this.deletePatternFromWs(parsed.value);
|
||||
break;
|
||||
}
|
||||
case 'COUNTERS_UPDATE': {
|
||||
const data = parsed.value;
|
||||
this.$store.commit('setCurrentPacketsCount', data.totalPackets);
|
||||
@ -171,10 +167,15 @@
|
||||
};
|
||||
},
|
||||
addPatternFromWs(pattern) {
|
||||
this.$store.commit('addPattern', pattern);
|
||||
},
|
||||
deletePatternFromWs(id) {
|
||||
this.$store.commit('setPatterns', this.$store.state.patterns.filter(o => o.id !== id));
|
||||
const foundIndex = this.$store.state.patterns.findIndex(el => el.id === pattern.id);
|
||||
if (foundIndex === -1) {
|
||||
this.$store.commit('addPattern', pattern);
|
||||
return;
|
||||
}
|
||||
|
||||
let newPatterns = this.$store.state.patterns.slice();
|
||||
newPatterns.splice(foundIndex, 1, pattern);
|
||||
this.$store.commit('setPatterns', newPatterns);
|
||||
},
|
||||
togglePatternFromWs(id, enabled) {
|
||||
this.$store.state.patterns.forEach(pattern => {
|
||||
|
||||
@ -124,6 +124,7 @@
|
||||
}, {}); // Array to object
|
||||
let offset = 0;
|
||||
this.packet.matches
|
||||
.filter(match => !patterns[match.patternId].deleted)
|
||||
.sort((a, b) => a.startPosition - b.startPosition)
|
||||
.forEach(match => {
|
||||
const pattern = patterns[match.patternId];
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
<b-dropdown-item-button @click.stop.prevent="resetPatternSelection">
|
||||
<strong>All streams</strong>
|
||||
</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)"
|
||||
:class="{ 'ignore-pattern' : pattern.actionType === 'IGNORE' }">
|
||||
|
||||
@ -36,16 +36,22 @@
|
||||
<i class="fas fa-backward"></i>
|
||||
</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)"
|
||||
title="Stop matching streams with this pattern">
|
||||
<i class="fas fa-pause"></i>
|
||||
</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)"
|
||||
title="Start matching streams with this pattern again">
|
||||
<i class="fas fa-play"></i>
|
||||
</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>
|
||||
</b-dropdown-item-button>
|
||||
</b-dropdown>
|
||||
@ -56,6 +62,11 @@
|
||||
mounted() {
|
||||
this.updatePatterns();
|
||||
},
|
||||
computed: {
|
||||
existingPatterns: function () {
|
||||
return this.$store.state.patterns.filter(p => !p.deleted)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getSearchTypeValue(searchType, value) {
|
||||
if (searchType === 'REGEX') return `/${value}/`;
|
||||
@ -113,7 +124,7 @@
|
||||
togglePattern(pattern) {
|
||||
const enabled = !pattern.enabled;
|
||||
console.debug('Toggling pattern', pattern);
|
||||
this.$http.post(`pattern/${pattern.id}/`, null, {
|
||||
this.$http.post(`pattern/${pattern.id}/enable`, null, {
|
||||
params: {
|
||||
enabled,
|
||||
},
|
||||
@ -130,6 +141,21 @@
|
||||
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>
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
</template>
|
||||
<template v-if="stream.userAgentHash"><br/>UA: {{ stream.userAgentHash }}</template>
|
||||
<br/>
|
||||
<span v-for="pattern in stream.foundPatterns"
|
||||
<span v-for="pattern in notDeletedFoundPatterns"
|
||||
:key="pattern.id"
|
||||
:style="`color: ${pattern.color};`">
|
||||
{{ pattern.name }}
|
||||
@ -44,6 +44,9 @@
|
||||
shouldShowServiceName: function () {
|
||||
return this.$route?.params?.servicePort === undefined;
|
||||
},
|
||||
notDeletedFoundPatterns: function () {
|
||||
return this.stream.foundPatterns.filter(p => !p.deleted);
|
||||
},
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user