Skip to content

Commit

Permalink
flash messages working on app
Browse files Browse the repository at this point in the history
  • Loading branch information
syrk4web committed Jul 3, 2024
1 parent a3514d2 commit f7bbffe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 28 deletions.
21 changes: 15 additions & 6 deletions src/client/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,21 @@ async function setBuildTempToUI() {
const bodyIndex = updateData.indexOf("<body>");
// Add attributs

const attributs = `<body>
<div class="hidden" data-csrf-token="{{ csrf_token() }}"></div>\n
<div class="hidden" data-server-global="{{data_server_global if data_server_global else {}}}"></div>\n
<div class="hidden" data-server-flash="{{data_server_flash if data_server_flash else []}}"></div>\n
<div class="hidden" data-server-builder="{{data_server_builder}}"></div>\n
<div id="app"></div>\n</body>\n</html>`;
const attributs = `
<body>
{% set data_server_flash = [] %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
{% if data_server_flash.append({"type": "error" if category == "error" else "success", "title": "dashboard_error" if category == "error" else "dashboard_success", "message": message}) %}{% endif %}
{% endfor %}
{% endwith %}
<div class='hidden' data-csrf-token='{{ csrf_token() }}'></div>
<div class='hidden' data-server-global='{{data_server_global if data_server_global else {}}}''></div>
<div class='hidden' data-server-flash='{{data_server_flash|tojson}}'></div>
<div class='hidden' data-server-builder='{{data_server_builder}}'></div>
<div id='app'></div>
</body>
</html>`;
// insert the new content
updateData = updateData.substring(0, bodyIndex) + attributs;
fs.writeFileSync(
Expand Down
25 changes: 14 additions & 11 deletions src/ui/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
<script nonce="{{ script_nonce }}" type="module" crossorigin src="assets/home-ef55bffd.js"></script>
<link rel="modulepreload" crossorigin href="assets/Title-9ae7a316.js">
</head>
<body>
<div class="hidden" data-csrf-token="{{ csrf_token() }}"></div>

<div class="hidden" data-server-global="{{data_server_global if data_server_global else {}}}"></div>

<div class="hidden" data-server-flash="{{data_server_flash if data_server_flash else []}}"></div>

<div class="hidden" data-server-builder="{{data_server_builder}}"></div>

<div id="app"></div>
</body>

<body>
{% set data_server_flash = [] %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
{% if data_server_flash.append({"type": "error" if category == "error" else "success", "title": "dashboard_error" if category == "error" else "dashboard_success", "message": message}) %}{% endif %}
{% endfor %}
{% endwith %}
<div class='hidden' data-csrf-token='{{ csrf_token() }}'></div>
<div class='hidden' data-server-global='{{data_server_global if data_server_global else {}}}''></div>
<div class='hidden' data-server-flash='{{data_server_flash|tojson}}'></div>
<div class='hidden' data-server-builder='{{data_server_builder}}'></div>
<div id='app'></div>
</body>
</html>
25 changes: 14 additions & 11 deletions src/ui/templates/instances.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@
<script nonce="{{ script_nonce }}" type="module" crossorigin src="assets/instances-67da6d8b.js"></script>
<link rel="modulepreload" crossorigin href="assets/Title-9ae7a316.js">
</head>
<body>
<div class="hidden" data-csrf-token="{{ csrf_token() }}"></div>

<div class="hidden" data-server-global="{{data_server_global if data_server_global else {}}}"></div>

<div class="hidden" data-server-flash="{{data_server_flash if data_server_flash else []}}"></div>

<div class="hidden" data-server-builder="{{data_server_builder}}"></div>

<div id="app"></div>
</body>

<body>
{% set data_server_flash = [] %}
{% with messages = get_flashed_messages(with_categories=true) %}
{% for category, message in messages %}
{% if data_server_flash.append({"type": "error" if category == "error" else "success", "title": "dashboard_error" if category == "error" else "dashboard_success", "message": message}) %}{% endif %}
{% endfor %}
{% endwith %}
<div class='hidden' data-csrf-token='{{ csrf_token() }}'></div>
<div class='hidden' data-server-global='{{data_server_global if data_server_global else {}}}''></div>
<div class='hidden' data-server-flash='{{data_server_flash|tojson}}'></div>
<div class='hidden' data-server-builder='{{data_server_builder}}'></div>
<div id='app'></div>
</body>
</html>

0 comments on commit f7bbffe

Please sign in to comment.