@panomc/theme-core 1.0.0-dev.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bundle-internal-libs.js +104 -0
- package/bin/check.js +253 -0
- package/bin/generate-licenses.js +125 -0
- package/bin/generate-runtime-shims.js +180 -0
- package/bin/license/file-fingerprint.js +74 -0
- package/bin/license/finalize-fingerprint.js +72 -0
- package/bin/license/generate-license-constants.js +335 -0
- package/bin/new.js +281 -0
- package/bin/package-zip.js +57 -0
- package/bin/sync.js +326 -0
- package/bin/templates/app.html +59 -0
- package/bin/theme-core.js +103 -0
- package/package.json +77 -0
- package/src/index.js +15 -0
- package/src/kit/hooks-client.js +128 -0
- package/src/kit/hooks-server.js +319 -0
- package/src/kit/license-runtime.js +373 -0
- package/src/kit/resolve.js +71 -0
- package/src/kit/specifiers.js +62 -0
- package/src/kit/svelte-config.js +74 -0
- package/src/kit/vite-config.js +249 -0
- package/src/lib/NotificationManager.js +1 -0
- package/src/lib/PluginAPI.js +368 -0
- package/src/lib/PluginManager.js +1 -0
- package/src/lib/Store.js +43 -0
- package/src/lib/api.util.js +5 -0
- package/src/lib/auth.util.js +77 -0
- package/src/lib/components/App.svelte +10 -0
- package/src/lib/components/Breadcrumb.svelte +88 -0
- package/src/lib/components/CardHeader.svelte +42 -0
- package/src/lib/components/Date.svelte +34 -0
- package/src/lib/components/DefaultToast.svelte +11 -0
- package/src/lib/components/ErrorAlert.svelte +16 -0
- package/src/lib/components/Footer.svelte +223 -0
- package/src/lib/components/Header.svelte +122 -0
- package/src/lib/components/Hook.svelte +71 -0
- package/src/lib/components/LinkCodeInput.svelte +129 -0
- package/src/lib/components/LoginFormBody.svelte +90 -0
- package/src/lib/components/Main.svelte +76 -0
- package/src/lib/components/Navbar.svelte +462 -0
- package/src/lib/components/NoContent.svelte +14 -0
- package/src/lib/components/NotificationContainer.svelte +304 -0
- package/src/lib/components/OnlineAdmins.svelte +64 -0
- package/src/lib/components/PageActions.svelte +39 -0
- package/src/lib/components/PageTitle.svelte +36 -0
- package/src/lib/components/Pagination.svelte +65 -0
- package/src/lib/components/PlayerHead.svelte +58 -0
- package/src/lib/components/PlayerPermissionBadge.svelte +19 -0
- package/src/lib/components/PlayerStatusBadge.svelte +63 -0
- package/src/lib/components/Post.svelte +240 -0
- package/src/lib/components/Posts.svelte +19 -0
- package/src/lib/components/RegisterForm.svelte +125 -0
- package/src/lib/components/Sidebar.svelte +12 -0
- package/src/lib/components/SuccessAlert.svelte +14 -0
- package/src/lib/components/TicketRow.svelte +61 -0
- package/src/lib/components/TicketStatus.svelte +24 -0
- package/src/lib/components/Tickets.svelte +43 -0
- package/src/lib/components/Toast.svelte +13 -0
- package/src/lib/components/ToastContainer.svelte +83 -0
- package/src/lib/components/ViewComponent.svelte +8 -0
- package/src/lib/components/modals/CloseTicketConfirmModal.svelte +121 -0
- package/src/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte +93 -0
- package/src/lib/components/modals/LogoutSessionConfirmModal.svelte +61 -0
- package/src/lib/components/sidebars/HomeSidebar.svelte +333 -0
- package/src/lib/components/sidebars/PlayerDetailSidebar.svelte +124 -0
- package/src/lib/components/sidebars/ProfileSidebar.svelte +149 -0
- package/src/lib/components/sidebars/SupportSidebar.svelte +54 -0
- package/src/lib/components/sidebars/TicketCreateAndDetailSidebar.svelte +84 -0
- package/src/lib/csrf.js +5 -0
- package/src/lib/init.libs.js +2 -0
- package/src/lib/language.util.js +154 -0
- package/src/lib/layouts/AppLayout.svelte +59 -0
- package/src/lib/layouts/AuthLayout.svelte +29 -0
- package/src/lib/layouts/MainLayout.svelte +60 -0
- package/src/lib/layouts/ProfileLayout.svelte +29 -0
- package/src/lib/layouts/ThemeSettingsLayout.svelte +37 -0
- package/src/lib/layouts/TicketsLayout.svelte +31 -0
- package/src/lib/loginInput.util.js +4 -0
- package/src/lib/orderNavLinks.util.js +58 -0
- package/src/lib/pages/ActivateEmailPage.svelte +48 -0
- package/src/lib/pages/ConfirmNewEmailPage.svelte +48 -0
- package/src/lib/pages/ErrorPage.svelte +41 -0
- package/src/lib/pages/HomePage.svelte +35 -0
- package/src/lib/pages/LoginPage.svelte +448 -0
- package/src/lib/pages/NotificationsPage.svelte +70 -0
- package/src/lib/pages/PlayerDetailPage.svelte +29 -0
- package/src/lib/pages/PostDetailPage.svelte +36 -0
- package/src/lib/pages/PreviewPostPage.svelte +38 -0
- package/src/lib/pages/RegisterPage.svelte +144 -0
- package/src/lib/pages/RenewPasswordPage.svelte +49 -0
- package/src/lib/pages/ResetPasswordPage.svelte +55 -0
- package/src/lib/pages/RulesPage.svelte +52 -0
- package/src/lib/pages/SupportPage.svelte +36 -0
- package/src/lib/pages/ThemeSettingsPage.svelte +551 -0
- package/src/lib/pages/profile/ProfilePage.svelte +32 -0
- package/src/lib/pages/profile/SettingsPage.svelte +163 -0
- package/src/lib/pages/profile/TicketsPage.svelte +54 -0
- package/src/lib/pages/ticket/CreateTicketPage.svelte +48 -0
- package/src/lib/pages/ticket/TicketDetailPage.svelte +59 -0
- package/src/lib/services/auth.js +85 -0
- package/src/lib/services/posts.js +152 -0
- package/src/lib/services/profile.js +37 -0
- package/src/lib/services/theme-setting.js +22 -0
- package/src/lib/services/tickets.js +95 -0
- package/src/lib/siteRealtime.js +244 -0
- package/src/lib/string.util.js +27 -0
- package/src/lib/tooltip.util.js +5 -0
- package/src/lib/ui-logics/layout-logics/AppLayoutLogics.js +321 -0
- package/src/lib/ui-logics/layout-logics/AuthLayoutLogics.js +10 -0
- package/src/lib/ui-logics/layout-logics/MainLayoutLogics.js +19 -0
- package/src/lib/ui-logics/layout-logics/ProfileLayoutLogics.js +10 -0
- package/src/lib/ui-logics/layout-logics/ThemeSettingsLayoutLogics.js +215 -0
- package/src/lib/ui-logics/layout-logics/TicketsLayoutLogics.js +10 -0
- package/src/lib/ui-logics/page-logics/ActiveEmailPageLogics.js +45 -0
- package/src/lib/ui-logics/page-logics/ConfirmNewEmailPageLogics.js +42 -0
- package/src/lib/ui-logics/page-logics/CreateTicketPageLogics.js +83 -0
- package/src/lib/ui-logics/page-logics/HomePageLogics.js +65 -0
- package/src/lib/ui-logics/page-logics/NotificationsPageLogics.js +264 -0
- package/src/lib/ui-logics/page-logics/PlayerDetailPageLogics.js +40 -0
- package/src/lib/ui-logics/page-logics/PostDetailPageLogics.js +58 -0
- package/src/lib/ui-logics/page-logics/PreviewPostPageLogics.js +53 -0
- package/src/lib/ui-logics/page-logics/ProfilePageLogics.js +44 -0
- package/src/lib/ui-logics/page-logics/RenewPasswordPageLogics.js +44 -0
- package/src/lib/ui-logics/page-logics/ResetPasswordPageLogics.js +53 -0
- package/src/lib/ui-logics/page-logics/SettingsPageLogics.js +230 -0
- package/src/lib/ui-logics/page-logics/SupportPageLogics.js +60 -0
- package/src/lib/ui-logics/page-logics/TicketDetailPageLogics.js +160 -0
- package/src/lib/ui-logics/page-logics/TicketsPageLogics.js +132 -0
- package/src/lib/variables.js +1 -0
- package/src/lib/views/ActivateEmailView.svelte +71 -0
- package/src/lib/views/AppLayoutView.svelte +31 -0
- package/src/lib/views/AuthLayoutView.svelte +23 -0
- package/src/lib/views/ConfirmNewEmailView.svelte +71 -0
- package/src/lib/views/CreateTicketView.svelte +73 -0
- package/src/lib/views/ErrorView.svelte +38 -0
- package/src/lib/views/HomeView.svelte +72 -0
- package/src/lib/views/LoginView.svelte +372 -0
- package/src/lib/views/MainLayoutView.svelte +86 -0
- package/src/lib/views/NotificationsView.svelte +129 -0
- package/src/lib/views/PlayerDetailView.svelte +31 -0
- package/src/lib/views/PostDetailView.svelte +199 -0
- package/src/lib/views/PreviewPostView.svelte +151 -0
- package/src/lib/views/ProfileLayoutView.svelte +16 -0
- package/src/lib/views/ProfileView.svelte +68 -0
- package/src/lib/views/RegisterView.svelte +113 -0
- package/src/lib/views/RenewPasswordView.svelte +98 -0
- package/src/lib/views/ResetPasswordView.svelte +88 -0
- package/src/lib/views/RulesView.svelte +26 -0
- package/src/lib/views/SettingsView.svelte +471 -0
- package/src/lib/views/SupportView.svelte +79 -0
- package/src/lib/views/ThemeSettingsLayoutView.svelte +19 -0
- package/src/lib/views/ThemeSettingsView.svelte +1508 -0
- package/src/lib/views/TicketDetailView.svelte +185 -0
- package/src/lib/views/TicketsLayoutView.svelte +21 -0
- package/src/lib/views/TicketsView.svelte +87 -0
- package/src/plugin-engine/engine.js +484 -0
- package/src/registry/index.js +86 -0
- package/src/routes/RootLayout.svelte +21 -0
- package/src/routes/plugin-ui/Layout.svelte +291 -0
- package/src/routes/plugin-ui/Page.svelte +117 -0
- package/src/routes/plugin-ui/layout.js +8 -0
- package/src/routes/plugin-ui/page.js +8 -0
- package/src/routes/plugins-client-file.js +76 -0
- package/src/routes/root-layout-load.js +15 -0
- package/src/routes/theme-api-languages.js +52 -0
- package/src/routes/theme-api-licenses.js +28 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<Sidebar side={side}>
|
|
2
|
+
<div class="vstack gap-3">
|
|
3
|
+
{#each $items as item (item.id)}
|
|
4
|
+
{#if item.id === 'player-info'}
|
|
5
|
+
<!-- Player Info Snippet -->
|
|
6
|
+
<div class="card border-0 square-card-desktop">
|
|
7
|
+
<div class="card-body vstack gap-3">
|
|
8
|
+
<PlayerHead
|
|
9
|
+
username={$data.username}
|
|
10
|
+
inGame={$data.inGame}
|
|
11
|
+
banned={$data.banned}
|
|
12
|
+
lastActivityTime={$data.lastActivityTime}
|
|
13
|
+
checkTime={checkTime}
|
|
14
|
+
width="64"
|
|
15
|
+
height="64" />
|
|
16
|
+
|
|
17
|
+
<PageTitle title={$data.username} breadcrumb={false} />
|
|
18
|
+
|
|
19
|
+
<div class="text-center">
|
|
20
|
+
<PlayerStatusBadge
|
|
21
|
+
banned={$data.banned}
|
|
22
|
+
lastActivityTime={$data.lastActivityTime}
|
|
23
|
+
inGame={$data.inGame}
|
|
24
|
+
checkTime={checkTime} />
|
|
25
|
+
</div>
|
|
26
|
+
<div class="text-center">
|
|
27
|
+
<PlayerPermissionBadge
|
|
28
|
+
permissionGroupName={$data.permissionGroupName} />
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
{:else}
|
|
33
|
+
<!-- External Component -->
|
|
34
|
+
<ViewComponent component={item.component} data={$data} checkTime={checkTime} {...item.props} />
|
|
35
|
+
{/if}
|
|
36
|
+
{/each}
|
|
37
|
+
</div>
|
|
38
|
+
</Sidebar>
|
|
39
|
+
|
|
40
|
+
<script context="module">
|
|
41
|
+
import ApiUtil from "$pano/lib/api.util.js";
|
|
42
|
+
import { writable } from "svelte/store";
|
|
43
|
+
import { panoApi } from "$pano/lib/PluginAPI";
|
|
44
|
+
import { executeSidebarLoad } from "$pano/lib/PluginAPI";
|
|
45
|
+
|
|
46
|
+
const data = writable({
|
|
47
|
+
username: "",
|
|
48
|
+
lastActivityTime: 0,
|
|
49
|
+
inGame: false,
|
|
50
|
+
permissionGroupName: "",
|
|
51
|
+
banned: false,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
export const load = async (event) => {
|
|
55
|
+
/* Register Defaults */
|
|
56
|
+
panoApi.ui.sidebar.register({
|
|
57
|
+
sidebarId: "player-detail",
|
|
58
|
+
id: "player-info",
|
|
59
|
+
component: "local:player-info",
|
|
60
|
+
priority: 100,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Execute sidebar load and resolve components for SSR
|
|
64
|
+
await executeSidebarLoad('player-detail', event);
|
|
65
|
+
|
|
66
|
+
data.set({
|
|
67
|
+
...(await ApiUtil.get({
|
|
68
|
+
path: `/api/sidebars/profile/${event.params.player}`,
|
|
69
|
+
request: event,
|
|
70
|
+
})),
|
|
71
|
+
username: event.params.player,
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
String.prototype.capitalize = function () {
|
|
76
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
77
|
+
};
|
|
78
|
+
</script>
|
|
79
|
+
|
|
80
|
+
<script>
|
|
81
|
+
import { onDestroy, onMount } from "svelte";
|
|
82
|
+
import { _ } from "svelte-i18n";
|
|
83
|
+
|
|
84
|
+
import Sidebar from "$pano/lib/components/Sidebar.svelte";
|
|
85
|
+
import ViewComponent from "$pano/lib/components/ViewComponent.svelte";
|
|
86
|
+
import PlayerPermissionBadge from "$pano/lib/components/PlayerPermissionBadge.svelte";
|
|
87
|
+
import PlayerStatusBadge from "$pano/lib/components/PlayerStatusBadge.svelte";
|
|
88
|
+
import PlayerHead from "$pano/lib/components/PlayerHead.svelte";
|
|
89
|
+
import PageTitle from "../PageTitle.svelte";
|
|
90
|
+
|
|
91
|
+
let checkTime = 0;
|
|
92
|
+
let interval;
|
|
93
|
+
|
|
94
|
+
export let side;
|
|
95
|
+
|
|
96
|
+
onMount(() => {
|
|
97
|
+
interval = setInterval(() => {
|
|
98
|
+
checkTime += 1;
|
|
99
|
+
}, 1000);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
onDestroy(() => {
|
|
103
|
+
clearInterval(interval);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const items = panoApi.ui.sidebar.get("player-detail");
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<style>
|
|
110
|
+
@media (min-width: 992px) {
|
|
111
|
+
.square-card-desktop {
|
|
112
|
+
aspect-ratio: 1 / 1;
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-direction: column;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.square-card-desktop :global(.card-body) {
|
|
118
|
+
flex: 1;
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-direction: column;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
</style>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<Sidebar side={side}>
|
|
2
|
+
<div class="d-flex flex-column gap-3">
|
|
3
|
+
{#if showDeleteAll}
|
|
4
|
+
<div class="order-last order-lg-first w-100">
|
|
5
|
+
<button
|
|
6
|
+
class="btn btn-danger w-100"
|
|
7
|
+
type="button"
|
|
8
|
+
on:click={() => showDeleteAllNotificationsModal()}>
|
|
9
|
+
<i class="fas fa-trash-alt me-2"></i>
|
|
10
|
+
{$_("buttons.delete-all")}
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
{/if}
|
|
14
|
+
<div
|
|
15
|
+
class="vstack gap-3"
|
|
16
|
+
class:order-first={showDeleteAll}
|
|
17
|
+
class:order-lg-last={showDeleteAll}>
|
|
18
|
+
{#each $items as item (item.id)}
|
|
19
|
+
{#if item.id === "profile-info"}
|
|
20
|
+
<!-- Profile Info Snippet -->
|
|
21
|
+
<div class="card square-card-desktop">
|
|
22
|
+
<div class="card-body vstack gap-3">
|
|
23
|
+
<div class="d-block">
|
|
24
|
+
<PlayerHead
|
|
25
|
+
width="64"
|
|
26
|
+
height="64"
|
|
27
|
+
username={user.username}
|
|
28
|
+
inGame={$data.inGame}
|
|
29
|
+
lastActivityTime={$data.lastActivityTime}
|
|
30
|
+
checkTime={checkTime} />
|
|
31
|
+
</div>
|
|
32
|
+
<PageTitle title={user.username} breadcrumb={false} />
|
|
33
|
+
<div class="text-center">
|
|
34
|
+
<PlayerStatusBadge
|
|
35
|
+
banned={$data.isBanned}
|
|
36
|
+
lastActivityTime={$data.lastActivityTime}
|
|
37
|
+
inGame={$data.inGame}
|
|
38
|
+
checkTime={checkTime} />
|
|
39
|
+
</div>
|
|
40
|
+
<div class="text-center">
|
|
41
|
+
<PlayerPermissionBadge
|
|
42
|
+
permissionGroupName={$data.permissionGroupName} />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
{:else}
|
|
47
|
+
<!-- External Component -->
|
|
48
|
+
<ViewComponent
|
|
49
|
+
component={item.component}
|
|
50
|
+
data={$data}
|
|
51
|
+
user={user}
|
|
52
|
+
checkTime={checkTime}
|
|
53
|
+
{...item.props} />
|
|
54
|
+
{/if}
|
|
55
|
+
{/each}
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
</Sidebar>
|
|
59
|
+
|
|
60
|
+
<script context="module">
|
|
61
|
+
import ApiUtil from "$pano/lib/api.util.js";
|
|
62
|
+
import { writable } from "svelte/store";
|
|
63
|
+
import { executeSidebarLoad, panoApi } from "$pano/lib/PluginAPI";
|
|
64
|
+
|
|
65
|
+
const data = writable({
|
|
66
|
+
lastActivityTime: 0,
|
|
67
|
+
inGame: false,
|
|
68
|
+
permissionGroupName: "",
|
|
69
|
+
isBanned: false,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const load = async (event) => {
|
|
73
|
+
/* Register Defaults */
|
|
74
|
+
panoApi.ui.sidebar.register({
|
|
75
|
+
sidebarId: "profile",
|
|
76
|
+
id: "profile-info",
|
|
77
|
+
component: "local:profile-info",
|
|
78
|
+
priority: 100,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Execute sidebar load and resolve components for SSR
|
|
82
|
+
await executeSidebarLoad("profile", event);
|
|
83
|
+
|
|
84
|
+
data.set(
|
|
85
|
+
await ApiUtil.get({
|
|
86
|
+
path: "/api/sidebars/profile",
|
|
87
|
+
request: event,
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
String.prototype.capitalize = function () {
|
|
93
|
+
return this.charAt(0).toUpperCase() + this.slice(1);
|
|
94
|
+
};
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<script>
|
|
98
|
+
import { getContext, onDestroy, onMount } from "svelte";
|
|
99
|
+
import { _ } from "svelte-i18n";
|
|
100
|
+
|
|
101
|
+
import tooltip from "$pano/lib/tooltip.util";
|
|
102
|
+
|
|
103
|
+
import PlayerPermissionBadge from "$pano/lib/components/PlayerPermissionBadge.svelte";
|
|
104
|
+
import PlayerStatusBadge from "$pano/lib/components/PlayerStatusBadge.svelte";
|
|
105
|
+
import Sidebar from "$pano/lib/components/Sidebar.svelte";
|
|
106
|
+
import ViewComponent from "$pano/lib/components/ViewComponent.svelte";
|
|
107
|
+
import PlayerHead from "$pano/lib/components/PlayerHead.svelte";
|
|
108
|
+
import PageTitle from "../PageTitle.svelte";
|
|
109
|
+
import { show as showDeleteAllNotificationsModal } from "$pano/lib/components/modals/ConfirmRemoveAllNotificationsModal.svelte";
|
|
110
|
+
|
|
111
|
+
export let side;
|
|
112
|
+
export let showDeleteAll = false;
|
|
113
|
+
|
|
114
|
+
const session = getContext("session");
|
|
115
|
+
|
|
116
|
+
$: user = $session.user ? $session.user : {};
|
|
117
|
+
|
|
118
|
+
let checkTime = 0;
|
|
119
|
+
let interval;
|
|
120
|
+
|
|
121
|
+
onMount(() => {
|
|
122
|
+
interval = setInterval(() => {
|
|
123
|
+
checkTime += 1;
|
|
124
|
+
}, 1000);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
onDestroy(() => {
|
|
128
|
+
clearInterval(interval);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const items = panoApi.ui.sidebar.get("profile");
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<style>
|
|
135
|
+
@media (min-width: 992px) {
|
|
136
|
+
.square-card-desktop {
|
|
137
|
+
aspect-ratio: 1 / 1;
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: column;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.square-card-desktop :global(.card-body) {
|
|
143
|
+
flex: 1;
|
|
144
|
+
display: flex;
|
|
145
|
+
flex-direction: column;
|
|
146
|
+
justify-content: center;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
</style>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<Sidebar side="{side}">
|
|
2
|
+
<div class="vstack gap-3">
|
|
3
|
+
{#each $items as item (item.id)}
|
|
4
|
+
{#if item.id === 'online-admins'}
|
|
5
|
+
<!-- Online Admins Snippet -->
|
|
6
|
+
<OnlineAdmins onlineAdmins="{$data.onlineAdmins}" />
|
|
7
|
+
{:else}
|
|
8
|
+
<!-- External Component -->
|
|
9
|
+
<ViewComponent component={item.component} data={$data} {...item.props} />
|
|
10
|
+
{/if}
|
|
11
|
+
{/each}
|
|
12
|
+
</div>
|
|
13
|
+
</Sidebar>
|
|
14
|
+
|
|
15
|
+
<script context="module">
|
|
16
|
+
import ApiUtil from "$pano/lib/api.util.js";
|
|
17
|
+
import { writable } from "svelte/store";
|
|
18
|
+
import { panoApi } from "$pano/lib/PluginAPI";
|
|
19
|
+
import { executeSidebarLoad } from "$pano/lib/PluginAPI";
|
|
20
|
+
|
|
21
|
+
const data = writable({
|
|
22
|
+
onlineAdmins: [],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const load = async (event) => {
|
|
26
|
+
/* Register Defaults */
|
|
27
|
+
panoApi.ui.sidebar.register({
|
|
28
|
+
sidebarId: "support",
|
|
29
|
+
id: "online-admins",
|
|
30
|
+
component: "local:online-admins",
|
|
31
|
+
priority: 100,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Execute sidebar load and resolve components for SSR
|
|
35
|
+
await executeSidebarLoad('support', event);
|
|
36
|
+
|
|
37
|
+
data.set(
|
|
38
|
+
await ApiUtil.get({
|
|
39
|
+
path: "/api/sidebars/support",
|
|
40
|
+
request: event,
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
import Sidebar from "$pano/lib/components/Sidebar.svelte";
|
|
48
|
+
import ViewComponent from "$pano/lib/components/ViewComponent.svelte";
|
|
49
|
+
import OnlineAdmins from "$pano/lib/components/OnlineAdmins.svelte";
|
|
50
|
+
|
|
51
|
+
export let side;
|
|
52
|
+
|
|
53
|
+
const items = panoApi.ui.sidebar.get("support");
|
|
54
|
+
</script>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
<Sidebar side={side}>
|
|
2
|
+
<div class="vstack gap-3">
|
|
3
|
+
{#each $items as item (item.id)}
|
|
4
|
+
{#if item.id === 'online-admins'}
|
|
5
|
+
<!-- Online Admins Snippet -->
|
|
6
|
+
<OnlineAdmins onlineAdmins={$data.onlineAdmins} />
|
|
7
|
+
{:else if item.id === 'close-ticket-button'}
|
|
8
|
+
<!-- Close Ticket Button Snippet -->
|
|
9
|
+
{#if $ticketData && $ticketData.status !== TicketStatuses.CLOSED}
|
|
10
|
+
<button
|
|
11
|
+
class="btn btn-danger w-100"
|
|
12
|
+
type="button"
|
|
13
|
+
on:click={() => showCloseTicketConfirmModal($ticketData)}>
|
|
14
|
+
<i class="fas fa-times me-2"></i>
|
|
15
|
+
{$_("buttons.close-ticket")}
|
|
16
|
+
</button>
|
|
17
|
+
{/if}
|
|
18
|
+
{:else}
|
|
19
|
+
<!-- External Component -->
|
|
20
|
+
<ViewComponent component={item.component} data={$data} ticketData={$ticketData} {...item.props} />
|
|
21
|
+
{/if}
|
|
22
|
+
{/each}
|
|
23
|
+
</div>
|
|
24
|
+
</Sidebar>
|
|
25
|
+
|
|
26
|
+
<script context="module">
|
|
27
|
+
import { writable } from "svelte/store";
|
|
28
|
+
import ApiUtil from "$pano/lib/api.util.js";
|
|
29
|
+
import { panoApi } from "$pano/lib/PluginAPI";
|
|
30
|
+
import { executeSidebarLoad } from "$pano/lib/PluginAPI";
|
|
31
|
+
|
|
32
|
+
const data = writable({
|
|
33
|
+
onlineAdmins: [],
|
|
34
|
+
});
|
|
35
|
+
const ticketData = writable(null);
|
|
36
|
+
|
|
37
|
+
export const load = async (event, ticket) => {
|
|
38
|
+
/* Register Defaults */
|
|
39
|
+
panoApi.ui.sidebar.register({
|
|
40
|
+
sidebarId: "ticket",
|
|
41
|
+
id: "online-admins",
|
|
42
|
+
component: "local:online-admins",
|
|
43
|
+
priority: 100,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
panoApi.ui.sidebar.register({
|
|
47
|
+
sidebarId: "ticket",
|
|
48
|
+
id: "close-ticket-button",
|
|
49
|
+
component: "local:close-ticket-button",
|
|
50
|
+
priority: 110,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Execute sidebar load and resolve components for SSR
|
|
54
|
+
await executeSidebarLoad('ticket', event);
|
|
55
|
+
|
|
56
|
+
data.set(
|
|
57
|
+
await ApiUtil.get({
|
|
58
|
+
path: "/api/sidebars/support",
|
|
59
|
+
request: event,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (ticket) {
|
|
64
|
+
ticketData.set(ticket);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const update = (ticket) => {
|
|
69
|
+
ticketData.set(ticket);
|
|
70
|
+
};
|
|
71
|
+
</script>
|
|
72
|
+
|
|
73
|
+
<script>
|
|
74
|
+
import { _ } from "svelte-i18n";
|
|
75
|
+
import Sidebar from "$pano/lib/components/Sidebar.svelte";
|
|
76
|
+
import ViewComponent from "$pano/lib/components/ViewComponent.svelte";
|
|
77
|
+
import OnlineAdmins from "$pano/lib/components/OnlineAdmins.svelte";
|
|
78
|
+
import { show as showCloseTicketConfirmModal } from "$pano/lib/components/modals/CloseTicketConfirmModal.svelte";
|
|
79
|
+
import { TicketStatuses } from "$pano/lib/components/TicketStatus.svelte";
|
|
80
|
+
|
|
81
|
+
export let side;
|
|
82
|
+
|
|
83
|
+
const items = panoApi.ui.sidebar.get("ticket");
|
|
84
|
+
</script>
|
package/src/lib/csrf.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { getLocaleFromNavigator, init as initI18n, locale, register, waitLocale } from "svelte-i18n";
|
|
2
|
+
import { get, writable } from "svelte/store";
|
|
3
|
+
|
|
4
|
+
import { browser } from "$app/environment";
|
|
5
|
+
|
|
6
|
+
import { base } from "$app/paths";
|
|
7
|
+
import ApiUtil from "$pano/lib/api.util.js";
|
|
8
|
+
|
|
9
|
+
export const languageLoading = writable(false);
|
|
10
|
+
export const currentLanguage = writable(null);
|
|
11
|
+
export const Languages = writable({});
|
|
12
|
+
|
|
13
|
+
async function fetchLanguages(event) {
|
|
14
|
+
const response = await ApiUtil.get({
|
|
15
|
+
path: `/api/locales`,
|
|
16
|
+
request: event
|
|
17
|
+
});
|
|
18
|
+
const locales = response.data;
|
|
19
|
+
|
|
20
|
+
Languages.set(Object.fromEntries(locales.map(item => [item.code, item])));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function init(initialLocale, event) {
|
|
24
|
+
await fetchLanguages(event);
|
|
25
|
+
|
|
26
|
+
if (browser && !initialLocale) {
|
|
27
|
+
initialLocale = get(locale);
|
|
28
|
+
|
|
29
|
+
if (get(locale) === null) {
|
|
30
|
+
initialLocale = getLocaleFromNavigator();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const language = getLanguageByLocale(initialLocale);
|
|
35
|
+
const languageToLoad = language || get(Languages)["en-US"];
|
|
36
|
+
|
|
37
|
+
const enUS = get(Languages)["en-US"];
|
|
38
|
+
|
|
39
|
+
// Load fallback and target language in parallel (they are independent)
|
|
40
|
+
if (languageToLoad.code === enUS.code) {
|
|
41
|
+
await loadLanguage(enUS, event);
|
|
42
|
+
} else {
|
|
43
|
+
await Promise.all([
|
|
44
|
+
loadLanguage(enUS, event),
|
|
45
|
+
loadLanguage(languageToLoad, event)
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
currentLanguage.set(languageToLoad);
|
|
50
|
+
|
|
51
|
+
await waitLocale();
|
|
52
|
+
|
|
53
|
+
initI18n({
|
|
54
|
+
fallbackLocale: "en-US",
|
|
55
|
+
initialLocale: languageToLoad.code
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getAcceptedLanguage(headers) {
|
|
60
|
+
if (
|
|
61
|
+
typeof headers.get("accept-language") === "undefined" ||
|
|
62
|
+
headers.get("accept-language") == null
|
|
63
|
+
) {
|
|
64
|
+
return "";
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return headers.get("accept-language").split(",")[0];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function loadLanguage(language, event) {
|
|
71
|
+
const useFetch = event ? event.fetch : fetch;
|
|
72
|
+
|
|
73
|
+
const [localTranslationsResponse, translationsResponse] = await Promise.all([
|
|
74
|
+
useFetch(base + `/theme-api/languages/${language.code}.json`),
|
|
75
|
+
ApiUtil.get({
|
|
76
|
+
path: `/api/locales/${language.code}/translations/types/THEME`,
|
|
77
|
+
request: event
|
|
78
|
+
})
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
const languageFile = await localTranslationsResponse.json();
|
|
82
|
+
const customTranslations = translationsResponse.result !== "ok" ? {} : translationsResponse.data;
|
|
83
|
+
|
|
84
|
+
const translations = unflattenObject({ ...flattenObject(languageFile), ...flattenObject(customTranslations) });
|
|
85
|
+
|
|
86
|
+
register(language.code, async () => translations);
|
|
87
|
+
|
|
88
|
+
await waitLocale(language.code);
|
|
89
|
+
|
|
90
|
+
if (language.derivatives) {
|
|
91
|
+
for (const derivative of language.derivatives) {
|
|
92
|
+
register(derivative, async () => translations);
|
|
93
|
+
await waitLocale(language.code);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export async function changeLanguage(language) {
|
|
99
|
+
if (get(currentLanguage) === language) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
languageLoading.set(true);
|
|
104
|
+
|
|
105
|
+
await loadLanguage(language);
|
|
106
|
+
|
|
107
|
+
locale.set(language.code);
|
|
108
|
+
currentLanguage.set(language);
|
|
109
|
+
|
|
110
|
+
languageLoading.set(false);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function getLanguageByLocale(locale) {
|
|
114
|
+
let foundLanguage = null;
|
|
115
|
+
const languages = get(Languages);
|
|
116
|
+
|
|
117
|
+
Object.keys(languages).forEach((key) => {
|
|
118
|
+
const language = languages[key];
|
|
119
|
+
if (language.code === locale) {
|
|
120
|
+
foundLanguage = language;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
return foundLanguage;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function flattenObject(obj, prefix = "", result = {}) {
|
|
128
|
+
for (const key in obj) {
|
|
129
|
+
const value = obj[key];
|
|
130
|
+
const newKey = prefix ? `${prefix}.${key}` : key;
|
|
131
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
132
|
+
flattenObject(value, newKey, result);
|
|
133
|
+
} else {
|
|
134
|
+
result[newKey] = value;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function unflattenObject(flatObj) {
|
|
141
|
+
const result = {};
|
|
142
|
+
for (const flatKey in flatObj) {
|
|
143
|
+
const keys = flatKey.split(".");
|
|
144
|
+
keys.reduce((acc, key, idx) => {
|
|
145
|
+
if (idx === keys.length - 1) {
|
|
146
|
+
acc[key] = flatObj[flatKey];
|
|
147
|
+
} else {
|
|
148
|
+
acc[key] = acc[key] || {};
|
|
149
|
+
}
|
|
150
|
+
return acc[key];
|
|
151
|
+
}, result);
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<svelte:component this={layoutView} data={viewData} {session} {pageTitle} {getTitle}>
|
|
2
|
+
<slot />
|
|
3
|
+
</svelte:component>
|
|
4
|
+
|
|
5
|
+
<script context="module">
|
|
6
|
+
import { processLoad, processServerLoad } from "$pano/lib/ui-logics/layout-logics/AppLayoutLogics";
|
|
7
|
+
import { resolveView } from "$pano/registry/index.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {import("@sveltejs/kit").LayoutServerLoad}
|
|
11
|
+
*/
|
|
12
|
+
export async function loadServer(event) {
|
|
13
|
+
return await processServerLoad(event);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {import("@sveltejs/kit").LayoutLoad}
|
|
18
|
+
*/
|
|
19
|
+
export async function load(event) {
|
|
20
|
+
// Resolved in load (not {#await} in markup): universal load data is not
|
|
21
|
+
// serialized, so the component class can travel in it, and SSR renders the
|
|
22
|
+
// view instead of an await-pending branch.
|
|
23
|
+
const viewPromise = resolveView(
|
|
24
|
+
"AppLayoutView",
|
|
25
|
+
() => import("../views/AppLayoutView.svelte"),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const data = await processLoad(event);
|
|
29
|
+
|
|
30
|
+
return { ...data, appLayoutView: await viewPromise };
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import { page } from "$app/stores";
|
|
36
|
+
import { _ } from "svelte-i18n";
|
|
37
|
+
import { init } from "$pano/lib/ui-logics/layout-logics/AppLayoutLogics";
|
|
38
|
+
import { onMount } from "svelte";
|
|
39
|
+
import { get } from "svelte/store";
|
|
40
|
+
import { avatarVersion } from "$pano/lib/Store.js";
|
|
41
|
+
|
|
42
|
+
export let data = undefined;
|
|
43
|
+
|
|
44
|
+
const { session, pageTitle } = init(data);
|
|
45
|
+
|
|
46
|
+
function getTitle(pt, siteName) {
|
|
47
|
+
if (!pt) return siteName;
|
|
48
|
+
const titleStr = typeof pt === "string"
|
|
49
|
+
? $_(pt)
|
|
50
|
+
: (pt.title ? $_(pt.title, { values: pt.titleValues || {} }) : "");
|
|
51
|
+
return `${titleStr} \u2014 ${siteName}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Layout view resolution: every layout uses a UNIQUE data key (appLayoutView)
|
|
55
|
+
// because SvelteKit merges all layout+page load results into one bag —
|
|
56
|
+
// a generic `View` key gets clobbered by deeper layouts/pages.
|
|
57
|
+
$: viewData = data ?? $page.data;
|
|
58
|
+
$: layoutView = viewData?.appLayoutView ?? $page.data.appLayoutView;
|
|
59
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<svelte:component this={layoutView} data={viewData}><slot /></svelte:component>
|
|
2
|
+
|
|
3
|
+
<script context="module">
|
|
4
|
+
import { processLoad } from "$pano/lib/ui-logics/layout-logics/AuthLayoutLogics";
|
|
5
|
+
import { resolveView } from "$pano/registry/index.js";
|
|
6
|
+
|
|
7
|
+
export async function load(event) {
|
|
8
|
+
// Resolved in load (not {#await} in markup): universal load data is not
|
|
9
|
+
// serialized, so the component class can travel in it, and SSR renders the
|
|
10
|
+
// view instead of an await-pending branch.
|
|
11
|
+
const viewPromise = resolveView(
|
|
12
|
+
"AuthLayoutView",
|
|
13
|
+
() => import("../views/AuthLayoutView.svelte"),
|
|
14
|
+
);
|
|
15
|
+
const data = await processLoad(event);
|
|
16
|
+
return { ...data, authLayoutView: await viewPromise };
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script>
|
|
21
|
+
import { page } from "$app/stores";
|
|
22
|
+
export let data = undefined;
|
|
23
|
+
|
|
24
|
+
// Layout view resolution: every layout uses a UNIQUE data key (authLayoutView)
|
|
25
|
+
// because SvelteKit merges all layout+page load results into one bag —
|
|
26
|
+
// a generic `View` key gets clobbered by deeper layouts/pages.
|
|
27
|
+
$: viewData = data ?? $page.data;
|
|
28
|
+
$: layoutView = viewData?.authLayoutView ?? $page.data.authLayoutView;
|
|
29
|
+
</script>
|