mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
clean up logging
This commit is contained in:
@@ -359,8 +359,6 @@
|
|||||||
shopping_list: [],
|
shopping_list: [],
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
console.log("MOUNTED")
|
|
||||||
|
|
||||||
this.default_shared_users = [{% for u in request.user.userpreference.plan_share.all %}
|
this.default_shared_users = [{% for u in request.user.userpreference.plan_share.all %}
|
||||||
{{ u.pk }},
|
{{ u.pk }},
|
||||||
{% endfor %}]
|
{% endfor %}]
|
||||||
@@ -371,7 +369,7 @@
|
|||||||
this.updatePlan();
|
this.updatePlan();
|
||||||
this.getRecipes();
|
this.getRecipes();
|
||||||
},
|
},
|
||||||
methods: { // TODO stop chain loading and do async
|
methods: {
|
||||||
updatePlan: function () {
|
updatePlan: function () {
|
||||||
let planEntryPromise = this.getPlanEntries();
|
let planEntryPromise = this.getPlanEntries();
|
||||||
let planTypePromise = this.getPlanTypes();
|
let planTypePromise = this.getPlanTypes();
|
||||||
@@ -381,16 +379,13 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPlanEntries: function () {
|
getPlanEntries: function () {
|
||||||
console.log("GET PLAN EXECUTED")
|
|
||||||
return this.$http.get("{% url 'api:mealplan-list' %}?html_week=" + this.week).then((response) => {
|
return this.$http.get("{% url 'api:mealplan-list' %}?html_week=" + this.week).then((response) => {
|
||||||
this.plan_entries = response.data;
|
this.plan_entries = response.data;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
this.loading = false;
|
console.log("getPlanEntries error: ", err);
|
||||||
console.log(err);
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPlanTypes: function () {
|
getPlanTypes: function () {
|
||||||
console.log("GET TYPE EXECUTED")
|
|
||||||
return this.$http.get("{% url 'api:mealtype-list' %}").then((response) => {
|
return this.$http.get("{% url 'api:mealtype-list' %}").then((response) => {
|
||||||
this.meal_types = response.data;
|
this.meal_types = response.data;
|
||||||
this.meal_types_edit = Array.from(this.meal_types)
|
this.meal_types_edit = Array.from(this.meal_types)
|
||||||
@@ -398,11 +393,10 @@
|
|||||||
this.$set(mte, 'delete', false)
|
this.$set(mte, 'delete', false)
|
||||||
}
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log("getPlanTypes error: ",err);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
buildGrid: function () {
|
buildGrid: function () {
|
||||||
console.log("BUILD GRID EXECUTED")
|
|
||||||
this.meal_plan = {}
|
this.meal_plan = {}
|
||||||
|
|
||||||
for (let e of this.plan_entries) {
|
for (let e of this.plan_entries) {
|
||||||
@@ -448,11 +442,10 @@
|
|||||||
this.$http.get(url).then((response) => {
|
this.$http.get(url).then((response) => {
|
||||||
this.recipes = response.data;
|
this.recipes = response.data;
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log("getRecipes error: ", err);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateUserNames: function () {
|
updateUserNames: function () {
|
||||||
console.log("UPDATE USER NAMES EXECUTED")
|
|
||||||
return this.$http.get("{% url 'api:username-list' %}?filter_list=[" + this.user_id_update + ']').then((response) => {
|
return this.$http.get("{% url 'api:username-list' %}?filter_list=[" + this.user_id_update + ']').then((response) => {
|
||||||
for (let u of response.data) {
|
for (let u of response.data) {
|
||||||
let name = u.username
|
let name = u.username
|
||||||
@@ -463,14 +456,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log("updateUserNames error: ", err);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
dragChanged: function (date, meal_type, evt) {
|
dragChanged: function (date, meal_type, evt) {
|
||||||
console.log("log")
|
|
||||||
if (evt.added !== undefined) {
|
if (evt.added !== undefined) {
|
||||||
console.log("added")
|
|
||||||
|
|
||||||
let plan_entry = evt.added.element
|
let plan_entry = evt.added.element
|
||||||
|
|
||||||
plan_entry.date = date
|
plan_entry.date = date
|
||||||
@@ -479,64 +469,53 @@
|
|||||||
plan_entry.shared = this.default_shared_users
|
plan_entry.shared = this.default_shared_users
|
||||||
|
|
||||||
if (plan_entry.is_new) { // its not a meal plan object
|
if (plan_entry.is_new) { // its not a meal plan object
|
||||||
console.log("undef")
|
|
||||||
plan_entry.created_by = {{ request.user.id }};
|
plan_entry.created_by = {{ request.user.id }};
|
||||||
|
|
||||||
this.$http.post(`{% url 'api:mealplan-list' %}`, plan_entry).then((response) => {
|
this.$http.post(`{% url 'api:mealplan-list' %}`, plan_entry).then((response) => {
|
||||||
console.log("create success", response)
|
|
||||||
let entry = response.data
|
let entry = response.data
|
||||||
this.meal_plan[entry.meal_type_name].days[entry.date].items = this.meal_plan[entry.meal_type_name].days[entry.date].items.filter(item => !item.is_new)
|
this.meal_plan[entry.meal_type_name].days[entry.date].items = this.meal_plan[entry.meal_type_name].days[entry.date].items.filter(item => !item.is_new)
|
||||||
this.meal_plan[entry.meal_type_name].days[entry.date].items.push(entry)
|
this.meal_plan[entry.meal_type_name].days[entry.date].items.push(entry)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log("create error", err);
|
console.log("dragChanged create error", err);
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$http.put(`{% url 'api:mealplan-list' %}${plan_entry.id}/`, plan_entry).then((response) => {
|
this.$http.put(`{% url 'api:mealplan-list' %}${plan_entry.id}/`, plan_entry).then((response) => {
|
||||||
console.log("Update success", response)
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log("update error", err);
|
console.log("dragChanged update error", err);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteEntry: function (entry) {
|
deleteEntry: function (entry) {
|
||||||
console.log("delete click")
|
|
||||||
$('#id_plan_detail_modal').modal('hide')
|
$('#id_plan_detail_modal').modal('hide')
|
||||||
this.$http.delete(`{% url 'api:mealplan-list' %}${entry.id}/`, entry).then((response) => {
|
this.$http.delete(`{% url 'api:mealplan-list' %}${entry.id}/`, entry).then((response) => {
|
||||||
console.log("delete success", response)
|
|
||||||
this.meal_plan[entry.meal_type_name].days[entry.date].items = this.meal_plan[entry.meal_type_name].days[entry.date].items.filter(item => item !== entry)
|
this.meal_plan[entry.meal_type_name].days[entry.date].items = this.meal_plan[entry.meal_type_name].days[entry.date].items.filter(item => item !== entry)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log("delete error", err);
|
console.log("deleteEntry error: ", err);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updatePlanTypes: function () {
|
updatePlanTypes: function () {
|
||||||
console.log("UPDATING TYPES")
|
|
||||||
let promise_list = []
|
let promise_list = []
|
||||||
let i = 0
|
let i = 0
|
||||||
for (let x of this.meal_types_edit) {
|
for (let x of this.meal_types_edit) {
|
||||||
x.order = i
|
x.order = i
|
||||||
i++
|
i++
|
||||||
if (x.id === undefined && !x.delete) {
|
if (x.id === undefined && !x.delete) {
|
||||||
console.log("creating new ", x)
|
|
||||||
x.created_by = {{ request.user.id }}
|
x.created_by = {{ request.user.id }}
|
||||||
promise_list.push(this.$http.post("{% url 'api:mealtype-list' %}", x).then((response) => {
|
promise_list.push(this.$http.post("{% url 'api:mealtype-list' %}", x).then((response) => {
|
||||||
console.log("successfully created plan type");
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log("updatePlanTypes create error: ",err);
|
||||||
}))
|
}))
|
||||||
} else if (x.delete) {
|
} else if (x.delete) {
|
||||||
console.log("deleting ", x)
|
|
||||||
promise_list.push(this.$http.delete(`{% url 'api:mealtype-list' %}${x.id}/`, x).then((response) => {
|
promise_list.push(this.$http.delete(`{% url 'api:mealtype-list' %}${x.id}/`, x).then((response) => {
|
||||||
console.log("successfully deleted plan type");
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log("updatePlanTypes delete error: ",err);
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
console.log("updating ", x)
|
|
||||||
promise_list.push(this.$http.put(`{% url 'api:mealtype-list' %}${x.id}/`, x).then((response) => {
|
promise_list.push(this.$http.put(`{% url 'api:mealtype-list' %}${x.id}/`, x).then((response) => {
|
||||||
console.log("successfully updated plan type");
|
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log("updatePlanTypes update error: ",err);
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -551,7 +530,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
cloneRecipe: function (recipe) {
|
cloneRecipe: function (recipe) {
|
||||||
console.log("clone recipe")
|
|
||||||
return {
|
return {
|
||||||
id: Math.round(Math.random() * 1000) + 10000,
|
id: Math.round(Math.random() * 1000) + 10000,
|
||||||
recipe: recipe.id,
|
recipe: recipe.id,
|
||||||
@@ -562,7 +540,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
cloneNote: function () {
|
cloneNote: function () {
|
||||||
console.log("clone note")
|
|
||||||
let new_entry = {
|
let new_entry = {
|
||||||
id: Math.round(Math.random() * 1000) + 10000,
|
id: Math.round(Math.random() * 1000) + 10000,
|
||||||
title: this.new_note_title,
|
title: this.new_note_title,
|
||||||
@@ -626,15 +603,12 @@
|
|||||||
getIcalUrl: function () {
|
getIcalUrl: function () {
|
||||||
return "{% url 'api_get_plan_ical' 12345 %}".replace(/12345/, this.week);
|
return "{% url 'api_get_plan_ical' 12345 %}".replace(/12345/, this.week);
|
||||||
},
|
},
|
||||||
|
|
||||||
addDayToShopping: function (day) {
|
addDayToShopping: function (day) {
|
||||||
let date = moment(this.week).weekday(this.days.indexOf(day)).format('YYYY-MM-DD')
|
let date = moment(this.week).weekday(this.days.indexOf(day)).format('YYYY-MM-DD')
|
||||||
|
|
||||||
for (let t of this.meal_types) {
|
for (let t of this.meal_types) {
|
||||||
console.log(t.id, date)
|
|
||||||
for (let i of this.meal_plan[t.name].days[date].items) {
|
for (let i of this.meal_plan[t.name].days[date].items) {
|
||||||
if (!this.shopping_list.includes(i)) {
|
if (!this.shopping_list.includes(i)) {
|
||||||
console.log("adding ", i)
|
|
||||||
this.shopping_list.push(i)
|
this.shopping_list.push(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user