summaryrefslogtreecommitdiff
path: root/src/views/_sila/Settings/TransferInfo/Syslog.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/views/_sila/Settings/TransferInfo/Syslog.vue')
-rw-r--r--src/views/_sila/Settings/TransferInfo/Syslog.vue150
1 files changed, 130 insertions, 20 deletions
diff --git a/src/views/_sila/Settings/TransferInfo/Syslog.vue b/src/views/_sila/Settings/TransferInfo/Syslog.vue
index 1d2111c9..bc64cc0d 100644
--- a/src/views/_sila/Settings/TransferInfo/Syslog.vue
+++ b/src/views/_sila/Settings/TransferInfo/Syslog.vue
@@ -1,30 +1,55 @@
<template>
- <page-section :section-title="$t('pageLdap.settings')">
- <b-row class="mt-4 justify-content-end">
- <b-col xs="12" sm="6" lg="4">
- <b-form-group label="Расположение системы" label-for="system-location">
+ <page-section :section-title="$t('pageTransfer.syslog.title')">
+ <b-row class="mt-4 justify-content-end syslog-warning">
+ <b-col xs="12" sm="12">
+ <div class="switch-group">
+ <label for="statusSwitch">{{
+ $t('pageTransfer.syslog.status')
+ }}</label>
+ <b-form-checkbox
+ id="statusSwitch"
+ v-model="syslogStatus"
+ data-test-id="checkbox-status"
+ switch
+ :disabled="loading || isNotAdmin"
+ >
+ <span v-if="syslogStatus">
+ {{ $t('global.status.enabled') }}
+ </span>
+ <span v-else>{{ $t('global.status.disabled') }}</span>
+ </b-form-checkbox>
+ </div>
+ </b-col>
+ <b-col xs="12" sm="6">
+ <b-form-group
+ :label="$t('pageTransfer.syslog.ip')"
+ label-for="syslog-ip"
+ >
<b-form-input
- id="system-location"
- placeholder="Ведите значение"
- :disabled="$store.getters['authentication/role'] === 'ReadOnly'"
+ id="syslog-ip"
+ v-model="form.Address"
+ :disabled="!syslogStatus || loading || isNotAdmin"
/> </b-form-group
></b-col>
- <b-col xs="12" sm="6" lg="4">
- <b-form-group label="Контакты системы" label-for="system-contacts">
+ <b-col xs="12" sm="6">
+ <b-form-group
+ :label="$t('pageTransfer.syslog.port')"
+ label-for="syslog-port"
+ >
<b-form-input
- id="system-contacts"
- placeholder="Ведите значение"
- :disabled="$store.getters['authentication/role'] === 'ReadOnly'"
+ id="syslog-port"
+ v-model="form.Port"
+ type="number"
+ :disabled="!syslogStatus || loading || isNotAdmin"
/>
</b-form-group>
</b-col>
- <b-col xs="12" sm="6" lg="4">
- <b-form-group label="Статус" label-for="SMNP-status">
- <b-form-select id="SMNP-status"> </b-form-select>
- </b-form-group>
- </b-col>
<b-col xs="4" class="d-flex justify-content-end align-items-start">
- <b-button variant="primary">
+ <b-button
+ variant="primary"
+ :disabled="loading || isNotAdmin"
+ @click="saveSyslog"
+ >
{{ $t('global.action.save') }}
</b-button>
</b-col>
@@ -34,16 +59,101 @@
<script>
import PageSection from '@/components/_sila/Global/PageSection';
+import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin';
+import LoadingBarMixin, {
+ loading,
+} from '@/components/_sila/Mixins/LoadingBarMixin';
export default {
name: 'Syslog',
components: {
PageSection,
},
+ mixins: [BVToastMixin, LoadingBarMixin],
data() {
- return {};
+ return {
+ loading,
+ syslogStatus: false,
+ form: {
+ Address: null,
+ Port: null,
+ },
+ };
+ },
+ computed: {
+ settings() {
+ return this.$store.getters['syslogStore/settings'];
+ },
+ isNotAdmin() {
+ return (
+ this.$store.getters['authentication/role'] === 'ReadOnly' ||
+ this.$store.getters['authentication/role'] === 'Operator'
+ );
+ },
+ },
+
+ watch: {
+ settings() {
+ this.setForm();
+ },
+ },
+
+ created() {
+ this.startLoader();
+ this.$store.dispatch('syslogStore/getSettings').finally(() => {
+ this.setForm();
+ this.endLoader();
+ });
+ },
+
+ methods: {
+ saveSyslog() {
+ this.startLoader();
+ if (!this.syslogStatus) {
+ this.form = {
+ Address: '',
+ Port: 0,
+ };
+ }
+
+ this.form.Port = +this.form.Port;
+ this.$store
+ .dispatch('syslogStore/saveSettings', this.form)
+ .then((success) => this.successToast(success))
+ .catch(({ message }) => this.errorToast(message))
+ .finally(() => this.endLoader());
+ },
+
+ setForm() {
+ if (!this.settings) {
+ return;
+ }
+
+ if (!this.settings.Address && this.settings.Port === 0) {
+ this.syslogStatus = false;
+ } else {
+ this.syslogStatus = true;
+ }
+
+ this.form.Address = this.settings.Address;
+ this.form.Port = this.settings.Port;
+ },
},
- computed: {},
};
</script>
+
+<style lang="scss" scoped>
+.switch-group {
+ margin-bottom: 1.5rem;
+}
+.syslog-warning {
+ width: 50%;
+ @media (max-width: 1200px) {
+ width: 75%;
+ }
+ @media (max-width: 576px) {
+ width: 100%;
+ }
+}
+</style>