Skip to content

Commit

Permalink
Fix(App): Update component
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Feb 9, 2024
1 parent 617cebd commit 40ca31d
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 34 deletions.
4 changes: 2 additions & 2 deletions js/bruteforcesettings-main.js

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion js/bruteforcesettings-main.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
* @license MIT
*/

/*!
* Toastify js 1.12.0
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/

/*!
* Vue.js v2.7.16
* (c) 2014-2023 Evan You
Expand All @@ -30,16 +38,20 @@

/*! For license information please see NcButton.js.LICENSE.txt */

/*! For license information please see NcInputField.js.LICENSE.txt */

/*! For license information please see NcSettingsSection.js.LICENSE.txt */

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

/**
* @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion js/bruteforcesettings-main.js.map

Large diffs are not rendered by default.

72 changes: 44 additions & 28 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-
- @author Roeland Jago Douma <roeland@famdouma.nl>
-
- @license GNU AGPL version 3 or any later version
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -36,36 +36,42 @@
</tbody>
</table>

<h3>{{ t('bruteforcesettings', 'Add new whitelist') }}</h3>
<form @submit.prevent="addWhitelist">
<input id="ip"
v-model="newWhitelist.ip"
<h3>{{ t('bruteforcesettings', 'Add a new whitelist') }}</h3>
<div class="whitelist__form">
<NcInputField id="ip"
class="whitelist__ip"
:value.sync="newWhitelist.ip"
type="text"
name="ip"
placeholder="2001:db8::">/
<input id="mask"
v-model="newWhitelist.mask"
placeholder="2001:db8::" />
<NcInputField id="mask"
class="whitelist__mask"
:value.sync="newWhitelist.mask"
type="number"
name="mask"
min="1"
max="128"
maxlength="2"
placeholder="64">
<NcButton type="secondary">
placeholder="64" />
<NcButton type="secondary"
@click="addWhitelist">
<template #icon>
<PlusIcon />
</template>
{{ t('bruteforcesettings', 'Add') }}
</NcButton>
</form>
</div>
</NcSettingsSection>
</template>

<script>
import { generateUrl } from '@nextcloud/router'
import { showError } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'

import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcSettingsSection from '@nextcloud/vue/dist/Components/NcSettingsSection.js'
import NcInputField from '@nextcloud/vue/dist/Components/NcInputField.js'

import PlusIcon from 'vue-material-design-icons/Plus.vue'

import BruteForceItem from './components/BruteForceItem.vue'
Expand All @@ -75,8 +81,10 @@ export default {
components: {
NcButton,
BruteForceItem,
PlusIcon,
NcSettingsSection,
NcInputField,
PlusIcon,

},
data() {
return {
Expand All @@ -100,17 +108,19 @@ export default {
this.items = this.items.filter(item => item.id !== id)
})
},
addWhitelist() {
axios.post(generateUrl('apps/bruteforcesettings/ipwhitelist'),
{
ip: this.newWhitelist.ip,
mask: this.newWhitelist.mask,
})
.then((response) => {
this.items.push(response.data)
this.newWhitelist.ip = ''
this.newWhitelist.mask = ''
})
async addWhitelist() {
try {
const response = await axios.post(generateUrl('apps/bruteforcesettings/ipwhitelist'),
{
ip: this.newWhitelist.ip,
mask: this.newWhitelist.mask,
})
this.items.push(response.data)
this.newWhitelist.ip = ''
this.newWhitelist.mask = ''
} catch (error) {
showError(t('spreed', 'There was an error adding the IP to the whitelist.'))
}
},
},
}
Expand All @@ -121,11 +131,17 @@ export default {
min-width: 262px;
}

form {
.whitelist__form {
display: flex;
gap: 8px;
align-items: center;
input {
margin: 8px;
}
}

.whitelist__ip {
width: 300px;
}

.whitelist__mask {
width: 100px;
}
</style>
1 change: 0 additions & 1 deletion src/components/BruteForceItem.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<!--
- @copyright Copyright (c) 2018 Roeland Jago Douma <roeland@famdouma.nl>
-
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down

0 comments on commit 40ca31d

Please sign in to comment.