initial import

This commit is contained in:
2021-05-05 19:17:01 +00:00
commit 09e1d643b6
54 changed files with 14073 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
.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?
+24
View File
@@ -0,0 +1,24 @@
# edcompanion
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
+5
View File
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}
+12226
View File
File diff suppressed because it is too large Load Diff
+47
View File
@@ -0,0 +1,47 @@
{
"name": "edcompanion",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"bulma": "^0.9.0",
"core-js": "^3.6.5",
"vue": "^2.6.11",
"vue-router": "^3.3.4"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-plugin-eslint": "~4.4.0",
"@vue/cli-plugin-router": "^4.4.6",
"@vue/cli-service": "~4.4.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.14.1",
"sass-loader": "^9.0.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

+17
View File
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<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">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
+33
View File
@@ -0,0 +1,33 @@
<template>
<div id="app">
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="container">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
<img src="https://bulma.io/images/bulma-logo.png" width="112" height="28" />
</a>
<a
role="button"
class="navbar-burger burger"
aria-label="menu"
aria-expanded="false"
data-target="navbarBasicExample"
>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item">Home</a>
</div>
<div class="navbar-end"></div>
</div>
</div>
</nav>
<router-view />
</div>
</template>
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

+7
View File
@@ -0,0 +1,7 @@
@import "~bulma/sass/utilities/initial-variables";
$scheme-main: $black-ter;
$scheme-invert: $white-ter;
$text: $grey-lightest;
@import "~bulma/bulma";
+24
View File
@@ -0,0 +1,24 @@
<template>
<div class="notification" v-bind:class="active ? 'is-success' : 'is-danger'">
<span v-if="active">Connected as {{ channel }}</span>
<span v-else>Disconnected</span>
</div>
</template>
<script>
import eventSource from "@/eventsource";
export default {
name: "Connection",
computed: {
active() {
return eventSource.isConnected()
},
},
props: {
channel: String,
active: Boolean,
},
};
</script>
+14
View File
@@ -0,0 +1,14 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
@@ -0,0 +1,7 @@
import store from '@/store'
export default {
handle(data) {
store.setCreditsAction(data.content)
}
}
@@ -0,0 +1,13 @@
import credits from './credits'
var handlers = {
'credits': credits
}
export default {
handle(data) {
if(handlers[data.type]) {
handlers[data.type].handle(data)
}
}
}
+56
View File
@@ -0,0 +1,56 @@
import store from "../store"
import handler from './handlers'
var connection = null
var onOpenCallback = null
var onCloseCallback = null
const eventSource = {
connect(channel) {
if(connection != null) {
connection.close();
}
connection = new EventSource('/feed/updates/' + channel)
connection.addEventListener("message", function(message) {
var data = JSON.parse(message.data)
handler.handle(data)
store.setRawMessageAction(message.data)
})
connection.addEventListener("open", function () {
if(typeof onOpenCallback === 'function') {
onOpenCallback()
}
})
connection.addEventListener("close", function () {
if(typeof onCloseCallback === 'function') {
onCloseCallback()
}
})
connection.addEventListener("error", function () {
if(connection.readyState !== EventSource.CONNECTING) {
if(typeof onCloseCallback === 'function') {
onCloseCallback()
}
}
})
},
isConnected() {
return connection.readyState === EventSource.OPEN
},
isConnecting() {
return connection.readyState === EventSource.CONNECTING
},
onOpen(callback) {
onOpenCallback = callback
},
onClose(callback) {
onCloseCallback = callback
}
}
export default eventSource
+17
View File
@@ -0,0 +1,17 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import store from './store'
import router from './router'
import './assets/main.scss'
Vue.config.productionTip = false
Vue.use(VueRouter)
new Vue({
data: store.state,
router,
render: h => h(App)
}).$mount('#app')
+27
View File
@@ -0,0 +1,27 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/:channel?',
name: 'Home',
component: Home
}
// {
// 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/About.vue')
// }
]
const router = new VueRouter({
routes
})
export default router
+20
View File
@@ -0,0 +1,20 @@
const store = {
state: {
credits: 0,
message: 'Hello World!',
},
setCreditsAction(newValue) {
this.state.credits = newValue
},
setRawMessageAction(newValue) {
this.state.message = newValue
},
setMessageAction(newValue) {
this.state.message = newValue
},
clearMessageAction() {
this.state.message = ''
}
}
export default store
+61
View File
@@ -0,0 +1,61 @@
<template>
<div class="home">
<Connection v-bind:active="active" v-bind:channel="currentChannel" />
<HelloWorld v-bind:msg="message" />
<div>
Credits: {{ credits }}
</div>
</div>
</template>
<script>
// @ is an alias to /src
import HelloWorld from "@/components/HelloWorld.vue";
import Connection from "@/components/Connection.vue";
import eventSource from "@/eventsource";
var connect = function (channel) {
if (channel != "undefined" && channel != data.currentChannel) {
data.currentChannel = channel;
eventSource.connect(channel);
}
};
var data = {
active: false,
currentChannel: "",
};
export default {
name: "Home",
data() {
return data;
},
computed: {
message() {
return this.$root.message;
},
credits() {
return this.$root.credits;
}
},
watch: {
$route(to) {
connect(to.params.channel);
},
},
created() {
eventSource.onOpen(function () {
data.active = true;
});
eventSource.onClose(function () {
data.active = false;
});
connect(this.$route.params.channel);
},
components: {
HelloWorld,
Connection,
},
};
</script>
+7
View File
@@ -0,0 +1,7 @@
module.exports = {
outputDir: '../src/main/resources/static',
devServer: {
port: 3000,
proxy: 'http://localhost:8080'
}
}