Start working on csv

This commit is contained in:
2021-08-05 12:51:51 +02:00
parent 4a9e49fc20
commit 791aa12d2d
9 changed files with 8353 additions and 8492 deletions

42
src/store/config/index.js Normal file
View File

@@ -0,0 +1,42 @@
import path from 'path'
import Papa from 'papaparse'
const config = {
namespaced: true,
state() {
return {
//userDir: '~/.config/sousmargot/',
userDir: './userDir/',
dataFile: 'datas.csv'
}
},
getters: {
userDir (state) { return state.userDir },
dataFilePath (state) { return path.join(state.userDir, state.dataFile) },
},
mutations: {
},
actions: {
loadConfig (context) {
// load config file at ~/.config/sousmargot/config.json
return context.state.userDir
},
loadData (context) {
// load data in userDir on dataFile
console.log("Loading data")
console.log(context.getters.dataFilePath)
},
writeData (context) {
// overwrite the dataFile with months datas
console.log("Writing data")
console.log(context.getters.dataFilePath)
const months = context.rootGetters['travail/monthsAll']
console.log(Object.keys(months).map(k => {return { ...months[k], date: k}}))
const csv = Papa.unparse(context.rootGetters['travail/monthsAll'])
console.log(csv)
},
},
}
export default config

View File

@@ -1,10 +1,12 @@
import { createStore } from 'vuex'
import travailStore from "./travail"
import configStore from "./config"
// Create a new store instance.
const store = createStore({
modules:{
travail: travailStore,
config: configStore,
}
})

View File

@@ -1,3 +1,4 @@
function monthCA(month) {
if (month.ca_react) {
return month.ca_react
@@ -94,6 +95,10 @@ const travail = {
return acc;
}, {})
},
monthsAll: (state) => {
// Get in range months
return state.months
},
getMonth: (state) => (date) => {
return state.months[date]
},
@@ -190,7 +195,6 @@ const travail = {
setRange(context, range) {
context.commit("setRange", range)
},
},
}