Skip to content

Commit

Permalink
Admin panel, basic stuff to list them, plus other fixes around the web.
Browse files Browse the repository at this point in the history
  • Loading branch information
guillecro committed Jan 16, 2025
1 parent fbed15f commit 6ac600f
Show file tree
Hide file tree
Showing 52 changed files with 3,821 additions and 1,640 deletions.
12 changes: 11 additions & 1 deletion app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,15 @@ export default defineAppConfig({
ui: {
primary: 'electricViolet',
gray: 'zinc',
}
table: {
wrapper: 'border border-gray-200 dark:border-gray-800 rounded-lg',
th: {
padding: 'px-2 py-2.5'
},
td: {
padding: 'px-2 py-1.5',
color: 'text-white'
}
}
},
})
9 changes: 9 additions & 0 deletions components/LoadingBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div class="text-center">
<UProgress />
<div class="flex justify-between text-sm mt-3">
<p>Cargando...</p>
<UIcon name="i-heroicons-arrow-path" class="animate-spin" />
</div>
</div>
</template>
71 changes: 50 additions & 21 deletions components/TheNavbar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<script setup lang="ts">
const { status, signOut } = useAuth()
const { status, signOut, data: userData } = useAuth()
// computed loggedIn
const loggedIn = computed(() => status.value === 'authenticated')
const userFullname = computed(() => {
if(userData.value) {
return `${userData.value.firstName} ${userData.value.lastName}`
}
return '-'
})
// const mobileBurgerActive = ref(false)
const handleLogout = async () => {
try {
Expand All @@ -11,29 +19,50 @@ const handleLogout = async () => {
console.error('Error logging out:', error)
}
}
const items = [
[{
label: userFullname.value,
disabled: true
}], [{
label: 'Admin',
to: '/admin',
icon: 'i-heroicons-cog'
}, {
label: 'Salir',
icon: 'i-heroicons-arrow-left-start-on-rectangle-16-solid',
click: () => handleLogout()
}]
]
</script>

<template>
<nav id="navbar" class="bg-primary-800 py-4 rounded-br-2xl rounded-bl-2xl">
<UContainer>
<div class="flex justify-between items-center">
<NuxtLink to="/" class="flex-1">
<img src="/img/incidir-para-existir-logo.png" alt="Incidir para existir" class="h-12 w-auto ml-auto mr-auto md:ml-0 md:mr-auto" >
</NuxtLink>
<div class="hidden md:flex items-center space-x-5 font-oswald uppercase">
<NuxtLink to="/" class="navbar-item">Inicio</NuxtLink>
<NuxtLink to="/quienes-somos" class="navbar-item">¿Quienes Somos?</NuxtLink>
<NuxtLink to="/iniciativas" class="navbar-item leading-none text-center">Iniciativas<br><span class="text-sm font-normal">de la juventud</span></NuxtLink>
<NuxtLink to="/desafios" class="navbar-item leading-none text-center">Desafios<br><span class="text-sm font-normal">de la juventud</span></NuxtLink>
<NuxtLink to="/actualidad" class="navbar-item leading-none text-center">Actualidad<br><span class="text-sm font-normal">de la juventud</span></NuxtLink>
<UButton to="https://linktr.ee/incidirparaexistir" target="_blank" color="mindaro" :ui="{ rounded: 'rounded-full' }">Contactános</UButton>
<UButton v-if="!loggedIn" to="/login" color="orange" variant="solid" :ui="{ rounded: 'rounded-full' }" icon="i-heroicons-arrow-left-end-on-rectangle-16-solid">Ingresa</UButton>
<UButton v-if="loggedIn" color="orange" variant="solid" icon="i-heroicons-arrow-left-start-on-rectangle-16-solid" @click="handleLogout">Salir</UButton>
<!-- <NuxtLink v-if="!loggedIn" to="/login" class="navbar-item">
Ingresa<UIcon name="i-heroicons-arrow-left-end-on-rectangle-16-solid" class="size-6 ml-2" />
</NuxtLink> -->
<nav id="navbar" >
<div class="bg-primary-800 py-4 rounded-br-2xl rounded-bl-2xl">
<UContainer>
<div class="flex justify-between items-center">
<NuxtLink to="/" class="flex-1">
<img src="/img/incidir-para-existir-logo.png" alt="Incidir para existir" class="h-12 w-auto mr-auto md:ml-0 md:mr-auto" >
</NuxtLink>
<div class="hidden md:flex items-center space-x-5 font-oswald uppercase">
<NuxtLink to="/" class="navbar-item">Inicio</NuxtLink>
<NuxtLink to="/quienes-somos" class="navbar-item">¿Quienes Somos?</NuxtLink>
<NuxtLink to="/iniciativas" class="navbar-item leading-none text-center">Iniciativas<br><span class="text-sm font-normal">de la juventud</span></NuxtLink>
<NuxtLink to="/desafios" class="navbar-item leading-none text-center">Desafios<br><span class="text-sm font-normal">de la juventud</span></NuxtLink>
<NuxtLink to="/actualidad" class="navbar-item leading-none text-center">Actualidad<br><span class="text-sm font-normal">de la juventud</span></NuxtLink>
<UButton to="https://linktr.ee/incidirparaexistir" target="_blank" color="mindaro" :ui="{ rounded: 'rounded-full' }">Contactános</UButton>
<UButton v-if="!loggedIn" to="/login" color="orange" variant="solid" :ui="{ rounded: 'rounded-full' }" icon="i-heroicons-arrow-left-end-on-rectangle-16-solid">Ingresa</UButton>
<!-- <UButton v-if="loggedIn" color="orange" variant="solid" icon="i-heroicons-arrow-left-start-on-rectangle-16-solid" @click="handleLogout">Salir</UButton> -->
<!-- <NuxtLink v-if="!loggedIn" to="/login" class="navbar-item">
Ingresa<UIcon name="i-heroicons-arrow-left-end-on-rectangle-16-solid" class="size-6 ml-2" />
</NuxtLink> -->
<UDropdown v-if="loggedIn" :items="items" class="font-inter capitalize" :popper="{ placement: 'bottom-start' }">
<UAvatar :alt="userFullname" />
</UDropdown>
</div>
</div>
</div>
</UContainer>
</UContainer>
</div>
</nav>
</template>
191 changes: 191 additions & 0 deletions components/UploadPicture.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<template>
<div >
<!-- Select a picture for cropping -->
<section class="section">

<!-- Set a button that invokes selecting an image -->
<button class="select-picture">
<UButton @click="openFile">Seleccionar imagen</UButton>
<input
ref="uploadInput"
type="file"
class="hidden"
accept="image/jpg, image/jpeg, image/png, image/gif"
@change="selectFile"
>
</button>
</section>

<!-- Crop result preview -->
<!-- <section v-if="result.dataURL && result.blobURL" class="section">
<p>TheDataURL</p>
<div class="preview">
<img :src="result.dataURL" >
</div>
<p>TheBlob</p>
<div class="preview">
<img :src="result.blobURL" >
</div>
<p>ThePrint</p>
</section> -->

<!-- A Popup for cropping -->
<!-- You can replace it with the framework's Modal component -->
<UModal v-model="isShowModal" >
<UCard>
<template #header>
Ajuste de imagen
</template>
<template #footer>
<div class="flex justify-end gap-2">
<UButton color="white" variant="ghost" @click="isShowModal = false">Cancelar</UButton>
<UButton color="white" variant="ghost" @click="clear">Limpiar</UButton>
<UButton color="white" variant="ghost" @click="reset">Reset</UButton>
<UButton color="mindaro" @click="getResult">Aceptar</UButton>
</div>
</template>
<template #default>

<div class="modal-content">
<!-- The component imported from `vue-picture-cropper` plugin -->
<VuePictureCropper
:box-style="{
width: '100%',
height: '100%',
backgroundColor: '#f8f8f8',
margin: 'auto',
}"
:img="pic"
:options="{
viewMode: 1,
dragMode: 'crop',
// aspectRatio: 16 / 9,
aspectRatio: 1/1,
}"
@ready="ready"
/>
</div>
</template>
</UCard>
</UModal>
</div>
</template>

<script lang="ts">
import { defineComponent, reactive, ref } from 'vue'
import VuePictureCropper, { cropper } from 'vue-picture-cropper'
export default defineComponent({
components: {
VuePictureCropper,
},
setup() {
const isShowModal = ref<boolean>(false)
const uploadInput = ref<HTMLInputElement | null>(null)
const pic = ref<string>('')
const result = reactive({
dataURL: '',
blobURL: '',
})
/**
* Select the picture to be cropped
*/
function selectFile(e: Event) {
// Reset last selection and results
pic.value = ''
result.dataURL = ''
result.blobURL = ''
// Get selected files
const { files } = e.target as HTMLInputElement
if (!files || !files.length) return
// Convert to dataURL and pass to the cropper component
const file = files[0]
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => {
// Update the picture source of the `img` prop
pic.value = String(reader.result)
// Show the modal
isShowModal.value = true
// Clear selected files of input element
if (!uploadInput.value) return
uploadInput.value.value = ''
}
}
/**
* Get cropping results
*/
async function getResult() {
if (!cropper) return
const base64 = cropper.getDataURL()
const blob: Blob | null = await cropper.getBlob()
if (!blob) return
const file = await cropper.getFile({
fileName: 'test-test',
})
console.log({ base64, blob, file })
result.dataURL = base64
result.blobURL = URL.createObjectURL(blob)
isShowModal.value = false
}
/**
* Clear the crop box
*/
function clear() {
if (!cropper) return
cropper.clear()
}
/**
* Reset the default cropping area
*/
function reset() {
if (!cropper) return
cropper.reset()
}
/**
* The ready event passed to Cropper.js
*/
function ready() {
console.log('Cropper is ready.')
}
/**
* Open the file dialog
*/
function openFile(event: MouseEvent) {
event.preventDefault()
if (!uploadInput.value) return
uploadInput.value.click()
}
return {
// Data
uploadInput,
pic,
result,
isShowModal,
openFile,
// Methods
selectFile,
getResult,
clear,
reset,
ready,
}
},
})
</script>
Loading

0 comments on commit 6ac600f

Please sign in to comment.