Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit847e8c5

Browse files
committed
refactor main and lib into new mods
1 parentf2c7cb8 commit847e8c5

File tree

24 files changed

+1157
-1142
lines changed

24 files changed

+1157
-1142
lines changed

‎pgml-dashboard/src/catchers.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use rocket::{catch, http::Status, request::Request, response::Redirect};
2+
3+
usecrate::responses::{self,BadRequest,Response};
4+
5+
#[catch(403)]
6+
pubasyncfnnot_authorized_catcher(_status:Status,_request:&Request<'_>) ->Redirect{
7+
Redirect::to("/login")
8+
}
9+
10+
#[catch(404)]
11+
pubasyncfnnot_found_handler(_status:Status,_request:&Request<'_>) ->Response{
12+
Response::not_found()
13+
}
14+
15+
#[catch(default)]
16+
pubasyncfnerror_catcher(status:Status,request:&Request<'_>) ->Result<BadRequest, responses::Error>{
17+
Err(responses::Error(anyhow::anyhow!(
18+
"{} {}\n{:?}",
19+
status.code,
20+
status.reason().unwrap(),
21+
request
22+
)))
23+
}

‎pgml-dashboard/src/components/inputs/radio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct RadioOption {
1616
implRadioOption{
1717
pubfnnew(label:Component,value:implToString) ->Self{
1818
RadioOption{
19-
label: label,
19+
label,
2020
value: value.to_string(),
2121
checked:false,
2222
actions:StimulusActions::default(),

‎pgml-dashboard/src/components/layouts/marketing/base/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::components::layouts::Head;
22
usecrate::components::notifications::marketing::AlertBanner;
33
usecrate::guards::Cluster;
44
usecrate::models::User;
5-
usecrate::Notification;
5+
usecrate::notifications::Notification;
66
use pgml_components::component;
77
use sailfish::TemplateOnce;
88
use std::fmt;

‎pgml-dashboard/src/components/navigation/toc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
usecrate::docs::TocLink;
1+
usecrate::templates::docs::TocLink;
22
use pgml_components::component;
33
use sailfish::TemplateOnce;
44

‎pgml-dashboard/src/components/notifications/marketing/alert_banner/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usecrate::Notification;
21
use pgml_components::component;
32
use sailfish::TemplateOnce;
43

4+
usecrate::notifications::Notification;
5+
56
#[derive(TemplateOnce,Default,Clone)]
67
#[template(path ="notifications/marketing/alert_banner/template.html")]
78
pubstructAlertBanner{
Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
<% use crate::NotificationLevel; %>
2-
<turbo-frameid="notifications-banner"class="position-relative d-block">
3-
<% if notification.is_some() {%>
4-
<% let notification = notification.unwrap(); %>
5-
<divdata-controller="notifications-marketing-alert-banner">
6-
<divclass="<%- notification.level.to_string() %> W-100">
7-
<divclass="banner d-flex container p-1">
8-
<divclass="flex-grow-1 d-flex flex-column flex-md-row justify-content-center align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
9-
<divclass="mx-3 overflow-hidden"style="max-width: 80%;">
10-
<pclass="m-0 text-center"><%- notification.message %></p>
1+
<% use crate::notifications::NotificationLevel; %>
2+
<turbo-frameid="notifications-banner"class="position-relative d-block">
3+
<% if notification.is_some() {%>
4+
<% let notification=notification.unwrap(); %>
5+
<divdata-controller="notifications-marketing-alert-banner">
6+
<divclass="<%- notification.level.to_string() %> W-100">
7+
<divclass="banner d-flex container p-1">
8+
<div
9+
class="flex-grow-1 d-flex flex-column flex-md-row justify-content-center align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
10+
<divclass="mx-3 overflow-hidden"style="max-width: 80%;">
11+
<pclass="m-0 text-center"><%- notification.message %></p>
12+
</div>
13+
</div>
14+
15+
<% if notification.dismissible && notification.level !=NotificationLevel::Level3 {%>
16+
<aclass="w-0 overflow-visible d-flex align-items-center"style="right: 4vw"
17+
href="/dashboard/notifications/remove_banner?id=<%- notification.id%>&notification_type=alert">
18+
<span
19+
class="material-symbols-outlined <% if notification.level == NotificationLevel::Level2 {%>close-light<% } else {%>close-dark<% } %>">
20+
close
21+
</span></a>
22+
<% } %>
23+
</div>
1124
</div>
1225
</div>
13-
14-
<% if notification.dismissible && notification.level != NotificationLevel::Level3 {%>
15-
<aclass="w-0 overflow-visible d-flex align-items-center"style="right: 4vw"href="/dashboard/notifications/remove_banner?id=<%- notification.id%>&notification_type=alert">
16-
<spanclass="material-symbols-outlined <% if notification.level == NotificationLevel::Level2 {%>close-light<% } else {%>close-dark<% } %>">
17-
close
18-
</span></a>
1926
<% } %>
20-
</div>
21-
</div>
22-
</div>
23-
<% } %>
24-
</turbo-frame>
27+
</turbo-frame>

‎pgml-dashboard/src/components/notifications/marketing/feature_banner/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
usecrate::Notification;
21
use pgml_components::component;
32
use sailfish::TemplateOnce;
43

4+
usecrate::notifications::Notification;
5+
56
#[derive(TemplateOnce,Default,Clone)]
67
#[template(path ="notifications/marketing/feature_banner/template.html")]
78
pubstructFeatureBanner{
Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
1-
<% use crate::NotificationLevel; %>
2-
<turbo-frameid="marketing-notifications-banner-feature"class="position-relative z-1">
3-
<% if notification.is_some() {%>
4-
<% let notification =notification.unwrap(); %>
5-
<divdata-controller="notifications-marketing-feature-banner">
1+
<% use crate::notifications::NotificationLevel; %>
2+
<turbo-frameid="marketing-notifications-banner-feature"class="position-relative z-1">
3+
<% if notification.is_some() {%>
4+
<% let notification=notification.unwrap(); %>
5+
<divdata-controller="notifications-marketing-feature-banner">
66

7-
<divclass="<%- notification.level.to_string() %> <% if notification.level == NotificationLevel::Feature3 {%>main-gradient-border-card<% } %> rounded-3 W-100">
8-
<divclass="banner d-flex container">
7+
<div
8+
class="<%- notification.level.to_string() %> <% if notification.level == NotificationLevel::Feature3 {%>main-gradient-border-card<% } %> rounded-3 W-100">
9+
<divclass="banner d-flex container">
910

10-
<% let content = format!(
11-
r#"
12-
<{} class="{} flex-grow-1 d-flex flex-column flex-md-row justify-content-center align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
13-
<divclass="px-3 py-3 py-sm-0 overflow-hidden">
14-
<pclass="m-0 text-center">{} {}</p>
15-
</div>
16-
</{}>
17-
"#,
18-
if notification.link.is_some() { format!(r#"a href="{}" data-turbo="false" "#, notification.link.clone().unwrap()) } else { "div".to_string() },
19-
if notification.link.is_some() { "btn btn-tertiary p-0 goto-arrow-hover-trigger" } else { "" },
20-
notification.message,
21-
if notification.link.is_some() { r#"<spanclass="material-symbols-outlined more-info position-relative goto-arrow-shift-animation"style="top: 2px;">arrow_forward</span>"# } else { "" },
22-
if notification.link.is_some() { "a" } else { "div" },
23-
); %>
24-
25-
<%- content %>
11+
<% let content=format!( r#"<{}
12+
class="{} flex-grow-1 d-flex flex-column flex-md-row justify-content-center align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
13+
<divclass="px-3 py-3 py-sm-0 overflow-hidden">
14+
<pclass="m-0 text-center">{} {}</p>
15+
</div>
16+
</{}>
17+
"#,
18+
if notification.link.is_some() { format!(r#"a href="{}" data-turbo="false" "#,
19+
notification.link.clone().unwrap()) } else { "div".to_string() },
20+
if notification.link.is_some() { "btn btn-tertiary p-0 goto-arrow-hover-trigger" } else { "" },
21+
notification.message,
22+
if notification.link.is_some() { r#"<span
23+
class="material-symbols-outlined more-info position-relative goto-arrow-shift-animation"
24+
style="top: 2px;">arrow_forward</span>"# } else { "" },
25+
if notification.link.is_some() { "a" } else { "div" },
26+
); %>
27+
28+
<%- content %>
2629

27-
<% if notification.dismissible {%>
28-
<aclass="w-0 btn btn-tertiary overflow-visible d-flex align-items-start p-2"style="height: fit-content"href="/dashboard/notifications/remove_banner?id=<%- notification.id%>&notification_type=feature">
29-
<spanclass="material-symbols-outlined close">
30-
close
31-
</span></a>
30+
<% if notification.dismissible {%>
31+
<aclass="w-0 btn btn-tertiary overflow-visible d-flex align-items-start p-2"
32+
style="height: fit-content"
33+
href="/dashboard/notifications/remove_banner?id=<%- notification.id%>&notification_type=feature">
34+
<spanclass="material-symbols-outlined close">
35+
close
36+
</span></a>
37+
<% } %>
38+
</div>
39+
</div>
40+
</div>
3241
<% } %>
33-
</div>
34-
</div>
35-
</div>
36-
<% } %>
37-
</turbo-frame>
42+
</turbo-frame>

‎pgml-dashboard/src/components/notifications/product/product_banner/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
usecrate::utils::random_string;
2-
usecrate::{Notification,NotificationLevel};
1+
usecrate::{
2+
notifications::{Notification,NotificationLevel},
3+
utils::random_string,
4+
};
35
use pgml_components::component;
46
use sailfish::TemplateOnce;
57

Lines changed: 78 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,84 @@
1-
<%
2-
use crate::NotificationLevel;
3-
use crate::components::Modal;
4-
%>
1+
<% use crate::notifications::NotificationLevel; use crate::components::Modal; %>
52

6-
<divclass="<%- location_id %>">
7-
<% if notification.is_some() {%>
8-
<%
9-
let notification = notification.unwrap();
10-
let modal_id = format!("modal-{}", notification.id);
11-
let show_modal = notification.trigger_modal && show_modal_on_load;
12-
%>
13-
<div
14-
data-controller="notifications-product-product-banner"
15-
<% if show_modal {%>
16-
data-action="
17-
hide.bs.modal->notifications-product-product-banner#updateModalCookie
18-
turbo:load@window->notifications-product-product-banner#showModal
19-
"
20-
<% } %>
21-
data-notifications-product-product-banner-notification-id-value="<%- notification.id %>"
22-
data-notifications-product-product-banner-modal-value="<%- modal_id %>">
23-
<%
24-
let icon = {
25-
if notification.level == NotificationLevel::ProductHigh {
26-
"error"
27-
} else if notification.level == NotificationLevel::ProductMedium {
28-
"notifications"
29-
} else {
30-
"lightbulb"
31-
}
32-
};
33-
%>
34-
<divclass="rounded-2 W-100 <%- notification.level.to_string() %>">
35-
<divclass="banner d-flex container">
36-
<%
37-
let title = if notification.title.is_some() {
38-
format!(r#"<pclass="title m-0">{}</p>"#, notification.title.clone().unwrap())} else {String::from("")};
39-
%>
40-
41-
<% let content = format!(
42-
r#"
43-
<{open_tag} class="{} flex-grow-1 d-flex flex-column flex-md-row justify-content-start align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
44-
<divclass="px-3 py-3 py-sm-1 overflow-hidden text-container d-flex flex-row gap-2">
45-
<spanclass="material-symbols-outlined {display} preset-icon">{icon}</span>
46-
<div>
47-
{title}
48-
<pclass="m-0">{message}</p>
49-
</div>
50-
</div>
51-
</{close_tag}>
52-
"#,
53-
if notification.link.is_some() { "btn btn-tertiary p-0" } else { "" },
54-
display = if notification.preset_icon { "d-block" } else { "d-none" },
55-
icon = icon,
56-
title = title,
57-
message = notification.message,
58-
open_tag = if notification.link.is_some() { format!(r#"a href="{}" data-turbo="false" "#, notification.link.clone().unwrap()) } else { "div".to_string() },
59-
close_tag = if notification.link.is_some() { "a" } else { "div" },
60-
); %>
61-
62-
<%- content %>
63-
64-
<% if notification.dismissible {%>
65-
<aclass="w-0 btn btn-tertiary overflow-visible d-flex align-items-start p-2"style="height: fit-content"href="<%- url %>">
66-
<spanclass="material-symbols-outlined close">
67-
close
68-
</span>
69-
</a>
70-
<% } %>
71-
</div>
72-
<% if show_modal {%>
73-
<%
74-
let title = if notification.title.is_some() {
75-
format!(r#"<h6data-action="click->notifications-product-product-banner#followModalLink">{}</h6>"#, notification.title.unwrap())} else {String::from("")};
76-
%>
3+
<divclass="<%- location_id %>">
4+
<% if notification.is_some() {%>
5+
<% let notification=notification.unwrap(); let modal_id=format!("modal-{}", notification.id); let
6+
show_modal=notification.trigger_modal && show_modal_on_load; %>
7+
<divdata-controller="notifications-product-product-banner"<% if show_modal {%>
8+
data-action="
9+
hide.bs.modal->notifications-product-product-banner#updateModalCookie
10+
turbo:load@window->notifications-product-product-banner#showModal
11+
"
12+
<% } %>
13+
data-notifications-product-product-banner-notification-id-value="<%- notification.id %>"
14+
data-notifications-product-product-banner-modal-value="<%- modal_id %>">
15+
<% let icon={ if notification.level==NotificationLevel::ProductHigh { "error" } else if
16+
notification.level==NotificationLevel::ProductMedium { "notifications" } else { "lightbulb" } }; %>
17+
<divclass="rounded-2 W-100 <%- notification.level.to_string() %>">
18+
<divclass="banner d-flex container">
19+
<% let title=if notification.title.is_some() { format!(r#"<pclass="title m-0">{}</p>"#,
20+
notification.title.clone().unwrap())} else {String::from("")};
21+
%>
7722

78-
<%+ Modal::new(format!(r#"
79-
<divclass="d-flex flex-column gap-4 align-items-center text-center">
80-
<aclass="btn btn-tertiary position-absolute top-0 end-0"data-action="click->notifications-product-product-banner#hideModal"><spanclass="material-symbols-outlined close m-2">close</span></a>
81-
<spanclass="material-symbols-outlined {display} preset-icon"style="font-size: 44px">{icon}</span>
82-
{title}
83-
<pclass="m-0"data-action="click->notifications-product-product-banner#followModalLink">{message}</p>
23+
<% let content=format!( r#"<{open_tag}
24+
class="{} flex-grow-1 d-flex flex-column flex-md-row justify-content-start align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
25+
<divclass="px-3 py-3 py-sm-1 overflow-hidden text-container d-flex flex-row gap-2">
26+
<spanclass="material-symbols-outlined {display} preset-icon">{icon}</span>
27+
<div>
28+
{title}
29+
<pclass="m-0">{message}</p>
30+
</div>
31+
</div>
32+
</{close_tag}>
33+
"#,
34+
if notification.link.is_some() { "btn btn-tertiary p-0" } else { "" },
35+
display = if notification.preset_icon { "d-block" } else { "d-none" },
36+
icon = icon,
37+
title = title,
38+
message = notification.message,
39+
open_tag = if notification.link.is_some() { format!(r#"a href="{}" data-turbo="false" "#,
40+
notification.link.clone().unwrap()) } else { "div".to_string() },
41+
close_tag = if notification.link.is_some() { "a" } else { "div" },
42+
); %>
43+
44+
<%- content %>
45+
46+
<% if notification.dismissible {%>
47+
<aclass="w-0 btn btn-tertiary overflow-visible d-flex align-items-start p-2"
48+
style="height: fit-content"href="<%- url %>">
49+
<spanclass="material-symbols-outlined close">
50+
close
51+
</span>
52+
</a>
53+
<% } %>
54+
</div>
55+
<% if show_modal {%>
56+
<% let title=if notification.title.is_some() { format!(r#"<h6
57+
data-action="click->notifications-product-product-banner#followModalLink">{}</h6>"#,
58+
notification.title.unwrap())} else {String::from("")};
59+
%>
60+
61+
<%+ Modal::new(format!(r#"<divclass="d-flex flex-column gap-4 align-items-center text-center">
62+
<aclass="btn btn-tertiary position-absolute top-0 end-0"
63+
data-action="click->notifications-product-product-banner#hideModal"><span
64+
class="material-symbols-outlined close m-2">close</span></a>
65+
<spanclass="material-symbols-outlined {display} preset-icon"
66+
style="font-size: 44px">{icon}</span>
67+
{title}
68+
<pclass="m-0"data-action="click->notifications-product-product-banner#followModalLink">
69+
{message}</p>
70+
</div>
71+
"#,
72+
display = if notification.preset_icon { "d-block" } else { "d-none" },
73+
icon = icon,
74+
title = title,
75+
message = notification.message
76+
)
77+
.into()).id(&modal_id)
78+
.set_static_backdrop(true) %>
79+
<% } %>
8480
</div>
85-
"#,
86-
display = if notification.preset_icon { "d-block" } else { "d-none" },
87-
icon = icon,
88-
title = title,
89-
message = notification.message
90-
)
91-
.into()).id(&modal_id)
92-
.set_static_backdrop(true) %>
93-
<% } %>
94-
</div>
9581
</div>
9682

9783
<% } %>
98-
</div>
84+
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp