From f5ed3cf3d65f4dadae8f49de1a3d49e1a82f9e5f Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 22 Aug 2024 09:46:18 +0200 Subject: [PATCH] system: replace confirm() use for consistency (#7801) --- .../www/js/opnsense_widget_manager.js | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/opnsense/www/js/opnsense_widget_manager.js b/src/opnsense/www/js/opnsense_widget_manager.js index 1c1dde757..564fedbff 100644 --- a/src/opnsense/www/js/opnsense_widget_manager.js +++ b/src/opnsense/www/js/opnsense_widget_manager.js @@ -134,7 +134,7 @@ class WidgetManager { this.persistedOptions = configuration.options; } catch (error) { // persisted config likely out of date, reset to defaults - this._restoreDefaults(false); + this.__restoreDefaults(); } const promises = data.modules.map(async (item) => { @@ -564,18 +564,37 @@ class WidgetManager { return $panel; } - _restoreDefaults(confirmDialog = true) { - if (confirmDialog) { - if (!confirm(this.gettext.restoreconfirm)) { - return; - } - } + __restoreDefaults(dialog) { $.ajax({type: "POST", url: "/api/core/dashboard/restoreDefaults"}).done((response) => { if (response['result'] == 'failed') { console.error('Failed to restore default widgets'); + if (dialog !== undefined) { + dialog.close(); + } } else { window.location.reload(); } + }) + } + + _restoreDefaults() { + BootstrapDialog.show({ + title: this.gettext.restore, + draggable: true, + animate: false, + message: this.gettext.restoreconfirm, + buttons: [{ + label: this.gettext.ok, + hotkey: 13, + action: (dialog) => { + this.__restoreDefaults(dialog); + } + }, { + label: this.gettext.cancel, + action: (dialog) => { + dialog.close(); + } + }] }); }