Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Switch to toasts for notices #566

Merged
merged 1 commit into from
Sep 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions cmd/server/assets/_flash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{define "flash"}}
<div style="position:absolute; top:0; right:1rem; z-index:2000;">
{{range $msg := .flash.Errors}}
<div class="toast bg-white" role="alert" aria-live="assertive" aria-atomic="true" data-delay="10000" data-autohide="false">
<div class="toast-header text-danger">
<span class="oi oi-circle-x mr-2" aria-hidden="true"></span>
<strong class="mr-auto">Error</strong>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="toast-body">
{{$msg}}
</div>
</div>
{{end}}
{{range $msg := .flash.Warnings}}
<div class="toast bg-white" role="alert" aria-live="assertive" aria-atomic="true" data-delay="10000" data-autohide="false">
<div class="toast-header text-warning">
<span class="oi oi-warning mr-2" aria-hidden="true"></span>
<strong class="mr-auto">Warning</strong>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="toast-body">
{{$msg}}
</div>
</div>
{{end}}
{{range $msg := .flash.Alerts}}
<div class="toast bg-white" role="alert" aria-live="assertive" aria-atomic="true" data-delay="10000" data-autohide="true">
<div class="toast-header text-info">
<span class="oi oi-info mr-2" aria-hidden="true"></span>
<strong class="mr-auto">Notice</strong>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="toast-body">
{{$msg}}
</div>
</div>
{{end}}
</div>
{{end}}
29 changes: 6 additions & 23 deletions cmd/server/assets/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
color: lightgray;
pointer-events: none;
}

main.container[role=main] {
position: relative;
}
</style>
{{end}}

Expand Down Expand Up @@ -229,29 +233,6 @@ <h6 class="dropdown-header">Actions</h6>
</header>
{{end}}

{{define "flash"}}
<div id="alerts-container">
{{range $msg := .flash.Errors}}
<div class="alert alert-danger" role="alert">
{{$msg}}
</div>
{{end}}
{{range $msg := .flash.Warnings}}
<div class="alert alert-warning" role="alert">
{{$msg}}
</div>
{{end}}
{{range $msg := .flash.Alerts}}
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{$msg}}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{{end}}
</div>
{{end}}

{{define "scripts"}}
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
Expand Down Expand Up @@ -360,6 +341,8 @@ <h6 class="dropdown-header">Actions</h6>
$this.tooltip('hide');
document.getSelection().removeAllRanges();
});

$('.toast').toast('show');
});

var $alerts = $('#alerts-container');
Expand Down