initial commit. WIP

This commit is contained in:
lebeau 2024-01-15 14:42:53 -05:00
commit 04fd45a792
51 changed files with 10754 additions and 0 deletions

35
.dockerignore Normal file
View File

@ -0,0 +1,35 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
**/.classpath
**/.dockerignore
**/.env
**/.env.local
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.next
**/.cache
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/build
**/dist
LICENSE
README.md

14
.eslintrc.cjs Normal file
View File

@ -0,0 +1,14 @@
/* eslint-env node */
require('@rushstack/eslint-patch/modern-module-resolution')
module.exports = {
root: true,
'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-prettier/skip-formatting'
],
parserOptions: {
ecmaVersion: 'latest'
}
}

28
.gitignore vendored Normal file
View File

@ -0,0 +1,28 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
.DS_Store
dist
dist-ssr
coverage
*.local
/cypress/videos/
/cypress/screenshots/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

8
.prettierrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}

8
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,8 @@
{
"recommendations": [
"Vue.volar",
"Vue.vscode-typescript-vue-plugin",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}

75
Dockerfile Normal file
View File

@ -0,0 +1,75 @@
# syntax=docker/dockerfile:1
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Dockerfile reference guide at
# https://docs.docker.com/engine/reference/builder/
ARG NODE_VERSION=20.8.1
################################################################################
# Use node image for base image for all stages.
FROM node:${NODE_VERSION}-alpine as base
# Set working directory for all build stages.
WORKDIR /usr/src/app
################################################################################
# Create a stage for installing production dependecies.
FROM base as deps
# Download dependencies as a separate step to take advantage of Docker's caching.
# Leverage a cache mount to /root/.npm to speed up subsequent builds.
# Leverage bind mounts to package.json and package-lock.json to avoid having to copy them
# into this layer.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci --omit=dev
################################################################################
# Create a stage for building the application.
FROM deps as build
# Download additional development dependencies before building, as some projects require
# "devDependencies" to be installed to build. If you don't need this, remove this step.
RUN --mount=type=bind,source=package.json,target=package.json \
--mount=type=bind,source=package-lock.json,target=package-lock.json \
--mount=type=cache,target=/root/.npm \
npm ci
# Copy the rest of the source files into the image.
COPY . .
# Run the build script.
RUN npm run build
################################################################################
# Create a new stage to run the application with minimal runtime dependencies
# where the necessary files are copied from the build stage.
FROM base as final
# Install http-server globally.
RUN npm install -g http-server
RUN npm install -g vite
# Use production node environment by default.
ENV NODE_ENV production
ENV VITE_CONJUREOS_HOST http://142.137.247.118:8080/
# Run the application as a non-root user.
USER node
# Copy package.json so that package manager commands can be used.
COPY package.json .
COPY .env.production.local .env
# Copy the production dependencies from the deps stage and also
# the built application from the build stage into the image.
COPY --from=deps /usr/src/app/node_modules ./node_modules
COPY --from=build /usr/src/app/dist ./dist
# Expose the port that the application listens on.
EXPOSE 5174
# Run the application.
CMD http-server dist -p 5174

41
README.md Normal file
View File

@ -0,0 +1,41 @@
# ConjureOS
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Compile and Minify for Production
```sh
npm run build
```
### Run Unit Tests with [Vitest](https://vitest.dev/)
```sh
npm run test:unit
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```

53
compose.yaml Normal file
View File

@ -0,0 +1,53 @@
# Comments are provided throughout this file to help you get started.
# If you need more help, visit the Docker compose reference guide at
# https://docs.docker.com/compose/compose-file/
# Here the instructions define your application as a service called "server".
# This service is built from the Dockerfile in the current directory.
# You can add other services your application may depend on here, such as a
# database or a cache. For examples, see the Awesome Compose repository:
# https://github.com/docker/awesome-compose
services:
server:
build:
context: .
environment:
NODE_ENV: production
VITE_CONJUREOS_HOST: http://142.137.247.118:8080/
ports:
- 5174:5174
# The commented out section below is an example of how to define a PostgreSQL
# database that your application can use. `depends_on` tells Docker Compose to
# start the database before your application. The `db-data` volume persists the
# database data between container restarts. The `db-password` secret is used
# to set the database password. You must create `db/password.txt` and add
# a password of your choosing to it before running `docker-compose up`.
# depends_on:
# db:
# condition: service_healthy
# db:
# image: postgres
# restart: always
# user: postgres
# secrets:
# - db-password
# volumes:
# - db-data:/var/lib/postgresql/data
# environment:
# - POSTGRES_DB=example
# - POSTGRES_PASSWORD_FILE=/run/secrets/db-password
# expose:
# - 5432
# healthcheck:
# test: [ "CMD", "pg_isready" ]
# interval: 10s
# timeout: 5s
# retries: 5
# volumes:
# db-data:
# secrets:
# db-password:
# file: db/password.txt

12
entrypoint.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
ROOT_DIR=/usr/share/nginx/html
echo "Replacing env constants in JS"
for file in $ROOT_DIR/js/app.*.js* $ROOT_DIR/index.html $ROOT_DIR/precache-manifest*.js;
do
echo "Processing $file ...";
sed -i 's|VITE_CONJUREOS_HOST|'${VITE_CONJUREOS_HOST}'|g' $file
done

13
index.html Normal file
View File

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conjure OS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

8284
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

40
package.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "conjureos",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"test:unit": "vitest",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path .gitignore",
"format": "prettier --write src/"
},
"dependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/container-queries": "^0.1.1",
"@tailwindcss/forms": "^0.5.6",
"@tailwindcss/typography": "^0.5.10",
"mqtt": "^5.3.3",
"pinia": "^2.1.6",
"vue": "^3.3.4",
"vue-router": "^4.2.4"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.3.3",
"@vitejs/plugin-vue": "^4.3.4",
"@vue/eslint-config-prettier": "^8.0.0",
"@vue/test-utils": "^2.4.1",
"autoprefixer": "^10.4.16",
"dotenv": "^16.3.1",
"eslint": "^8.49.0",
"eslint-plugin-vue": "^9.17.0",
"jsdom": "^22.1.0",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
"sass": "^1.68.0",
"tailwindcss": "^3.3.3",
"vite": "^4.4.9",
"vitest": "^0.34.4"
}
}

6
postcss.config.js Normal file
View File

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

23
src/App.vue Normal file
View File

@ -0,0 +1,23 @@
<script setup>
import {RouterLink, RouterView, useRoute} from 'vue-router'
import {storeToRefs} from 'pinia';
import {useAuthStore} from '@/stores/auth';
import router from '@/router';
import Errors from '@/components/Errors.vue'
import {ref} from 'vue';
const authStr = useAuthStore()
const {auth} = storeToRefs(authStr)
</script>
<template>
<RouterView/>
</template>
<style>
footer {
padding: 2rem 0;
}
</style>

94
src/assets/base.css Normal file
View File

@ -0,0 +1,94 @@
/* color palette from <https://github.com/vuejs/theme> */
:root {
--vt-c-white: #FDFDFF;
--vt-c-white-soft: #f8f8f8;
--vt-c-white-mute: #f2f2f2;
--vt-c-black: #171A1B;
--vt-c-black-soft: #2C2F31;
--vt-c-black-mute: #393D3F;
--vt-c-payne: 135, 151, 163;
--vt-c-bittersweet: #C14953;
--vt-c-silver: #C6C5B9;
--vt-c-munsell: #8EC5CC;
--vt-c-divider-light-1: rgba(60, 60, 60, 0.29);
--vt-c-divider-light-2: rgba(60, 60, 60, 0.12);
--vt-c-divider-dark-1: rgba(84, 84, 84, 0.65);
--vt-c-divider-dark-2: rgba(84, 84, 84, 0.48);
--vt-c-text-light-1: var(--vt-c-payne);
--vt-c-text-light-2: rgba(60, 60, 60, 0.66);
--vt-c-text-dark-1: var(--vt-c-white);
--vt-c-text-dark-2: rgba(235, 235, 235, 0.64);
}
/* semantic color variables for this project */
:root {
--color-background: var(--vt-c-white);
--color-background-soft: var(--vt-c-white-soft);
--color-background-mute: var(--vt-c-white-mute);
--color-border: var(--vt-c-divider-light-2);
--color-border-hover: var(--vt-c-divider-light-1);
--color-heading: var(--vt-c-text-light-1);
--color-text: var(--vt-c-text-light-1);
--section-gap: 160px;
}
@media (prefers-color-scheme: dark) {
:root {
--color-background: var(--vt-c-black);
--color-background-soft: var(--vt-c-black-soft);
--color-background-mute: var(--vt-c-black-mute);
--color-border: var(--vt-c-divider-dark-2);
--color-border-hover: var(--vt-c-divider-dark-1);
--color-heading: var(--vt-c-text-dark-1);
--color-text: var(--vt-c-text-dark-2);
}
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
font-weight: normal;
}
body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
transition:
color 0.5s,
background-color 0.5s;
line-height: 1.6;
font-family:
Inter,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
Oxygen,
Ubuntu,
Cantarell,
'Fira Sans',
'Droid Sans',
'Helvetica Neue',
sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
@tailwind base;
@tailwind components;
@tailwind utilities;

1
src/assets/logo.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg>

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

60
src/assets/main.css Normal file
View File

@ -0,0 +1,60 @@
@import 'base.css';
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
gap: 1rem;
font-weight: normal;
}
a.router-link-active {
color: var(--vt-c-munsell) !important;
}
a {
text-decoration: none;
color: var(--vt-c-silver);
transition: 0.4s;
}
@media (hover: hover) {
/*a:hover,*/
/*button:hover {*/
/* background-color: var(--vt-c-payne);*/
/*}*/
}
@media (min-width: 1024px) {
body {
display: flex;
place-items: center;
}
#app {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 0 2rem;
}
}
/* Example CSS for headings with additional styles */
h1 {
font-size: 2rem;
line-height: 4rem
}
h2 {
font-size: 1.5rem;
line-height: 3rem;
}
h3 {
font-size: 1.2rem;
line-height: 2.4rem;
}

43
src/components/Errors.vue Normal file
View File

@ -0,0 +1,43 @@
<script setup>
import { useErrorStore } from '@/stores/errors'
import {storeToRefs} from "pinia";
import { ref } from 'vue'
let isOpen = ref(false)
const errorStore = useErrorStore()
const { errors } = storeToRefs(errorStore)
</script>
<template>
<section>
<ul v-if="isOpen" class="bg-warn rounded p-4 pl-8 mb-2 list-disc">
<li v-for="error in errors" :key="error">
{{ error }}
</li>
</ul>
<button
v-if="!!errors.length"
class="bg-transparent text-warn font-semibold py-2 px-4 border border-warn hover:border-transparent rounded"
type="submit"
@click="isOpen = !isOpen"
>
{{ errors.length }} error(s)
</button>
</section>
</template>
<style scoped>
section {
position: relative;
width: 100%;
}
ul {
position: absolute;
bottom: 100%;
max-height: 25dvh;
overflow: scroll;
display: flex;
flex-direction: column-reverse;
}
</style>

View File

@ -0,0 +1,42 @@
<script setup>
defineProps({
msg: {
type: String,
required: true
}
})
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
Youre successfully a foken 🍞 in the ass.
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>

311
src/components/Loader.vue Normal file
View File

@ -0,0 +1,311 @@
<script setup>
// https://codepen.io/jkantner/pen/YzdpEVO
defineProps({
variant: Number
})
</script>
<template>
<svg
class="pl1"
v-if="!variant || variant === 1"
viewBox="0 0 128 128"
width="128px"
height="128px"
>
<defs>
<linearGradient id="pl-grad" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stop-color="#000" />
<stop offset="100%" stop-color="#fff" />
</linearGradient>
<mask id="pl-mask">
<rect x="0" y="0" width="128" height="128" fill="url(#pl-grad)" />
</mask>
</defs>
<g fill="var(--vt-c-munsell)">
<g class="pl1__g">
<g transform="translate(20,20) rotate(0,44,44)">
<g class="pl1__rect-g">
<rect class="pl1__rect" rx="8" ry="8" width="40" height="40" />
<rect
class="pl1__rect"
rx="8"
ry="8"
width="40"
height="40"
transform="translate(0,48)"
/>
</g>
<g class="pl1__rect-g" transform="rotate(180,44,44)">
<rect class="pl1__rect" rx="8" ry="8" width="40" height="40" />
<rect
class="pl1__rect"
rx="8"
ry="8"
width="40"
height="40"
transform="translate(0,48)"
/>
</g>
</g>
</g>
</g>
<g fill="var(--vt-c-silver)" mask="url(#pl-mask)">
<g class="pl1__g">
<g transform="translate(20,20) rotate(0,44,44)">
<g class="pl1__rect-g">
<rect class="pl1__rect" rx="8" ry="8" width="40" height="40" />
<rect
class="pl1__rect"
rx="8"
ry="8"
width="40"
height="40"
transform="translate(0,48)"
/>
</g>
<g class="pl1__rect-g" transform="rotate(180,44,44)">
<rect class="pl1__rect" rx="8" ry="8" width="40" height="40" />
<rect
class="pl1__rect"
rx="8"
ry="8"
width="40"
height="40"
transform="translate(0,48)"
/>
</g>
</g>
</g>
</g>
</svg>
<svg class="pl2" v-if="variant === 2" viewBox="0 0 128 24" width="128px" height="24px">
<g fill="var(--vt-c-silver)">
<g class="pl2__rect-g">
<rect
class="pl2__rect"
rx="8"
ry="8"
x="0"
y="24"
width="40"
height="24"
transform="rotate(180)"
/>
</g>
<g class="pl2__rect-g">
<rect
class="pl2__rect"
rx="8"
ry="8"
x="44"
y="24"
width="40"
height="24"
transform="rotate(180)"
/>
</g>
<g class="pl2__rect-g">
<rect
class="pl2__rect"
rx="8"
ry="8"
x="88"
y="24"
width="40"
height="24"
transform="rotate(180)"
/>
</g>
</g>
<g fill="var(--vt-c-munsell)" mask="url(#pl-mask)">
<g class="pl2__rect-g">
<rect
class="pl2__rect"
rx="8"
ry="8"
x="0"
y="24"
width="40"
height="24"
transform="rotate(180)"
/>
</g>
<g class="pl2__rect-g">
<rect
class="pl2__rect"
rx="8"
ry="8"
x="44"
y="24"
width="40"
height="24"
transform="rotate(180)"
/>
</g>
<g class="pl2__rect-g">
<rect
class="pl2__rect"
rx="8"
ry="8"
x="88"
y="24"
width="40"
height="24"
transform="rotate(180)"
/>
</g>
</g>
</svg>
</template>
<style scoped>
svg {
margin: auto;
}
.pl1,
.pl2,
.pl3 {
display: block;
width: 8em;
height: 8em;
}
.pl1__g,
.pl1__rect,
.pl2__rect,
.pl2__rect-g,
.pl3__rect {
animation: pl1-a 1.5s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
.pl1__g {
transform-origin: 64px 64px;
}
.pl1__rect:first-child {
animation-name: pl1-b;
}
.pl1__rect:nth-child(2) {
animation-name: pl1-c;
}
.pl2__rect,
.pl2__rect-g {
animation-name: pl2-a;
}
.pl2__rect {
animation-name: pl2-b;
}
.pl2__rect-g .pl2__rect {
transform-origin: 20px 24px;
}
.pl2__rect-g:first-child,
.pl2__rect-g:first-child .pl2__rect {
animation-delay: -0.25s;
}
.pl2__rect-g:nth-child(2),
.pl2__rect-g:nth-child(2) .pl2__rect {
animation-delay: -0.125s;
}
.pl2__rect-g:nth-child(2) .pl2__rect {
transform-origin: 64px 24px;
}
.pl2__rect-g:nth-child(3) .pl2__rect {
transform-origin: 108px 24px;
}
.pl3__rect {
animation-name: pl3;
}
.pl3__rect-g {
transform-origin: 64px 64px;
}
@keyframes pl1-b {
from {
animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
width: 40px;
height: 40px;
}
20% {
animation-timing-function: steps(1, start);
width: 40px;
height: 0;
}
60% {
animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1);
width: 0;
height: 40px;
}
80%,
to {
width: 40px;
height: 40px;
}
}
@keyframes pl1-c {
from {
animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
width: 40px;
height: 40px;
transform: translate(0, 48px);
}
20% {
animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
width: 40px;
height: 64px;
transform: translate(0, 0);
}
40% {
animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
width: 40px;
height: 40px;
transform: translate(0, 0);
}
60% {
animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
width: 88px;
height: 40px;
transform: translate(0, 0);
}
80%,
to {
width: 40px;
height: 40px;
transform: translate(48px, 0);
}
}
@keyframes pl2-a {
from,
25%,
66.67%,
to {
transform: translateY(0);
}
50% {
animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
transform: translateY(-80px);
}
}
@keyframes pl2-b {
from,
to {
animation-timing-function: cubic-bezier(0.33, 0, 0.67, 0);
width: 40px;
height: 12px;
transform: rotate(180deg) translateX(0);
}
33.33% {
animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
width: 20px;
height: 32px;
transform: rotate(180deg) translateX(10px);
}
66.67% {
animation-timing-function: cubic-bezier(0.33, 1, 0.67, 1);
width: 28px;
height: 24px;
transform: rotate(180deg) translateX(6px);
}
}
</style>

View File

@ -0,0 +1,91 @@
<script setup>
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template>
<article>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vues
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vitejs.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a> +
<a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
you need to test your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a> and
<a href="https://on.cypress.io/component" target="_blank" rel="noopener"
>Cypress Component Testing</a
>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
you need more resources, we suggest paying
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>, our official
Discord server, or
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
>StackOverflow</a
>. You should also subscribe to
<a href="https://news.vuejs.org" target="_blank" rel="noopener">our mailing list</a> and follow
the official
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
</WelcomeItem>
</article>
</template>

View File

@ -0,0 +1,86 @@
<template>
<div class="item">
<i>
<slot name="icon"></slot>
</i>
<div class="details">
<h3>
<slot name="heading"></slot>
</h3>
<slot></slot>
</div>
</div>
</template>
<style scoped>
.item {
margin-top: 2rem;
display: flex;
position: relative;
}
.details {
flex: 1;
margin-left: 1rem;
}
i {
display: flex;
place-items: center;
place-content: center;
width: 32px;
height: 32px;
color: var(--color-text);
}
h3 {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 0.4rem;
color: var(--color-heading);
}
@media (min-width: 1024px) {
.item {
margin-top: 0;
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
}
i {
top: calc(50% - 25px);
left: -26px;
position: absolute;
border: 1px solid var(--color-border);
background: var(--color-background);
border-radius: 8px;
width: 50px;
height: 50px;
}
.item:before {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
bottom: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:after {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
top: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:first-of-type:before {
display: none;
}
.item:last-of-type:after {
display: none;
}
}
</style>

View File

@ -0,0 +1,11 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import HelloWorld from '../HelloWorld.vue'
describe('HelloWorld', () => {
it('renders properly', () => {
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
expect(wrapper.text()).toContain('Hello Vitest')
})
})

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M15 4a1 1 0 1 0 0 2V4zm0 11v-1a1 1 0 0 0-1 1h1zm0 4l-.707.707A1 1 0 0 0 16 19h-1zm-4-4l.707-.707A1 1 0 0 0 11 14v1zm-4.707-1.293a1 1 0 0 0-1.414 1.414l1.414-1.414zm-.707.707l-.707-.707.707.707zM9 11v-1a1 1 0 0 0-.707.293L9 11zm-4 0h1a1 1 0 0 0-1-1v1zm0 4H4a1 1 0 0 0 1.707.707L5 15zm10-9h2V4h-2v2zm2 0a1 1 0 0 1 1 1h2a3 3 0 0 0-3-3v2zm1 1v6h2V7h-2zm0 6a1 1 0 0 1-1 1v2a3 3 0 0 0 3-3h-2zm-1 1h-2v2h2v-2zm-3 1v4h2v-4h-2zm1.707 3.293l-4-4-1.414 1.414 4 4 1.414-1.414zM11 14H7v2h4v-2zm-4 0c-.276 0-.525-.111-.707-.293l-1.414 1.414C5.42 15.663 6.172 16 7 16v-2zm-.707 1.121l3.414-3.414-1.414-1.414-3.414 3.414 1.414 1.414zM9 12h4v-2H9v2zm4 0a3 3 0 0 0 3-3h-2a1 1 0 0 1-1 1v2zm3-3V3h-2v6h2zm0-6a3 3 0 0 0-3-3v2a1 1 0 0 1 1 1h2zm-3-3H3v2h10V0zM3 0a3 3 0 0 0-3 3h2a1 1 0 0 1 1-1V0zM0 3v6h2V3H0zm0 6a3 3 0 0 0 3 3v-2a1 1 0 0 1-1-1H0zm3 3h2v-2H3v2zm1-1v4h2v-4H4zm1.707 4.707l.586-.586-1.414-1.414-.586.586 1.414 1.414z"
/>
</svg>
</template>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" fill="currentColor">
<path
d="M11 2.253a1 1 0 1 0-2 0h2zm-2 13a1 1 0 1 0 2 0H9zm.447-12.167a1 1 0 1 0 1.107-1.666L9.447 3.086zM1 2.253L.447 1.42A1 1 0 0 0 0 2.253h1zm0 13H0a1 1 0 0 0 1.553.833L1 15.253zm8.447.833a1 1 0 1 0 1.107-1.666l-1.107 1.666zm0-14.666a1 1 0 1 0 1.107 1.666L9.447 1.42zM19 2.253h1a1 1 0 0 0-.447-.833L19 2.253zm0 13l-.553.833A1 1 0 0 0 20 15.253h-1zm-9.553-.833a1 1 0 1 0 1.107 1.666L9.447 14.42zM9 2.253v13h2v-13H9zm1.553-.833C9.203.523 7.42 0 5.5 0v2c1.572 0 2.961.431 3.947 1.086l1.107-1.666zM5.5 0C3.58 0 1.797.523.447 1.42l1.107 1.666C2.539 2.431 3.928 2 5.5 2V0zM0 2.253v13h2v-13H0zm1.553 13.833C2.539 15.431 3.928 15 5.5 15v-2c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM5.5 15c1.572 0 2.961.431 3.947 1.086l1.107-1.666C9.203 13.523 7.42 13 5.5 13v2zm5.053-11.914C11.539 2.431 12.928 2 14.5 2V0c-1.92 0-3.703.523-5.053 1.42l1.107 1.666zM14.5 2c1.573 0 2.961.431 3.947 1.086l1.107-1.666C18.203.523 16.421 0 14.5 0v2zm3.5.253v13h2v-13h-2zm1.553 12.167C18.203 13.523 16.421 13 14.5 13v2c1.573 0 2.961.431 3.947 1.086l1.107-1.666zM14.5 13c-1.92 0-3.703.523-5.053 1.42l1.107 1.666C11.539 15.431 12.928 15 14.5 15v-2z"
/>
</svg>
</template>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="20" fill="currentColor">
<path
d="M11.447 8.894a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm0 1.789a1 1 0 1 0 .894-1.789l-.894 1.789zM7.447 7.106a1 1 0 1 0-.894 1.789l.894-1.789zM10 9a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0H8zm9.447-5.606a1 1 0 1 0-.894-1.789l.894 1.789zm-2.894-.789a1 1 0 1 0 .894 1.789l-.894-1.789zm2 .789a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zM18 5a1 1 0 1 0-2 0h2zm-2 2.5a1 1 0 1 0 2 0h-2zm-5.447-4.606a1 1 0 1 0 .894-1.789l-.894 1.789zM9 1l.447-.894a1 1 0 0 0-.894 0L9 1zm-2.447.106a1 1 0 1 0 .894 1.789l-.894-1.789zm-6 3a1 1 0 1 0 .894 1.789L.553 4.106zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zm-2-.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 2.789a1 1 0 1 0 .894-1.789l-.894 1.789zM2 5a1 1 0 1 0-2 0h2zM0 7.5a1 1 0 1 0 2 0H0zm8.553 12.394a1 1 0 1 0 .894-1.789l-.894 1.789zm-1.106-2.789a1 1 0 1 0-.894 1.789l.894-1.789zm1.106 1a1 1 0 1 0 .894 1.789l-.894-1.789zm2.894.789a1 1 0 1 0-.894-1.789l.894 1.789zM8 19a1 1 0 1 0 2 0H8zm2-2.5a1 1 0 1 0-2 0h2zm-7.447.394a1 1 0 1 0 .894-1.789l-.894 1.789zM1 15H0a1 1 0 0 0 .553.894L1 15zm1-2.5a1 1 0 1 0-2 0h2zm12.553 2.606a1 1 0 1 0 .894 1.789l-.894-1.789zM17 15l.447.894A1 1 0 0 0 18 15h-1zm1-2.5a1 1 0 1 0-2 0h2zm-7.447-5.394l-2 1 .894 1.789 2-1-.894-1.789zm-1.106 1l-2-1-.894 1.789 2 1 .894-1.789zM8 9v2.5h2V9H8zm8.553-4.894l-2 1 .894 1.789 2-1-.894-1.789zm.894 0l-2-1-.894 1.789 2 1 .894-1.789zM16 5v2.5h2V5h-2zm-4.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zm-2.894-1l-2 1 .894 1.789 2-1L8.553.106zM1.447 5.894l2-1-.894-1.789-2 1 .894 1.789zm-.894 0l2 1 .894-1.789-2-1-.894 1.789zM0 5v2.5h2V5H0zm9.447 13.106l-2-1-.894 1.789 2 1 .894-1.789zm0 1.789l2-1-.894-1.789-2 1 .894 1.789zM10 19v-2.5H8V19h2zm-6.553-3.894l-2-1-.894 1.789 2 1 .894-1.789zM2 15v-2.5H0V15h2zm13.447 1.894l2-1-.894-1.789-2 1 .894 1.789zM18 15v-2.5h-2V15h2z"
/>
</svg>
</template>

View File

@ -0,0 +1,7 @@
<template>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor">
<path
d="M10 3.22l-.61-.6a5.5 5.5 0 0 0-7.666.105 5.5 5.5 0 0 0-.114 7.665L10 18.78l8.39-8.4a5.5 5.5 0 0 0-.114-7.665 5.5 5.5 0 0 0-7.666-.105l-.61.61z"
/>
</svg>
</template>

View File

@ -0,0 +1,19 @@
<!-- This icon is from <https://github.com/Templarian/MaterialDesign>, distributed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0) license-->
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
aria-hidden="true"
role="img"
class="iconify iconify--mdi"
width="24"
height="24"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 24 24"
>
<path
d="M20 18v-4h-3v1h-2v-1H9v1H7v-1H4v4h16M6.33 8l-1.74 4H7v-1h2v1h6v-1h2v1h2.41l-1.74-4H6.33M9 5v1h6V5H9m12.84 7.61c.1.22.16.48.16.8V18c0 .53-.21 1-.6 1.41c-.4.4-.85.59-1.4.59H4c-.55 0-1-.19-1.4-.59C2.21 19 2 18.53 2 18v-4.59c0-.32.06-.58.16-.8L4.5 7.22C4.84 6.41 5.45 6 6.33 6H7V5c0-.55.18-1 .57-1.41C7.96 3.2 8.44 3 9 3h6c.56 0 1.04.2 1.43.59c.39.41.57.86.57 1.41v1h.67c.88 0 1.49.41 1.83 1.22l2.34 5.39z"
fill="currentColor"
></path>
</svg>
</template>

14
src/main.js Normal file
View File

@ -0,0 +1,14 @@
import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
const app = createApp(App)
app.use(createPinia())
app.use(router)
app.mount('#app')

113
src/router/index.js Normal file
View File

@ -0,0 +1,113 @@
import {createRouter, createWebHistory} from 'vue-router'
import HomeView from '../views/HomeView.vue'
import {useAuthStore} from '@/stores/auth';
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/',
name: 'home',
component: HomeView,
},
{
path: '',
name: 'member',
component: () => import('../views/Member.vue'),
children: [
{
path: '',
name: 'dashboard',
component: () => import('../components/TheWelcome.vue'),
meta: {requiresAuth: true}
},
{
path: '/upload',
name: 'upload',
component: () => import('../views/games/UploadView.vue'),
meta: {requiresAuth: true}
},
{
path: '/events',
name: 'events',
component: () => import('../views/mqtt/Events.vue'),
meta: {requiresAuth: true}
},
{
path: '/games/:gameId',
name: 'game',
component: () => import('../views/games/GameView.vue'),
meta: {requiresAuth: true,},
},
{
path: '/games',
name: 'games',
component: () => import('../views/games/GamesView.vue'),
meta: {requiresAuth: true,}
},
{
path: '/games',
name: 'games',
component: () => import('../views/games/GamesView.vue'),
meta: {requiresAuth: true,}
},
{
path: '/login',
name: 'login',
component: () => import('../views/auths/Login.vue'),
meta: {requiresAuth: false,}
},
{
path: '/sign-up',
name: 'sign-up',
component: () => import('../views/auths/SignUp.vue'),
meta: {requiresAuth: false,}
},
],
},
{
path: '',
name: 'limited',
component: () => import('../views/Limited.vue'),
children: [
{
path: '/close',
name: 'close',
component: () => import('../views/players/Close.vue')
},
{
path: '/action',
name: 'action',
component: () => import('../views/players/QrAction.vue'),
},
{
path: '/:catchAll(.*)',
name: 'shit',
component: () => import('../views/NotFound.vue'),
},
]
}
]
})
router.beforeEach((to, from, next) => {
if (to.meta.requiresAuth === undefined)
next();
if (useAuthStore().isAuth() === to.meta.requiresAuth) {
// If the condition is met, allow access to the route
next();
} else if (to.meta.requiresAuth) {
console.error('sneaky')
// If the condition is not met, redirect to another route
next('/login'); // Redirect to the login page
} else {
console.error('sneaky')
next('/')
}
})
export default router

28
src/stores/auth.js Normal file
View File

@ -0,0 +1,28 @@
import {defineStore} from "pinia";
import {ref} from "vue";
const key = "AUTH"
export const useAuthStore = defineStore('auth', () => {
/** @type {(undefined | any)} */
const auth = ref(JSON.parse(localStorage.getItem(key)) || undefined)
/** @param {(undefined | string)} auth */
function set(auth) {
this.auth = auth
if (auth)
localStorage.setItem(key, JSON.stringify(auth))
else
localStorage.removeItem(key)
}
function isAuth() {
return !!this.auth?.token
}
function getAuth() {
return this.auth
}
return {auth, getAuth, set, isAuth}
})

21
src/stores/errors.js Normal file
View File

@ -0,0 +1,21 @@
import {defineStore} from "pinia";
import {ref} from "vue";
export const useErrorStore = defineStore('error', () => {
/** @type {(string[])} */
const errors = ref([])
/** @param {(undefined | string)} error */
function unshift(error) {
console.error('Error:', error);
this.errors.unshift(error)
}
function getErrors() {
return this.errors
}
return { errors, getErrors, unshift}
})

14
src/stores/gamelist.js Normal file
View File

@ -0,0 +1,14 @@
import {defineStore} from 'pinia';
import {ref} from 'vue';
export const useGamelistStore = defineStore('gamelist', () => {
/** @type {(undefined | any[])} */
const list = ref(undefined)
/** @param {(undefined | string[])} list */
function set(list) {
this.list = list
}
return {list, set}
})

28
src/stores/player-auth.js Normal file
View File

@ -0,0 +1,28 @@
import {defineStore} from "pinia";
import {ref} from "vue";
const key = "AUTH"
export const usePlayerAuthStore = defineStore('auth', () => {
/** @type {(undefined | string | any)} */
const auth = ref(JSON.parse(localStorage.getItem(key)) || undefined)
/** @param {(undefined | string)} auth */
function set(auth) {
this.auth = auth
if (auth)
localStorage.setItem(key, auth.toString())
else
localStorage.removeItem(key)
}
function isAuth() {
return !!this.auth
}
function getAuth() {
return this.auth
}
return {auth, getAuth, set, isAuth}
})

9
src/views/HomeView.vue Normal file
View File

@ -0,0 +1,9 @@
<script setup>
import TheWelcome from '../components/TheWelcome.vue'
</script>
<template>
<main>
<TheWelcome />
</main>
</template>

107
src/views/Limited.vue Normal file
View File

@ -0,0 +1,107 @@
<script setup>
import {RouterLink, RouterView, useRoute} from 'vue-router'
import {storeToRefs} from 'pinia';
import {useAuthStore} from '@/stores/auth';
import router from '@/router';
import Errors from '@/components/Errors.vue'
import {ref} from 'vue';
const authStr = useAuthStore()
const {auth} = storeToRefs(authStr)
</script>
<template>
<header>
<img alt="Conjure logo" class="logo" src="@/assets/logo_conjure_dark.png" width="2228" height="349"/>
</header>
<RouterView/>
<footer>
<router-link v-if="auth" to="/"
class="bg-transparent text-primary font-semibold hover:text-white py-2 px-4 border border-gray-500 hover:border-transparent rounded w-full">
To dashboard
</router-link>
<Errors/>
</footer>
</template>
<style scoped>
.logo {
user-drag: none;
-webkit-user-drag: none;
}
header {
line-height: 1.5;
max-height: 100dvh;
flex-direction: column;
gap: 1rem;
margin-bottom: 2rem;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
nav {
width: 100%;
font-size: 12px;
text-align: center;
margin-top: 2rem;
}
nav a.router-link-exact-active {
color: var(--color-text);
}
nav a.router-link-exact-active:hover {
background-color: transparent;
}
nav a {
display: inline-block;
padding: 0 1rem;
border-left: 1px solid var(--color-border);
}
nav a:first-of-type {
border: 0;
}
footer {
display: flex;
gap: 1rem;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
nav {
text-align: left;
margin-left: -1rem;
font-size: 1rem;
padding: 1rem 0;
margin-top: 1rem;
}
}
</style>

118
src/views/Member.vue Normal file
View File

@ -0,0 +1,118 @@
<script setup>
import {RouterLink, RouterView, useRoute} from 'vue-router'
import {storeToRefs} from 'pinia';
import {useAuthStore} from '@/stores/auth';
import router from '@/router';
import Errors from '@/components/Errors.vue'
import {ref} from 'vue';
const authStr = useAuthStore()
const {auth} = storeToRefs(authStr)
const logout = () => {
authStr.set(undefined)
router.push('/')
}
</script>
<template>
<header>
<RouterLink to="/">
<img alt="Conjure logo" class="logo" src="@/assets/logo_conjure_dark.png" width="2228" height="349"/>
</RouterLink>
<nav v-if="auth">
<RouterLink to="/games">Games</RouterLink>
<RouterLink to="/upload">Upload</RouterLink>
</nav>
<nav v-else>
<RouterLink to="/login">Login</RouterLink>
<RouterLink to="/sign-up">Sign up</RouterLink>
</nav>
</header>
<RouterView/>
<footer>
<button @click="logout()" v-if="auth">Logout</button>
<Errors/>
</footer>
</template>
<style scoped>
.logo {
user-drag: none;
-webkit-user-drag: none;
}
header {
line-height: 1.5;
max-height: 100dvh;
flex-direction: column;
gap: 1rem;
margin-bottom: 2rem;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
nav {
width: 100%;
font-size: 12px;
text-align: center;
margin-top: 2rem;
}
nav a.router-link-exact-active {
color: var(--color-text);
}
nav a.router-link-exact-active:hover {
background-color: transparent;
}
nav a {
display: inline-block;
padding: 0 1rem;
border-left: 1px solid var(--color-border);
}
nav a:first-of-type {
border: 0;
}
footer {
display: flex;
gap: 1rem;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
nav {
text-align: left;
margin-left: -1rem;
font-size: 1rem;
padding: 1rem 0;
margin-top: 1rem;
}
}
</style>

68
src/views/NotFound.vue Normal file
View File

@ -0,0 +1,68 @@
<script setup>
import {RouterLink, useRoute, useRouter} from 'vue-router';
const route = useRoute();
const router = useRouter();
function getPathSegment() {
const pathSegments = route.path.split('/').filter(segment => segment !== '');
const routes = router.getRoutes().reduce((p, c) => ({...p, [c.path]: true}), {})
const back = '/';
for (let i = 1; i < pathSegments.length; i++) {
const toTest = back + pathSegments.slice(0, -i).join('/');
console.log(toTest, routes[toTest])
if (!routes[toTest]) {
continue
}
return toTest
}
return back
}
</script>
<template>
<article>
<h1>
Shit not found bruh
</h1>
<RouterLink :to="getPathSegment()"
class="bg-transparent font-bold text-foreground underline underline-offset-8 hover:no-underline hover:text-foreground py-2 px-4 border border-transparent hover:border-transparent rounded hover:bg-primary">
go back
</RouterLink>
</article>
</template>
<style scoped lang="scss">
article {
display: flex;
flex-direction: column;
gap: 1rem;
align-items: flex-end;
}
ul {
display: flex;
flex-direction: column;
gap: 1rem;
li {
background-color: rgba(var(--vt-c-payne), 0.6);
display: grid;
grid-template-columns: 1fr 2fr;
gap: 1rem;
img {
max-height: 6rem;
}
}
}
</style>

99
src/views/auths/Login.vue Normal file
View File

@ -0,0 +1,99 @@
<script setup>
import {useErrorStore} from '@/stores/errors'
import {useAuthStore} from '@/stores/auth'
import router from '@/router'
import {ref} from 'vue'
import Loader from '@/components/Loader.vue'
const apiHost = import.meta.env.VITE_CONJUREOS_HOST
const errorStore = useErrorStore()
const isLoginIn = ref(false)
const login = (form) => {
const formData = new FormData(form)
isLoginIn.value = true
fetch(apiHost + 'login', {
method: 'POST',
body: formData
})
.then((response) => {
isLoginIn.value = false
if (response.status !== 200)
return response.text().then(error => {
throw new Error(error)
}
)
return response.text()
})
.then((result) => {
useAuthStore().set(JSON.parse(result))
router.push('/')
})
.catch((error) => {
isLoginIn.value = false
errorStore.unshift(error)
})
}
</script>
<template>
<article>
<h1>Login</h1>
<form ref="loginForm" enctype="multipart/form-data" @submit.prevent="login($refs.loginForm)">
<label for="username">username</label>
<input
required
type="text"
class="border border-primary rounded-lg px-3 py-2 bg-transparent focus:outline-none focus:border-accent"
name="username"
id="username"
/>
<label for="password">password</label>
<input
required
type="password"
class="border border-primary rounded-lg px-3 py-2 bg-transparent focus:outline-none focus:border-accent"
name="password"
id="password"
/>
<button
v-if="!isLoginIn"
class="bg-transparent text-primary font-semibold hover:text-white py-2 px-4 border border-gray-500 hover:border-transparent rounded"
type="submit"
>
Login
</button>
<span class="loader" v-else>
<Loader :variant="2"/>
</span>
</form>
</article>
</template>
<style scoped>
form {
padding: 1rem 0;
display: flex;
flex-direction: column;
gap: 2rem;
position: relative;
}
.loader {
position: absolute;
top: 100%;
left: 50%;
height: 6rem;
transform: translateX(-50%);
}
input {
outline: none !important;
outline-offset: 0 !important;
--tw-ring-color: --vt-c-silver !important;
}
label {
margin-bottom: -1.5rem;
}
</style>

View File

@ -0,0 +1,77 @@
<script setup>
import {useErrorStore} from '@/stores/errors'
import {ref} from "vue";
import {usePlayerAuthStore} from '@/stores/player-auth';
import router from '@/router';
const apiHost = import.meta.env.VITE_CONJUREOS_HOST
const errorStore = useErrorStore()
const isLoginIn = ref(false)
const signup = (form) => {
const formData = new FormData(form);
isLoginIn.value = true
fetch(apiHost + 'signup', {
method: 'POST',
body: formData,
})
.then((response) => {
if (response.status !== 200)
return response.text().then(error => {
throw new Error(error)
}
)
return response.text()
})
.then((result) => {
isLoginIn.value = false
usePlayerAuthStore().set(JSON.parse(result))
router.push('/')
})
.catch((error) => {
isLoginIn.value = false
errorStore.unshift(error)
});
}
</script>
<template>
<article>
<h1>Sign up</h1>
<form ref="signupForm" enctype="multipart/form-data" @submit.prevent="signup($refs.signupForm)">
<label for="username">username</label>
<input required type="text"
class="border border-primary rounded-lg px-3 py-2 bg-transparent focus:outline-none focus:border-accent"
name="username" id="username"/>
<label for="password">password</label>
<input required type="password"
class="border border-primary rounded-lg px-3 py-2 bg-transparent focus:outline-none focus:border-accent"
name="password" id="password"/>
<button
class="bg-transparent text-primary font-semibold hover:text-white py-2 px-4 border border-gray-500 hover:border-transparent rounded"
type="submit">
Signup
</button>
</form>
</article>
</template>
<style scoped>
form {
padding: 1rem 0;
display: flex;
flex-direction: column;
gap: 2rem;
}
input {
outline: none !important;
outline-offset: 0 !important;
--tw-ring-color: --vt-c-silver !important;
}
label {
margin-bottom: -1.5rem;
}
</style>

View File

@ -0,0 +1,140 @@
<script setup>
import {onMounted, ref} from 'vue';
import {useErrorStore} from '@/stores/errors'
import Loader from '@/components/Loader.vue';
import {useRoute} from 'vue-router';
import {useAuthStore} from '@/stores/auth';
import {storeToRefs} from 'pinia';
const errorStore = useErrorStore()
const authStore = useAuthStore()
const {auth} = storeToRefs(authStore)
const apiHost = import.meta.env.VITE_CONJUREOS_HOST
const route = useRoute();
const gameId = ref(route.params.gameId);
const game = ref(undefined)
const isActivating = ref(false)
console.log(route, route.meta)
onMounted(() => {
fetch(apiHost + 'games/' + gameId.value, {
method: 'GET',
})
.then((response) => response.json())
.then((result) => {
game.value = result
})
.catch((error) => {
console.error('Error:', error);
errorStore.unshift(error)
});
})
/**
*
*/
function activate() {
fetch(apiHost + 'games/' + gameId.value + '/activate', {
method: 'POST', headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${auth.value.token}`,
},
})
.then((response) => {
if (response.status !== 204)
return response.json().then((errorBody) => {
throw new Error(errorBody);
});
return true
})
.then((result) => {
game.value = {...game.value, active: true}
isActivating.value = false
})
.catch((error) => {
errorStore.unshift(error)
isActivating.value = false
});
}
/**
*
*/
function deactivate() {
isActivating.value = true
fetch(apiHost + 'games/' + gameId.value + '/deactivate', {
method: 'POST', headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${auth.value.token}`,
},
})
.then((response) => {
if (response.status !== 204)
return response.json().then((errorBody) => {
throw new Error(errorBody);
});
return true
})
.then((result) => {
game.value = {...game.value, active: false}
isActivating.value = false
})
.catch((error) => {
errorStore.unshift(error)
isActivating.value = false
});
}
</script>
<template>
<article>
<loader v-if="game === undefined"></loader>
<template v-else>
<img v-if="game.image" :src="'data:image/png;base64,'+game.image" alt="thumbnail"/>
<h1>{{ game.game }}</h1>
<p>{{ game.description }}</p>
<loader :variant="2" v-if="isActivating"></loader>
<template v-else>
<button v-if="game.active" @click="deactivate()"
class="bg-transparent font-bold text-primary underline underline-offset-8 hover:no-underline hover:text-primary py-2 px-4 border border-transparent hover:border-transparent rounded hover:bg-primary">
deactivate
</button>
<button v-else @click="activate()"
class="bg-transparent font-bold text-primary underline underline-offset-8 hover:no-underline hover:text-primary py-2 px-4 border border-transparent hover:border-transparent rounded hover:bg-primary">
activate
</button>
</template>
</template>
</article>
</template>
<style scoped lang="scss">
article {
display: flex;
flex-direction: column;
gap: 1rem;
align-items: flex-end;
}
ul {
display: flex;
flex-direction: column;
gap: 1rem;
li {
background-color: rgba(var(--vt-c-payne), 0.6);
display: grid;
grid-template-columns: 1fr 2fr;
gap: 1rem;
img {
max-height: 6rem;
}
}
}
</style>

View File

@ -0,0 +1,121 @@
<script setup>
import {onMounted} from 'vue';
import {useGamelistStore} from '@/stores/gamelist';
import {storeToRefs} from 'pinia';
import {useErrorStore} from '@/stores/errors'
import Loader from '@/components/Loader.vue';
import {RouterLink} from 'vue-router';
const errorStore = useErrorStore()
const apiHost = import.meta.env.VITE_CONJUREOS_HOST
const gamelistStore = useGamelistStore()
const {list: gamelist} = storeToRefs(gamelistStore)
onMounted(() => {
fetch(apiHost + 'games', {
method: 'GET',
})
.then((response) => response.json())
.then((result) => {
gamelistStore.set(result)
})
.catch((error) => {
console.error('Error:', error);
errorStore.unshift(error)
});
})
/**
* @param {string} name
*/
function download(name) {
const a = document.createElement('a');
a.href = apiHost + 'games/' + name + '/download';
document.body.appendChild(a);
// Programmatically click the anchor element to start the download
a.click();
// Clean up by removing the anchor element
document.body.removeChild(a);
}
function downloadAll() {
const a = document.createElement('a');
a.href = apiHost + 'games/download';
document.body.appendChild(a);
// Programmatically click the anchor element to start the download
a.click();
// Clean up by removing the anchor element
document.body.removeChild(a);
}
</script>
<template>
<article>
<loader v-if="gamelist === undefined"></loader>
<template v-else>
<header>
<button
class="bg-transparent font-bold text-foreground underline underline-offset-8 hover:no-underline py-2 px-4 border border-primary rounded hover:bg-primary"
@click="downloadAll()"
>
Download all
</button>
</header>
<ul>
<li class="game rounded-lg p-4" v-for="(item) in gamelist" :key="item.id">
<img v-if="item.thumbnail" :src="'data:image/png;base64,'+item.thumbnail" alt="thumbnail"/>
<span v-else></span>
<div class="flex flex-col">
<p>{{ item.description }}</p>
<i class="ml-auto" v-if="item.active">active</i>
</div>
<h2>{{ item.game }}</h2>
<div>
<RouterLink :to="'/games/' + item.id"
class="bg-transparent font-bold text-foreground underline underline-offset-8 hover:no-underline hover:text-foreground py-2 px-4 border border-transparent hover:border-transparent rounded hover:bg-primary">
open
</RouterLink>
<button
class="bg-transparent font-bold text-foreground underline underline-offset-8 hover:no-underline hover:text-foreground py-2 px-4 border border-transparent hover:border-transparent rounded hover:bg-primary"
type="button" @click="download(item.id + '.conj')">Download
</button>
</div>
</li>
</ul>
</template>
</article>
</template>
<style scoped lang="scss">
article {
display: flex;
flex-direction: column;
gap: 1rem;
align-items: flex-end;
}
ul {
display: flex;
flex-direction: column;
gap: 1rem;
li {
background-color: rgba(var(--vt-c-payne), 0.6);
display: grid;
grid-template-columns: 1fr 2fr;
gap: 1rem;
img {
max-height: 6rem;
}
}
}
</style>

View File

@ -0,0 +1,132 @@
<script>
import { useAuthStore } from '@/stores/auth'
import { useErrorStore } from '@/stores/errors'
const errorStore = useErrorStore()
const apiHost = import.meta.env.VITE_CONJUREOS_HOST
const authStr = useAuthStore()
export default {
data() {
return {
selectedFiles: [],
textInput: ''
}
},
methods: {
submitForm() {
const form = this.$refs.uploadForm
const formData = new FormData(form)
fetch(apiHost + 'games', {
method: 'POST',
body: formData,
headers: {
Authorization: authStr.getAuth()
}
})
.then((response) => response.text())
.then((result) => {
console.log(result)
})
.catch((error) => {
console.error('Error:', error)
errorStore.unshift(error)
})
},
filesChanges() {
this.selectedFiles = Array.from(this.$refs.inputFile.files || [])
}
}
}
</script>
<template>
<article>
<h1 class="text-foreground">Upload</h1>
<form ref="uploadForm" enctype="multipart/form-data" @submit.prevent="submitForm">
<!-- <div class="name-input-wrapper">-->
<!-- <label for="name" class="block text-sm font-medium text-gray-700">Name:</label>-->
<!-- <input type="text" name="name" id="name" required v-model="textInput"-->
<!-- class="mt-1 p-2 border border-gray-300 rounded-md text-background focus:ring-primary-500 focus:border-primary-500 w-full">-->
<!-- </div>-->
<div class="file-upload-wrapper">
<input
ref="inputFile"
type="file"
name="file"
id="file"
accept=".conj"
@change="filesChanges"
/>
<label>
<strong class="instruction">Upload your file here</strong>
<em class="rules">Only <code>.conj</code> accepted.</em>
<em class="file-name" v-if="!!selectedFiles?.length">{{ selectedFiles[0].name }}</em>
</label>
</div>
<button
class="bg-transparent text-gray-700 font-semibold hover:text-white py-2 px-4 border border-gray-500 hover:border-transparent rounded"
type="submit"
>
Upload
</button>
</form>
</article>
</template>
<style scoped lang="scss">
form {
padding: 1rem 0;
display: flex;
flex-direction: column;
gap: 2rem;
}
.file-upload-wrapper {
position: relative;
display: flex;
flex-direction: column;
gap: 0.5rem;
input {
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
opacity: 0;
}
label {
display: flex;
flex-direction: column;
justify-content: space-between;
border-radius: 0.5rem;
padding: 1rem;
color: var(--vt-c-black);
background-color: var(--vt-c-white);
.file-name {
align-self: end;
color: var(--vt-c-black-soft);
}
&.invalid {
background-color: var(--vt-c-bittersweet);
}
}
button[type='submit'] {
&:hover {
background-color: var(--vt-c-munsell);
}
}
&:hover {
label {
background-color: var(--vt-c-white-mute);
}
}
}
</style>

45
src/views/mqtt/Events.vue Normal file
View File

@ -0,0 +1,45 @@
<script setup>
import {ref, onMounted, onUnmounted} from 'vue';
import mqtt from 'mqtt';
const wsHost = import.meta.env.VITE_CONJUREOS_MQTT
const topic = '#';
const receivedMessages = ref([]);
let client;
onMounted(() => {
// Connect to MQTT broker
client = mqtt.connect(wsHost, {clientId: 'frontend', protocol: 'ws'});
// Subscribe to a topic
client.subscribe(topic);
// Handle incoming messages
client.on('message', (topic, message) => {
receivedMessages.value.push({topic, message: JSON.parse(message.toString())});
});
// Additional setup or event listeners if needed
});
// Cleanup on component unmount
onUnmounted(() => {
// Unsubscribe and disconnect when the component is unmounted
if (client) {
client.unsubscribe(topic);
client.end();
}
});
</script>
<template>
<div>
<h1>Received Message:</h1>
<p v-for="receivedMessage in receivedMessages"> {{ receivedMessage.topic }} : {{receivedMessage.message["username"]}}</p>
<!-- Your template content goes here -->
</div>
</template>
<style scoped>
/* Your scoped styles go here */
</style>

View File

@ -0,0 +1,11 @@
<script setup>
</script>
<template>
<h1>Please close this page.</h1>
</template>
<style scoped>
</style>

View File

@ -0,0 +1,113 @@
<script setup>
import {ref} from 'vue'
import {useRoute} from 'vue-router';
import Loader from '@/components/Loader.vue';
import router from '@/router'
import {useErrorStore} from '@/stores/errors'
const errorStore = useErrorStore()
const apiHost = import.meta.env.VITE_CONJUREOS_HOST
const isLoginIn = ref(false)
const route = useRoute();
if (!route.query.token || !route.query.action) {
router.push("/close")
}
const submit = (form) => {
const formData = new FormData(form)
formData.set('token', route.query.token.toString())
isLoginIn.value = true
fetch(apiHost + route.query.action, {
method: 'POST',
body: formData
})
.then((response) => {
isLoginIn.value = false
if (response.status !== 200)
return response.text().then(error => {
throw new Error(error)
}
)
return response.text()
})
.then((result) => {
router.push('/close')
})
.catch((error) => {
isLoginIn.value = false
errorStore.unshift(error)
})
}
</script>
<template>
<form ref="loginForm" enctype="multipart/form-data" @submit.prevent="submit($refs.loginForm)">
<label for="username">username</label>
<input
required
type="text"
class="border border-primary rounded-lg px-3 py-2 bg-transparent focus:outline-none focus:border-accent"
name="username"
id="username"
/>
<label for="password">password</label>
<input
required
type="password"
class="border border-primary rounded-lg px-3 py-2 bg-transparent focus:outline-none focus:border-accent"
name="password"
id="password"
/>
<button
v-if="!isLoginIn"
class="bg-transparent text-primary font-semibold hover:text-white py-2 px-4 border border-gray-500 hover:border-transparent rounded"
type="submit"
>
Login
</button>
<span class="loader" v-else>
<Loader :variant="2"/>
</span>
</form>
</template>
<style scoped>
header {
line-height: 1.5;
}
form {
display: flex;
flex-direction: column;
gap: 1rem;
}
.logo {
user-drag: none;
-webkit-user-drag: none;
display: block;
margin: 0 auto 2rem;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
}
</style>

31
tailwind.config.js Normal file
View File

@ -0,0 +1,31 @@
const colors = require('tailwindcss/colors')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {},
colors: {
...colors,
foreground: '#FDFDFF',
primary: '#8797A3',
accent: '#c6c5b9',
warn: '#C14953',
background: '#393D3F'
}
},
variants: {
extend: {
},
},
plugins: [
require("@tailwindcss/typography"),
require("@tailwindcss/container-queries"),
require("@tailwindcss/forms"),
require("@tailwindcss/aspect-ratio"),
],
}

25
vite.config.js Normal file
View File

@ -0,0 +1,25 @@
import {fileURLToPath, URL} from 'node:url'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
process.env.VUE_APP_VERSION = require('./package.json').version
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
build: {
terserOptions: {
compress: {
drop_console: false,
},
},
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
}
})

14
vitest.config.js Normal file
View File

@ -0,0 +1,14 @@
import { fileURLToPath } from 'node:url'
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
import viteConfig from './vite.config'
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/*'],
root: fileURLToPath(new URL('./', import.meta.url))
}
})
)