Compare commits
3 Commits
75bf7c205a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ae0cf61124 | |||
| c4cad4f875 | |||
| 15d3a13d0a |
@@ -38,8 +38,8 @@ const routes = {
|
||||
},
|
||||
'session.destroy': {
|
||||
methods: ["POST"],
|
||||
pattern: '/logout',
|
||||
tokens: [{"old":"/logout","type":0,"val":"logout","end":""}],
|
||||
pattern: '/auth/logout',
|
||||
tokens: [{"old":"/auth/logout","type":0,"val":"auth","end":""},{"old":"/auth/logout","type":0,"val":"logout","end":""}],
|
||||
types: placeholder as Registry['session.destroy']['types'],
|
||||
},
|
||||
'computers.index': {
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ export interface Registry {
|
||||
}
|
||||
'session.destroy': {
|
||||
methods: ["POST"]
|
||||
pattern: '/logout'
|
||||
pattern: '/auth/logout'
|
||||
types: {
|
||||
body: {}
|
||||
paramsTuple: []
|
||||
|
||||
Vendored
+1
-1
@@ -32,10 +32,10 @@ declare module '@adonisjs/inertia/types' {
|
||||
'widgets/ComputerCard': ExtractProps<(typeof import('../../inertia/pages/widgets/ComputerCard.vue'))['default']>
|
||||
'widgets/ComputerComponentsTable': ExtractProps<(typeof import('../../inertia/pages/widgets/ComputerComponentsTable.vue'))['default']>
|
||||
'widgets/ComputersViewer': ExtractProps<(typeof import('../../inertia/pages/widgets/ComputersViewer.vue'))['default']>
|
||||
'widgets/CustomSelect': ExtractProps<(typeof import('../../inertia/pages/widgets/CustomSelect.vue'))['default']>
|
||||
'widgets/DeleteConfirmationModal': ExtractProps<(typeof import('../../inertia/pages/widgets/DeleteConfirmationModal.vue'))['default']>
|
||||
'widgets/SimpleGallery': ExtractProps<(typeof import('../../inertia/pages/widgets/SimpleGallery.vue'))['default']>
|
||||
'widgets/TableComponent': ExtractProps<(typeof import('../../inertia/pages/widgets/TableComponent.vue'))['default']>
|
||||
'widgets/ValidationError': ExtractProps<(typeof import('../../inertia/pages/widgets/ValidationError.vue'))['default']>
|
||||
'widgets/CustomSelect': ExtractProps<(typeof import('../../inertia/pages/widgets/CustomSelect.vue'))['default']>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,5 +51,6 @@ jobs:
|
||||
cd /volume1/docker/pc_builder &&
|
||||
echo '${{ secrets.NASPASS }}' | sudo -S /usr/bin/bash setup-db.sh &&
|
||||
echo '${{ secrets.NASPASS }}' | sudo -S /usr/bin/docker compose -f docker-compose.prod.yml pull &&
|
||||
echo '${{ secrets.NASPASS }}' | sudo -S /usr/bin/docker compose -f docker-compose.prod.yml up -d --remove-orphans
|
||||
echo '${{ secrets.NASPASS }}' | sudo -S /usr/bin/docker compose -f docker-compose.prod.yml up -d --remove-orphans &&
|
||||
echo '${{ secrets.NASPASS }}' | sudo -S /usr/bin/docker exec pc-builder node ace migration:run --force
|
||||
"
|
||||
|
||||
@@ -9,7 +9,7 @@ export default class ComponentsController {
|
||||
async index({ inertia, auth }: HttpContext) {
|
||||
const user = await auth.authenticate()
|
||||
const components = await Component.query().preload('type').where('userId', user.id)
|
||||
return inertia.render('components/index', { components: components.map((c) => c.serialize({ relations: true })) })
|
||||
return inertia.render('components/index', { components: components.map((c) => c.serialize()) })
|
||||
}
|
||||
|
||||
async create({ inertia }: HttpContext) {
|
||||
@@ -40,7 +40,7 @@ export default class ComponentsController {
|
||||
.where('userId', user.id)
|
||||
.andWhere('id', componentId)
|
||||
.firstOrFail()
|
||||
return inertia.render('components/show', { component: component.serialize({ relations: true }) })
|
||||
return inertia.render('components/show', { component: component.serialize() })
|
||||
}
|
||||
|
||||
async edit({ params, auth, inertia }: HttpContext) {
|
||||
@@ -53,7 +53,7 @@ export default class ComponentsController {
|
||||
.andWhere('id', componentId)
|
||||
.firstOrFail()
|
||||
return inertia.render('components/edit', {
|
||||
component: component.serialize({ relations: true }),
|
||||
component: component.serialize(),
|
||||
types: types.map((t) => t.serialize()),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class ComputersController {
|
||||
picturesQuery.where('order', 1)
|
||||
})
|
||||
|
||||
return inertia.render('computers/index', { computers: computers.map((c) => c.serialize({ relations: true })) })
|
||||
return inertia.render('computers/index', { computers: computers.map((c) => c.serialize()) })
|
||||
}
|
||||
|
||||
async create({ auth, inertia }: HttpContext) {
|
||||
@@ -29,7 +29,7 @@ export default class ComputersController {
|
||||
.where('userId', user.id)
|
||||
.whereNull('computerId')
|
||||
.preload('type')
|
||||
return inertia.render('computers/create', { components: components.map((c) => c.serialize({ relations: true })), states: states.map((s) => s.serialize()) })
|
||||
return inertia.render('computers/create', { components: components.map((c) => c.serialize()), states: states.map((s) => s.serialize()) })
|
||||
}
|
||||
|
||||
async store({ auth, request, response }: HttpContext) {
|
||||
@@ -60,7 +60,7 @@ export default class ComputersController {
|
||||
.where('user_id', user.id)
|
||||
.andWhere('id', computerId)
|
||||
.firstOrFail()
|
||||
return inertia.render('computers/show', { computer: computer.serialize({ relations: true }) })
|
||||
return inertia.render('computers/show', { computer: computer.serialize() })
|
||||
}
|
||||
|
||||
async edit({ params, inertia, auth }: HttpContext) {
|
||||
@@ -86,7 +86,7 @@ export default class ComputersController {
|
||||
'id',
|
||||
computer.components.map((c) => c.id)
|
||||
)
|
||||
return inertia.render('computers/edit', { computer: computer.serialize({ relations: true }), availableComponents: availableComponents.map((c) => c.serialize({ relations: true })), states: states.map((s) => s.serialize()) })
|
||||
return inertia.render('computers/edit', { computer: computer.serialize(), availableComponents: availableComponents.map((c) => c.serialize()), states: states.map((s) => s.serialize()) })
|
||||
}
|
||||
|
||||
async update({ params, request, response }: HttpContext) {
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
import app from '@adonisjs/core/services/app'
|
||||
import { defineConfig } from '@adonisjs/core/http'
|
||||
|
||||
/**
|
||||
@@ -66,7 +65,7 @@ export const http = defineConfig({
|
||||
/**
|
||||
* Send cookies only over HTTPS in production.
|
||||
*/
|
||||
secure: app.inProduction,
|
||||
secure: false,
|
||||
|
||||
/**
|
||||
* Cross-site policy for cookie sending.
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import env from '#start/env'
|
||||
import app from '@adonisjs/core/services/app'
|
||||
import { defineConfig, stores } from '@adonisjs/session'
|
||||
|
||||
const sessionConfig = defineConfig({
|
||||
@@ -43,7 +42,7 @@ const sessionConfig = defineConfig({
|
||||
/**
|
||||
* Send cookies only over HTTPS in production.
|
||||
*/
|
||||
secure: app.inProduction,
|
||||
secure: false,
|
||||
|
||||
/**
|
||||
* Cross-site policy for cookie sending.
|
||||
|
||||
+2
-2
@@ -415,9 +415,9 @@ export class StreamSchema extends BaseModel {
|
||||
declare udpForwarding: number
|
||||
}
|
||||
|
||||
export class UserSchema extends BaseModel {
|
||||
export class NpmUserSchema extends BaseModel {
|
||||
static $columns = ['avatar', 'createdOn', 'email', 'id', 'isDeleted', 'isDisabled', 'modifiedOn', 'name', 'nickname', 'roles'] as const
|
||||
$columns = UserSchema.$columns
|
||||
$columns = NpmUserSchema.$columns
|
||||
@column()
|
||||
declare avatar: string
|
||||
@column.dateTime()
|
||||
|
||||
@@ -1,35 +1,14 @@
|
||||
<script lang="ts" setup>
|
||||
import { Link } from '@adonisjs/inertia/vue'
|
||||
import { useForm } from '@inertiajs/vue3'
|
||||
import { computed } from 'vue'
|
||||
import EmptyLayout from '~/pages/layout/emptyLayout.vue'
|
||||
|
||||
defineOptions({ layout: EmptyLayout })
|
||||
|
||||
const props = defineProps<{ errors?: Record<string, string> }>()
|
||||
|
||||
const vineErrors = computed(() => {
|
||||
if (props.errors && !Array.isArray(props.errors)) {
|
||||
return props.errors
|
||||
}
|
||||
return {}
|
||||
})
|
||||
|
||||
const authError = computed(() => {
|
||||
if (props.errors && !Array.isArray(props.errors)) {
|
||||
return props.errors
|
||||
}
|
||||
return null
|
||||
})
|
||||
|
||||
const form = useForm({
|
||||
email: '',
|
||||
password: '',
|
||||
})
|
||||
|
||||
function getErrorMessage(field: string): string | null {
|
||||
return vineErrors.value[field] || null
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -21,7 +21,7 @@ const form = useForm({
|
||||
<p class="text-sm text-gray-600 mt-2">Join PC Creator today</p>
|
||||
</div>
|
||||
|
||||
<Form route="new_account.store" #default="{ processing, errors }">
|
||||
<Form route="new_account.store" #default="{ processing }">
|
||||
<div class="space-y-4 sm:space-y-6">
|
||||
<div>
|
||||
<label class="block">
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import { Link } from '@adonisjs/inertia/vue'
|
||||
import { useForm } from '@inertiajs/vue3'
|
||||
import CustomSelect from '~/pages/widgets/CustomSelect.vue'
|
||||
|
||||
const props = defineProps<{ types: any[]; errors?: Record<string, string> }>()
|
||||
const errors = computed(() => props.errors || {})
|
||||
defineProps<{ types: any[]; errors?: Record<string, string> }>()
|
||||
const form = reactive({
|
||||
name: '',
|
||||
price: 0,
|
||||
@@ -14,18 +13,6 @@ const form = reactive({
|
||||
quantity: 1,
|
||||
})
|
||||
|
||||
function getErrorMessage(field: string): string | null {
|
||||
return errors.value[field] || null
|
||||
}
|
||||
|
||||
function formatDateForMySQL(date: string) {
|
||||
const d = new Date(date)
|
||||
const year = d.getFullYear()
|
||||
const month = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
form.purchase_date = `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
function submitForm() {
|
||||
const inertiaForm = useForm(form)
|
||||
inertiaForm.post('/components')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import { Link } from '@adonisjs/inertia/vue'
|
||||
import { usePage } from '@inertiajs/vue3'
|
||||
import CustomSelect from '~/pages/widgets/CustomSelect.vue'
|
||||
@@ -11,7 +11,6 @@ const { props } = usePage<{
|
||||
errors?: Record<string, string>
|
||||
}>()
|
||||
const { component, types, origin } = props
|
||||
const errors = computed(() => props.errors || {})
|
||||
|
||||
const form = reactive({
|
||||
id: component.id,
|
||||
@@ -21,18 +20,6 @@ const form = reactive({
|
||||
purchaseDate: component.purchaseDate,
|
||||
origin: origin,
|
||||
})
|
||||
|
||||
function getErrorMessage(field: string): string | null {
|
||||
return errors.value[field] || null
|
||||
}
|
||||
|
||||
function formatDateForMySQL(date: string) {
|
||||
const d = new Date(date)
|
||||
const year = d.getFullYear()
|
||||
const month = String(d.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(d.getDate()).padStart(2, '0')
|
||||
form.purchase_date = `${year}-${month}-${day}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -9,7 +9,6 @@ const { props } = usePage<{
|
||||
errors: Record<string, string>
|
||||
}>()
|
||||
const { components, states } = props
|
||||
const errors = computed(() => props.errors || {})
|
||||
|
||||
const componentTypeOrder = [
|
||||
'Processor',
|
||||
@@ -48,10 +47,6 @@ const form = reactive({
|
||||
globalScore: 0,
|
||||
componentsId: [] as number[],
|
||||
})
|
||||
|
||||
function getErrorMessage(field: string): string | null {
|
||||
return errors.value[field] || null
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive } from 'vue'
|
||||
import { reactive } from 'vue'
|
||||
import { Link } from '@adonisjs/inertia/vue'
|
||||
import { router, usePage } from '@inertiajs/vue3'
|
||||
|
||||
@@ -9,8 +9,7 @@ const { props } = usePage<{
|
||||
states: any[]
|
||||
errors?: Record<string, string>
|
||||
}>()
|
||||
const { computer, availableComponents, states } = props
|
||||
const errors = computed(() => props.errors || {})
|
||||
const { computer, states } = props
|
||||
|
||||
const form = reactive({
|
||||
id: computer.id,
|
||||
@@ -23,17 +22,9 @@ const form = reactive({
|
||||
componentsId: computer.components.map((c: any) => c.id),
|
||||
})
|
||||
|
||||
function updateComponents(componentsId: number[]) {
|
||||
form.componentsId = componentsId
|
||||
}
|
||||
|
||||
function deleteComputer(id: number) {
|
||||
router.delete(`/computers/${id}`)
|
||||
}
|
||||
|
||||
function getErrorMessage(field: string): string | null {
|
||||
return errors.value[field] || null
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from '@adonisjs/inertia/vue'
|
||||
|
||||
const { props } = defineProps<{ computer: any }>()
|
||||
const { computer } = defineProps<{ computer: any }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
import { useSidebar } from '~/composables/useSidebar'
|
||||
import { Link } from '@adonisjs/inertia/vue'
|
||||
import { usePage } from '@inertiajs/vue3'
|
||||
import { userProfileIcon } from '~/assets/icons'
|
||||
|
||||
const dropdownOpen = ref(false)
|
||||
const { isOpen } = useSidebar()
|
||||
|
||||
const page = usePage()
|
||||
|
||||
@@ -80,6 +78,7 @@ const user = computed(() => {
|
||||
|
||||
<Link
|
||||
href="/auth/logout"
|
||||
method="post"
|
||||
class="flex items-center gap-3 px-4 py-2 text-body-sm font-body-sm text-on-surface hover:bg-surface-container-low transition-colors"
|
||||
>
|
||||
<span class="material-symbols-outlined text-[20px]">logout</span>
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { PageProps } from '@adonisjs/inertia/types'
|
||||
import { InertiaAppProps } from '@inertiajs/vue3/types/app'
|
||||
|
||||
interface ComponentType {
|
||||
id: number
|
||||
name: string
|
||||
@@ -39,13 +36,13 @@ export type Component = {
|
||||
type: ComponentType
|
||||
}
|
||||
|
||||
interface ServerImage {
|
||||
export interface ServerImage {
|
||||
id: number
|
||||
link: string
|
||||
order: number
|
||||
}
|
||||
|
||||
interface NewImage {
|
||||
export interface NewImage {
|
||||
file: File
|
||||
order: number
|
||||
}
|
||||
@@ -63,15 +60,4 @@ export type UIAuthError = {
|
||||
message: string
|
||||
}
|
||||
|
||||
interface SharedProps extends PageProps {
|
||||
auth: {
|
||||
user: {
|
||||
id: number
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type PageWithSharedProps = InertiaAppProps<SharedProps>
|
||||
export type Image = ServerImage | NewImage
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
type UIAuthError = {
|
||||
status: number
|
||||
code: string
|
||||
message: string
|
||||
}
|
||||
|
||||
defineProps<{
|
||||
authError?: UIAuthError
|
||||
}>()
|
||||
|
||||
@@ -84,8 +84,7 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { crossIcon } from '~/assets/icons'
|
||||
import { Navigation, Pagination } from 'vue3-carousel'
|
||||
import type { NewImage, ServerImage } from '../../../app/types/UItypes'
|
||||
import type { Image } from '~/pages/types/UITypes'
|
||||
import type { Image, NewImage, ServerImage } from '~/pages/types/UITypes'
|
||||
|
||||
const props = defineProps<{
|
||||
galleryId: string
|
||||
@@ -134,12 +133,12 @@ function addImage() {
|
||||
|
||||
function removeImage(image: Image) {
|
||||
if ('id' in image) {
|
||||
const index = serverImages.value.findIndex((img) => img.id === image.id)
|
||||
const index = serverImages.value.findIndex((img: ServerImage) => img.id === image.id)
|
||||
if (index !== -1) {
|
||||
serverImages.value.splice(index, 1)
|
||||
}
|
||||
} else {
|
||||
const index = newImages.value.findIndex((img) => img.file === image.file)
|
||||
const index = newImages.value.findIndex((img: NewImage) => img.file === image.file)
|
||||
if (index !== -1) {
|
||||
newImages.value.splice(index, 1)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ export default await Env.create(new URL('../', import.meta.url), {
|
||||
|
||||
// App
|
||||
APP_KEY: Env.schema.secret(),
|
||||
APP_URL: Env.schema.string(),
|
||||
|
||||
// Session
|
||||
SESSION_DRIVER: Env.schema.enum(['cookie', 'memory', 'database'] as const),
|
||||
|
||||
@@ -30,6 +30,7 @@ router
|
||||
.group(() => {
|
||||
router.post('logout', [controllers.Session, 'destroy'])
|
||||
})
|
||||
.prefix('/auth')
|
||||
.use(middleware.auth())
|
||||
|
||||
router
|
||||
|
||||
Reference in New Issue
Block a user