Skip to content

Commit

Permalink
Changing gui, adding timeout with a fix value
Browse files Browse the repository at this point in the history
  • Loading branch information
Berczi Sandor committed Jan 12, 2023
1 parent 459c64f commit e66f12e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/components/settings/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
</div>

<div class="my-4 pt-4">
<h5 class="my-4 settings-subheading">{{ $t("toastMessagesDescription") }}</h5>
<h5 class="my-4 settings-subheading">{{ $t("toastMessagesLabel") }}</h5>
<p>{{ $t("toastMessagesDescription") }}</p>
<label for="toastErrorTimeoutSecs" class="form-label">
{{
$t("toastErrorTimeoutSecs", [
Expand All @@ -34,7 +35,7 @@
v-model="settings.toastErrorTimeoutSecs"
type="number"
class="form-control"
min="0"
min="-1"
step="1"
/>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ export default {
Notifications: "Notifications",
"Not available, please setup.": "Not available, please setup.",
"Setup Notification": "Setup Notification",
toastMessagesDescription: "Popup notifications",
toastErrorTimeoutSecs: "The notifications about errors will dieappear after {0} seconds.",
toastMessagesLabel: "Popup notifications",
toastMessagesDescription: "The notifications disappear after the given time. -1: no timeout",
toastErrorTimeoutSecs: "Timeout for errors",
toastOkTimeoutSecs: "Timeout for success",
"": "",
Light: "Light",
Dark: "Dark",
Expand Down
17 changes: 14 additions & 3 deletions src/mixins/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { useToast } from "vue-toastification";
import jwtDecode from "jwt-decode";
import Favico from "favico.js";
import dayjs from "dayjs";
// import { getSettings } from "../../server/util-server";

const toast = useToast();

let socket;
Expand Down Expand Up @@ -173,10 +175,19 @@ export default {
if (data.important) {

if (data.status === 0) {
toast.error(`[${this.monitorList[data.monitorID].name}] [DOWN] ${data.msg}`, {
timeout: false,
});
// let timeout = getSettings("toastErrorTimeoutSecs");
let timeout = 10;
if (timeout === -1) {
toast.error(`[${this.monitorList[data.monitorID].name}] [DOWN] ${data.msg}`, {
timeout: false,
});
} else if (timeout > 0) {
toast.error(`[${this.monitorList[data.monitorID].name}] [DOWN] ${data.msg}`, {
timeout: timeout * 1000,
});
}
} else if (data.status === 1) {
// TODO toastOkTimeoutSecs
toast.success(`[${this.monitorList[data.monitorID].name}] [Up] ${data.msg}`, {
timeout: 20000,
});
Expand Down

0 comments on commit e66f12e

Please sign in to comment.