Skip to content

Commit

Permalink
Merge pull request #40 from JoelBerglund05/Supabase-API
Browse files Browse the repository at this point in the history
Supabase api
  • Loading branch information
JoelBerglund05 authored Nov 8, 2024
2 parents 10bdade + 6f7f963 commit 0986eba
Show file tree
Hide file tree
Showing 15 changed files with 234 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# pwa-quizz-game
# pwa-quizz-game
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<title>Document</title>
</head>
<body>
<script src="js/main.js"></script>
<p>hej</p>
<button type="submit" id="btnDBRequest">press here</button>
<p id="dBData"></p>

<script type="module" src="./js/main.js"></script>
</body>
</html>
4 changes: 1 addition & 3 deletions js/AnswerButton.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
class AnswerBuron{

}
class AnswerBuron {}
4 changes: 1 addition & 3 deletions js/Authentication.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
class Authentication{

}
class Authentication {}
27 changes: 27 additions & 0 deletions js/DataBase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { createClient } from 'https://esm.sh/@supabase/supabase-js@2'

class DataBase {
constructor() {
this.supabase = createClient(
"https://unswumzybkmeifdigbfn.supabase.co",
"KEY",
);

}
async GetARowFrow(table, idToRow) {
try {
const { data, error } = await this.supabase
.from(table)
.select()
.eq('id', idToRow);
console.log(table, data);
return data;
}
catch (e) {
console.log("An Error has occured: " + event);
}

}
}

export default DataBase;
2 changes: 1 addition & 1 deletion js/NavigationBar.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
class NavigationBar{}
class NavigationBar {}
4 changes: 1 addition & 3 deletions js/ProfileSettings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
class ProfileSettings{

}
class ProfileSettings {}
4 changes: 1 addition & 3 deletions js/Question.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
class Question{

}
class Question {}
5 changes: 1 addition & 4 deletions js/ServiceWorker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
class ServiceWorker{

}

class ServiceWorker {}
2 changes: 1 addition & 1 deletion js/Settings.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
class Settings{}
class Settings {}
39 changes: 31 additions & 8 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
class Main{
RegisterServiceWorker() {
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('./js/ServiceWorker.js').then((reg) => {
console.log('Registration succeeded. Scope is ' + reg.scope);
});
}
import DataBase from "./DataBase.js";

class Main {
constructor() {
this.dataBase = new DataBase();
this.btnDBRequest = document.getElementById("btnDBRequest");
this.displayData = document.getElementById("dBData");
}
RegisterServiceWorker() {
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("./js/ServiceWorker.js").then((reg) => {
console.log("Registration succeeded. Scope is " + reg.scope);
});
}
}
Main() {
this.RegisterServiceWorker();

this.btnDBRequest.addEventListener("click", async () => {
const DBData = await this.dataBase.GetARowFrow('quizz', 1);

DBData.map(data => {
this.displayData.innerHTML = data.questions;
});
});

}
}





const main = new Main();
main.RegisterServiceWorker();
main.Main();
26 changes: 25 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
{"theme_color":"#26a269","background_color":"#8ff0a4","icons":[{"purpose":"maskable","sizes":"512x512","src":"icon512_maskable.png","type":"image/png"},{"purpose":"any","sizes":"512x512","src":"icon512_rounded.png","type":"image/png"}],"orientation":"any","display":"standalone","dir":"auto","lang":"en-US","name":"Quizz Game","short_name":"QG","start_url":"https://joelberglund05.github.io/pwa-quizz-game/"}
{
"theme_color": "#26a269",
"background_color": "#8ff0a4",
"icons": [
{
"purpose": "maskable",
"sizes": "512x512",
"src": "icon512_maskable.png",
"type": "image/png"
},
{
"purpose": "any",
"sizes": "512x512",
"src": "icon512_rounded.png",
"type": "image/png"
}
],
"orientation": "any",
"display": "standalone",
"dir": "auto",
"lang": "en-US",
"name": "Quizz Game",
"short_name": "QG",
"start_url": "https://joelberglund05.github.io/pwa-quizz-game/"
}
134 changes: 134 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"prettier": "prettier . --write"
},
"dependencies": {
"@supabase/supabase-js": "^2.45.6",
"prettier": "^3.3.3",
"sass": "^1.80.3"
}
Expand Down

0 comments on commit 0986eba

Please sign in to comment.