testen
This commit is contained in:
parent
b6cafcc636
commit
b2f7fc9e7e
@ -1,318 +0,0 @@
|
||||
// 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"
|
||||
};
|
||||
|
||||
firebase.initializeApp(config);
|
||||
|
||||
var app = new Vue({
|
||||
el: ".myapp",
|
||||
data: {
|
||||
title: "smartshopper.cf",
|
||||
myshoppinglists: [],
|
||||
sharedshoppinglists: [],
|
||||
currentlist: {},
|
||||
currentGroup: String,
|
||||
users: [],
|
||||
done_purchases: []
|
||||
},
|
||||
|
||||
methods: {
|
||||
deleteShoppinglist(sl_id) {
|
||||
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
axios({
|
||||
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)
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
},
|
||||
|
||||
getShoppinglistDetail(sl_id) {
|
||||
|
||||
axios({
|
||||
method: 'get',
|
||||
url: "/shoppinglist_json/" + sl_id,
|
||||
|
||||
}).then((res) => {
|
||||
app.currentlist = res.data;
|
||||
console.log(res.data);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
createShoppinglist(name, description) {
|
||||
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: "#00a1ff",
|
||||
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)
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
deleteGroup(group_id, sl_id) {
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: "/group",
|
||||
data: {
|
||||
sl_id: sl_id,
|
||||
group_id: group_id
|
||||
}
|
||||
}).then((res) => {
|
||||
console.log(res.data);
|
||||
app.currentlist = res.data;
|
||||
});
|
||||
},
|
||||
|
||||
addGroup(sl_id, name) {
|
||||
|
||||
axios({
|
||||
method: 'post',
|
||||
url: "/group",
|
||||
data: {
|
||||
sl_id: sl_id,
|
||||
name: name,
|
||||
color: "#00a1ff",
|
||||
hidden: false
|
||||
}
|
||||
}).then((res) => {
|
||||
console.log(res.data);
|
||||
app.currentlist = res.data;
|
||||
});
|
||||
},
|
||||
|
||||
addItem(group_id, sl_id, name, count) {
|
||||
|
||||
console.log("AAA" + group_id + " ddd, " + sl_id)
|
||||
|
||||
axios({
|
||||
method: 'post',
|
||||
url: "/item",
|
||||
data: {
|
||||
sl_id: sl_id,
|
||||
group_id: group_id,
|
||||
name: name,
|
||||
count: count
|
||||
}
|
||||
}).then((res) => {
|
||||
console.log(res.data);
|
||||
app.currentlist = res.data;
|
||||
});
|
||||
},
|
||||
|
||||
setCurrentGroup(group_id) {
|
||||
app.currentGroup = group_id;
|
||||
console.log(group_id);
|
||||
},
|
||||
|
||||
delItem(item_id, group_id, sl_id) {
|
||||
|
||||
console.log(item_id + " d " + group_id + " " + sl_id)
|
||||
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: "/item",
|
||||
data: {
|
||||
sl_id: sl_id,
|
||||
group_id: group_id,
|
||||
item_id: item_id
|
||||
}
|
||||
}).then((res) => {
|
||||
console.log(res.data);
|
||||
app.currentlist = res.data;
|
||||
});
|
||||
},
|
||||
|
||||
removeMember(sl_id) {
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
axios({
|
||||
method: 'delete',
|
||||
url: "/exitinvite",
|
||||
data: {
|
||||
sl_id: sl_id,
|
||||
idtoken: idtoken
|
||||
}
|
||||
}).then((res) => {
|
||||
app.sharedshoppinglists = res.data;
|
||||
});
|
||||
}).catch((error) => console.error("Get id token client error: ", error));
|
||||
} else {
|
||||
console.log("Check Auth error", user)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
createInvite(sl_id) {
|
||||
axios({
|
||||
method: 'post',
|
||||
url: "/invite",
|
||||
data: {
|
||||
sl_id: sl_id
|
||||
}
|
||||
}).then((res) => {
|
||||
M.toast({html: 'Invite Link created'});
|
||||
});
|
||||
},
|
||||
|
||||
searchUsers(search) {
|
||||
axios({
|
||||
method: 'get',
|
||||
url: "/users?search=" + search
|
||||
}).then((res) => {
|
||||
app.users = res.data
|
||||
});
|
||||
},
|
||||
|
||||
inviteMan(sl_id, user_id) {
|
||||
axios({
|
||||
method: 'post',
|
||||
url: "/maninvite",
|
||||
data : {
|
||||
uid: user_id,
|
||||
sl_id: sl_id
|
||||
}
|
||||
}).then((res) => {
|
||||
M.toast({html: 'User invited'});
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
firebase.auth().onAuthStateChanged(function (user) {
|
||||
if (user) {
|
||||
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||
axios.get('/donepurchases?idtoken=' + idtoken)
|
||||
.then(function (res) {
|
||||
|
||||
app.done_purchases = 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");
|
||||
});
|
||||
|
||||
$(".crtList").click(function() {
|
||||
$('#modal1').modal("open");
|
||||
});
|
||||
|
||||
$(document).on("click", ".modlGR", function () {
|
||||
$('#modalGR').modal("open");
|
||||
});
|
||||
|
||||
|
||||
$(document).on("click", ".modlIT", function () {
|
||||
$('#modalIT').modal("open");
|
||||
});
|
||||
|
||||
$(".modlINV").click(function() {
|
||||
$('#modalINV').modal("open");
|
||||
});
|
||||
|
||||
$(".modlINVM").click(function() {
|
||||
$('#modalINVM').modal("open");
|
||||
});
|
@ -1,24 +0,0 @@
|
||||
body {
|
||||
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;
|
||||
}
|
||||
|
||||
.icoR {
|
||||
color: #e53935;
|
||||
}
|
@ -1,229 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Dashboard</title>
|
||||
|
||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||
|
||||
<!--Import Google Icon Font-->
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
|
||||
|
||||
<!--Let browser know website is optimized for mobile-->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="/test/materialize/css/materialize.min.css">
|
||||
|
||||
<!-- Compiled and minified JavaScript -->
|
||||
<script src="/test/materialize/js/materialize.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="test/style.css">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="myapp">
|
||||
<div class="navbar-fixed">
|
||||
<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>Done Purchases</a></li>
|
||||
<li><a href="/scan">Scan bill</a></li>
|
||||
<li class="nav-createlist crtList"><a>Create Shoppinglist</a></li>
|
||||
<li class="nav-createlist modlGR"><a>Add Group</a></li>
|
||||
<li class="nav-createlist modlINV"><a>Show Invitelink</a></li>
|
||||
<li class="nav-createlist modlINVM"><a>Invite User manually</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container row">
|
||||
<div class="col s6">
|
||||
<ul class="collection with-header">
|
||||
<li class="collection-header">
|
||||
<h4>Your Shoppinglists</h4>
|
||||
</li>
|
||||
<li class="collection-item citemL" v-for="item in myshoppinglists">
|
||||
<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>
|
||||
<i class="material-icons ico" v-on:click="createInvite(item.sl_id)">share</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 class="secondary-content"><i class="material-icons ico"
|
||||
v-on:click="removeMember(item.sl_id)">remove_circle_outline</i></a></div>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<ul class="collection with-header">
|
||||
<li class="collection-header">
|
||||
<h4>Your Done Purchases</h4>
|
||||
</li>
|
||||
<li class="collection-item citemL" v-for="item in done_purchases">
|
||||
<div>{{item.count}}x {{item.name}} ({{item.date}})<a class="secondary-content"></a></div>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- detainansicht -->
|
||||
<div class="col s6">
|
||||
|
||||
<ul class="collapsible">
|
||||
<li v-for="group in currentlist.groups">
|
||||
<div class="collapsible-header" v-on:click="setCurrentGroup(group.group_id)"><i
|
||||
class="material-icons ico"
|
||||
v-on:click="deleteGroup(group.group_id, currentlist.sl_id)">delete</i><i
|
||||
class="material-icons ico">edit</i><i class="large material-icons ico modlIT"
|
||||
v-on:click="setCurrentGroup(group.group_id)">add</i>{{group.name}}</div>
|
||||
<div class="collapsible-body"><span>
|
||||
|
||||
<ul class="collection">
|
||||
<li class="collection-item msl" v-for="item in group.content">
|
||||
<div>{{item.name}} {{item.count}}x
|
||||
<a v-on:click="delItem(item.item_id, currentGroup, currentlist.sl_id)"
|
||||
class="secondary-content"><i class="material-icons ico">delete</i></a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</span></div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Modal Structure ADD SHOPPINGLOST -->
|
||||
<div id="modal1" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Create new Shoppinglist</h4>
|
||||
|
||||
<input id="sl_name" type="text" class="validate" v-model="name">
|
||||
<label class="active" for="sl_desc">Name</label>
|
||||
|
||||
<input id="sl_name" type="text" class="validate" v-model="description">
|
||||
<label class="active" for="sl_desc">Description</label>
|
||||
|
||||
</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>
|
||||
|
||||
<!-- Modal Structure ADD GROUP -->
|
||||
<div id="modalGR" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Add Group to {{currentlist.name}}</h4>
|
||||
<input id="gr_name" type="text" class="validate" v-model="grname">
|
||||
<label class="active" for="gr_name">Group Name</label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-green btn-flat"
|
||||
v-on:click="addGroup(currentlist.sl_id, grname)">Add Group</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Structure ADD Item -->
|
||||
<div id="modalIT" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Add Item</h4>
|
||||
<input id="it_name" type="text" class="validate" v-model="it_name">
|
||||
<label class="active" for="it_name">Item Name</label>
|
||||
|
||||
<input id="it_count" type="text" class="validate" v-model="it_count">
|
||||
<label class="active" for="it_count">Count</label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-green btn-flat"
|
||||
v-on:click="addItem(currentGroup, currentlist.sl_id, it_name, it_count)">Add Item</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Invite link-->
|
||||
<div id="modalINV" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Invitelink: </h4>
|
||||
|
||||
<textarea id="textarea1"
|
||||
class="materialize-textarea">www.smartshopper.cf/invite/{{currentlist.invitelink}}</textarea>
|
||||
<label for="textarea1">Invitelink</label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-green btn-flat"
|
||||
v-on:click="addItem(currentGroup, currentlist.sl_id, it_name, it_count)">Skip</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- Modal Invite manually-->
|
||||
<div id="modalINVM" class="modal">
|
||||
<div class="modal-content">
|
||||
<h4>Invite User to Shoppinglist</h4>
|
||||
<div class="row">
|
||||
<div class="input-field col s6">
|
||||
<input value="" id="first_name2" type="text" class="validate" v-model="search" v-on:keyup="searchUsers(search)">
|
||||
<label class="active" for="first_name2">Name</label>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<ul class="collection">
|
||||
<li class="collection-item avatar" v-for="user in users">
|
||||
<img src="user.picture" alt="" class="circle">
|
||||
<span class="title">{{user.name}}</span>
|
||||
<p>{{user.email}}</p>
|
||||
|
||||
<a class="secondary-content"><i class="material-icons icoR" v-on:click="inviteMan(currentlist.sl_id, user.username)">add_circle</i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="modal-close waves-effect waves-red btn-flat">Cancel</a>
|
||||
<a class="modal-close waves-effect waves-green btn-flat">Confirm</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/test/vue.js"></script>
|
||||
<script src="/ocrscan/axios.js"></script>
|
||||
|
||||
<script src="/test/dash.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user