Compare commits

...

5 Commits

26 changed files with 3914 additions and 43542 deletions

23
.gitignore vendored
View File

@ -186,3 +186,26 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear # and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

0
backend/src/__init__.py Normal file
View File

View File

@ -1,10 +1,20 @@
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from ..months import retreive_months
from ..config import config from ..config import config
app = FastAPI() app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:8080"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/months") @app.get("/months")
async def get_months(): async def get_months():
print(config) return retreive_months(config["datapath"])
return {"message": "plop"}

28
backend/src/months.py Normal file
View File

@ -0,0 +1,28 @@
from pathlib import Path
import csv
CSV_STYLE = {
"delimiter": ",",
"quotechar": '"',
}
def list_month_files(path:str, file_schema:str="*_months.csv") -> list[Path]:
print(list(Path(path).glob("*")))
return list(Path(path).glob(file_schema))
def extract_month(filename:Path) -> list[dict[str,str]]:
months = []
with open(filename, 'r', newline='') as csvfile:
month_reader = csv.DictReader(csvfile, **CSV_STYLE)
for month in month_reader:
months.append(month)
return months
def retreive_months(path:str):
month_files = list_month_files(path)
months = []
for file in month_files:
months += extract_month(file)
return months

View File

@ -9,3 +9,10 @@ services:
volumes: volumes:
- ./backend/src:/app/src - ./backend/src:/app/src
- ./datas:/datas - ./datas:/datas
frontend:
build: ./front
volumes:
- './front:/app'
ports:
- 8080:8080

15
front/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM node:lts-alpine3.18 as node-base
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
FROM node-base as node-prepared
RUN npm install @vue/cli@5.0.8 -g
COPY package.json .
COPY yarn.lock .
RUN yarn install
FROM node-prepared as vue-set
CMD ["yarn", "serve"]

View File

@ -1,4 +1,4 @@
# sousmargot # front
## Project setup ## Project setup
``` ```

File diff suppressed because one or more lines are too long

View File

@ -1,54 +0,0 @@
{
"name": "sousmargot",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
},
"main": "background.js",
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0",
"vue-router": "^4.0.8"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"electron": "^13.1.1",
"electron-devtools-installer": "^3.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0",
"vue-cli-plugin-electron-builder": "~2.0.0"
},
"engines": {
"node": ">=16.0.0 <17.0.0"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

19
front/jsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}

33781
front/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +1,28 @@
{ {
"name": "sousmargot", "name": "front",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",
"lint": "vue-cli-service lint", "lint": "vue-cli-service lint"
"electron:build": "vue-cli-service electron:build",
"electron:serve": "vue-cli-service electron:serve",
"postinstall": "electron-builder install-app-deps",
"postuninstall": "electron-builder install-app-deps"
}, },
"main": "background.js",
"dependencies": { "dependencies": {
"core-js": "^3.6.5", "axios": "^1.4.0",
"vue": "^3.0.0", "core-js": "^3.8.3",
"vue-router": "^4.0.8" "vue": "^3.2.13",
"vue-router": "^4.0.3",
"vuex": "^4.1.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0", "@babel/core": "^7.12.16",
"@vue/cli-plugin-eslint": "~4.5.0", "@babel/eslint-parser": "^7.12.16",
"@vue/cli-service": "~4.5.0", "@vue/cli-plugin-babel": "~5.0.0",
"@vue/compiler-sfc": "^3.0.0", "@vue/cli-plugin-eslint": "~5.0.0",
"babel-eslint": "^10.1.0", "@vue/cli-plugin-router": "~5.0.0",
"electron": "^13.1.1", "@vue/cli-service": "~5.0.0",
"electron-devtools-installer": "^3.1.0", "eslint": "^7.32.0",
"eslint": "^6.7.2", "eslint-plugin-vue": "^8.0.3"
"eslint-plugin-vue": "^7.0.0",
"vue-cli-plugin-electron-builder": "~2.0.0"
},
"engines": {
"node": ">=16.0.0 <17.0.0"
}, },
"eslintConfig": { "eslintConfig": {
"root": true, "root": true,
@ -42,13 +34,14 @@
"eslint:recommended" "eslint:recommended"
], ],
"parserOptions": { "parserOptions": {
"parser": "babel-eslint" "parser": "@babel/eslint-parser"
}, },
"rules": {} "rules": {}
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",
"last 2 versions", "last 2 versions",
"not dead" "not dead",
"not ie 11"
] ]
} }

View File

@ -1,17 +1,15 @@
<template> <template>
<Nav></Nav> <div id="app">
<router-view></router-view> <router-view/>
</div>
</template> </template>
<script> <style>
import Nav from './components/nav.vue' #app {
font-family: Avenir, Helvetica, Arial, sans-serif;
export default { -webkit-font-smoothing: antialiased;
name: 'App', -moz-osx-font-smoothing: grayscale;
components: { text-align: center;
Nav color: #2c3e50;
}
} }
</script> </style>
<style></style>

View File

@ -1,83 +0,0 @@
'use strict'
import { app, protocol, BrowserWindow } from 'electron'
import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'
const isDevelopment = process.env.NODE_ENV !== 'production'
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([
{ scheme: 'app', privileges: { secure: true, standard: true } }
])
async function createWindow() {
// Create the browser window.
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,
contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION
}
})
if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
if (!process.env.IS_TEST) win.webContents.openDevTools()
} else {
createProtocol('app')
// Load the index.html when not in development
win.loadURL('app://./index.html')
}
}
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
try {
//await installExtension(VUEJS_DEVTOOLS)
// vuedev tools for vue3
await installExtension('ljjemllljcmogpfapbkkighbhhppjdbg')
} catch (e) {
console.error('Vue Devtools failed to install:', e.toString())
}
}
createWindow()
})
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === 'win32') {
process.on('message', (data) => {
if (data === 'graceful-exit') {
app.quit()
}
})
} else {
process.on('SIGTERM', () => {
app.quit()
})
}
}

View File

@ -0,0 +1,33 @@
<template>
<div>
<p>{{ msg }}</p>
</div>
</template>
<script>
import axios from 'axios';
export default {
name: 'HelloWolrd',
data() {
return {
msg: '',
};
},
methods: {
getMessage() {
axios.get('/months')
.then((res) => {
this.msg = res.data;
})
.catch((error) => {
console.error(error);
});
},
},
created() {
this.getMessage();
},
};
</script>

View File

@ -1,21 +0,0 @@
<template>
<div class="content">
Content
</div>
</template>
<script>
export default {
name: 'Content',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.content {
background-color: red;
}
</style>

View File

@ -1,21 +0,0 @@
<template>
<nav>
<router-link to="/"> Home </router-link>
<router-link to="/config"> Config </router-link>
</nav>
</template>
<script>
export default {
name: 'Nav',
props: {
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
nav {
background-color: green;
}
</style>

View File

@ -1,8 +1,14 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from '@/App.vue' import axios from 'axios';
import router from '@/router'
const app = createApp(App) import App from './App.vue'
app.use(router) import router from './router'
app.mount('#app')
const app = createApp(App);
axios.defaults.withCredentials = true;
axios.defaults.baseURL = 'http://localhost:8000/';
app.use(router);
app.mount('#app');

View File

@ -1,20 +0,0 @@
import { createRouter, createWebHistory } from 'vue-router'
import Home from "@/views/home.vue"
import Config from "@/views/config.vue"
const routes = [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/config',
name: 'config',
component: Config
}
]
const router = createRouter({ history: createWebHistory(), routes })
export default router

25
front/src/router/index.js Normal file
View File

@ -0,0 +1,25 @@
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const routes = [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
export default router

View File

@ -0,0 +1,5 @@
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>

View File

@ -0,0 +1,18 @@
<template>
<div class="home">
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: 'HomeView',
components: {
HelloWorld
}
}
</script>

View File

@ -1,3 +0,0 @@
<template>
<h1>Config</h1>
</template>

View File

@ -1,3 +0,0 @@
<template>
<h1>Home</h1>
</template>

4
front/vue.config.js Normal file
View File

@ -0,0 +1,4 @@
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})

File diff suppressed because it is too large Load Diff