Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dark mode logo support for BBB #1705

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
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
Add dark mode logo support
SamuelWei committed Dec 13, 2024
commit d03272a2583f4a5d9082a50e4cc3cdae30ab7d72
11 changes: 11 additions & 0 deletions app/Http/Controllers/api/v1/SettingsController.php
Original file line number Diff line number Diff line change
@@ -110,6 +110,17 @@
$bigBlueButtonSettings->logo = null;
}

// Dark version Logo for BBB
if ($request->has('bbb_logo_dark_file')) {
$path = $request->file('bbb_logo_dark_file')->store('images', 'public');
$url = Storage::url($path);
$bigBlueButtonSettings->logo_dark = url($url);

Check warning on line 117 in app/Http/Controllers/api/v1/SettingsController.php

Codecov / codecov/patch

app/Http/Controllers/api/v1/SettingsController.php#L115-L117

Added lines #L115 - L117 were not covered by tests
} elseif ($request->has('bbb_logo_dark') && trim($request->input('bbb_logo_dark') != '')) {
$bigBlueButtonSettings->logo_dark = $request->input('bbb_logo_dark');

Check warning on line 119 in app/Http/Controllers/api/v1/SettingsController.php

Codecov / codecov/patch

app/Http/Controllers/api/v1/SettingsController.php#L119

Added line #L119 was not covered by tests
} else {
$bigBlueButtonSettings->logo_dark = null;
}

// Custom style file for BBB
if ($request->has('bbb_style')) {
if (! empty($request->file('bbb_style'))) {
2 changes: 2 additions & 0 deletions app/Http/Requests/UpdateSettings.php
Original file line number Diff line number Diff line change
@@ -79,6 +79,8 @@ public function rules()

'bbb_logo' => ['string', 'max:255'],
'bbb_logo_file' => ['image', 'max:500'],
'bbb_logo_dark' => ['string', 'max:255'],
'bbb_logo_dark_file' => ['image', 'max:500'],
'bbb_style' => ['nullable', 'file', 'max:500'],
'bbb_default_presentation' => ['nullable', 'file', 'max:'.(config('bigbluebutton.max_filesize') * 1000), 'mimes:'.config('bigbluebutton.allowed_file_mimes')],
];
1 change: 1 addition & 0 deletions app/Http/Resources/Settings.php
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ public function toArray($request)
'recording_attendance_retention_period' => $recordingSettings->attendance_retention_period,
'recording_recording_retention_period' => $recordingSettings->recording_retention_period,
'bbb_logo' => $bigBlueButtonSettings->logo,
'bbb_logo_dark' => $bigBlueButtonSettings->logo_dark,
'bbb_style' => $bigBlueButtonSettings->style,
'bbb_default_presentation' => $bigBlueButtonSettings->default_presentation,
];
5 changes: 5 additions & 0 deletions app/Services/MeetingService.php
Original file line number Diff line number Diff line change
@@ -130,6 +130,11 @@
$meetingParams->setLogo(app(BigBlueButtonSettings::class)->logo);
}

// if a dark logo is defined, set dark logo
if (app(BigBlueButtonSettings::class)->logo_dark) {
$meetingParams->setDarklogo(app(BigBlueButtonSettings::class)->logo_dark);

Check warning on line 135 in app/Services/MeetingService.php

Codecov / codecov/patch

app/Services/MeetingService.php#L135

Added line #L135 was not covered by tests
}

// Try to start meeting
try {
$result = $this->serverService->getBigBlueButton()->createMeeting($meetingParams);
2 changes: 2 additions & 0 deletions app/Settings/BigBlueButtonSettings.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ class BigBlueButtonSettings extends Settings
{
public ?string $logo;

public ?string $logo_dark;

public ?string $style;

public ?string $default_presentation;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Spatie\LaravelSettings\Migrations\SettingsMigration;

return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('bbb.logo_dark');
}
};
42 changes: 42 additions & 0 deletions resources/js/views/AdminSettings.vue
Original file line number Diff line number Diff line change
@@ -1098,6 +1098,34 @@
/>
</div>
</fieldset>
<fieldset class="grid grid-cols-12 gap-4">
<legend
id="bbb-logo-dark-label"
class="col-span-12 md:col-span-4 md:mb-0"
>
{{ $t("admin.settings.logo_dark.title") }}
</legend>
<div class="col-span-12 md:col-span-8">
<SettingsImageSelector
v-model:image-url="settings.bbb_logo_dark"
v-model:image="uploadBBBLogoDarkFile"
v-model:image-deleted="bbbLogoDarkDeleted"
:disabled="disabled"
:readonly="viewOnly"
:max-file-size="500000"
preview-width="150"
preview-bg-class="bg-surface-900"
show-delete
:preview-alt="$t('admin.settings.bbb.logo.alt')"
:allowed-extensions="['jpg', 'jpeg', 'png', 'gif', 'svg']"
input-id="bbb-logo"
:url-invalid="formErrors.fieldInvalid('bbb_logo_dark')"
:file-invalid="formErrors.fieldInvalid('bbb_logo_dark_file')"
:url-error="formErrors.fieldError('bbb_logo_dark')"
:file-error="formErrors.fieldError('bbb_logo_dark_file')"
/>
</div>
</fieldset>
<fieldset class="grid grid-cols-12 gap-4">
<legend
id="bbb-style-label"
@@ -1191,6 +1219,8 @@
const uploadLogoDarkFile = ref(null);
const uploadBBBLogoFile = ref(null);
const bbbLogoDeleted = ref(false);
const uploadBBBLogoDarkFile = ref(null);
const bbbLogoDarkDeleted = ref(false);

Check warning on line 1223 in resources/js/views/AdminSettings.vue

Codecov / codecov/patch

resources/js/views/AdminSettings.vue#L1222-L1223

Added lines #L1222 - L1223 were not covered by tests
const defaultPresentation = ref(null);
const defaultPresentationDeleted = ref(false);
const bbbStyle = ref(null);
@@ -1289,6 +1319,15 @@
formData.append("bbb_logo", settings.value.bbb_logo);
}

if (uploadBBBLogoDarkFile.value) {
formData.append("bbb_logo_dark_file", uploadBBBLogoDarkFile.value);
} else if (
!bbbLogoDarkDeleted.value &&
settings.value.bbb_logo_dark != null

Check warning on line 1326 in resources/js/views/AdminSettings.vue

Codecov / codecov/patch

resources/js/views/AdminSettings.vue#L1322-L1326

Added lines #L1322 - L1326 were not covered by tests
) {
formData.append("bbb_logo_dark", settings.value.bbb_logo_dark);

Check warning on line 1328 in resources/js/views/AdminSettings.vue

Codecov / codecov/patch

resources/js/views/AdminSettings.vue#L1328

Added line #L1328 was not covered by tests
}

if (bbbStyle.value !== null) {
formData.append("bbb_style", bbbStyle.value);
} else if (bbbStyleDeleted.value) {
@@ -1307,6 +1346,7 @@
"theme_favicon",
"theme_favicon_dark",
"bbb_logo",
"bbb_logo_dark",
"bbb_style",
"bbb_default_presentation",
];
@@ -1346,9 +1386,11 @@
defaultPresentation.value = null;
defaultPresentationDeleted.value = false;
uploadBBBLogoFile.value = null;
uploadBBBLogoDarkFile.value = null;

Check warning on line 1389 in resources/js/views/AdminSettings.vue

Codecov / codecov/patch

resources/js/views/AdminSettings.vue#L1389

Added line #L1389 was not covered by tests
bbbStyle.value = null;
bbbStyleDeleted.value = false;
bbbLogoDeleted.value = false;
bbbLogoDarkDeleted.value = false;

Check warning on line 1393 in resources/js/views/AdminSettings.vue

Codecov / codecov/patch

resources/js/views/AdminSettings.vue#L1393

Added line #L1393 was not covered by tests

// update form input
settings.value = response.data.data;