diff --git a/src/main.js b/src/main.js
index e96bcfd..0e53ee1 100644
--- a/src/main.js
+++ b/src/main.js
@@ -1,7 +1,7 @@
import Vue from 'vue'
import App from './App.vue'
import router from './router'
-import store from './store'
+import store from './store/index'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
@@ -17,8 +17,6 @@ library.add(
faCar, faChargingStation, faUtensils, faFileInvoiceDollar
)
-console.log(library.definitions.fas)
-
Vue.component('font-awesome-icon', FontAwesomeIcon)
Vue.use(BootstrapVue)
diff --git a/src/store.js b/src/store/index.js
similarity index 55%
rename from src/store.js
rename to src/store/index.js
index 3c7424e..c45b454 100644
--- a/src/store.js
+++ b/src/store/index.js
@@ -1,16 +1,11 @@
import Vue from 'vue'
import Vuex from 'vuex'
+import configModule from './modules/config'
Vue.use(Vuex)
export default new Vuex.Store({
- state: {
-
- },
- mutations: {
-
- },
- actions: {
-
+ modules: {
+ config: configModule
}
})
diff --git a/src/store/modules/< b/src/store/modules/<
new file mode 100644
index 0000000..340cbe5
--- /dev/null
+++ b/src/store/modules/<
@@ -0,0 +1,53 @@
+import { readdir, readFile } from 'fs'
+
+export default {
+ namespaced: true,
+ state: {
+ data_dir: '/home/lafrite/scripts/comptes/data/',
+ csv_files: [],
+ data: []
+ },
+ getters: {
+ data_dir: (state) => {
+ return state.data_dir
+ },
+ csvs: (state) => {
+ return state.csv_files
+ },
+ data: (state) => {
+ return state.data
+ }
+ },
+ mutations: {
+ APPEND_DATA: (state, { data }) => {
+ state.data.push(data)
+ },
+ SET_CSV_FILES: (state, { csvs }) => {
+ state.csv_files = csvs
+ }
+
+ },
+ actions: {
+ async find_csv (context) {
+ readdir(context.getters.data_dir, (err, list) => {
+ if (err) {
+ console.log(err)
+ } else {
+ var csvs = list.filter(x => {
+ return x.split('.').pop() == 'csv'
+ })
+ context.commit('SET_CSV_FILES', { csvs })
+ }
+ })
+ },
+ async load_csv (context, csv) {
+ readFile(path.join(context.getters.data_dir, csv) , (err, content) => {
+ if (err) {
+ console.log(err)
+ } else {
+ context.commit('APPEND_DATA', { content })
+ }
+ })
+ }
+ }
+}
diff --git a/src/store/modules/config.js b/src/store/modules/config.js
new file mode 100644
index 0000000..d423e57
--- /dev/null
+++ b/src/store/modules/config.js
@@ -0,0 +1,57 @@
+import { readdir, readFile } from 'fs'
+import path from 'path'
+
+export default {
+ namespaced: true,
+ state: {
+ data_dir: '/home/lafrite/scripts/comptes/data/',
+ csv_files: [],
+ datas: []
+ },
+ getters: {
+ data_dir: (state) => {
+ return state.data_dir
+ },
+ csvs: (state) => {
+ return state.csv_files
+ },
+ datas: (state) => {
+ return state.datas
+ }
+ },
+ mutations: {
+ APPEND_DATA: (state, { content }) => {
+ state.datas.push(content)
+ },
+ SET_CSV_FILES: (state, { csvs }) => {
+ state.csv_files = csvs
+ }
+
+ },
+ actions: {
+ async find_csv (context) {
+ readdir(context.getters.data_dir, (err, list) => {
+ if (err) {
+ console.log(err)
+ } else {
+ var csvs = list.filter(x => {
+ return x.split('.').pop() === 'csv'
+ })
+ for (var i in csvs) {
+ context.dispatch('load_csv', csvs[i])
+ }
+ context.commit('SET_CSV_FILES', { csvs })
+ }
+ })
+ },
+ async load_csv (context, csv) {
+ readFile(path.join(context.getters.data_dir, csv), 'utf8', (err, content) => {
+ if (err) {
+ console.log(err)
+ } else {
+ context.commit('APPEND_DATA', { content })
+ }
+ })
+ }
+ }
+}
diff --git a/src/views/analysis.vue b/src/views/analysis.vue
index 219b88b..7047f61 100644
--- a/src/views/analysis.vue
+++ b/src/views/analysis.vue
@@ -1,5 +1,34 @@
Analyse
+
{{ data_dir }}
+
{{ csvs }}
+
{{ datas }}
+
+