First version of diabets kalk

This commit is contained in:
Milvert Simon 2020-10-04 15:44:59 +02:00
parent 4c5b5b4405
commit 75ba28f3af
7 changed files with 49 additions and 26 deletions

View File

@ -1,2 +0,0 @@
# diabets_app

View File

@ -0,0 +1,24 @@
FROM node:lts-alpine as build-stage
# make the 'app' folder the current working directory
WORKDIR /client
# copy both 'package.json' and 'package-lock.json' (if available)
COPY package.json ./
# install project dependencies
RUN npm install
# copy project files and folders to the current working directory (i.e. 'app' folder)
COPY . .
# build app for production with minification
RUN npm run build
# production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /client/dist /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

BIN
client/public/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<link rel="icon" href="<%= BASE_URL %>favicon.png">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>

View File

@ -2,7 +2,7 @@
<div id="app">
<div id="nav">
<b-navbar variant="faded" type="light">
<b-navbar-brand href="#">CalcMilvert</b-navbar-brand>
<b-navbar-brand href="#">Diabets Kalkylator</b-navbar-brand>
</b-navbar>
</div>
<router-view />

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View File

@ -11,29 +11,29 @@
<form @submit.prevent='submit'>
<b-row>
<b-col>
<label for='form.number1'>Ange ditt totala inslunintag</label>
<label for='form.total'>Ange ditt totala inslunintag</label>
<b-form-input
id='form.number1'
v-model='form.number1'
id='form.total'
v-model='form.total'
number
placeholder='Enter first number'
type='number'
:class='{ hasError: $v.form.number1.$error }'
@input='$v.form.number1.$touch()'
:state='!$v.form.number1.$error && null'
:class='{ hasError: $v.form.total.$error }'
@input='$v.form.total.$touch()'
:state='!$v.form.total.$error && null'
></b-form-input>
</b-col>
<b-col>
<label for='form.number2'>Ange måltidens kolhydrater</label>
<label for='form.carb'>Ange måltidens kolhydrater</label>
<b-form-input
id='form.number2'
v-model='form.number2'
id='form.carb'
v-model='form.carb'
number
placeholder='Enter second number'
:class='{ hasError: $v.form.number1.$error }'
:class='{ hasError: $v.form.carb.$error }'
type='number'
@input='$v.form.number2.$touch()'
:state='!$v.form.number2.$error && null'
@input='$v.form.carb.$touch()'
:state='!$v.form.carb.$error && null'
></b-form-input>
</b-col>
</b-row>
@ -77,7 +77,7 @@
</b-form-input>
</b-col>
<b-col>
<label for='form_corr.wanted'>Ange måltidens kolhydrater</label>
<label for='form_corr.wanted'>Vill till</label>
<b-form-input
id='form_corr.wanted'
v-model='form_corr.wanted'
@ -109,8 +109,8 @@ export default {
data() {
return {
form: {
number1: 62,
number2: 0,
total: 62,
carb: '',
morning: false,
},
form_corr: {
@ -127,27 +127,28 @@ export default {
onSubmitCalc(evt) {
evt.preventDefault();
this.$v.form.$touch();
if (this.$v.form_corr.$error) return;
if (this.$v.form.$error) return;
if (this.form.morning) {
this.text = this.form.number1 + this.form.number2;
this.text = (this.form.carb / (300 / this.form.total)).toFixed(1);
this.show = true;
} else {
this.text = this.form.number1 - this.form.number2;
this.text = (this.form.carb / (500 / this.form.total)).toFixed(1);
this.show = true;
}
},
onSubmitCorr(evt) {
evt.preventDefault();
this.$v.form_corr.$touch();
if (this.$v.form.$error) return;
this.text_current = this.form_corr.current - this.form_corr.wanted;
if (this.$v.form_corr.$error) return;
this.text_current = (
this.form_corr.current - this.form_corr.wanted) / (100 / this.form.total);
this.show_current = true;
},
},
validations: {
form: {
number1: { required },
number2: { required },
total: { required },
carb: { required },
},
form_corr: {
current: { required },