token expire, remove console

This commit is contained in:
2021-08-24 20:08:42 -05:00
parent 3b2a06b043
commit a55f45cafd
10 changed files with 279 additions and 179 deletions

View File

@@ -60,7 +60,7 @@ export var pieOptions={
chart: { chart: {
renderTo: "container", renderTo: "container",
defaultSeriesType: "pie", defaultSeriesType: "pie",
backgroundColor: "rgba(0,0,0,0)" //backgroundColor: "rgba(255,0,0,)"
}, },
xAxis: { xAxis: {
categories: [], categories: [],
@@ -81,3 +81,111 @@ export var pieOptions={
} }
}, },
}; };
export var ingresosvscomprasOptions = {
chart: {
renderTo: "container",
defaultSeriesType: "bar",
backgroundColor: "rgba(0,0,0,0)"
},
title: {
text: "Gastos Vs Ingresos"
},
plotOptions: {
bar: {
grouping: false,
shadow: false,
borderWidth: 0.5
},
},
legend: {
shadow: true
},
credits: {
enabled: false
},
xAxis: {
categories: [""],
crosshair: false
},
yAxis: [
{
min: 0,
title: {
text: "Pesos"
}
}
],
series: [
{
name: "Ingresos",
color: "rgba(0,80,200,.5)",
data: [150],
pointPadding: 0.25,
pointPlacement: -0.2
},
{
name: "Gastos",
color: "rgba(165,0,217,1)",
data: [120],
pointPadding: 0.3,
pointPlacement: -0.2
}
]
};
export var ingresosvsegresosOptions = {
chart: {
renderTo: "container",
defaultSeriesType: "bar",
backgroundColor: "rgba(0,0,0,0)"
},
title: {
text: ""
},
plotOptions: {
bar: {
grouping: false,
shadow: false,
borderWidth: 0.5
},
},
legend: {
shadow: false
},
credits: {
enabled: false
},
xAxis: {
categories: [""],
crosshair: false
},
yAxis: [
{
min: 0,
title: {
text: "Pesos"
}
}
],
series: [
{
name: "Ingresos",
color: "rgba(0,80,200,.5)",
data: [],
pointPadding: 0.25,
pointPlacement: -0.2
},
{
name: "Egresos",
color: "rgba(165,0,217,1)",
data: [],
pointPadding: 0.3,
pointPlacement: -0.2
}
]
};

View File

@@ -61,8 +61,8 @@ export default {
// Axios module configuration (https://go.nuxtjs.dev/config-axios) // Axios module configuration (https://go.nuxtjs.dev/config-axios)
axios: { axios: {
//baseURL: "http://192.168.1.111:4000/api" //baseURL: "http://192.168.1.111:4000/api"
baseURL:"http://localhost:4000/api" //baseURL:"http://localhost:4000/api"
//baseURL:"https://finanzasm.herokuapp.com/api" // baseURL:"https://finanzasm.herokuapp.com/api"
}, },
/* /*

View File

@@ -136,7 +136,6 @@ export default {
this.$axios this.$axios
.get("/compras", axiosHeader) .get("/compras", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.data);
this.compras = res.data.data; this.compras = res.data.data;
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -151,12 +150,11 @@ export default {
}, },
}; };
const toSend = this.newCompra; const toSend = this.newCompra;
console.log(axiosHeader.data);
this.$axios this.$axios
.post("/compra", toSend, axiosHeader) .post("/compra", toSend, axiosHeader)
.then((res) => { .then((res) => {
this.clearFormCompra(); this.clearFormCompra();
console.log(res.data.status);
this.getCompras(); this.getCompras();
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -168,12 +166,10 @@ export default {
}, },
}; };
const toSend = this.newCompra; const toSend = this.newCompra;
console.log(axiosHeader.data);
this.$axios this.$axios
.put("/compra", toSend, axiosHeader) .put("/compra", toSend, axiosHeader)
.then((res) => { .then((res) => {
this.clearFormCompra(); this.clearFormCompra();
console.log(res.data.status);
this.getCompras(); this.getCompras();
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -183,7 +179,7 @@ export default {
var reg_edit = this.compras.filter((ic) => ic._id===id)[0]; var reg_edit = this.compras.filter((ic) => ic._id===id)[0];
this.newCompra = JSON.parse(JSON.stringify(reg_edit)); this.newCompra = JSON.parse(JSON.stringify(reg_edit));
this.openForm = true; this.openForm = true;
console.log(reg_edit)
}, },
deleteCompra(id) { deleteCompra(id) {
@@ -198,7 +194,6 @@ export default {
this.$axios this.$axios
.delete("/compra", axiosHeader) .delete("/compra", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data);
this.getCompras(); this.getCompras();
this.clearFormCompra(); this.clearFormCompra();
}) })
@@ -214,7 +209,6 @@ export default {
}, },
getIcon(row, column, cellValue, index) { getIcon(row, column, cellValue, index) {
const found = this.$store.state.categorias.filter((ic) => ic.name === cellValue)[0]; const found = this.$store.state.categorias.filter((ic) => ic.name === cellValue)[0];
//console.log(found);
return `<i class="${found.icon}"></i>${cellValue}` return `<i class="${found.icon}"></i>${cellValue}`
}, },

View File

@@ -1,9 +1,13 @@
<template> <template>
<div> <div>
<card title='Filtro general'> <card title="Filtro general">
<base-input label="Filtro de fechas" v-model="filtro.fechas"></base-input> <base-input label="Filtro de fechas" v-model="filtro.fechas"></base-input>
<base-input label="Número de presupuestos" type="number" v-model="filtro.npresupuesto"></base-input> <base-input
<base-button @click='guardarFiltro()' type="info">Guardar</base-button> label="Número de presupuestos"
type="number"
v-model="filtro.npresupuesto"
></base-input>
<base-button @click="guardarFiltro()" type="info">Guardar</base-button>
</card> </card>
<div class="row"> <div class="row">
<card title="Categorias"> <card title="Categorias">
@@ -37,14 +41,12 @@
</div> </div>
<div class="col-4"> <div class="col-4">
<form> <form>
<base-input <base-input
type="text" type="text"
placeholder="Nombre de categoria" placeholder="Nombre de categoria"
v-model="newCategoria.name" v-model="newCategoria.name"
/> />
<base-input> <base-input>
<select class="form-control" v-model="newCategoria.icon"> <select class="form-control" v-model="newCategoria.icon">
<option v-for="icono in iconos"> <option v-for="icono in iconos">
@@ -100,7 +102,10 @@
</div> </div>
<div class="col-4"> <div class="col-4">
<form> <form>
<base-input placeholder="Nombre pago" v-model="newMetodo.name"></base-input> <base-input
placeholder="Nombre pago"
v-model="newMetodo.name"
></base-input>
<base-input> <base-input>
<select class="form-control" v-model="newMetodo.icon"> <select class="form-control" v-model="newMetodo.icon">
<option v-for="icono in iconos"> <option v-for="icono in iconos">
@@ -137,7 +142,7 @@ export default {
mounted() { mounted() {
this.getCategorias(); this.getCategorias();
this.getMetodos(); this.getMetodos();
this.filtro=this.$store.state.filtro this.filtro = JSON.parse(JSON.stringify(this.$store.state.filtro));
}, },
data() { data() {
return { return {
@@ -183,15 +188,15 @@ export default {
], ],
categorias: [], categorias: [],
metodos: [], metodos: [],
filtro:{ filtro: {
fechas:this.$store.state.filtro.fechas, fechas: "",
npresupuesto:this.$store.state.filtro.npresupuesto npresupuesto: 0
} },
}; };
}, },
methods: { methods: {
guardarFiltro(){ guardarFiltro() {
this.$store.commit("actualizarFiltro",this.filtro) this.$store.commit("actualizarFiltro", this.filtro);
}, },
enviarCategoria() { enviarCategoria() {
const axiosHeader = { const axiosHeader = {
@@ -204,7 +209,6 @@ export default {
this.$axios this.$axios
.post("/categoria", toSend, axiosHeader) .post("/categoria", toSend, axiosHeader)
.then((res) => { .then((res) => {
console.log(res);
this.getCategorias(); this.getCategorias();
}) })
.catch((e) => { .catch((e) => {
@@ -213,7 +217,6 @@ export default {
icon: "tim-icons icon-alert-circle-exc", icon: "tim-icons icon-alert-circle-exc",
message: JSON.parse(e.request.response).error, message: JSON.parse(e.request.response).error,
}); });
console.log(e.request.responseText);
}); });
}, },
@@ -226,7 +229,6 @@ export default {
this.$axios this.$axios
.get("/categoria", axiosHeader) .get("/categoria", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.data);
this.categorias = res.data.data; this.categorias = res.data.data;
this.$store.commit("setCategorias", this.categorias); this.$store.commit("setCategorias", this.categorias);
}) })
@@ -244,7 +246,6 @@ export default {
this.$axios this.$axios
.delete("/categoria", axiosHeader) .delete("/categoria", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data);
this.getCategorias(); this.getCategorias();
}) })
.catch((e) => { .catch((e) => {
@@ -262,7 +263,6 @@ export default {
this.$axios this.$axios
.post("/metodo", toSend, axiosHeader) .post("/metodo", toSend, axiosHeader)
.then((res) => { .then((res) => {
console.log(res);
this.getMetodos(); this.getMetodos();
}) })
.catch((e) => { .catch((e) => {
@@ -271,7 +271,6 @@ export default {
icon: "tim-icons icon-alert-circle-exc", icon: "tim-icons icon-alert-circle-exc",
message: JSON.parse(e.request.response).error, message: JSON.parse(e.request.response).error,
}); });
console.log(e.request.responseText);
}); });
}, },
@@ -284,7 +283,6 @@ export default {
this.$axios this.$axios
.get("/metodo", axiosHeader) .get("/metodo", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.data);
this.metodos = res.data.data; this.metodos = res.data.data;
this.$store.commit("setMetodos", this.metodos); this.$store.commit("setMetodos", this.metodos);
}) })
@@ -302,7 +300,6 @@ export default {
this.$axios this.$axios
.delete("/metodo", axiosHeader) .delete("/metodo", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data);
this.getMetodos(); this.getMetodos();
}) })
.catch((e) => { .catch((e) => {

View File

@@ -234,7 +234,6 @@ export default {
this.$axios this.$axios
.put("/Credito", toSend, axiosHeader) .put("/Credito", toSend, axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.status);
this.getItems(); this.getItems();
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -316,7 +315,6 @@ export default {
this.selectedCredito = this.Creditos[0]; this.selectedCredito = this.Creditos[0];
this.selectedCreditoName = this.selectedCredito.nombreCredito; this.selectedCreditoName = this.selectedCredito.nombreCredito;
this.newItem._id = this.selectedCredito._id; this.newItem._id = this.selectedCredito._id;
console.log(this.selectedCredito);
this.sumItems(); this.sumItems();
} }
}) })
@@ -330,7 +328,6 @@ export default {
this.sumItems(); this.sumItems();
}, },
deleteCredito() { deleteCredito() {
console.log(this.selectedCredito._id);
const axiosHeader = { const axiosHeader = {
headers: { headers: {
token: this.$store.state.auth.token, token: this.$store.state.auth.token,
@@ -342,7 +339,6 @@ export default {
this.$axios this.$axios
.delete("/Credito", axiosHeader) .delete("/Credito", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data);
this.selectedCredito = { this.selectedCredito = {
_id: "", _id: "",

View File

@@ -115,7 +115,6 @@ export default {
this.$axios this.$axios
.get("/ingreso", axiosHeader) .get("/ingreso", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.data);
this.ingresos = res.data.data; this.ingresos = res.data.data;
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -130,12 +129,10 @@ export default {
}, },
}; };
const toSend = this.newIngreso; const toSend = this.newIngreso;
console.log(axiosHeader.data);
this.$axios this.$axios
.post("/ingreso", toSend, axiosHeader) .post("/ingreso", toSend, axiosHeader)
.then((res) => { .then((res) => {
this.clearFormIngreso(); this.clearFormIngreso();
console.log(res.data.status);
this.getIngresos(); this.getIngresos();
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -147,12 +144,10 @@ export default {
}, },
}; };
const toSend = this.newIngreso; const toSend = this.newIngreso;
console.log(axiosHeader.data);
this.$axios this.$axios
.put("/ingreso", toSend, axiosHeader) .put("/ingreso", toSend, axiosHeader)
.then((res) => { .then((res) => {
this.clearFormIngreso(); this.clearFormIngreso();
console.log(res.data.status);
this.getIngresos(); this.getIngresos();
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -176,7 +171,6 @@ export default {
this.$axios this.$axios
.delete("/ingreso", axiosHeader) .delete("/ingreso", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data);
this.getIngresos(); this.getIngresos();
this.clearFormIngreso(); this.clearFormIngreso();
}) })

View File

@@ -71,7 +71,6 @@ export default {
icon: "tim-icons icon-check-2", icon: "tim-icons icon-check-2",
message: "Success! Welcome " + res.data.userData.name message: "Success! Welcome " + res.data.userData.name
}); });
console.log(res.data)
const auth = { const auth = {
token: res.data.token, token: res.data.token,
userData: res.data.userData userData: res.data.userData

View File

@@ -119,9 +119,9 @@
<script> <script>
import { Table, TableColumn } from "element-ui"; import { Table, TableColumn } from "element-ui";
export default { export default {
components: { components: {
[Table.name]: Table, [Table.name]: Table,
[TableColumn.name]: TableColumn, [TableColumn.name]: TableColumn,
}, },
@@ -195,7 +195,6 @@ export default {
this.$axios this.$axios
.put("/presupuesto", toSend, axiosHeader) .put("/presupuesto", toSend, axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.status);
this.getItems(); this.getItems();
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
@@ -246,6 +245,7 @@ export default {
0 0
); );
this.total = this.totalIngresos - this.totalEgresos; this.total = this.totalIngresos - this.totalEgresos;
}, },
formatMoneda(dato) { formatMoneda(dato) {
var num = dato; var num = dato;
@@ -277,7 +277,7 @@ export default {
this.selectedPresupuesto = this.presupuestos[0]; this.selectedPresupuesto = this.presupuestos[0];
this.selectedPresupuestoName = this.selectedPresupuesto.nombrePresupuesto; this.selectedPresupuestoName = this.selectedPresupuesto.nombrePresupuesto;
this.newItem._id = this.selectedPresupuesto._id; this.newItem._id = this.selectedPresupuesto._id;
console.log(this.selectedPresupuesto);
this.sumItems(); this.sumItems();
} }
}) })
@@ -291,7 +291,7 @@ export default {
this.sumItems(); this.sumItems();
}, },
deletePresupuesto() { deletePresupuesto() {
console.log(this.selectedPresupuesto._id);
const axiosHeader = { const axiosHeader = {
headers: { headers: {
token: this.$store.state.auth.token, token: this.$store.state.auth.token,
@@ -303,7 +303,6 @@ export default {
this.$axios this.$axios
.delete("/presupuesto", axiosHeader) .delete("/presupuesto", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data);
this.selectedPresupuesto = { this.selectedPresupuesto = {
_id: "", _id: "",
@@ -319,6 +318,10 @@ export default {
mounted() { mounted() {
this.getPresupuesto(); this.getPresupuesto();
}, },
watch:{
data(){this.sumItems()}
}
}; };
</script> </script>

View File

@@ -1,32 +1,43 @@
<template> <template>
<div> <div>
<h1>Resumen mensual</h1> <h1>Resumen Mensual</h1>
<div class="row">
<Badge type="primary" class="col-3 p-4 rounded-pill"
>Total Ingresos: <br /><b>{{ formatMoneda(ingresos) }}</b></Badge
>
<Badge type="info" class="col-3 p-4 offset-md-1 rounded-pill"
>Total Compras: <br /><b>{{ formatMoneda(compras) }}</b></Badge
>
</div>
<card> <card>
<div class="chart-area" style="height: 300px"> <div class="row">
<highchart style="height: 100%" v-if="isMounted" :options="comprasChart"/> <Badge type="info" class="col-6 p-1 rounded-pill"
>Total Ingresos: <br /><b>{{ formatMoneda(ingresos) }}</b></Badge
>
<Badge type="primary" class="col-6 p-1 rounded-pill"
>Total Gastos: <br /><b>{{ formatMoneda(compras) }}</b></Badge
>
</div> </div>
<div class="chart-area" style="height: 300px"> <div class="chart-area" style="height: 300px">
<highchart style="height: 100%" v-if="isMounted" :options="metodosChart"/> <highchart
style="height: 100%"
v-if="isMounted"
:options="ingresosVscompras"
/>
</div>
</card>
<card>
<div class="chart-area" style="height: 300px">
<highchart
style="height: 100%"
v-if="isMounted"
:options="comprasChart"
/>
</div>
</card>
<card>
<div class="chart-area">
<highchart
style="height: 100%"
v-if="isMounted"
:options="metodosChart"
/>
</div> </div>
</card> </card>
</div> </div>
</template> </template>
@@ -43,33 +54,32 @@ export default {
return { return {
isMounted: false, isMounted: false,
comprasChart:{ comprasChart: {
...configPlot.chartOptions, ...configPlot.chartOptions,
title: { title: {
text: 'Compras por categorías' text: "Gastos por categoría",
},
series: [],
}, },
series: [{
name: '',
data: [],
color: "#e14eca"
},],
}, ingresosVscompras: {
...configPlot.ingresosvscomprasOptions,
},
metodosChart:{ metodosChart: {
...configPlot.pieOptions, ...configPlot.pieOptions,
title: { title: {
text: 'Métodos de pago' text: "Métodos de pago",
}, },
series: [{ series: [
{
data: [], data: [],
},], },
],
}, },
ingresos: 1000, ingresos: 1000,
compras: 1000, compras: 1000,
}; };
}, },
@@ -99,8 +109,9 @@ metodosChart:{
this.$axios this.$axios
.get("/resumen_compras", axiosHeader) .get("/resumen_compras", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.data); //console.log(res.data.data);
this.compras = res.data.data; this.compras = res.data.data;
this.ingresosVscompras.series[1].data[0] = this.compras;
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
}, },
@@ -115,8 +126,14 @@ metodosChart:{
this.$axios this.$axios
.get("/resumen_ingresos", axiosHeader) .get("/resumen_ingresos", axiosHeader)
.then((res) => { .then((res) => {
console.log(res.data.data); // console.log(res.data.data);
this.ingresos = res.data.data; this.ingresos = res.data.data;
this.ingresosVscompras.series[0].data[0] = this.ingresos;
if (this.compras / this.ingresos > 0.8) {
this.ingresosVscompras.chart.backgroundColor = "rgba(150,0,0,0.4)";
} else {
this.ingresosVscompras.chart.backgroundColor = "rgba(0,0,0,0)";
}
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
}, },
@@ -134,15 +151,8 @@ metodosChart:{
let categorias = res.data.labels; let categorias = res.data.labels;
let valores = res.data.datos; let valores = res.data.datos;
this.comprasChart.xAxis.categories =categorias; this.comprasChart.xAxis.categories = categorias;
this.comprasChart.series =[{name: '', this.comprasChart.series = [{ name: "", data: valores }];
data: valores,
}]
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
}, },
@@ -161,23 +171,16 @@ metodosChart:{
let valores = res.data.datos; let valores = res.data.datos;
//this.metodosChart.xAxis.categories =metodos; //this.metodosChart.xAxis.categories =metodos;
var series =[]; var series = [];
for (var i=0;i< metodos.length;i++){ for (var i = 0; i < metodos.length; i++) {
var serie={ var serie = {
name:metodos[i], name: metodos[i],
y:valores[i] y: valores[i],
};
series.push(serie);
} }
series.push(serie) //console.log(series);
} this.metodosChart.series = [{ name: "", data: series }];
console.log(series)
this.metodosChart.series = [{name: '',
data: series,
}];
}) })
.catch((e) => console.log(e)); .catch((e) => console.log(e));
}, },
@@ -186,6 +189,7 @@ metodosChart:{
async mounted() { async mounted() {
await this.getCompras(); await this.getCompras();
await this.getIngresos(); await this.getIngresos();
await this.getResumenCategorias(); await this.getResumenCategorias();
await this.getResumenMetodos(); await this.getResumenMetodos();
this.isMounted = true; this.isMounted = true;

View File

@@ -1,7 +1,7 @@
export const state = () => ({ export const state = () => ({
auth: null, auth: null,
notifications: [], notifications: [],
filtro: {fechas:fechaString().slice(0, 7),npresupuesto:5}, filtro: { fechas: fechaString().slice(0, 7), npresupuesto: 5 },
fecha: fechaString(), fecha: fechaString(),
categorias: [], categorias: [],
metodos_de_pago: [] metodos_de_pago: []
@@ -23,10 +23,8 @@ export const mutations = {
setMetodos(state, metodos) { setMetodos(state, metodos) {
state.metodos_de_pago = metodos; state.metodos_de_pago = metodos;
}, },
actualizarFiltro(state,filtro) { actualizarFiltro(state, filtro) {
state.filtro = filtro;
state.filtro=filtro
} }
}; };
@@ -64,7 +62,9 @@ export const actions = {
this.commit("setCategorias", res.data.data); this.commit("setCategorias", res.data.data);
}) })
.catch(error => { .catch(error => {
console.log(error); localStorage.clear();
const auth = {};
this.commit("setAuth", auth);
}); });
}, },
@@ -79,7 +79,12 @@ export const actions = {
.then(res => { .then(res => {
this.commit("setMetodos", res.data.data); this.commit("setMetodos", res.data.data);
}) })
.catch(e => console.log(e)); .catch(e => {
}, //Redireccion token
localStorage.clear();
const auth = {};
this.commit("setAuth", auth);
window.location.href = "/login";
});
}
}; };