From 6e99dfd54f0b95cb1c3d25df1bac0390cc5863bc Mon Sep 17 00:00:00 2001 From: Alexander Myasoedov Date: Sun, 9 Mar 2025 17:37:02 +0200 Subject: [PATCH] feat(add toast): --- agentic_security/static/index.html | 26 +++++++++++ agentic_security/static/main.js | 17 +++++++ agentic_security/static/partials/head.html | 52 ++++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/agentic_security/static/index.html b/agentic_security/static/index.html index 43e150e..fcdf046 100644 --- a/agentic_security/static/index.html +++ b/agentic_security/static/index.html @@ -63,6 +63,32 @@ +
+ +
+ {{ toast.message }} + +
+
+
+ +

Select a Config

diff --git a/agentic_security/static/main.js b/agentic_security/static/main.js index c998ea1..60fc6c3 100644 --- a/agentic_security/static/main.js +++ b/agentic_security/static/main.js @@ -25,6 +25,8 @@ var app = new Vue({ showModules: false, showLogs: false, showConsentModal: true, + toasts: [], // Array to store toast notifications + toastTimeout: 3000, // Duration in milliseconds (3 seconds) statusDotClass: 'bg-gray-500', // Default status dot class statusText: 'Verified', // Default status text statusClass: 'bg-green-500 text-dark-bg', // Default status class @@ -93,6 +95,19 @@ var app = new Vue({ }, methods: { + showToast(message, type = 'success') { + const id = Date.now(); // Unique ID for each toast + this.toasts.push({ id, message, type }); + + // Automatically remove toast after timeout + setTimeout(() => { + this.removeToast(id); + }, this.toastTimeout); + }, + + removeToast(id) { + this.toasts = this.toasts.filter(toast => toast.id !== id); + }, focusTextarea() { this.isFocused = true; self = this.$refs; @@ -210,10 +225,12 @@ var app = new Vue({ if (!response.ok) { this.updateStatusDot(false); this.errorMsg = 'Integration verification failed:' + JSON.stringify(r); + this.showToast('Integration verification failed', 'error'); } else { this.errorMsg = ''; this.updateStatusDot(true); this.okMsg = 'Integration verified'; + this.showToast('Integration verified successfully', 'success'); this.integrationVerified = true; // console.log('Integration verified', this.integrationVerified); // this.$forceUpdate(); diff --git a/agentic_security/static/partials/head.html b/agentic_security/static/partials/head.html index 9807c8f..152eb6f 100644 --- a/agentic_security/static/partials/head.html +++ b/agentic_security/static/partials/head.html @@ -86,6 +86,7 @@ } } + +