■ ■ ■ ■ ■ ■
GraphSpy/static/js/functions.js
| skipped 110 lines |
111 | 111 | | url: "/api/generate_device_code", |
112 | 112 | | data: { "resource": resource, "client_id": client_id } |
113 | 113 | | }); |
114 | | - | bootstrapToast("Device Code", `[Success] Generated Device Code with User Code '${response.responseText}'.`); |
| 114 | + | bootstrapToast("Device Code", `[Success] Generated Device Code with User Code '${response.responseText}'.`, "primary"); |
115 | 115 | | reloadTables(); |
116 | 116 | | } |
117 | 117 | | |
| skipped 181 lines |
299 | 299 | | var type_class = `alert-${type}`; |
300 | 300 | | var dom = $('<div>'); |
301 | 301 | | dom.addClass("alert alert-dismissible"); |
302 | | - | dom.addClass(type_class); |
| 302 | + | validTypes = ["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"] |
| 303 | + | if (type && validTypes.includes(type.toLowerCase())) { |
| 304 | + | dom.addClass(`alert-${type.toLowerCase()}`); |
| 305 | + | } |
303 | 306 | | dom.attr("role", "alert"); |
304 | 307 | | dom.text(message); |
305 | 308 | | dom.append($('<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>')); |
306 | 309 | | $('#alert_placeholder').append(dom); |
307 | 310 | | } |
308 | 311 | | |
309 | | - | function bootstrapToast(title, message) { |
| 312 | + | function bootstrapToast(title, message, type = null, alternative = false) { |
| 313 | + | // Types: primary, secondary, success, danger, warning, info, light, dark |
310 | 314 | | // Wrapper for new Toast Message |
311 | 315 | | var toast_wrapper = $('<div class="toast" role="alert" aria-live="assertive" aria-atomic="true"></div>'); |
| 316 | + | validTypes = ["primary", "secondary", "success", "danger", "warning", "info", "light", "dark"] |
| 317 | + | if (type && validTypes.includes(type.toLowerCase())) { |
| 318 | + | if (alternative) { |
| 319 | + | toast_wrapper.addClass(`bg-${type.toLowerCase()}-subtle`).addClass(`text-${type.toLowerCase()}-emphasis`); |
| 320 | + | } else { |
| 321 | + | toast_wrapper.addClass(`text-bg-${type.toLowerCase()}`); |
| 322 | + | } |
| 323 | + | } |
312 | 324 | | // Toast header |
313 | 325 | | var toast_header = $('<div class="toast-header"><small>Just now</small><button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button></div>'); |
314 | 326 | | var toast_title = $('<strong class="me-auto"></strong>'); |
| skipped 15 lines |