initial commit
This commit is contained in:
parent
fd882e5ebb
commit
14f9af54ef
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,12 +1,13 @@
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
*.map.*
|
||||
*.map
|
||||
*.*.map
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
.idea/
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
@ -107,8 +108,10 @@ ipython_config.py
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/#use-with-ide
|
||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||
.pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
@ -159,4 +162,3 @@ cython_debug/
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
|
18
Dockerfile
Normal file
18
Dockerfile
Normal file
@ -0,0 +1,18 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM node:alpine as build
|
||||
WORKDIR /web
|
||||
COPY ./web /web
|
||||
RUN npm install
|
||||
RUN npm run build
|
||||
|
||||
FROM python:3.10-alpine
|
||||
COPY ./ /code
|
||||
COPY --from=0 /web /code/web
|
||||
ENV FLASK_APP=app.py
|
||||
WORKDIR /code
|
||||
ENV FLASK_RUN_HOST=0.0.0.0
|
||||
RUN apk add --no-cache gcc musl-dev linux-headers
|
||||
EXPOSE 5000
|
||||
# COPY . .
|
||||
RUN pip install -r /code/requirements.txt
|
||||
CMD ["flask", "run", "--debug"]
|
25
README.md
25
README.md
@ -1,2 +1,25 @@
|
||||
# GeoTracking
|
||||
# zahlenraten-miniprojekt
|
||||
|
||||
## milestone 1 barebones implementierung
|
||||
Die barebones Implementierung nach Teamsvorgabe.
|
||||
Wir erwarten damit deutlich früher fertig zu werden ,um an anderen Milestones zu arbeiten.
|
||||
|
||||
Feature dieses Milestones:
|
||||
- WebUI (Barrierefrei)
|
||||
- Modernes Design
|
||||
- Farbeinstellungen bei Farbenblindheit
|
||||
- Screenreader
|
||||
- Webanwendung mit dem Spiel
|
||||
- Möglichkeit Highscores in einer Datenbank zu erfassen
|
||||
|
||||
- Datenbank
|
||||
- Möglichkeit aus der Webanwendung daten in der Datenbank zu sichern
|
||||
|
||||
Spielablauf:
|
||||
- benutzer gibt zahl ein
|
||||
- server berechnet ob richtig, zu hoch, zu niedrig
|
||||
- server speichert anzahl versuche
|
||||
|
||||
Spielende:
|
||||
- spiel endet beim erraten der richtigen zahl
|
||||
- server speichert name, anzahl versuche ab
|
||||
|
20
app.py
Normal file
20
app.py
Normal file
@ -0,0 +1,20 @@
|
||||
from dotenv import load_dotenv
|
||||
from flask import Flask, send_from_directory, jsonify, session, request
|
||||
|
||||
print("load environment")
|
||||
load_dotenv()
|
||||
|
||||
print("create flask application")
|
||||
app = Flask(__name__, static_folder='web/dist')
|
||||
|
||||
@app.route('/')
|
||||
def serve_vue_app():
|
||||
return send_from_directory(app.static_folder, 'index.html')
|
||||
|
||||
@app.route('/upload', methods=['POST'])
|
||||
def upload_file():
|
||||
file = request.files['file']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
15
class/db/database.py
Normal file
15
class/db/database.py
Normal file
@ -0,0 +1,15 @@
|
||||
from sqlalchemy import create_engine, Column, Integer, String
|
||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||
|
||||
# Datenbankverbindung und Basis erstellen
|
||||
engine = create_engine('sqlite:///beispiel.db')
|
||||
Base = declarative_base()
|
||||
|
||||
class database():
|
||||
__db: engine
|
||||
|
||||
def __init__(self):
|
||||
self.__db = create_engine('sqlite:///users.db')
|
||||
|
||||
def get(self):
|
||||
return self.__db
|
21
class/db/user.py
Normal file
21
class/db/user.py
Normal file
@ -0,0 +1,21 @@
|
||||
from sqlalchemy import create_engine, Column, Integer, String, engine
|
||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||
import database
|
||||
|
||||
class User():
|
||||
__db: engine
|
||||
__base: declarative_base
|
||||
def __init__(self, database:database):
|
||||
self.__db = database.get()
|
||||
self.__base = declarative_base()
|
||||
return
|
||||
def createUser(self, username, email, password):
|
||||
return ""
|
||||
def removeUser(self, username):
|
||||
return ""
|
||||
def getUserData(self, username):
|
||||
return ""
|
||||
def login(self, username, password):
|
||||
return ""
|
||||
def logout(self):
|
||||
return ""
|
8
class/gpxInterpreter.py
Normal file
8
class/gpxInterpreter.py
Normal file
@ -0,0 +1,8 @@
|
||||
class gpxInterpreter:
|
||||
def __init__(self):
|
||||
|
||||
def processFile(self, file):
|
||||
return True
|
||||
|
||||
def importDataInDB(self, data):
|
||||
return True
|
27
compose.yaml
Normal file
27
compose.yaml
Normal file
@ -0,0 +1,27 @@
|
||||
services:
|
||||
db:
|
||||
image: postgres
|
||||
environment:
|
||||
- POSTGRES_USER=zahlenraten
|
||||
- POSTGRES_PASSWORD=CYrcTzCEKyDtq&N0M
|
||||
- POSTGRES_DB=game
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
networks:
|
||||
- backend
|
||||
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "8000:5000"
|
||||
networks:
|
||||
- backend
|
||||
|
||||
networks:
|
||||
backend:
|
||||
|
||||
volumes:
|
||||
pgdata:
|
5
init.sql
Normal file
5
init.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS scoreboard (
|
||||
score INTEGER NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
flask
|
24
web/.gitignore
vendored
Normal file
24
web/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
3
web/.vscode/extensions.json
vendored
Normal file
3
web/.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["Vue.volar"]
|
||||
}
|
5
web/README.md
Normal file
5
web/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Vue 3 + TypeScript + Vite
|
||||
|
||||
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||
|
||||
Learn more about the recommended Project Setup and IDE Support in the [Vue Docs TypeScript Guide](https://vuejs.org/guide/typescript/overview.html#project-setup).
|
13
web/index.html
Normal file
13
web/index.html
Normal file
@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + Vue + TS</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
2837
web/package-lock.json
generated
Normal file
2837
web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
web/package.json
Normal file
24
web/package.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "my-vue-app",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vue-tsc -b && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"my-vue-app": "file:",
|
||||
"vue": "^3.4.37",
|
||||
"vue-daisyui-theme-manager": "^0.0.29"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vitejs/plugin-vue": "^5.1.2",
|
||||
"daisyui": "^4.12.10",
|
||||
"tailwindcss": "^3.4.11",
|
||||
"typescript": "^5.5.3",
|
||||
"vite": "^5.4.1",
|
||||
"vue-tsc": "^2.0.29"
|
||||
}
|
||||
}
|
6
web/postcss.config.cjs
Normal file
6
web/postcss.config.cjs
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
}
|
1
web/public/vite.svg
Normal file
1
web/public/vite.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
After Width: | Height: | Size: 1.5 KiB |
60
web/src/App.vue
Normal file
60
web/src/App.vue
Normal file
@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import {defineComponent, Ref, ref, SetupContext} from 'vue';
|
||||
import DebugLog from "./classes/debugger";
|
||||
import Settings from "./components/Settings.vue";
|
||||
|
||||
export default defineComponent({
|
||||
components: {Settings, GameInput, AttemptList},
|
||||
setup() {
|
||||
var showSettings:Ref<boolean> = ref(false);
|
||||
|
||||
// check if data storage was allowed and if check for localstorage settings
|
||||
if (localStorage.getItem("allow-data-storage") !== null) {
|
||||
|
||||
if (localStorage.getItem("theme") !== null) {
|
||||
document.documentElement.setAttribute('data-theme', localStorage.getItem("theme") ?? "dark");
|
||||
}
|
||||
|
||||
} else {
|
||||
// if data collection isn't allowed set the default values
|
||||
document.documentElement.setAttribute('data-theme', "dark");
|
||||
}
|
||||
|
||||
var debugInputs = [
|
||||
{logText: "httpAttr: theme", logValue: document.documentElement.getAttribute('data-theme')},
|
||||
{logText: "storage: allow-data-storage", logValue:localStorage.getItem("allow-data-storage")},
|
||||
{logText: "storage theme", logValue: localStorage.getItem("theme")},
|
||||
]
|
||||
DebugLog(debugInputs);
|
||||
|
||||
const toggleSettings = () => {
|
||||
showSettings.value = !showSettings.value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const attemptList = ref<InstanceType<typeof AttemptList> | null>(null);
|
||||
|
||||
return { showSettings, toggleSettings, attemptList };
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="container">
|
||||
<button class="btn btn-primary round" style="float: right" @click="toggleSettings">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed">
|
||||
<path d="m370-80-16-128q-13-5-24.5-12T307-235l-119 50L78-375l103-78q-1-7-1-13.5v-27q0-6.5 1-13.5L78-585l110-190 119 50q11-8 23-15t24-12l16-128h220l16 128q13 5 24.5 12t22.5 15l119-50 110 190-103 78q1 7 1 13.5v27q0 6.5-2 13.5l103 78-110 190-118-50q-11 8-23 15t-24 12L590-80H370Zm70-80h79l14-106q31-8 57.5-23.5T639-327l99 41 39-68-86-65q5-14 7-29.5t2-31.5q0-16-2-31.5t-7-29.5l86-65-39-68-99 42q-22-23-48.5-38.5T533-694l-13-106h-79l-14 106q-31 8-57.5 23.5T321-633l-99-41-39 68 86 64q-5 15-7 30t-2 32q0 16 2 31t7 30l-86 65 39 68 99-42q22 23 48.5 38.5T427-266l13 106Zm42-180q58 0 99-41t41-99q0-58-41-99t-99-41q-59 0-99.5 41T342-480q0 58 40.5 99t99.5 41Zm-2-140Z"/>
|
||||
</svg>
|
||||
</button>
|
||||
<Settings v-if="showSettings" @close="toggleSettings"/>
|
||||
</div>
|
||||
<GameInput @attemptUpdate="attemptList?.addAttempt"></GameInput>
|
||||
<AttemptList ref="attemptList"/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
margin: 10%;
|
||||
}
|
||||
</style>
|
2
web/src/App.vue.d.ts
vendored
Normal file
2
web/src/App.vue.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
||||
export default _default;
|
12
web/src/assets/lang.json
Normal file
12
web/src/assets/lang.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"en_mode_colorblind": "Mode for colorblind",
|
||||
"ger_mode_colorblind": "Modus für Farbenblinde",
|
||||
"en_theme":"Theme",
|
||||
"ger_theme": "Darstellung",
|
||||
"en_settings": "Settings",
|
||||
"ger_settings": "Einstellungen",
|
||||
"en_audio_feedback": "Audio Feedack",
|
||||
"ger_audio_feedback": "Ton Wiedergabe",
|
||||
"en_language": "Language",
|
||||
"ger_language": "Sprache"
|
||||
}
|
8
web/src/assets/language.json
Normal file
8
web/src/assets/language.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"en_theme":"Theme",
|
||||
"ger_theme":"Darstellung",
|
||||
"en_mode_color_blindness":"Mode for Color blindness",
|
||||
"ger_mode_color_blindness":"Modus für Farbenblinde",
|
||||
"en_lang":"Language",
|
||||
"ger_lang":"Sprache"
|
||||
}
|
1
web/src/assets/vue.svg
Normal file
1
web/src/assets/vue.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
|
After Width: | Height: | Size: 496 B |
16
web/src/classes/debugger.js
Normal file
16
web/src/classes/debugger.js
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Used to log values given as parameter
|
||||
* Function triggers when debug is set to true in local storage
|
||||
* @param debugLogs An array of type debugInput logged
|
||||
*/
|
||||
function DebugLog(debugLogs) {
|
||||
if (localStorage.getItem("debug") === "true") {
|
||||
console.log("========================== [ fetched settings values from document ] ==========================");
|
||||
debugLogs.forEach((log) => {
|
||||
console.log(log.logText, log.logValue);
|
||||
});
|
||||
console.log("===============================================================================================");
|
||||
}
|
||||
}
|
||||
export default DebugLog;
|
||||
//# sourceMappingURL=debugger.js.map
|
21
web/src/classes/debugger.ts
Normal file
21
web/src/classes/debugger.ts
Normal file
@ -0,0 +1,21 @@
|
||||
type DebugInput = {
|
||||
logText: string;
|
||||
logValue: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to log values given as parameter
|
||||
* Function triggers when debug is set to true in local storage
|
||||
* @param debugLogs An array of type debugInput logged
|
||||
*/
|
||||
function DebugLog(debugLogs: DebugInput[]): void {
|
||||
if (localStorage.getItem("debug") === "true") {
|
||||
console.log("========================== [ fetched settings values from document ] ==========================");
|
||||
debugLogs.forEach((log) => {
|
||||
console.log(log.logText, log.logValue);
|
||||
});
|
||||
console.log("===============================================================================================");
|
||||
}
|
||||
}
|
||||
|
||||
export default DebugLog;
|
31
web/src/classes/language.js
Normal file
31
web/src/classes/language.js
Normal file
@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Handles getting the correct localized string for the requested key
|
||||
* @param textKey The key for which text should be fetched
|
||||
* @returns The localized text as a string
|
||||
*/
|
||||
async function GetLocalizedText(textKey) {
|
||||
try {
|
||||
// Dynamically import the JSON data and cast it to LocalizationData
|
||||
const jsonData = (await import("../assets/language.json")).default;
|
||||
// Return a new Promise
|
||||
return new Promise((resolve, reject) => {
|
||||
// Get the language from the 'data-language' attribute, default to "en"
|
||||
const lang = document.documentElement.getAttribute("data-language") ?? "en";
|
||||
// Construct the key based on the language and textKey
|
||||
const localizedText = jsonData[`${lang}_${textKey}`];
|
||||
// Check if the localized text exists
|
||||
if (localizedText) {
|
||||
resolve(localizedText); // Resolve with the localized text
|
||||
}
|
||||
else {
|
||||
reject(`No localized text found for key: ${lang}_${textKey}`); // Reject if not found
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
// Handle any errors from importing the JSON file
|
||||
return Promise.reject(`Failed to load localization with error: ${error}`);
|
||||
}
|
||||
}
|
||||
export default GetLocalizedText;
|
||||
//# sourceMappingURL=language.js.map
|
37
web/src/classes/language.ts
Normal file
37
web/src/classes/language.ts
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Handles getting the correct localized string for the requested key
|
||||
* @param textKey The key for which text should be fetched
|
||||
* @returns The localized text as a string
|
||||
*/
|
||||
async function GetLocalizedText(textKey: string): Promise<string> {
|
||||
try {
|
||||
// Define the type of the JSON data
|
||||
interface LocalizationData {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
// Dynamically import the JSON data and cast it to LocalizationData
|
||||
const jsonData = (await import("../assets/language.json")).default as LocalizationData;
|
||||
|
||||
// Return a new Promise
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
// Get the language from the 'data-language' attribute, default to "en"
|
||||
const lang: string = document.documentElement.getAttribute("data-language") ?? "en";
|
||||
|
||||
// Construct the key based on the language and textKey
|
||||
const localizedText = jsonData[`${lang}_${textKey}`];
|
||||
|
||||
// Check if the localized text exists
|
||||
if (localizedText) {
|
||||
resolve(localizedText); // Resolve with the localized text
|
||||
} else {
|
||||
reject(`No localized text found for key: ${lang}_${textKey}`); // Reject if not found
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
// Handle any errors from importing the JSON file
|
||||
return Promise.reject(`Failed to load localization with error: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
export default GetLocalizedText;
|
34
web/src/classes/settings.ts
Normal file
34
web/src/classes/settings.ts
Normal file
@ -0,0 +1,34 @@
|
||||
enum SettingNodes {
|
||||
allowDateCollect,
|
||||
theme,
|
||||
language,
|
||||
}
|
||||
|
||||
/**
|
||||
* class which handles reading and writing settings
|
||||
*/
|
||||
class SettingsHandler {
|
||||
|
||||
settings:Map<string,string>
|
||||
constructor() {
|
||||
this.settings = new Map<SettingNodes, any>();
|
||||
// TODO: load settings from localstorage if any present
|
||||
}
|
||||
|
||||
/**
|
||||
* writes settings to the localstorage and handles errors
|
||||
* @param name the settings name
|
||||
* @param value
|
||||
*/
|
||||
writeSetting(name:SettingNodes, value:any):boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches settings from the localstorage and handles errors
|
||||
* @param name the requested setting
|
||||
*/
|
||||
fetchSettings(name:SettingNodes):any {
|
||||
return ""
|
||||
}
|
||||
}
|
100
web/src/components/Settings.vue
Normal file
100
web/src/components/Settings.vue
Normal file
@ -0,0 +1,100 @@
|
||||
<script lang="ts">
|
||||
import {defineComponent, SetupContext, ref, Ref} from 'vue';
|
||||
import GetLocalizedText from "../classes/language";
|
||||
|
||||
export default defineComponent({
|
||||
emits: ['close'],
|
||||
name: 'settings',
|
||||
setup(_, { emit }: SetupContext) {
|
||||
var attributeTheme:Ref<string> = ref(document.documentElement.getAttribute("data-theme") ?? "dark")
|
||||
var attributeLang:Ref<string> = ref(document.documentElement.getAttribute("data-language") ?? "english")
|
||||
|
||||
// localized text
|
||||
var settingsThemeLocalized:Ref<string> = ref("");
|
||||
var settingsLangLocalized:Ref<string> = ref("");
|
||||
async function getLocalization() {
|
||||
settingsThemeLocalized.value = await GetLocalizedText("theme")
|
||||
settingsLangLocalized.value = await GetLocalizedText("lang")
|
||||
}
|
||||
|
||||
const changeTheme = (theme:string) => {
|
||||
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
if (localStorage.getItem("allow-data-storage") == "true") {
|
||||
localStorage.setItem("theme", theme)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const changeLang = (lang:string) => {
|
||||
document.documentElement.setAttribute('data-language', lang);
|
||||
if (localStorage.getItem("allow-data-storage") == "true") {
|
||||
localStorage.setItem("lang", lang)
|
||||
}
|
||||
}
|
||||
|
||||
getLocalization()
|
||||
const close = () => {
|
||||
emit("close");
|
||||
};
|
||||
|
||||
return {
|
||||
close,
|
||||
changeTheme,
|
||||
changeLang,
|
||||
settingsThemeLocalized,
|
||||
settingsLangLocalized,
|
||||
attributeTheme,
|
||||
attributeLang
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<div class="card bg-base-100 w-full shadow-xl">
|
||||
<div class="card-body">
|
||||
|
||||
<h2 class="card-title">Settings</h2>
|
||||
|
||||
<button class="btn btn-error close round" @click="close()">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e8eaed">
|
||||
<path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="w-full">
|
||||
{{ settingsLangLocalized }}:
|
||||
<div class="dropdown dropdown-bottom">
|
||||
<div tabindex="0" role="button" class="btn m-1"> {{ attributeLang }}</div>
|
||||
<ul tabindex="0" class="dropdown-content menu bg-base-100 rounded-box z-[1] w-fill p-2 shadow">
|
||||
<li @click="changeLang('ger')"><a>Deutsch</a></li>
|
||||
<li @click="changeLang('en')"><a>English</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-full">
|
||||
{{ settingsThemeLocalized }}:
|
||||
<div class="dropdown dropdown-bottom">
|
||||
<div tabindex="0" role="button" class="btn m-1"> {{ attributeTheme }}</div>
|
||||
<ul tabindex="0" class="dropdown-content menu bg-base-100 rounded-box z-[1] w-fill p-2 shadow">
|
||||
<li @click="changeTheme('dark')"><a>Dark</a></li>
|
||||
<li @click="changeTheme('light')"><a>Light</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.btn.close {
|
||||
position: absolute;
|
||||
right: 30px;
|
||||
top: 30px;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
1
web/src/main.d.ts
vendored
Normal file
1
web/src/main.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
import './style.css';
|
7
web/src/main.js
Normal file
7
web/src/main.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { createApp } from 'vue';
|
||||
import './style.css';
|
||||
import App from './App.vue';
|
||||
const app = createApp(App);
|
||||
// Mount the app
|
||||
app.mount('#app');
|
||||
//# sourceMappingURL=main.js.map
|
11
web/src/main.ts
Normal file
11
web/src/main.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { createApp } from 'vue';
|
||||
import './style.css';
|
||||
import App from './App.vue';
|
||||
|
||||
// @ts-ignore
|
||||
import { createThemeManager } from 'vue-daisyui-theme-manager';
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
// Mount the app
|
||||
app.mount('#app');
|
10
web/src/style.css
Normal file
10
web/src/style.css
Normal file
@ -0,0 +1,10 @@
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
.btn.round{
|
||||
height: 55px;
|
||||
width: auto;
|
||||
font-size: 12pt;
|
||||
border-radius: 100%;
|
||||
}
|
1
web/src/vite-env.d.ts
vendored
Normal file
1
web/src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
24
web/tailwind.config.js
Normal file
24
web/tailwind.config.js
Normal file
@ -0,0 +1,24 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: [
|
||||
"./index.html",
|
||||
"./src/**/*.{vue,js,ts,jsx,tsx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [
|
||||
require('daisyui'),
|
||||
],
|
||||
// daisyUI config (optional - here are the default values)
|
||||
daisyui: {
|
||||
themes: false, // false: only light + dark | true: all themes | array: specific themes like this ["light", "dark", "cupcake"]
|
||||
darkTheme: "dark", // name of one of the included themes for dark mode
|
||||
base: true, // applies background color and foreground color for root element by default
|
||||
styled: true, // include daisyUI colors and design decisions for all components
|
||||
utils: true, // adds responsive and modifier utility classes
|
||||
prefix: "", // prefix for daisyUI classnames (components, modifiers and responsive class names. Not colors)
|
||||
logs: true, // Shows info about daisyUI version and used config in the console when building your CSS
|
||||
themeRoot: ":root", // The element that receives theme color CSS variables
|
||||
},
|
||||
}
|
38
web/theme-manager.config.js
Normal file
38
web/theme-manager.config.js
Normal file
@ -0,0 +1,38 @@
|
||||
// add the names of the themes you want to use here
|
||||
// warning: you need to specify them in tailwind.config.js as well
|
||||
// DO NOT REMOVE: 'default', 'light', 'dark'
|
||||
export default [
|
||||
'default',
|
||||
'light',
|
||||
'dark',
|
||||
'storm',
|
||||
'breeze',
|
||||
'cupcake',
|
||||
'bumblebee',
|
||||
'emerald',
|
||||
'corporate',
|
||||
'synthwave',
|
||||
'retro',
|
||||
'cyberpunk',
|
||||
'valentine',
|
||||
'halloween',
|
||||
'garden',
|
||||
'forest',
|
||||
'aqua',
|
||||
'lofi',
|
||||
'pastel',
|
||||
'fantasy',
|
||||
'wireframe',
|
||||
'black',
|
||||
'luxury',
|
||||
'dracula',
|
||||
'cmyk',
|
||||
'autumn',
|
||||
'business',
|
||||
'acid',
|
||||
'lemonade',
|
||||
'night',
|
||||
'coffee',
|
||||
'winter',
|
||||
];
|
||||
//# sourceMappingURL=theme-manager.config.js.map
|
37
web/theme-manager.config.ts
Normal file
37
web/theme-manager.config.ts
Normal file
@ -0,0 +1,37 @@
|
||||
// add the names of the themes you want to use here
|
||||
// warning: you need to specify them in tailwind.config.js as well
|
||||
// DO NOT REMOVE: 'default', 'light', 'dark'
|
||||
export default[
|
||||
'default',
|
||||
'light',
|
||||
'dark',
|
||||
'storm',
|
||||
'breeze',
|
||||
'cupcake',
|
||||
'bumblebee',
|
||||
'emerald',
|
||||
'corporate',
|
||||
'synthwave',
|
||||
'retro',
|
||||
'cyberpunk',
|
||||
'valentine',
|
||||
'halloween',
|
||||
'garden',
|
||||
'forest',
|
||||
'aqua',
|
||||
'lofi',
|
||||
'pastel',
|
||||
'fantasy',
|
||||
'wireframe',
|
||||
'black',
|
||||
'luxury',
|
||||
'dracula',
|
||||
'cmyk',
|
||||
'autumn',
|
||||
'business',
|
||||
'acid',
|
||||
'lemonade',
|
||||
'night',
|
||||
'coffee',
|
||||
'winter',
|
||||
] as const;
|
24
web/tsconfig.app.json
Normal file
24
web/tsconfig.app.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "preserve",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
|
||||
}
|
1
web/tsconfig.app.tsbuildinfo
Normal file
1
web/tsconfig.app.tsbuildinfo
Normal file
@ -0,0 +1 @@
|
||||
{"root":["./src/main.ts","./src/vite-env.d.ts","./src/app.vue","./src/components/gameinput.vue","./src/components/helloworld.vue"],"version":"5.6.2"}
|
16
web/tsconfig.json
Normal file
16
web/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"strict": true,
|
||||
"jsx": "preserve",
|
||||
"sourceMap": false,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"esModuleInterop": true,
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"skipLibCheck": true
|
||||
},
|
||||
}
|
23
web/tsconfig.node.json
Normal file
23
web/tsconfig.node.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
"composite": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
1
web/tsconfig.node.tsbuildinfo
Normal file
1
web/tsconfig.node.tsbuildinfo
Normal file
File diff suppressed because one or more lines are too long
1
web/tsconfig.tsbuildinfo
Normal file
1
web/tsconfig.tsbuildinfo
Normal file
@ -0,0 +1 @@
|
||||
{"root":["./theme-manager.config.ts","./vite.config.ts","./src/app.vue","./src/app.vue.d.ts","./src/main.ts","./src/vite-env.d.ts","./src/classes/debugger.ts","./src/classes/language.ts","./src/components/attemptlist.vue","./src/components/gameinput.vue","./src/components/settings.vue"],"version":"5.6.2"}
|
7
web/vite.config.js
Normal file
7
web/vite.config.js
Normal file
@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()]
|
||||
});
|
||||
//# sourceMappingURL=vite.config.js.map
|
7
web/vite.config.ts
Normal file
7
web/vite.config.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue()]
|
||||
})
|
Loading…
x
Reference in New Issue
Block a user