Start of web app
This commit is contained in:
parent
fcfc200410
commit
483f6c8bd6
@ -1,16 +1,50 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div id="nav">
|
<a v-if="started" v-on:click.prevent="finish" href="#">Закончить</a>
|
||||||
<router-link to="/">Home</router-link> |
|
<a v-else v-on:click.prevent="start" href="#">Начать</a>
|
||||||
<router-link to="/about">About</router-link>
|
|
||||||
</div>
|
|
||||||
<router-view />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import qs from 'qs';
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
started: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
const haystack = window.location.search || window.location.hash;
|
||||||
|
const q = haystack.substring(haystack.indexOf('?') + 1, haystack.length);
|
||||||
|
const query = qs.parse(q);
|
||||||
|
const profile = query['profile'] || '';
|
||||||
|
console.log('PROFILE', query, profile);
|
||||||
|
const p = fetch('/api/status?profile_id=' + profile, {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
p.then(response => {
|
||||||
|
return response.json();
|
||||||
|
}).then(data => {
|
||||||
|
this.started = data.started;
|
||||||
|
console.log('DATA', data);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
start() {
|
||||||
|
console.log('START');
|
||||||
|
this.started = true;
|
||||||
|
},
|
||||||
|
finish() {
|
||||||
|
console.log('FINISH');
|
||||||
|
this.started = false;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
#app {
|
#app {
|
||||||
font-family: "Avenir", Helvetica, Arial, sans-serif;
|
font-family: 'Avenir', Helvetica, Arial, sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -104,10 +104,10 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "HelloWorld",
|
name: 'HelloWorld',
|
||||||
props: {
|
props: {
|
||||||
msg: String
|
msg: String,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
// @ is an alias to /src
|
// @ is an alias to /src
|
||||||
import HelloWorld from "../components/HelloWorld.vue";
|
import HelloWorld from '../components/HelloWorld.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "home",
|
name: 'home',
|
||||||
components: {
|
components: {
|
||||||
HelloWorld
|
HelloWorld,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
14
package-lock.json
generated
14
package-lock.json
generated
@ -5359,9 +5359,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"qs": {
|
"qs": {
|
||||||
"version": "6.5.2",
|
"version": "6.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.9.0.tgz",
|
||||||
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
|
"integrity": "sha512-27RP4UotQORTpmNQDX8BHPukOnBP3p1uUJY5UnDhaJB+rMt9iMsok724XL+UHU23bEFOHRMQ2ZhI99qOWUMGFA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"query-string": {
|
"query-string": {
|
||||||
@ -5657,6 +5657,14 @@
|
|||||||
"tough-cookie": "~2.4.3",
|
"tough-cookie": "~2.4.3",
|
||||||
"tunnel-agent": "^0.6.0",
|
"tunnel-agent": "^0.6.0",
|
||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"qs": {
|
||||||
|
"version": "6.5.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
|
||||||
|
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-directory": {
|
"require-directory": {
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
"node-sass": "^4.13.0",
|
"node-sass": "^4.13.0",
|
||||||
"postcss-loader": "^3.0.0",
|
"postcss-loader": "^3.0.0",
|
||||||
"prettier": "^1.18.2",
|
"prettier": "^1.18.2",
|
||||||
|
"qs": "^6.9.0",
|
||||||
"sass-loader": "^7.3.1",
|
"sass-loader": "^7.3.1",
|
||||||
"style-loader": "^0.23.1",
|
"style-loader": "^0.23.1",
|
||||||
"underscore": "^1.9.1",
|
"underscore": "^1.9.1",
|
||||||
@ -32,9 +33,9 @@
|
|||||||
"build": "webpack --config webpack.config.js --progress",
|
"build": "webpack --config webpack.config.js --progress",
|
||||||
"build-prod": "webpack --config webpack.config.js --env.production",
|
"build-prod": "webpack --config webpack.config.js --env.production",
|
||||||
"format-webpack": "prettier --single-quote --trailing-comma es5 --write \"./webpack.config.js\"",
|
"format-webpack": "prettier --single-quote --trailing-comma es5 --write \"./webpack.config.js\"",
|
||||||
"format-js": "prettier --single-quote --trailing-comma es5 --write \"./source/_assets/**/*.js\"",
|
"format-js": "prettier --single-quote --trailing-comma es5 --write \"./assets/**/*.js\"",
|
||||||
"format-vue": "prettier --single-quote --trailing-comma es5 --write \"./source/_assets/**/*.vue\"",
|
"format-vue": "prettier --single-quote --trailing-comma es5 --write \"./assets/**/*.vue\"",
|
||||||
"format-style": "prettier --single-quote --write \"source/_assets/**/*.scss\"",
|
"format-style": "prettier --single-quote --write \"assets/**/*.scss\"",
|
||||||
"format-md": "prettier --print-width=80 --parser=markdown --write \"source/**/*.md\""
|
"format-md": "prettier --print-width=80 --parser=markdown --write \"source/**/*.md\""
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
|
@ -24,10 +24,11 @@ post "/api/finish" do |env|
|
|||||||
env.response.status_code = 204
|
env.response.status_code = 204
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/api/remaining-time" do |env|
|
get "/api/status" do |env|
|
||||||
profile = app.profile Dayoff::ProfileId.new(env.get("profile_id").to_s)
|
profile = app.profile Dayoff::ProfileId.new(env.get("profile_id").to_s)
|
||||||
rem_span = profile.remaining_time now
|
rem_span = profile.remaining_time now
|
||||||
data = {
|
data = {
|
||||||
|
started: profile.started?,
|
||||||
hours: rem_span.total_hours.to_i32,
|
hours: rem_span.total_hours.to_i32,
|
||||||
minutes: rem_span.minutes.to_i32,
|
minutes: rem_span.minutes.to_i32,
|
||||||
}
|
}
|
||||||
@ -35,4 +36,8 @@ get "/api/remaining-time" do |env|
|
|||||||
data.to_json
|
data.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get "/" do
|
||||||
|
render "public/index.ecr"
|
||||||
|
end
|
||||||
|
|
||||||
Kemal.run
|
Kemal.run
|
||||||
|
@ -34,8 +34,12 @@ module Dayoff
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def started? : Bool
|
||||||
|
!started_point.nil?
|
||||||
|
end
|
||||||
|
|
||||||
def start(time : Time) : Nil
|
def start(time : Time) : Nil
|
||||||
if started_point
|
if started?
|
||||||
raise AlreadyStarted.new
|
raise AlreadyStarted.new
|
||||||
end
|
end
|
||||||
@wrecords.each do |wr|
|
@wrecords.each do |wr|
|
||||||
|
Loading…
Reference in New Issue
Block a user