Skip to content

Commit

Permalink
feat: dpi ui
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 committed Oct 23, 2023
1 parent 48dbaf1 commit 166051c
Show file tree
Hide file tree
Showing 15 changed files with 1,343 additions and 42 deletions.
79 changes: 51 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
"@fortawesome/free-solid-svg-icons": "github:nethesis/Font-Awesome#solid",
"@fortawesome/vue-fontawesome": "^3.0.3",
"@headlessui/vue": "^1.7.13",
"@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands",
"@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light",
"@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid",
"@nethserver/vue-tailwind-lib": "^0.0.81",
"@nethserver/vue-tailwind-lib": "^0.0.86",
"@types/lodash": "^4.14.195",
"@vueuse/core": "^10.5.0",
"axios": "^1.4.0",
"chart.js": "^4.4.0",
"chartjs-adapter-date-fns": "^3.0.0",
Expand Down
55 changes: 50 additions & 5 deletions public/i18n/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"edit": "Edit",
"delete": "Delete",
"filter": "Filter",
"advanced_settings": "Advanced settings"
"advanced_settings": "Advanced settings",
"enable": "Enable",
"disable": "Disable",
"enabled": "Enabled",
"disabled": "Disabled",
"page_under_construction": "Page under construction"
},
"error": {
"generic_error": "Something went wrong",
Expand Down Expand Up @@ -94,7 +99,15 @@
"cannot_retrieve_dhcp_interfaces": "Cannot retrieve DHCP interfaces",
"cannot_retrieve_storage_configuration": "Cannot retrieve storage configuration",
"cannot_configure_storage": "Cannot configure storage",
"cannot_remove_storage": "Cannot remove storage"
"cannot_remove_storage": "Cannot remove storage",
"cannot_retrieve_dpi_rules": "Cannot retrieve DPI rules",
"cannot_create_dpi_rule": "Cannot create DPI rule",
"cannot_edit_dpi_rule": "Cannot edit DPI rule",
"cannot_retrieve_popular_apps": "Cannot retrieve popular apps",
"cannot_retrieve_devices": "Cannot retrieve devices",
"cannot_retrieve_applications": "Cannot retrieve applications",
"zone_already_exists": "Zone already exists",
"cannot_delete_rule": "Cannote delete rule"
},
"ne_text_input": {
"show_password": "Show password",
Expand Down Expand Up @@ -411,7 +424,8 @@
"bond_balance_alb": "Adaptive load balancing",
"bond_primary_device": "Primary device",
"primary_device_not_included": "Primary device must be included in selected devices",
"no_devices_available": "No devices available"
"no_devices_available": "No devices available",
"custom_zone": "Custom"
},
"multi_wan": {
"title": "MultiWAN",
Expand Down Expand Up @@ -627,8 +641,7 @@
"limit_log_messages": "Limit log messages",
"enable_logging": "Enable logging on this zone",
"delete_zone": "Delete \"{0}\"?",
"edit_zone_name": "Edit zone {name}",
"zone_already_exists": "Zone already exists"
"edit_zone_name": "Edit zone {name}"
},
"port_forward": {
"title": "Port forward",
Expand Down Expand Up @@ -675,6 +688,38 @@
"security": {
"title": "Security"
},
"dpi": {
"title": "DPI filter",
"rules": "Rules",
"exceptions": "Exceptions",
"rules_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"no_rules_found": "No rules found",
"create_rule": "Create rule",
"edit_rule": "Edit rule",
"save_rule": "Save rule",
"enable_rule": "Enable rule",
"source": "Source",
"choose_interface": "Choose interface",
"source_tooltip": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"no_interfaces_available": "No interfaces available",
"apps_and_protocols": "Apps and protocols to block",
"apps_and_protocols_placeholder": "Search {num} apps, protocols and categories",
"no_apps": "No apps or protocols",
"clear_search": "Clear search",
"num_apps_and_protocols_selected": "{num} apps and protocols selected",
"search_results": "Search results",
"no_apps_or_protocols_found": "No apps or protocols found",
"try_changing_search_filter": "Try changing your search filter",
"available_with_subscription": "Available with subscription",
"continue_typing_to_show_other_search_results": "Continue typing your search query to show other search results",
"select_at_least_one_app_or_protocol": "Select at least one app or protocol",
"type_application": "App",
"type_protocol": "Protocol",
"confirm_delete_rule": "You are about to delete DPI rule on interface '{iface}'",
"delete_rule": "Delete rule",
"blocked_apps_and_protocols": "Blocked apps and protocols",
"plus_num_others": "+{num} others"
},
"vpn": {
"title": "VPN"
},
Expand Down
12 changes: 11 additions & 1 deletion src/components/standalone/SideMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@ const navigation: Ref<any> = ref([
}
]
},
{ name: t('standalone.security.title'), to: 'security', icon: 'shield-halved' },
{
name: t('standalone.security.title'),
to: 'security',
icon: 'shield-halved',
children: [
{
name: t('standalone.dpi.title'),
to: 'security/dpi'
}
]
},
{ name: t('standalone.vpn.title'), to: 'vpn', icon: 'globe' },
{ name: t('standalone.logs.title'), to: 'logs', icon: 'list' },
{ name: t('standalone.report.title'), to: 'report', icon: 'chart-line' }
Expand Down
90 changes: 90 additions & 0 deletions src/components/standalone/dpi/DeleteDpiRuleModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!--
Copyright (C) 2023 Nethesis S.r.l.
SPDX-License-Identifier: GPL-3.0-or-later
-->

<script setup lang="ts">
import type { DpiRule } from '@/lib/standalone/dpi'
import { ubusCall } from '@/lib/standalone/ubus'
import { NeInlineNotification, NeModal, getAxiosErrorMessage } from '@nethserver/vue-tailwind-lib'
import { ref, watch } from 'vue'
import { useI18n } from 'vue-i18n'

interface Props {
visible: boolean
rule?: DpiRule
}

const props = defineProps<Props>()

const emit = defineEmits(['close', 'reloadData'])

const { t } = useI18n()

let loading = ref({
deleteRule: false
})

let error = ref({
notificationTitle: '',
notificationDescription: ''
})

watch(
() => props.visible,
() => {
if (props.visible) {
error.value.notificationTitle = ''
error.value.notificationDescription = ''
}
}
)

async function deleteRule() {
if (!props.rule) {
return
}
error.value.notificationTitle = ''
error.value.notificationDescription = ''
loading.value.deleteRule = true

try {
await ubusCall('ns.dpi', 'delete-rule', {
'config-name': props.rule['config-name']
})
emit('close')
emit('reloadData')
} catch (err: any) {
console.error(err)
error.value.notificationTitle = t('error.cannot_delete_rule')
error.value.notificationDescription = t(getAxiosErrorMessage(err))
} finally {
loading.value.deleteRule = false
}
}
</script>

<template>
<NeModal
:visible="visible"
:title="t('standalone.dpi.delete_rule')"
kind="warning"
:primaryLabel="t('standalone.dpi.delete_rule')"
:cancelLabel="t('common.cancel')"
primaryButtonKind="danger"
:primaryButtonDisabled="loading.deleteRule"
:primaryButtonLoading="loading.deleteRule"
:closeAriaLabe="t('common.close')"
@close="emit('close')"
@primaryClick="deleteRule"
>
{{ t('standalone.dpi.confirm_delete_rule', { iface: rule?.interface }) }}
<NeInlineNotification
v-if="error.notificationTitle"
kind="error"
:title="error.notificationTitle"
:description="error.notificationDescription"
class="mt-4"
/>
</NeModal>
</template>
Loading

0 comments on commit 166051c

Please sign in to comment.