Skip to content

Commit f904bf6

Browse files
Merge pull request #14 from SyncfusionExamples/1007221-PostGreSample
1007221: Need to create sample for DataGrid with PostgreSQL server
2 parents 6c6596b + 2d5c44a commit f904bf6

File tree

88 files changed

+61326
-645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+61326
-645
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<base href="/" />
8+
<ResourcePreloader />
9+
<link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
10+
<link rel="stylesheet" href="@Assets["app.css"]" />
11+
<link rel="stylesheet" href="@Assets["Grid_PostgreSQL.styles.css"]" />
12+
<link href="_content/Syncfusion.Blazor.Themes/tailwind3.css" rel="stylesheet" />
13+
<link href="./grid-column-template.css" rel="stylesheet" />
14+
<ImportMap />
15+
<link rel="icon" type="image/png" href="favicon.png" />
16+
<HeadOutlet />
17+
</head>
18+
19+
<body>
20+
<Routes @rendermode="InteractiveServer"/>
21+
<ReconnectModal />
22+
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
23+
<script src="@Assets["_framework/blazor.web.js"]"></script>
24+
</body>
25+
26+
</html>

Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Grid_PostgreSQL/Grid_PostgreSQL/Components/Layout/MainLayout.razor renamed to Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Components/Layout/MainLayout.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
@inherits LayoutComponentBase
22

33
<div class="page">
4-
<div class="sidebar">
4+
@* <div class="sidebar">
55
<NavMenu />
6-
</div>
6+
</div> *@
77

88
<main>
9-
<div class="top-row px-4">
9+
@* <div class="top-row px-4">
1010
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
11-
</div>
11+
</div> *@
1212

1313
<article class="content px-4">
1414
@Body
1515
</article>
1616
</main>
1717
</div>
1818

19-
<div id="blazor-error-ui">
19+
<div id="blazor-error-ui" data-nosnippet>
2020
An unhandled error has occurred.
21-
<a href="" class="reload">Reload</a>
22-
<a class="dismiss">🗙</a>
21+
<a href="." class="reload">Reload</a>
22+
<span class="dismiss">🗙</span>
2323
</div>

Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Grid_PostgreSQL/Grid_PostgreSQL/Components/Layout/MainLayout.razor.css renamed to Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Components/Layout/MainLayout.razor.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ main {
7777
}
7878

7979
#blazor-error-ui {
80+
color-scheme: light only;
8081
background: lightyellow;
8182
bottom: 0;
8283
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
84+
box-sizing: border-box;
8385
display: none;
8486
left: 0;
8587
padding: 0.6rem 1.25rem 0.7rem 1.25rem;

Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Grid_PostgreSQL/Grid_PostgreSQL/Components/Layout/NavMenu.razor renamed to Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Components/Layout/NavMenu.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
88

99
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
10-
<nav class="flex-column">
10+
<nav class="nav flex-column">
1111
<div class="nav-item px-3">
1212
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
1313
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home

Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Grid_PostgreSQL/Grid_PostgreSQL/Components/Layout/NavMenu.razor.css renamed to Binding PostgreSQL database using CustomAdaptor/Grid_PostgreSQL/Components/Layout/NavMenu.razor.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717

1818
.top-row {
19-
height: 3.5rem;
19+
min-height: 3.5rem;
2020
background-color: rgba(0,0,0,0.4);
2121
}
2222

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script type="module" src="@Assets["Components/Layout/ReconnectModal.razor.js"]"></script>
2+
3+
<dialog id="components-reconnect-modal" data-nosnippet>
4+
<div class="components-reconnect-container">
5+
<div class="components-rejoining-animation" aria-hidden="true">
6+
<div></div>
7+
<div></div>
8+
</div>
9+
<p class="components-reconnect-first-attempt-visible">
10+
Rejoining the server...
11+
</p>
12+
<p class="components-reconnect-repeated-attempt-visible">
13+
Rejoin failed... trying again in <span id="components-seconds-to-next-attempt"></span> seconds.
14+
</p>
15+
<p class="components-reconnect-failed-visible">
16+
Failed to rejoin.<br />Please retry or reload the page.
17+
</p>
18+
<button id="components-reconnect-button" class="components-reconnect-failed-visible">
19+
Retry
20+
</button>
21+
<p class="components-pause-visible">
22+
The session has been paused by the server.
23+
</p>
24+
<button id="components-resume-button" class="components-pause-visible">
25+
Resume
26+
</button>
27+
<p class="components-resume-failed-visible">
28+
Failed to resume the session.<br />Please reload the page.
29+
</p>
30+
</div>
31+
</dialog>
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
.components-reconnect-first-attempt-visible,
2+
.components-reconnect-repeated-attempt-visible,
3+
.components-reconnect-failed-visible,
4+
.components-pause-visible,
5+
.components-resume-failed-visible,
6+
.components-rejoining-animation {
7+
display: none;
8+
}
9+
10+
#components-reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
11+
#components-reconnect-modal.components-reconnect-show .components-rejoining-animation,
12+
#components-reconnect-modal.components-reconnect-paused .components-pause-visible,
13+
#components-reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible,
14+
#components-reconnect-modal.components-reconnect-retrying,
15+
#components-reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
16+
#components-reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
17+
#components-reconnect-modal.components-reconnect-failed,
18+
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible {
19+
display: block;
20+
}
21+
22+
23+
#components-reconnect-modal {
24+
background-color: white;
25+
width: 20rem;
26+
margin: 20vh auto;
27+
padding: 2rem;
28+
border: 0;
29+
border-radius: 0.5rem;
30+
box-shadow: 0 3px 6px 2px rgba(0, 0, 0, 0.3);
31+
opacity: 0;
32+
transition: display 0.5s allow-discrete, overlay 0.5s allow-discrete;
33+
animation: components-reconnect-modal-fadeOutOpacity 0.5s both;
34+
&[open]
35+
36+
{
37+
animation: components-reconnect-modal-slideUp 1.5s cubic-bezier(.05, .89, .25, 1.02) 0.3s, components-reconnect-modal-fadeInOpacity 0.5s ease-in-out 0.3s;
38+
animation-fill-mode: both;
39+
}
40+
41+
}
42+
43+
#components-reconnect-modal::backdrop {
44+
background-color: rgba(0, 0, 0, 0.4);
45+
animation: components-reconnect-modal-fadeInOpacity 0.5s ease-in-out;
46+
opacity: 1;
47+
}
48+
49+
@keyframes components-reconnect-modal-slideUp {
50+
0% {
51+
transform: translateY(30px) scale(0.95);
52+
}
53+
54+
100% {
55+
transform: translateY(0);
56+
}
57+
}
58+
59+
@keyframes components-reconnect-modal-fadeInOpacity {
60+
0% {
61+
opacity: 0;
62+
}
63+
64+
100% {
65+
opacity: 1;
66+
}
67+
}
68+
69+
@keyframes components-reconnect-modal-fadeOutOpacity {
70+
0% {
71+
opacity: 1;
72+
}
73+
74+
100% {
75+
opacity: 0;
76+
}
77+
}
78+
79+
.components-reconnect-container {
80+
display: flex;
81+
flex-direction: column;
82+
align-items: center;
83+
gap: 1rem;
84+
}
85+
86+
#components-reconnect-modal p {
87+
margin: 0;
88+
text-align: center;
89+
}
90+
91+
#components-reconnect-modal button {
92+
border: 0;
93+
background-color: #6b9ed2;
94+
color: white;
95+
padding: 4px 24px;
96+
border-radius: 4px;
97+
}
98+
99+
#components-reconnect-modal button:hover {
100+
background-color: #3b6ea2;
101+
}
102+
103+
#components-reconnect-modal button:active {
104+
background-color: #6b9ed2;
105+
}
106+
107+
.components-rejoining-animation {
108+
position: relative;
109+
width: 80px;
110+
height: 80px;
111+
}
112+
113+
.components-rejoining-animation div {
114+
position: absolute;
115+
border: 3px solid #0087ff;
116+
opacity: 1;
117+
border-radius: 50%;
118+
animation: components-rejoining-animation 1.5s cubic-bezier(0, 0.2, 0.8, 1) infinite;
119+
}
120+
121+
.components-rejoining-animation div:nth-child(2) {
122+
animation-delay: -0.5s;
123+
}
124+
125+
@keyframes components-rejoining-animation {
126+
0% {
127+
top: 40px;
128+
left: 40px;
129+
width: 0;
130+
height: 0;
131+
opacity: 0;
132+
}
133+
134+
4.9% {
135+
top: 40px;
136+
left: 40px;
137+
width: 0;
138+
height: 0;
139+
opacity: 0;
140+
}
141+
142+
5% {
143+
top: 40px;
144+
left: 40px;
145+
width: 0;
146+
height: 0;
147+
opacity: 1;
148+
}
149+
150+
100% {
151+
top: 0px;
152+
left: 0px;
153+
width: 80px;
154+
height: 80px;
155+
opacity: 0;
156+
}
157+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Set up event handlers
2+
const reconnectModal = document.getElementById("components-reconnect-modal");
3+
reconnectModal.addEventListener("components-reconnect-state-changed", handleReconnectStateChanged);
4+
5+
const retryButton = document.getElementById("components-reconnect-button");
6+
retryButton.addEventListener("click", retry);
7+
8+
const resumeButton = document.getElementById("components-resume-button");
9+
resumeButton.addEventListener("click", resume);
10+
11+
function handleReconnectStateChanged(event) {
12+
if (event.detail.state === "show") {
13+
reconnectModal.showModal();
14+
} else if (event.detail.state === "hide") {
15+
reconnectModal.close();
16+
} else if (event.detail.state === "failed") {
17+
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
18+
} else if (event.detail.state === "rejected") {
19+
location.reload();
20+
}
21+
}
22+
23+
async function retry() {
24+
document.removeEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
25+
26+
try {
27+
// Reconnect will asynchronously return:
28+
// - true to mean success
29+
// - false to mean we reached the server, but it rejected the connection (e.g., unknown circuit ID)
30+
// - exception to mean we didn't reach the server (this can be sync or async)
31+
const successful = await Blazor.reconnect();
32+
if (!successful) {
33+
// We have been able to reach the server, but the circuit is no longer available.
34+
// We'll reload the page so the user can continue using the app as quickly as possible.
35+
const resumeSuccessful = await Blazor.resumeCircuit();
36+
if (!resumeSuccessful) {
37+
location.reload();
38+
} else {
39+
reconnectModal.close();
40+
}
41+
}
42+
} catch (err) {
43+
// We got an exception, server is currently unavailable
44+
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
45+
}
46+
}
47+
48+
async function resume() {
49+
try {
50+
const successful = await Blazor.resumeCircuit();
51+
if (!successful) {
52+
location.reload();
53+
}
54+
} catch {
55+
location.reload();
56+
}
57+
}
58+
59+
async function retryWhenDocumentBecomesVisible() {
60+
if (document.visibilityState === "visible") {
61+
await retry();
62+
}
63+
}

0 commit comments

Comments
 (0)