fehler behoben
This commit is contained in:
parent
8c01024d99
commit
d55b3576db
6
.gitignore
vendored
6
.gitignore
vendored
@ -1 +1,7 @@
|
|||||||
express-server\public\javascripts\test.js
|
express-server\public\javascripts\test.js
|
||||||
|
express-server\views\dash2.ejs
|
||||||
|
express-server\public\test\style.css
|
||||||
|
express-server\public\test\dash.js
|
||||||
|
express-server/views/dash2.ejs
|
||||||
|
express-server/public/test/style.css
|
||||||
|
express-server/public/test/dash.js
|
||||||
|
@ -119,6 +119,8 @@ async function newShoppinglist(name, description, username, color) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return getShoppinglistsAdmin(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
//rename Shoppinglist
|
//rename Shoppinglist
|
||||||
@ -174,12 +176,16 @@ async function displayShoppinglist(sl_id) {
|
|||||||
|
|
||||||
//delete shoppinglist
|
//delete shoppinglist
|
||||||
|
|
||||||
async function deleteShoppinglist(sl_id) {
|
async function deleteShoppinglist(sl_id,uid) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await nonQuery('DELETE FROM "Shoppinglist_admin" WHERE sl_id = $1', [sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist_admin" WHERE sl_id = $1', [sl_id]);
|
||||||
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE sl_id = $1', [sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE sl_id = $1', [sl_id]);
|
||||||
|
await nonQuery('DELETE FROM "Group" WHERE sl_id = $1', [sl_id]);
|
||||||
|
await nonQuery('DELETE FROM "Item" WHERE sl_id = $1', [sl_id]);
|
||||||
await nonQuery('DELETE FROM "Shoppinglist" WHERE sl_id = $1', [sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist" WHERE sl_id = $1', [sl_id]);
|
||||||
|
|
||||||
|
return getShoppinglistsAdmin(uid);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -1,49 +1,147 @@
|
|||||||
import Axios from "axios";
|
// Initialize Firebase
|
||||||
|
var config = {
|
||||||
|
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||||
|
authDomain: "test-667ca.firebaseapp.com",
|
||||||
|
databaseURL: "https://test-667ca.firebaseio.com",
|
||||||
|
projectId: "test-667ca",
|
||||||
|
storageBucket: "test-667ca.appspot.com",
|
||||||
|
messagingSenderId: "221332577314"
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function () {
|
firebase.initializeApp(config);
|
||||||
|
|
||||||
M.AutoInit();
|
var app = new Vue({
|
||||||
//initialize all modals
|
el: ".myapp",
|
||||||
$('.modal').modal({
|
data: {
|
||||||
dismissible: false
|
title: "smartshopper.cf",
|
||||||
});
|
myshoppinglists: [],
|
||||||
|
sharedshoppinglists: [],
|
||||||
|
currentlist: {}
|
||||||
|
},
|
||||||
|
|
||||||
// Initialize Firebase
|
methods: {
|
||||||
var config = {
|
deleteShoppinglist(sl_id) {
|
||||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
|
||||||
authDomain: "test-667ca.firebaseapp.com",
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
databaseURL: "https://test-667ca.firebaseio.com",
|
if (user) {
|
||||||
projectId: "test-667ca",
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
storageBucket: "test-667ca.appspot.com",
|
axios({
|
||||||
messagingSenderId: "221332577314"
|
method: 'delete',
|
||||||
};
|
url: "/shoppinglist",
|
||||||
|
data: {
|
||||||
|
sl_id: sl_id,
|
||||||
|
idtoken: idtoken
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
app.myshoppinglists = res.data;
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
firebase.initializeApp(config);
|
|
||||||
|
|
||||||
var app = new Vue({
|
|
||||||
el: "myapp",
|
|
||||||
data: {
|
|
||||||
myshoppinglists: [],
|
|
||||||
sharedshoppinglists: []
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
getShoppinglistDetail(sl_id) {
|
||||||
fetchData: function() {
|
|
||||||
firebase.auth().onAuthStateChanged(function (user) {
|
axios({
|
||||||
if (user) {
|
method: 'get',
|
||||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
url: "/shoppinglist_json/" + sl_id,
|
||||||
alert("LALALALAL");
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));
|
}).then((res) => {
|
||||||
} else {
|
app.currentlist = res.data;
|
||||||
console.log("Check Auth error", user)
|
console.log(res.data);
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
createShoppinglist(name, description) {
|
||||||
this.fetchData();
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
axios({
|
||||||
|
method: 'post',
|
||||||
|
url: "/shoppinglist",
|
||||||
|
data: {
|
||||||
|
name: name,
|
||||||
|
description: description,
|
||||||
|
color: "white",
|
||||||
|
idtoken: idtoken
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
app.myshoppinglists = res.data;
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
|
||||||
|
created() {
|
||||||
|
|
||||||
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
axios.get('/myshoppinglists?idtoken=' + idtoken)
|
||||||
|
.then(function (res) {
|
||||||
|
|
||||||
|
app.myshoppinglists = res.data;
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
axios.get('sharedshoppinglists?idtoken=' + idtoken)
|
||||||
|
.then(function (res) {
|
||||||
|
|
||||||
|
app.sharedshoppinglists = res.data;
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$('.collapsible').collapsible();
|
||||||
|
$('.modal').modal();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on("click", ".citemL", function () {
|
||||||
|
$(".activeL").removeClass("activeL");
|
||||||
|
$(this).addClass("activeL");
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".nav-createlist").click(function() {
|
||||||
|
$('#modal1').modal("open");
|
||||||
});
|
});
|
@ -1,3 +1,20 @@
|
|||||||
body {
|
body {
|
||||||
background-color: rgb(238, 238, 238);
|
background-color: rgb(240, 240, 240) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.msl {
|
||||||
|
color: rgb(56, 56, 56) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activeL {
|
||||||
|
background-color: #e53935 !important;
|
||||||
|
color: #f0f0f0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ico {
|
||||||
|
color: #bdbdbd !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.brand-logo {
|
||||||
|
margin-left: 30px !important;
|
||||||
}
|
}
|
11926
express-server/public/test/vue.js
Normal file
11926
express-server/public/test/vue.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -51,6 +51,7 @@ router.get('/dash/:idtoken', function (req, res, next) {
|
|||||||
res.render('dash');
|
res.render('dash');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
router.get('/register', (req, res) => {
|
router.get('/register', (req, res) => {
|
||||||
res.status(200).render('registrieremail');
|
res.status(200).render('registrieremail');
|
||||||
});
|
});
|
||||||
@ -167,20 +168,13 @@ router.post("/shoppinglist", async function (req, res, next) {
|
|||||||
//GET Shoppinglist detail
|
//GET Shoppinglist detail
|
||||||
|
|
||||||
router.get("/shoppinglist_json/:sl_id", async (req, res) => {
|
router.get("/shoppinglist_json/:sl_id", async (req, res) => {
|
||||||
var token = req.query.idtoken;
|
|
||||||
var uid;
|
try {
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
res.status(200).send(await postgres.displayShoppinglist(req.params.sl_id));
|
||||||
.then(async function (decodedToken) {
|
} catch (err) {
|
||||||
uid = decodedToken.uid;
|
res.status(400).send(await err);
|
||||||
console.log("UID: ", uid);
|
}
|
||||||
try {
|
|
||||||
res.status(200).send(await postgres.displayShoppinglist(req.params.sl_id));
|
|
||||||
} catch (err) {
|
|
||||||
res.status(400).send(await err);
|
|
||||||
}
|
|
||||||
}).catch(function (error) {
|
|
||||||
console.log(error)
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -191,11 +185,21 @@ postgres.displayShoppinglist("4tezJYMK");
|
|||||||
//DELETE Shoppinglist
|
//DELETE Shoppinglist
|
||||||
|
|
||||||
router.delete("/shoppinglist", async (req, res) => {
|
router.delete("/shoppinglist", async (req, res) => {
|
||||||
try {
|
|
||||||
res.status(200).send(await postgres.deleteShoppinglist(req.body.sl_id));
|
var token = req.body.idtoken;
|
||||||
} catch (err) {
|
var uid;
|
||||||
res.status(400).send(await err);
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
}
|
.then(async function (decodedToken) {
|
||||||
|
uid = decodedToken.uid;
|
||||||
|
|
||||||
|
try {
|
||||||
|
res.status(200).send(await postgres.deleteShoppinglist(req.body.sl_id, uid));
|
||||||
|
} catch (err) {
|
||||||
|
res.status(400).send(await err);
|
||||||
|
}
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post("/movedoneitem", (req, res) => {
|
router.post("/movedoneitem", (req, res) => {
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
||||||
<script src="/ocrscan/axios.js"></script>
|
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||||
|
|
||||||
@ -22,51 +22,101 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
<!-- Compiled and minified CSS -->
|
<!-- Compiled and minified CSS -->
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
<link rel="stylesheet" href="/test/materialize/css/materialize.min.css">
|
||||||
|
|
||||||
<!-- Compiled and minified JavaScript -->
|
<!-- Compiled and minified JavaScript -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
<script src="/test/materialize/js/materialize.min.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="test/style.css">
|
<link rel="stylesheet" href="test/style.css">
|
||||||
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div class="myapp">
|
||||||
|
<nav>
|
||||||
|
<div class="nav-wrapper red darken-1">
|
||||||
|
<a class="brand-logo">{{title}}</a>
|
||||||
|
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
||||||
|
<li><a href="sass.html">Done Purchases</a></li>
|
||||||
|
<li><a href="/scan">Scan bill</a></li>
|
||||||
|
<li class="nav-createlist"><a>Create Shoppinglist</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<nav>
|
|
||||||
<div class="nav-wrapper red darken-1">
|
|
||||||
<a href="#" class="brand-logo">SmartShopper.cf</a>
|
|
||||||
<ul id="nav-mobile" class="right hide-on-med-and-down">
|
|
||||||
<li><a href="sass.html">Done Purchases</a></li>
|
|
||||||
<li><a href="/scan">Scan bill</a></li>
|
|
||||||
<li><a href="/logout">Logout</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<div class="container row myapp">
|
<div class="container row">
|
||||||
<div class="col s6">
|
<div class="col s6">
|
||||||
<p>My Shoppinglists</p>
|
<ul class="collection with-header">
|
||||||
<div class="collection">
|
<li class="collection-header">
|
||||||
<a href="#!" class="collection-item">Alvin</a>
|
<h4>Your Shoppinglists</h4>
|
||||||
<a href="#!" class="collection-item active">Alvin</a>
|
</li>
|
||||||
<a href="#!" class="collection-item">Alvin</a>
|
<li class="collection-item citemL" v-for="item in myshoppinglists">
|
||||||
<a href="#!" class="collection-item">Alvin</a>
|
<div v-on:click="getShoppinglistDetail(item.sl_id)">{{item.name}}<a href="#!"
|
||||||
|
class="secondary-content"><i v-on:click="deleteShoppinglist(item.sl_id)"
|
||||||
|
class="material-icons ico">delete</i> <i class="material-icons ico">edit</i></a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<ul class="collection with-header">
|
||||||
|
<li class="collection-header">
|
||||||
|
<h4>Shared Shoppinglists</h4>
|
||||||
|
</li>
|
||||||
|
<li class="collection-item citemL" v-for="item in sharedshoppinglists">
|
||||||
|
<div>{{item.name}}<a href="#!" class="secondary-content"><i
|
||||||
|
class="material-icons ico">remove_circle_outline</i></a></div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- etainansicht -->
|
||||||
|
<div class="col s6">
|
||||||
|
|
||||||
|
<ul class="collapsible">
|
||||||
|
<li v-for="group in currentlist.groups">
|
||||||
|
<div class="collapsible-header"><i class="material-icons">view_list</i>{{group.name}}</div>
|
||||||
|
<div class="collapsible-body"><span>
|
||||||
|
|
||||||
|
<div class="collection">
|
||||||
|
<a class="collection-item msl" v-for="item in group.content">{{item.name}}</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</span></div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col s6">
|
|
||||||
<p>Shared Shoppinglists</p>
|
<div id="modal1" class="modal">
|
||||||
<div class="collection">
|
<div class="modal-content">
|
||||||
<a href="#!" class="collection-item">Alvin</a>
|
<h4>Create new Shoppinglist</h4>
|
||||||
<a href="#!" class="collection-item active">Alvin</a>
|
|
||||||
<a href="#!" class="collection-item">Alvin</a>
|
<input id="sl_name" type="text" class="validate" v-model="name">
|
||||||
<a href="#!" class="collection-item">Alvin</a>
|
<label class="active" for="sl_desc">Name</label>
|
||||||
</div>
|
|
||||||
|
<input id="sl_name" type="text" class="validate" v-model="description">
|
||||||
|
<label class="active" for="sl_desc">Description</label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-green btn-flat" v-on:click="createShoppinglist(name, description)">Create</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="/test/vue.js"></script>
|
||||||
|
<script src="/ocrscan/axios.js"></script>
|
||||||
|
|
||||||
<script src="/test/dash.js"></script>
|
<script src="/test/dash.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user