Compare commits
25 Commits
c98a64d523
...
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 | |||
| 9d5147c060 | |||
| 56f6a45ccc | |||
| 286ae5135d |
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']};
|
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
---
|
---
|
||||||
import type { KarKarCarSession } from "../api/index.ts"
|
|
||||||
import { getUser } from "../api/index"
|
import { getUser } from "../api/index"
|
||||||
|
|
||||||
import type FullAuthConfig from 'auth-astro'
|
|
||||||
import config from 'auth:config'
|
import config from 'auth:config'
|
||||||
|
import authConfig from 'auth:config'
|
||||||
|
|
||||||
interface Props {
|
const { class: className, ...rest } = Astro.props;
|
||||||
authConfig?: typeof config
|
|
||||||
}
|
|
||||||
|
|
||||||
const { authConfig = config } = Astro.props as Props
|
|
||||||
|
|
||||||
let session = await getUser(Astro.request, authConfig)
|
let session = await getUser(Astro.request, authConfig)
|
||||||
---
|
---
|
||||||
|
|
||||||
<div>
|
<div class={className}>
|
||||||
<Fragment set:html={Astro.slots.render('default', [session])} />
|
<Fragment set:html={Astro.slots.render('default', [session])} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
24
src/components/UserInfo.astro
Normal file
24
src/components/UserInfo.astro
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
import type { KarKarCarSession } from "../api/index.ts";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
session: KarKarCarSession | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { session } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
{session && session.userData && session.userData.amount? (
|
||||||
|
<div class="text-gray-700">
|
||||||
|
<h2 class="m-0 mb-4 text-slate-800">{session.user?.email}</h2>
|
||||||
|
<div class="bg-white p-4 rounded shadow-sm">
|
||||||
|
<p>Saldo: <strong>{session.userData.amount}€</strong></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<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>
|
||||||
|
)}
|
||||||
@@ -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>
|
||||||
@@ -20,7 +16,10 @@ import './src/styles/global.css'
|
|||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<Image src={logo} alt="KarKarCar" />
|
<div class="min-h-screen grid place-items-center">
|
||||||
<slot />
|
<div class="grid gap-6 text-center">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -5,29 +5,30 @@ import { SignIn, SignOut } from 'auth-astro/components';
|
|||||||
import KarKarCarAuth from "../components/KarKarCarAuth.astro"
|
import KarKarCarAuth from "../components/KarKarCarAuth.astro"
|
||||||
// 1. Import any dependencies (Full support for JavaScript/TypeScript)
|
// 1. Import any dependencies (Full support for JavaScript/TypeScript)
|
||||||
|
|
||||||
import type { KarKarCarSession } from "../api/index.ts"
|
import { getUser, type KarKarCarSession } from "../api/index"
|
||||||
|
import UserInfo from "../components/UserInfo.astro"
|
||||||
|
import config from 'auth:config'
|
||||||
|
import { Image } from 'astro:assets';
|
||||||
|
import logo from '../images/logo-urdina.png';
|
||||||
|
|
||||||
|
const session = await getUser(Astro.request, config);
|
||||||
|
|
||||||
---
|
---
|
||||||
<Layout>
|
<Layout>
|
||||||
|
<div class="flex justify-center">
|
||||||
|
<Image src={logo} alt="KarKarCar" class="max-w-xs" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<UserInfo session={session} />
|
||||||
<KarKarCarAuth>
|
<KarKarCarAuth>
|
||||||
{(session: KarKarCarSession) => (
|
{(session: KarKarCarSession) => (
|
||||||
|
<>
|
||||||
<>
|
{session ?
|
||||||
{session ?
|
<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>
|
||||||
<SignOut>Logout</SignOut>
|
:
|
||||||
:
|
<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>
|
||||||
<SignIn provider="keycloak">Login</SignIn>
|
}
|
||||||
}
|
</>
|
||||||
<p>
|
|
||||||
|
|
||||||
{session ? `Logged in as ${session.user?.name}` : 'Not logged in'}
|
|
||||||
{session ? `Amount ${session.userData.amount}` : ''}
|
|
||||||
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</KarKarCarAuth>
|
</KarKarCarAuth>
|
||||||
</Layout>
|
</Layout>
|
||||||
Reference in New Issue
Block a user