Compare commits
22 Commits
9d5147c060
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a83ba855b | |||
| 08eb28aae4 | |||
| 27b17f0ec3 | |||
| c9dabe2c09 | |||
| b8b5d3c26c | |||
| 6ee0bc6f24 | |||
| 82e47f3a47 | |||
| 59f8a6fdf9 | |||
| 04db25ec5a | |||
| 7cdbb872b4 | |||
| 1e9740bf51 | |||
| baba1b7ade | |||
| 55b9b80a4e | |||
| 5c969eb51a | |||
| d466d05e79 | |||
| c63e5b6f16 | |||
| f110ea1d9d | |||
| 68187fe5c6 | |||
| 627b999423 | |||
| feeba4ff00 | |||
| b9bf840c84 | |||
| 2af3030840 |
7
.dockerignore
Normal file
7
.dockerignore
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
.DS_Store
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
data
|
||||||
|
example-data
|
||||||
|
.vscode
|
||||||
|
.astro
|
||||||
11
.env.development
Normal file
11
.env.development
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#XLSX
|
||||||
|
XLSX_AMOUNT_SOURCE=./example-data/saldos.xlsx
|
||||||
|
|
||||||
|
|
||||||
|
# Auth
|
||||||
|
AUTH_TRUST_HOST=false
|
||||||
|
AUTH_SECRET=fa428fc2e4c09d3b6dd914cfef0ddd1e
|
||||||
|
# Keycloak Configuration
|
||||||
|
KEYCLOAK_CLIENT_ID=karkarcar
|
||||||
|
KEYCLOAK_CLIENT_SECRET=fdI1OtyX0YNNUMqfcsbSMFTv9WfzQQwy
|
||||||
|
KEYCLOAK_ISSUER=http://localhost:8180/realms/master
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,3 +22,5 @@ pnpm-debug.log*
|
|||||||
|
|
||||||
# jetbrains setting folder
|
# jetbrains setting folder
|
||||||
.idea/
|
.idea/
|
||||||
|
data/
|
||||||
|
example-data/.~lock.saldos.xlsx#
|
||||||
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
|
||||||
|
FROM node:lts AS base
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# By copying only the package.json and package-lock.json here, we ensure that the following `-deps` steps are independent of the source code.
|
||||||
|
# Therefore, the `-deps` steps will be skipped if only the source code changes.
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
|
||||||
|
FROM base AS prod-deps
|
||||||
|
RUN npm install --omit=dev
|
||||||
|
|
||||||
|
FROM base AS build-deps
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
FROM build-deps AS build
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM base AS runtime
|
||||||
|
COPY --from=prod-deps /app/node_modules ./node_modules
|
||||||
|
COPY --from=build /app/dist ./dist
|
||||||
|
|
||||||
|
ENV HOST=0.0.0.0
|
||||||
|
ENV PORT=4321
|
||||||
|
EXPOSE 4321
|
||||||
|
CMD node ./dist/server/entry.mjs
|
||||||
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
container_name: karkarcar_saldo_app
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
ports:
|
||||||
|
- "4321:4321"
|
||||||
|
environment:
|
||||||
|
- HOST=0.0.0.0
|
||||||
|
- PORT=4321
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- ./data:/data
|
||||||
@@ -1 +0,0 @@
|
|||||||
,oier,XPS24,09.06.2025 18:50,file:///home/oier/.config/libreoffice/4;
|
|
||||||
Binary file not shown.
14
scp.md
Normal file
14
scp.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# SCP karkarcar.oier.ovh
|
||||||
|
|
||||||
|
|
||||||
|
## `~/.ssh/config`
|
||||||
|
```
|
||||||
|
Host karkarcar
|
||||||
|
Hostname 149.202.89.131
|
||||||
|
User ubuntu
|
||||||
|
IdentityFile ~/.ssh/id_rsa
|
||||||
|
```
|
||||||
|
|
||||||
|
- `scp RUTA.XLSX karkarcar:~/pmc/karkarcar-astro/data/saldos.xlsx`
|
||||||
|
- `ssh -t karkarcar 'cd ~/pmc/karkarcar-astro/; ./update.sh'`
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export async function getUser(req: Request, options = authConfig): Promise<KarKa
|
|||||||
|
|
||||||
|
|
||||||
export interface UserAmount {
|
export interface UserAmount {
|
||||||
amount?: String | null;
|
amount?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserAmount(email: String | null | undefined): Promise<UserAmount | null> {
|
async function getUserAmount(email: String | null | undefined): Promise<UserAmount | null> {
|
||||||
@@ -56,25 +56,8 @@ async function getUserAmount(email: String | null | undefined): Promise<UserAmou
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
let userData = data.filter(data => data.Email == email)
|
let userData = data.filter(data => data.Email == email)
|
||||||
|
if(userData[0] == undefined)
|
||||||
|
return{amount:0}
|
||||||
|
|
||||||
return {amount:userData[0]['Saldo Actual']};
|
return {amount:userData[0]['Saldo Actual'] ? userData[0]['Saldo Actual'] : 0};
|
||||||
}
|
|
||||||
|
|
||||||
function getUserData(){
|
|
||||||
const file = readFile(env.XLSX_AMOUNT_SOURCE);
|
|
||||||
let data = []
|
|
||||||
|
|
||||||
const sheets = file.SheetNames
|
|
||||||
|
|
||||||
for(let i = 0; i < sheets.length; i++)
|
|
||||||
{
|
|
||||||
const temp = utils.sheet_to_json(
|
|
||||||
file.Sheets[file.SheetNames[i]])
|
|
||||||
temp.forEach((res) => {
|
|
||||||
data.push(res)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
let userData = data.filter(data => data.Email == email)
|
|
||||||
|
|
||||||
return {amount:userData[0]['Saldo Actual']};
|
|
||||||
}
|
}
|
||||||
@@ -8,15 +8,17 @@ interface Props {
|
|||||||
const { session } = Astro.props;
|
const { session } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class="p-4 rounded-lg bg-gray-100 my-4">
|
{session && session.userData && session.userData.amount? (
|
||||||
{session ? (
|
|
||||||
<div class="text-gray-700">
|
<div class="text-gray-700">
|
||||||
<h2 class="m-0 mb-4 text-slate-800">{session.user?.name} | {session.user?.email}</h2>
|
<h2 class="m-0 mb-4 text-slate-800">{session.user?.email}</h2>
|
||||||
<div class="bg-white p-4 rounded shadow-sm">
|
<div class="bg-white p-4 rounded shadow-sm">
|
||||||
<p>Zure saldoa: {session.userData.amount}</p>
|
<p>Saldo: <strong>{session.userData.amount}€</strong></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<p class="text-gray-600 italic">Sartu zure kontua</p>
|
<div>
|
||||||
)}
|
{session && session.userData &&<p>E-Mail okerra. E-Mail incorrecto</p>}
|
||||||
|
{session && session.userData && <em>{session.user?.email}</em>}
|
||||||
|
{session && session.userData && <p><strong>Bidali e-mail bat/Envia un correo a: <a href="mailto:j0s3b4@protomakers.club">j0s3b4@protomakers.club</a></strong></p>}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
@@ -5,11 +5,7 @@ interface Props {
|
|||||||
|
|
||||||
const { title = "KarkarCar" } = Astro.props;
|
const { title = "KarkarCar" } = Astro.props;
|
||||||
|
|
||||||
import { Image } from 'astro:assets';
|
import '../styles/global.css'
|
||||||
import logo from './src/images/logo-urdina.png';
|
|
||||||
|
|
||||||
|
|
||||||
import './src/styles/global.css'
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ const session = await getUser(Astro.request, config);
|
|||||||
<div class="flex justify-center">
|
<div class="flex justify-center">
|
||||||
<Image src={logo} alt="KarKarCar" class="max-w-xs" />
|
<Image src={logo} alt="KarKarCar" class="max-w-xs" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<UserInfo session={session} />
|
<UserInfo session={session} />
|
||||||
<KarKarCarAuth>
|
<KarKarCarAuth>
|
||||||
{(session: KarKarCarSession) => (
|
{(session: KarKarCarSession) => (
|
||||||
<>
|
<>
|
||||||
{session ?
|
{session ?
|
||||||
<SignOut class="px-8 py-4 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors duration-200 font-medium text-xl">Logout</SignOut>
|
<SignOut class="px-8 py-4 text-white rounded-lg hover:bg-red-700 transition-colors duration-200 font-medium text-xl" style="background-color: #dc3545;">Irten/Salir</SignOut>
|
||||||
:
|
:
|
||||||
<SignIn provider="keycloak" class="px-8 py-4 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors duration-200 font-medium text-xl">Login</SignIn>
|
<SignIn provider="keycloak" class="px-8 py-4 text-white rounded-lg hover:bg-blue-700 transition-colors duration-200 font-medium text-xl" style="background-color: #005f7d;">Sartu/Entrar</SignIn>
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user