Skip to content

Commit bb04528

Browse files
committed
feat: dashboard wrapper
1 parent bcdd568 commit bb04528

File tree

9 files changed

+170
-21
lines changed

9 files changed

+170
-21
lines changed

apps/backend/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "web"
3-
version = "3.1.6"
3+
version = "3.1.7"
44
edition = "2024"
55

66
[dependencies]

apps/frontend/content/guides/dev/admincontroller.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ We're assuming your `admin.view` file is called `view.blade.php`, but it can be
128128

129129
<!-- prettier-ignore -->
130130
```html [view.blade.php]
131-
<p>
132-
{{ $foo }}
133-
</p>
131+
<p> {{ $foo }} </p>
134132
```
135133

136134
Save your changes, install your extension and check out your admin view. There should be a paragraph element with 'bar' (the value of `$foo`) as it's content.

apps/frontend/content/guides/dev/adminpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can now open up your extension's admin view (the `view.blade.php` created ea
3131
A `.blade.php` file is _basically_ just HTML, but with the ability to run PHP code and use special blade-template methods. You can read more about [Blade templates and it's directives in the Laravel documentation](https://laravel.com/docs/10.x/blade#blade-directives).
3232
::
3333

34-
```html
34+
```html [view.blade.php]
3535
<div style="background: black; padding: 5px;">
3636
<span style="color: white;"> The name of my extension is {name} </span>
3737
</div>
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: Extending the user dashboard wrapper
3+
description: Extend the Pterodactyl user dashboard using the Laravel blade wrapper
4+
author: Emma
5+
category: dev
6+
thumbnail: dashboard.jpeg
7+
---
8+
9+
::card
10+
The dashboard wrapper should not be your first choice for dashboard extensibility. It's quite limited and can cause weird issues with the React DOM. Use [Components.yml](/docs/configs/componentsyml) instead if available for your extension's use case.
11+
::
12+
13+
## Introduction
14+
15+
Blueprint's `dashboard.wrapper` [conf.yml](/docs/configs/confyml#dashboardwrapper) bind extends the user-side dashboard a `.blade.php` view. Dashboard wrappers can be used for quite a lot of purposes. For this guide, we'll be adding a (useless) "barrel roll" button to the Pterodactyl user-side dashboard.
16+
17+
## Create a basic dashboard wrapper
18+
19+
Create a file named `wrapper.blade.php` and bind it to `dashboard.wrapper` in your extension's [conf.yml](/docs/configs/confyml).
20+
21+
```yaml [conf.yml]
22+
dashboard:
23+
# bind dashboard.wrapper to the wrapper.blade.php
24+
# file you created:
25+
wrapper: 'wrapper.blade.php'
26+
```
27+
28+
In your `dashboard.wrapper`, add a simple button and run `blueprint -build` to apply your changes.
29+
30+
<!-- prettier-ignore -->
31+
```html [wrapper.blade.php]
32+
<button style="background: black;">
33+
Example button
34+
</button>
35+
```
36+
37+
Visit your Pterodactyl instance in your browser, it should look similar to this:
38+
39+
![Image showcasing the Pterodactyl panel, with an example button reading "Example button" in the bottom left.](/img/guides/examplebutton.png)
40+
41+
## Doing a barrel roll
42+
43+
Alright, now that we've got ourselves a button, let's replace "Example button" with something else and give it an identifier.
44+
45+
::card
46+
We're prefixing the buttons `id=` with the `{identifier}` [placeholder](/docs/concepts/placeholders#identifier). This prevents conflicts with other extensions when two extensions assign the same identifier for different elements.
47+
48+
Say, for example, both extensions "foo" and "bar" have an element with the identifier `fizz`. Extension "foo" wants to modify it's own `fizz` element, and does so via JavaScript, there's a non-zero chance that extension "bar"s element gets modified.
49+
50+
_tldr; don't give your element IDs generic names_
51+
::
52+
53+
<!-- prettier-ignore -->
54+
```html [wrapper.blade.php]
55+
<button id="{identifier}-barrel" style="background: black;">
56+
Do a barrel roll!
57+
</button>
58+
```
59+
60+
### Running a function on button press
61+
62+
We can now create ourselves a JavaScript function, then make `{identifier}-barrel` run it whenever it's pressed.
63+
64+
::card
65+
The same conflict potential as mentioned for the `id=` can happen here too. Adding placeholders for function names, however, may break syntax highlighting. Either bite the bullet on syntax highlighting, or name your function something unique.
66+
::
67+
68+
<!-- prettier-ignore -->
69+
```html [wrapper.blade.php]
70+
<script>
71+
function doBarrelRoll() {
72+
// something happened?!
73+
console.log("something happened!!")
74+
}
75+
</script>
76+
```
77+
78+
<!-- prettier-ignore -->
79+
```diff [wrapper.blade.php]
80+
- <button id="{identifier}-barrel" style="background: black;">
81+
+ <button id="{identifier}-barrel" onclick="doBarrelRoll()" style="background: black;">
82+
```
83+
84+
### Adding an animation
85+
86+
We'll use a CSS animation to animate rotating the page. Just like elements and scripts, you can also add stylesheets to your `dashboard.wrapper`.
87+
88+
::card
89+
Stylesheets added inside of `<style />` tags in `dashboard.wrapper` are slightly different to the `dashboard.css` stylesheet. The `dashboard.css` stylesheet is bundled with the React application, the `dashboard.wrapper` is not.
90+
91+
For styling elements made in `dashboard.wrapper`, you should use `dashboard.wrapper`. For styling elements from the React application, you should use `dashboard.css`.
92+
::
93+
94+
<!-- prettier-ignore -->
95+
```html [wrapper.blade.php]
96+
<style>
97+
@keyframes barrelRoll {
98+
0% { transform: rotate(0deg); }
99+
50% { transform: rotate(360deg); }
100+
100% { transform: rotate(0deg); }
101+
}
102+
103+
.barrel-roll {
104+
animation: barrelRoll 1s ease-in-out;
105+
}
106+
</style>
107+
```
108+
109+
This CSS animation will rotate any element with the `barrel-roll` class. We'll use JavaScript to apply this class to the `body` element when `{identifier}-barrel` is pressed.
110+
111+
### Applying the animation class
112+
113+
Update the JavaScript function to apply the `barrel-roll` class to the `body` element when the `doBarrelRoll()` function is called.
114+
115+
<!-- prettier-ignore -->
116+
```html [wrapper.blade.php]
117+
<script>
118+
function doBarrelRoll() {
119+
const body = document.body;
120+
body.classList.add('barrel-roll');
121+
122+
setTimeout(() => {
123+
body.classList.remove('barrel-roll');
124+
}, 1000);
125+
}
126+
</script>
127+
```
128+
129+
## Final results
130+
131+
Apply your changes using `blueprint -build` and visit your panel in your browser. The final result should look somewhat like this:
132+
133+
:prose-video-player{src='/img/guides/barrelroll.mp4'}

apps/frontend/content/guides/dev/dashboardwrapper.md.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.
1.51 MB
Binary file not shown.
181 KB
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<div class="my-4 first-line:mt-0">
3+
<video
4+
loop
5+
controls
6+
:width="props.width || undefined"
7+
:height="props.height || undefined"
8+
class="h-full w-full overflow-hidden rounded-2xl border border-neutral-700 object-cover"
9+
>
10+
<source :src="props.src" :type="props.type || 'video/mp4'" />
11+
</video>
12+
</div>
13+
</template>
14+
15+
<script setup lang="ts">
16+
const props = withDefaults(
17+
defineProps<{
18+
src: string
19+
type?: string
20+
alt?: string
21+
width?: string | number
22+
height?: string | number
23+
24+
// Disable class and style props
25+
class?: string
26+
style?: string
27+
}>(),
28+
{
29+
src: '',
30+
alt: '',
31+
}
32+
)
33+
</script>

apps/frontend/src/pages/browse/[id].vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
object: 'ProseDisabled',
9393
embed: 'ProseDisabled',
9494
pre: 'ProsePreSafe',
95+
ProseVideoPlayer: 'ProseDisabled',
9596
}"
9697
/>
9798
</template>

0 commit comments

Comments
 (0)