From 186c2633d8249b6eef518b6e8fa2bebd32600ea8 Mon Sep 17 00:00:00 2001 From: core Date: Thu, 27 Jul 2023 17:09:27 -0400 Subject: [PATCH] full role functionality --- tfweb/src/lib/i18n/locales/en.json | 32 +- tfweb/src/routes/roles/+page.svelte | 28 +- .../routes/roles/[role_id]/edit/+page.svelte | 411 ++++++++++++++++++ tfweb/src/routes/roles/add/+page.svelte | 4 +- 4 files changed, 471 insertions(+), 4 deletions(-) create mode 100644 tfweb/src/routes/roles/[role_id]/edit/+page.svelte diff --git a/tfweb/src/lib/i18n/locales/en.json b/tfweb/src/lib/i18n/locales/en.json index 74927f3..66d155a 100644 --- a/tfweb/src/lib/i18n/locales/en.json +++ b/tfweb/src/lib/i18n/locales/en.json @@ -82,6 +82,9 @@ "name": "Name", "rules": "Rule count", "description": "Description", + "actions": "Actions", + "editbtn": "Edit", + "delete": "Delete", "add": { "any": "Any", "name": "Role name", @@ -105,7 +108,34 @@ "role": "Allowed role", "desc": "Description", "add": "Add rule", - "edit": "Edit rule", + "edit": "Save edit", + "cancel": "Cancel" + } + }, + "edit": { + "any": "Any", + "name": "Role name", + "desc": "Role description", + "button": "Save", + "cancel": "Cancel", + "rules": "Inbound firewall rules", + "rulesexplainer": "Inbound traffic is denied by default. Add rules to allow traffic from hosts belonging to specific roles.", + "rulescols": { + "description": "Description", + "protocol": "Protocol", + "portrange": "Port range", + "allowedrole": "Allowed role" + }, + "ruleremove": "Remove rule", + "ruleedit": "Edit rule", + "rulesadd": "Add rule", + "editrule": { + "protocol": "Protocol", + "range": "Port or port range", + "role": "Allowed role", + "desc": "Description", + "add": "Add rule", + "edit": "Save edit", "cancel": "Cancel" } } diff --git a/tfweb/src/routes/roles/+page.svelte b/tfweb/src/routes/roles/+page.svelte index 93cb92c..0cfe0c4 100644 --- a/tfweb/src/routes/roles/+page.svelte +++ b/tfweb/src/routes/roles/+page.svelte @@ -76,6 +76,23 @@ async function roleAdd() { window.location.href = "/roles/add"; } + + async function roleDelete(id: string) { + const configuration = new Configuration({ + basePath: PUBLIC_BASE_URL, + accessToken: window.localStorage.getItem("session") + " " + window.localStorage.getItem("mfa") + }); + + const rolesApi = new RolesApi(configuration); + + await rolesApi.roleDelete( + { + roleID: id + } + ); + + window.location.reload(); + } @@ -98,12 +115,21 @@ {$t("roles.name")} {$t("roles.rules")} {$t("roles.description")} + {$t("roles.actions")} {#each roles.data as role} - {role.name} + + + {role.name} + + {role.firewallRules.length} {role.description} + + + + {/each} diff --git a/tfweb/src/routes/roles/[role_id]/edit/+page.svelte b/tfweb/src/routes/roles/[role_id]/edit/+page.svelte new file mode 100644 index 0000000..332b079 --- /dev/null +++ b/tfweb/src/routes/roles/[role_id]/edit/+page.svelte @@ -0,0 +1,411 @@ + + + + {$t("common.title", {values: {title: $t("common.page.roles")}})} + + + + + +
+ + + + +

{$t("roles.edit.rules")}

+

{$t("roles.edit.rulesexplainer")}

+ + + + + + + + + + {#each rules as rule} + + + + + + + + + {/each} +
{$t("roles.edit.rulescols.description")}{$t("roles.edit.rulescols.protocol")}{$t("roles.edit.rulescols.portrange")}{$t("roles.edit.rulescols.allowedrole")}
{rule.description}{protoToStringName(rule.protocol)}{prettyPortRange(rule.portRange)}{findRole(rule.allowedRole)}
+ + + + {#if isEditingRule} + + + + + + + + + + + +
+ {/if} + +
+ + + + +
diff --git a/tfweb/src/routes/roles/add/+page.svelte b/tfweb/src/routes/roles/add/+page.svelte index 9354afc..2d1d9d4 100644 --- a/tfweb/src/routes/roles/add/+page.svelte +++ b/tfweb/src/routes/roles/add/+page.svelte @@ -301,7 +301,7 @@ -
+ @@ -358,7 +358,7 @@
- +