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

Stacked 17: Various fixes. #2581

Merged
merged 18 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion app/Legacy/V1/Controllers/Administration/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use App\SmartAlbums\BaseSmartAlbum;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;

Expand Down Expand Up @@ -403,6 +404,9 @@ public function getAll(GetSetAllSettingsRequest $request): Collection
return Configs::query()
->orderBy('cat')
->orderBy('id')
// Only display settings which are not part of SE
d7415 marked this conversation as resolved.
Show resolved Hide resolved
->where('level', '=', 0)
->whereNotIn('key', ['email'])
->get();
}

Expand All @@ -419,7 +423,16 @@ public function getAll(GetSetAllSettingsRequest $request): Collection
public function saveAll(GetSetAllSettingsRequest $request): void
{
$lastException = null;
foreach ($request->except(['_token', 'function', '/api/Settings::saveAll']) as $key => $value) {
// Select all the SE settings.
ildyria marked this conversation as resolved.
Show resolved Hide resolved
$except = DB::table('configs')
->select('key')
->where('level', '=', '1')
->pluck('key')
// Concat bunch of things coming from the POST request.
->concat(['_token', 'function', '/api/Settings::saveAll'])
// Convert to array.
->all();
foreach ($request->except($except) as $key => $value) {
$value ??= '';
try {
Configs::set($key, $value);
Expand Down
2 changes: 1 addition & 1 deletion config/log-viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function renv_cond(string $cst): string
|
*/

'back_to_system_url' => renv('APP_URL', 'http://localhost') . renv_cond('APP_DIR'),
'back_to_system_url' => renv('APP_URL', 'http://localhost') . renv_cond('APP_DIR') . '/gallery',
ildyria marked this conversation as resolved.
Show resolved Hide resolved

'back_to_system_label' => null, // Displayed by default: "Back to {{ app.name }}"

Expand Down
22 changes: 22 additions & 0 deletions database/migrations/2024_10_23_222857_change_header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

return new class() extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('configs')->where('value', '=', 'Lychee v5')->update(['value' => 'Lychee v6']);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('configs')->where('value', '=', 'Lychee v6')->update(['value' => 'Lychee v5']);
}
};
21 changes: 21 additions & 0 deletions database/migrations/2024_10_23_225332_warning_html_content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Illuminate\Database\Migrations\Migration;

return new class() extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
DB::table('configs')->whereIn('key', ['nsfw_banner_override', 'footer_additional_text'])->update(['details' => '<span class="pi pi-exclamation-triangle text-orange-500"></span> Unsanitized html field.']);
}

/**
* Reverse the migrations.
*/
public function down(): void
{
DB::table('configs')->whereIn('key', ['nsfw_banner_override', 'footer_additional_text'])->update(['details' => '']);
}
};
28 changes: 18 additions & 10 deletions resources/js/components/forms/album/AlbumCreateDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Button @click="closeCallback" severity="secondary" class="w-full font-bold border-none rounded-bl-xl">
{{ $t("lychee.CANCEL") }}
</Button>
<Button @click="create" severity="contrast" class="font-bold w-full border-none rounded-none rounded-br-xl">
<Button @click="create" severity="contrast" class="font-bold w-full border-none rounded-none rounded-br-xl" :disabled="!isValid">
{{ $t("lychee.CREATE_ALBUM") }}
</Button>
</div>
Expand All @@ -25,10 +25,11 @@
import AlbumService from "@/services/album-service";
import Dialog from "primevue/dialog";
import InputText from "@/components/forms/basic/InputText.vue";
import { ref, watch } from "vue";
import { computed, ref, watch } from "vue";
import { useRouter } from "vue-router";
import FloatLabel from "primevue/floatlabel";
import Button from "primevue/button";
import { useToast } from "primevue/usetoast";

const props = defineProps<{
parentId: string | null;
Expand All @@ -37,24 +38,31 @@ const props = defineProps<{
const visible = defineModel("visible", { default: false });
const parentId = ref(props.parentId);

const toast = useToast();
const router = useRouter();

const title = ref(undefined as undefined | string);

const isValid = computed(() => title.value !== undefined && title.value.length > 0 && title.value.length <= 100);

function create() {
if (!title.value) {
if (!isValid.value) {
return;
}

AlbumService.createAlbum({
title: title.value,
title: title.value as string,
parent_id: parentId.value,
}).then((response) => {
title.value = undefined;
visible.value = false;
AlbumService.clearCache(parentId.value);
router.push(`/gallery/${response.data}`);
});
})
.then((response) => {
title.value = undefined;
visible.value = false;
AlbumService.clearCache(parentId.value);
router.push(`/gallery/${response.data}`);
})
.catch((error) => {
toast.add({ severity: "error", summary: "Oups", detail: error.message });
});
}

watch(
Expand Down
24 changes: 16 additions & 8 deletions resources/js/components/forms/album/AlbumCreateTagDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<Button @click="closeCallback" severity="secondary" class="w-full font-bold border-none rounded-bl-xl">
{{ $t("lychee.CANCEL") }}
</Button>
<Button @click="create" severity="contrast" class="font-bold w-full border-none rounded-none rounded-br-xl">
<Button @click="create" severity="contrast" class="font-bold w-full border-none rounded-none rounded-br-xl" :disabled="!isValid">
{{ $t("lychee.CREATE_TAG_ALBUM") }}
</Button>
</div>
Expand All @@ -36,34 +36,42 @@
import AlbumService from "@/services/album-service";
import Dialog from "primevue/dialog";
import FloatLabel from "primevue/floatlabel";
import { ref, watch } from "vue";
import { computed, ref, watch } from "vue";
import { useRouter } from "vue-router";
import InputText from "@/components/forms/basic/InputText.vue";
import Button from "primevue/button";
import AutoComplete from "primevue/autocomplete";
import { useToast } from "primevue/usetoast";

const props = defineProps<{
visible: boolean;
}>();

const toast = useToast();
const router = useRouter();
const visible = ref(props.visible);

const title = ref(undefined as undefined | string);
const tags = ref([] as string[]);

const isValid = computed(() => title.value !== undefined && title.value.length > 0 && title.value.length <= 100);

function create() {
if (!title.value || tags.value.length === 0) {
if (!isValid.value) {
return;
}

AlbumService.createTag({
title: title.value,
title: title.value as string,
tags: tags.value,
}).then((response) => {
AlbumService.clearAlbums();
router.push(`/gallery/${response.data}`);
});
})
.then((response) => {
AlbumService.clearAlbums();
router.push(`/gallery/${response.data}`);
})
.catch((error) => {
toast.add({ severity: "error", summary: "Oups", detail: error.message });
});
}

watch(
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/forms/album/AlbumShare.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<Card class="sm:p-4 xl:px-9 max-w-3xl w-full" v-if="perms !== undefined">
<template #content>
<div class="flex text-muted-color">
<div class="flex text-muted-color-emphasis">
<div class="w-5/12 flex">
<span class="w-full">{{ $t("lychee.USERNAME") }}</span>
</div>
Expand Down
10 changes: 9 additions & 1 deletion resources/js/components/forms/search/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ const search = defineModel<string>("search", { required: true });

const emits = defineEmits<{
search: [terms: string];
clear: [];
}>();

const isValid = computed<boolean>(() => {
return search.value === "" || search.value.length >= props.searchMinimumLengh;
});

const debouncedFn = useDebounceFn(() => {
emits("search", search.value);
if (search.value === "" || !isValid.value) {
emits("clear");
return;
}

if (search.value !== undefined && search.value.length >= props.searchMinimumLengh) {
emits("search", search.value);
}
}, 1000);
</script>
72 changes: 0 additions & 72 deletions resources/js/components/forms/settings/VersionField.vue

This file was deleted.

2 changes: 1 addition & 1 deletion resources/js/components/forms/sharing/ShareLine.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div class="flex">
<div class="w-5/12 flex items-center">
<div class="w-5/12 flex items-center text-muted-color">
<span v-if="props.withAlbum" class="w-full">{{ props.perm.album_title }}</span>
<span class="w-full">{{ props.perm.username }}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/forms/upload/UploadingLine.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="w-full flex flex-col" :id="'upload' + index">
<div class="flex gap-x-4 justify-between relative" :class="errorFlexClass">
<span class="text-ellipsis min-w-0 w-full overflow-hidden text-nowrap">{{ file.name }}</span>
<span class="text-ellipsis min-w-0 w-full overflow-hidden text-nowrap text-muted-color">{{ file.name }}</span>
<span :class="statusClass" v-if="progress < 100 && progress > 0">{{ progress }}%</span>
<span :class="statusClass">{{ statusMessage }}</span>
</div>
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/headers/AlbumsHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@click="lycheeStore.toggleLogin()"
/>
<!-- Logged in. -->
<Button v-if="user.id" @click="openLeftMenu" icon="pi pi-bars" class="mr-2 border-none" severity="secondary" text />
<OpenLeftMenu v-if="user.id" />
</template>

<template #center>
Expand Down Expand Up @@ -106,6 +106,7 @@ import { useGalleryModals } from "@/composables/modalsTriggers/galleryModals";
import WebAuthnService from "@/services/webauthn-service";
import { useRouter } from "vue-router";
import DropBox from "../modals/DropBox.vue";
import OpenLeftMenu from "./OpenLeftMenu.vue";

const props = defineProps<{
user: App.Http.Resources.Models.UserResource;
Expand Down
12 changes: 12 additions & 0 deletions resources/js/components/headers/OpenLeftMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<Button @click="openLeftMenu" icon="pi pi-bars" class="mr-2 border-none" severity="secondary" text />
</template>
<script setup lang="ts">
import { useLycheeStateStore } from "@/stores/LycheeState";
import { storeToRefs } from "pinia";
import Button from "primevue/button";

const lycheeStore = useLycheeStateStore();
const { left_menu_open } = storeToRefs(lycheeStore);
const openLeftMenu = () => (left_menu_open.value = !left_menu_open.value);
</script>
13 changes: 9 additions & 4 deletions resources/js/components/maintenance/MaintenanceCleaning.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ function load() {

function exec() {
loading.value = true;
MaintenanceService.cleaningDo(props.path).then((response) => {
toast.add({ severity: "success", summary: "Success", life: 3000 });
loading.value = false;
});
MaintenanceService.cleaningDo(props.path)
.then((response) => {
toast.add({ severity: "success", summary: "Success", life: 3000 });
loading.value = false;
})
.catch((e) => {
toast.add({ severity: "error", summary: "Error", detail: e.response.data.message, life: 3000 });
loading.value = false;
});
}

load();
Expand Down
Loading