Browse Source

Aaaaah Webpack!!! y u so huge? (and switch to dep for Go dependencies)

feature-rest
Moritz Marquardt 1 year ago
parent
commit
bf4078233f
53 changed files with 12040 additions and 11182 deletions
  1. +9
    -0
      .editorconfig
  2. +14
    -0
      .gitignore
  3. +43
    -0
      .run
  4. +8
    -0
      .watch
  5. +63
    -0
      Gopkg.lock
  6. +11
    -0
      Gopkg.toml
  7. +2
    -2
      README.md
  8. +12
    -0
      frontend/.babelrc
  9. +9
    -0
      frontend/.editorconfig
  10. +10
    -0
      frontend/.postcssrc.js
  11. +41
    -0
      frontend/build/build.js
  12. +54
    -0
      frontend/build/check-versions.js
  13. BIN
      frontend/build/logo.png
  14. +101
    -0
      frontend/build/utils.js
  15. +22
    -0
      frontend/build/vue-loader.conf.js
  16. +81
    -0
      frontend/build/webpack.base.conf.js
  17. +96
    -0
      frontend/build/webpack.dev.conf.js
  18. +145
    -0
      frontend/build/webpack.prod.conf.js
  19. +7
    -0
      frontend/config/dev.env.js
  20. +69
    -0
      frontend/config/index.js
  21. +4
    -0
      frontend/config/prod.env.js
  22. +11
    -0
      frontend/index.html
  23. +10798
    -0
      frontend/package-lock.json
  24. +62
    -0
      frontend/package.json
  25. +13
    -0
      frontend/src/App.vue
  26. +121
    -0
      frontend/src/api.js
  27. BIN
      frontend/src/assets/logo.png
  28. +38
    -0
      frontend/src/components/Courses.vue
  29. +151
    -0
      frontend/src/components/Tasks.vue
  30. +14
    -0
      frontend/src/main.js
  31. +22
    -0
      frontend/src/router/index.js
  32. +0
    -0
      frontend/static/.gitkeep
  33. +6
    -6
      frontend/static/fontawesome-all.css
  34. +0
    -0
      frontend/static/fontawesome/fa-brands-400.eot
  35. +0
    -0
      frontend/static/fontawesome/fa-brands-400.svg
  36. +0
    -0
      frontend/static/fontawesome/fa-brands-400.ttf
  37. +0
    -0
      frontend/static/fontawesome/fa-brands-400.woff
  38. +0
    -0
      frontend/static/fontawesome/fa-brands-400.woff2
  39. +0
    -0
      frontend/static/fontawesome/fa-regular-400.eot
  40. +0
    -0
      frontend/static/fontawesome/fa-regular-400.svg
  41. +0
    -0
      frontend/static/fontawesome/fa-regular-400.ttf
  42. +0
    -0
      frontend/static/fontawesome/fa-regular-400.woff
  43. +0
    -0
      frontend/static/fontawesome/fa-regular-400.woff2
  44. +0
    -0
      frontend/static/fontawesome/fa-solid-900.eot
  45. +0
    -0
      frontend/static/fontawesome/fa-solid-900.svg
  46. +0
    -0
      frontend/static/fontawesome/fa-solid-900.ttf
  47. +0
    -0
      frontend/static/fontawesome/fa-solid-900.woff
  48. +0
    -0
      frontend/static/fontawesome/fa-solid-900.woff2
  49. +0
    -0
      frontend/static/style.css
  50. +3
    -6
      main.go
  51. +0
    -177
      static/index.html
  52. +0
    -51
      static/landing.html
  53. +0
    -10940
      static/vue.js

+ 9
- 0
.editorconfig View File

@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

+ 14
- 0
.gitignore View File

@@ -0,0 +1,14 @@
/vendor/
/storage.db
/Votierungstracker
/frontend/dist/
/frontend/node_modules/
/frontend/npm-debug.log*

.DS_Store
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln

+ 43
- 0
.run View File

@@ -0,0 +1,43 @@
# Install https://github.com/moqmar/run for easy development

##############
## Frontend ##
##############

frontend Builds the frontend code using Webpack and Stylus: |
cd frontend; [ -d node_modules ] || npm install
npm run build

frontend-dev Builds the frontend code and watches for file changes: |
cd frontend; [ -d node_modules ] || npm install
PORT=8999 npm run dev

npm Updates npm packages: cd frontend && npm install

#############
## Backend ##
#############

backend Builds the backend code using Go: go build

backend-dev Builds the backend code and watches for file changes: |
go build
node .watch '*.go' -- sh -c 'go build && kill `pkill -fx ./Votierungstracker` 2>/dev/null'


################
## Everything ##
################

run Builds and starts the application: |
run frontend-dev & pid1=$!
run backend-dev & pid2=$!
sigterm_happened=
trap "sigterm_happened=1; pkill -fx ./Votierungstracker || echo -n" SIGINT SIGTERM
while true; do
./Votierungstracker || echo -n
if [ -n "$sigterm_happened" ]; then
kill -TERM $pid1 $pid2 2>/dev/null || echo -n
wait; exit 0
fi
done

+ 8
- 0
.watch View File

@@ -0,0 +1,8 @@
let cmd="", args=[], files=[], dash=false;
process.argv.forEach(x => { if (dash && !cmd) cmd=x; else if (x === "--") dash = true; else (dash ? args : files).push(x) });

let sem=0;
function update() { if(sem) return sem=2; else sem=1; require("child_process").spawn(cmd, args, {stdio:"inherit"}).on("exit", (c) => {
if (sem > 1) { sem = 0; update(); } else sem = 0;
})}
require("./frontend/node_modules/chokidar").watch([...files]).on("all", (e) => { if (e === "change") update() });

+ 63
- 0
Gopkg.lock View File

@@ -0,0 +1,63 @@
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.


[[projects]]
branch = "master"
name = "github.com/gin-contrib/sse"
packages = ["."]
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"

[[projects]]
name = "github.com/gin-gonic/gin"
packages = [
".",
"binding",
"render"
]
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
version = "v1.2"

[[projects]]
name = "github.com/golang/protobuf"
packages = ["proto"]
revision = "5a0f697c9ed9d68fef0116532c6e05cfeae00e55"

[[projects]]
name = "github.com/mattn/go-isatty"
packages = ["."]
revision = "57fdcb988a5c543893cc61bce354a6e24ab70022"

[[projects]]
name = "github.com/mattn/go-sqlite3"
packages = ["."]
revision = "6c771bb9887719704b210e87e934f08be014bdb1"
version = "v1.6.0"

[[projects]]
name = "github.com/ugorji/go"
packages = ["codec"]
revision = "c88ee250d0221a57af388746f5cf03768c21d6e2"

[[projects]]
branch = "master"
name = "golang.org/x/sys"
packages = ["unix"]
revision = "7db1c3b1a98089d0071c84f646ff5c96aad43682"

[[projects]]
name = "gopkg.in/go-playground/validator.v8"
packages = ["."]
revision = "5f57d2222ad794d0dffb07e664ea05e2ee07d60c"
version = "v8.18.1"

[[projects]]
name = "gopkg.in/yaml.v2"
packages = ["."]
revision = "a5b47d31c556af34a302ce5d659e6fea44d90de0"

[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "dc41cd78e1dbbe9abc3d913bdb5d056374b6f5f1bbaf8e73d42bbf20ebbb9935"
solver-name = "gps-cdcl"
solver-version = 1

+ 11
- 0
Gopkg.toml View File

@@ -0,0 +1,11 @@
[[constraint]]
name = "github.com/gin-gonic/gin"
version = "1.2.0"

[[constraint]]
name = "github.com/mattn/go-sqlite3"
version = "1.6.0"

[prune]
go-tests = true
unused-packages = true

+ 2
- 2
README.md View File

@@ -1,6 +1,6 @@
# Votierungstracker

Diese Webapp entwickel ich hauptsächlich für mich selber. Ich möchte gerne eine schnelle, minimale Möglichkeit meine Vortierungen/Vorträge und Punkte in Kursen zu speichern.
Diese Webapp entwickel ich hauptsächlich für mich selber. Ich möchte gerne eine schnelle, minimale Möglichkeit meine Vortierungen/Vorträge und Punkte in Kursen zu speichern.

Die App soll über https://vote.zottelchin.de erreichbar sein.

@@ -26,7 +26,7 @@ In einer V2.0 wird Verschlüsselung und Sicherheit hinzugefügt

Das Frontend: Vue.js und CSS Framework
^
| JSON
| JSON
v
Backend Golang mit Gin als Webframework und SQLite für die Datenspeicherung


+ 12
- 0
frontend/.babelrc View File

@@ -0,0 +1,12 @@
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"]
}

+ 9
- 0
frontend/.editorconfig View File

@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

+ 10
- 0
frontend/.postcssrc.js View File

@@ -0,0 +1,10 @@
// https://github.com/michael-ciniawsky/postcss-load-config

module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}

+ 41
- 0
frontend/build/build.js View File

@@ -0,0 +1,41 @@
'use strict'
require('./check-versions')()

process.env.NODE_ENV = 'production'

const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')

const spinner = ora('building for production...')
spinner.start()

rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')

if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}

console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})

+ 54
- 0
frontend/build/check-versions.js View File

@@ -0,0 +1,54 @@
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')

function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}

const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]

if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}

module.exports = function () {
const warnings = []

for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]

if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}

if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()

for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}

console.log()
process.exit(1)
}
}

BIN
frontend/build/logo.png View File

Before After
Width: 200  |  Height: 200  |  Size: 6.7KB

+ 101
- 0
frontend/build/utils.js View File

@@ -0,0 +1,101 @@
'use strict'
const path = require('path')
const config = require('../config')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const packageConfig = require('../package.json')

exports.assetsPath = function (_path) {
const assetsSubDirectory = process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory

return path.posix.join(assetsSubDirectory, _path)
}

exports.cssLoaders = function (options) {
options = options || {}

const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}

const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}

// generate loader string to be used with extract text plugin
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader] : [cssLoader]

if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}

// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader'
})
} else {
return ['vue-style-loader'].concat(loaders)
}
}

// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}

// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function (options) {
const output = []
const loaders = exports.cssLoaders(options)

for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}

return output
}

exports.createNotifierCallback = () => {
const notifier = require('node-notifier')

return (severity, errors) => {
if (severity !== 'error') return

const error = errors[0]
const filename = error.file && error.file.split('!').pop()

notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}

+ 22
- 0
frontend/build/vue-loader.conf.js View File

@@ -0,0 +1,22 @@
'use strict'
const utils = require('./utils')
const config = require('../config')
const isProduction = process.env.NODE_ENV === 'production'
const sourceMapEnabled = isProduction
? config.build.productionSourceMap
: config.dev.cssSourceMap

module.exports = {
loaders: utils.cssLoaders({
sourceMap: sourceMapEnabled,
extract: isProduction
}),
cssSourceMap: sourceMapEnabled,
cacheBusting: config.dev.cacheBusting,
transformToRequire: {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href'
}
}

+ 81
- 0
frontend/build/webpack.base.conf.js View File

@@ -0,0 +1,81 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')

function resolve (dir) {
return path.join(__dirname, '..', dir)
}



module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': resolve('src'),
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}

+ 96
- 0
frontend/build/webpack.dev.conf.js View File

@@ -0,0 +1,96 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')

const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)

const devWebpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({ sourceMap: config.dev.cssSourceMap, usePostCSS: true })
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,

// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})

module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port

// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
clearConsole: false,
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))

resolve(devWebpackConfig)
}
})
})

+ 145
- 0
frontend/build/webpack.prod.conf.js View File

@@ -0,0 +1,145 @@
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')

const env = require('../config/prod.env')

const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
// Setting the following option to `false` will not extract CSS from codesplit chunks.
// Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack.
// It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`,
// increasing file size: https://github.com/vuejs-templates/webpack/issues/1110
allChunks: true,
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false } }
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),

// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})

if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')

webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}

if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}

module.exports = webpackConfig

+ 7
- 0
frontend/config/dev.env.js View File

@@ -0,0 +1,7 @@
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')

module.exports = merge(prodEnv, {
NODE_ENV: '"development"'
})

+ 69
- 0
frontend/config/index.js View File

@@ -0,0 +1,69 @@
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')

module.exports = {
dev: {

// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},

// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

/**
* Source Maps
*/

// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',

// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,

cssSourceMap: true
},

build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),

// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',

/**
* Source Maps
*/

productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',

// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],

// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}

+ 4
- 0
frontend/config/prod.env.js View File

@@ -0,0 +1,4 @@
'use strict'
module.exports = {
NODE_ENV: '"production"'
}

+ 11
- 0
frontend/index.html View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Votierungstracker | zottelchin.de</title>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css">
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
<link rel="stylesheet" href="/fontawesome-all.css">
</head>

<div id="app"></div>

+ 10798
- 0
frontend/package-lock.json
File diff suppressed because it is too large
View File


+ 62
- 0
frontend/package.json View File

@@ -0,0 +1,62 @@
{
"name": "votierungstracker",
"version": "1.0.0",
"description": "Eine schnelle, minimale Möglichkeit, Vortierungen/Vorträge und Punkte in Kursen zu speichern",
"author": "Phillipp Engelke <zottelchin@gmail.com>",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"build": "node build/build.js"
},
"dependencies": {
"vue": "^2.5.2",
"vue-router": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"css-loader": "^0.28.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^2.30.1",
"node-notifier": "^5.1.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^0.5.8",
"vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}

+ 13
- 0
frontend/src/App.vue View File

@@ -0,0 +1,13 @@
<template>
<div id="app">
<router-view/>
</div>
</template>

<script>
import api from "./api"
if (window.location.host.match(/^(?:localhost|127\.\d+\.\d+\.\d+|\[::1?\]):8999/)) api.setEndpoint("http://" + window.location.hostname + ":8900/api")
export default {
name: "app"
}
</script>

+ 121
- 0
frontend/src/api.js View File

@@ -0,0 +1,121 @@
let endpoint = "/api";

function fetchResponseHandler(res) {
return new Promise(function(resolve, reject) {
(res.headers.get("Content-Type").match(/^application\/json(?:$|;)/) ? res.json() : res.text()).then(function(body) {
resolve({ body: body, response: res })
}, reject)
})
}

function sendWithBody(method, path, body, headers, options) {
let type = "text/plain";
if (body instanceof FormData) type = "multipart/form-data";
else if (body instanceof URLSearchParams) type = "application/x-www-form-urlencoded";
else if (body instanceof Object) { type = "application/json"; body = JSON.stringify(body); }

return fetch(path, {
...options,
method: method,
body,
headers: { "Content-Type": type, ...headers, ...(options ? options.headers : {}) }
}).then(fetchResponseHandler);
}

/**
* Change the API root URL
* @param {string} url New API root URL, without trailing slash (e.g. "https://api.example.org")
*/
function setEndpoint(url) {
endpoint = url;
}

/**
* Send a GET request to the API
* @param {string} path Path of the REST endpoint to request
* @param {object} headers Headers to set on the request
* @param {object} options Other options to forward to fetch()
* @returns {Promise<{body, response}>}
*/
function get(path, headers, options) {
return fetch(path, {
...options,
headers: { ...headers, ...(options ? options.headers : {}) }
}).then(fetchResponseHandler);
}

/**
* Send a POST request to the API
* @param {string} path Path of the REST endpoint to request
* @param {string|object|FormData|URLSearchParams} body Request body to send to the API; the content type will be determined automatically (text/plain, application/json, multipart/form-data, application/x-www-form-urlencoded)
* @param {object} headers Headers to set on the request
* @param {object} options Other options to forward to fetch()
* @returns {Promise<{body, response}>}
*/
function post(path, body, headers, options) {
return sendWithBody("POST", path, body, headers, options);
}

/**
* Send a PUT request to the API
* @param {string} path Path of the REST endpoint to request
* @param {string|object|FormData|URLSearchParams} body Request body to send to the API; the content type will be determined automatically (text/plain, application/json, multipart/form-data, application/x-www-form-urlencoded)
* @param {object} headers Headers to set on the request
* @param {object} options Other options to forward to fetch()
* @returns {Promise<{body, response}>}
*/
function put(path, body, headers, options) {
return sendWithBody("PUT", path, body, headers, options);
}

/**
* Send a DELETE request to the API
* @param {string} path Path of the REST endpoint to request
* @param {object} headers Headers to set on the request
* @param {object} options Other options to forward to fetch()
* @returns {Promise<{body, response}>}
*/
function del(path, headers, options) {
return fetch(path, {
method: "delete",
...options,
headers: { ...headers, ...(options ? options.headers : {}) }
}).then(fetchResponseHandler);
}

/**
* Send a HEAD request to the API
* @param {string} path Path of the REST endpoint to request
* @param {object} headers Headers to set on the request
* @param {object} options Other options to forward to fetch()
* @returns {Promise<Response>}
*/
function head(path, headers, options) {
return fetch(path, {
method: "head",
...options,
headers: { ...headers, ...(options ? options.headers : {}) }
});
}

/**
* Send a PATCH request to the API
* @param {string} path Path of the REST endpoint to request
* @param {string|object|FormData|URLSearchParams} body Request body to send to the API; the content type will be determined automatically (text/plain, application/json, multipart/form-data, application/x-www-form-urlencoded)
* @param {object} headers Headers to set on the request
* @param {object} options Other options to forward to fetch()
* @returns {Promise<{body, response}>}
*/
function patch(path, body, headers, options) {
return sendWithBody("PATCH", path, body, headers, options);
}

export default {
setEndpoint,
get,
post,
put,
del,
head,
patch
}

BIN
frontend/src/assets/logo.png View File

Before After
Width: 200  |  Height: 200  |  Size: 6.7KB

+ 38
- 0
frontend/src/components/Courses.vue View File

@@ -0,0 +1,38 @@
<template>
<div id="wrapper" class="container">
<h1>Votierungstracker</h1>

<label for="user"></label>
<input type="text" id="user" v-model="username">
<button @click="searchUser">Suchen</button>

<ul>
<li v-for="entry in userClasses">
<a :href=getLink(entry)>{{ entry.class }}</a>
</li>
</ul>
</div>
</template>

<script>
import api from "../api"
export default {
data() {
return {
username: "",
userClasses: []
}
},
methods: {
searchUser() {
api.get("/getUser/" + this.username).then(res => {
this.userClasses = res.body.items ? res.body.items : []
})
console.log("yaaa")
},
getLink(entry) {
return "/class?user=" + entry.user + "&class=" + entry.class
}
}
}
</script>

+ 151
- 0
frontend/src/components/Tasks.vue View File

@@ -0,0 +1,151 @@
<template>
<div id="wrapper" class="container">
<a href="/"><h1>Votierungstracker</h1></a>
<div class="row">
<div class="column">
<table>
<thead>
<tr>
<th v-for="key in gridColumns">
{{ key }}
</th>
<th class="small"></th>
</tr>
</thead>
<tbody>
<tr v-for="(entry, index) in gridData">
<td >
{{ entry['task'] }}
</td>
<td>
{{ entry['points'] }}
</td>
<td>
{{ entry['maxPoints'] }}
</td>
<td>
{{ entry['pres'] }}
</td>
<td class="small">
<i class="fas fa-edit" @click="edit(entry)"></i>
<i class="fas fa-trash-alt" @click="deleteItem(index, entry['id'])"></i>
</td>
</tr>
<tr>
<td>
<b>Gesamt</b>
</td>
<td>
<b>{{ gesPoints }}</b>
</td>
<td>
<b>{{ gesMaxPoints }}</b>
</td>
<td>
<b>{{ gesPres }}</b>
</td>
<td>
{{ gesPerc }}
</td>
</tr>
</tbody>
</table>
</div>
<div class="column column-33">
<fieldset>
<label for="Aufgabe">Aufgabe</label>
<input id="Aufgabe" type="text" v-model="editData.task">
<label for="punkte">Punkte</label>
<input id="punkte" type="number" v-model="editData.points">
<label for="maxPoints">m&ouml;gliche Punkte</label>
<input id="maxPoints" type="number" v-model="editData.maxPoints">
<label for="pres">Vortr&auml;ge</label>
<input id="pres" type="number" v-model="editData.pres">
<button class="button" type="button" @click="addTask()" v-if="isNew">Hinzuf&uuml;gen</button>
<button class="button" type="button" @click="saveEditTask()" v-else>&Auml;ndern hochladen</button>
</fieldset>
</div>
</div>
</div>
</template>

<script>
import api from "../api"
export default {
data() {
return {
gridColumns: ['Aufgabe', 'Punkte', 'mögliche Punkte', 'Vorträge'],
gridColumnsShort: ['task', 'points', 'maxPoints', "pres"],
gridData: [],
editData: { maxPoints: 0, points: 0, task: "", pres: 0, id: 0 },
isNew: true,
user: "",
clas: "",
}
},
created() {
this.user = this.$route.query.user
this.clas = this.$route.query.class
api.get('/getVotes/' + this.user + '/' + this.clas).then(res => {
this.gridData = res.body.items ? res.body.items : []
})

},
methods: {
addTask: async function () {
var res = await api.get('/addVotes/' + this.user + '/' + this.clas + '/' + this.editData.task + '/' + this.editData.points + '/' + this.editData.maxPoints + '/' + this.editData.pres)
this.gridData.push({id: Number(res.body.created), task: this.editData.task, points: Number(this.editData.points), maxPoints: Number(this.editData.maxPoints), pres: Number(this.editData.pres)})
this.editData = { maxPoints: 0, points: 0, task: "", pres: 0}


},
deleteItem: function(delId, id) {
this.gridData.splice(delId, 1)
api.get("/deleteVotes/" + id)
//TODO: Im Backend löschen
},
edit: function(row){
this.isNew = false
this.editData.id = Number(row.id)
this.editData.task = row.task
this.editData.points = Number(row.points)
this.editData.maxPoints = Number(row.maxPoints)
this.editData.pres = Number(row.pres)

},
saveEditTask:function(){
//Upload changes

this.isNew = true
this.editData = { maxPoints: 0, points: 0, task: "", pres: 0, id: 0 }
}
},
computed: {
gesPoints: function() {
let res = 0
for (let index in this.gridData){
res += this.gridData[index]['points']
}
return res
},
gesMaxPoints: function() {
let res = 0
for (let index in this.gridData){
res += this.gridData[index]['maxPoints']
}
return res
},
gesPres: function() {
let res = 0
for (let index in this.gridData){
res += Number(this.gridData[index]['pres'])
}
return res
},
gesPerc: function() {
return this.gesPoints ? Math.round(this.gesPoints/this.gesMaxPoints * 1000)/10 + '%' : 0 + '%'
}
}
}
</script>


+ 14
- 0
frontend/src/main.js View File

@@ -0,0 +1,14 @@
import Vue from "vue"
import App from "./App"

import router from "./router"

import resource from "vue-resource"

Vue.config.productionTip = false

new Vue({
el: "#app",
router,
render: h => h(App)
})

+ 22
- 0
frontend/src/router/index.js View File

@@ -0,0 +1,22 @@
import Vue from "vue"
import Router from "vue-router"

import Courses from "@/components/Courses"
import Tasks from "@/components/Tasks"

Vue.use(Router)

export default new Router({
routes: [
{
path: "/",
name: "Courses",
component: Courses
},
{
path: "/class",
name: "Tasks",
component: Tasks
}
]
})

+ 0
- 0
frontend/static/.gitkeep View File


static/css/fontawesome-all.css → frontend/static/fontawesome-all.css View File

@@ -2833,8 +2833,8 @@ readers do not read off random characters that represent icons */
font-family: 'Font Awesome 5 Brands';
font-style: normal;
font-weight: normal;
src: url("../webfonts/fa-brands-400.eot");
src: url("../webfonts/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-brands-400.woff2") format("woff2"), url("../webfonts/fa-brands-400.woff") format("woff"), url("../webfonts/fa-brands-400.ttf") format("truetype"), url("../webfonts/fa-brands-400.svg#fontawesome") format("svg"); }
src: url("fontawesome/fa-brands-400.eot");
src: url("fontawesome/fa-brands-400.eot?#iefix") format("embedded-opentype"), url("fontawesome/fa-brands-400.woff2") format("woff2"), url("fontawesome/fa-brands-400.woff") format("woff"), url("fontawesome/fa-brands-400.ttf") format("truetype"), url("fontawesome/fa-brands-400.svg#fontawesome") format("svg"); }

.fab {
font-family: 'Font Awesome 5 Brands'; }
@@ -2842,8 +2842,8 @@ readers do not read off random characters that represent icons */
font-family: 'Font Awesome 5 Free';
font-style: normal;
font-weight: 400;
src: url("../webfonts/fa-regular-400.eot");
src: url("../webfonts/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-regular-400.woff2") format("woff2"), url("../webfonts/fa-regular-400.woff") format("woff"), url("../webfonts/fa-regular-400.ttf") format("truetype"), url("../webfonts/fa-regular-400.svg#fontawesome") format("svg"); }
src: url("fontawesome/fa-regular-400.eot");
src: url("fontawesome/fa-regular-400.eot?#iefix") format("embedded-opentype"), url("fontawesome/fa-regular-400.woff2") format("woff2"), url("fontawesome/fa-regular-400.woff") format("woff"), url("fontawesome/fa-regular-400.ttf") format("truetype"), url("fontawesome/fa-regular-400.svg#fontawesome") format("svg"); }

.far {
font-family: 'Font Awesome 5 Free';
@@ -2852,8 +2852,8 @@ readers do not read off random characters that represent icons */
font-family: 'Font Awesome 5 Free';
font-style: normal;
font-weight: 900;
src: url("../webfonts/fa-solid-900.eot");
src: url("../webfonts/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("../webfonts/fa-solid-900.woff2") format("woff2"), url("../webfonts/fa-solid-900.woff") format("woff"), url("../webfonts/fa-solid-900.ttf") format("truetype"), url("../webfonts/fa-solid-900.svg#fontawesome") format("svg"); }
src: url("fontawesome/fa-solid-900.eot");
src: url("fontawesome/fa-solid-900.eot?#iefix") format("embedded-opentype"), url("fontawesome/fa-solid-900.woff2") format("woff2"), url("fontawesome/fa-solid-900.woff") format("woff"), url("fontawesome/fa-solid-900.ttf") format("truetype"), url("fontawesome/fa-solid-900.svg#fontawesome") format("svg"); }

.fa,
.fas {

static/webfonts/fa-brands-400.eot → frontend/static/fontawesome/fa-brands-400.eot View File


static/webfonts/fa-brands-400.svg → frontend/static/fontawesome/fa-brands-400.svg View File


static/webfonts/fa-brands-400.ttf → frontend/static/fontawesome/fa-brands-400.ttf View File


static/webfonts/fa-brands-400.woff → frontend/static/fontawesome/fa-brands-400.woff View File


static/webfonts/fa-brands-400.woff2 → frontend/static/fontawesome/fa-brands-400.woff2 View File


static/webfonts/fa-regular-400.eot → frontend/static/fontawesome/fa-regular-400.eot View File


static/webfonts/fa-regular-400.svg → frontend/static/fontawesome/fa-regular-400.svg View File


static/webfonts/fa-regular-400.ttf → frontend/static/fontawesome/fa-regular-400.ttf View File


static/webfonts/fa-regular-400.woff → frontend/static/fontawesome/fa-regular-400.woff View File


static/webfonts/fa-regular-400.woff2 → frontend/static/fontawesome/fa-regular-400.woff2 View File


static/webfonts/fa-solid-900.eot → frontend/static/fontawesome/fa-solid-900.eot View File


static/webfonts/fa-solid-900.svg → frontend/static/fontawesome/fa-solid-900.svg View File


static/webfonts/fa-solid-900.ttf → frontend/static/fontawesome/fa-solid-900.ttf View File


static/webfonts/fa-solid-900.woff → frontend/static/fontawesome/fa-solid-900.woff View File


static/webfonts/fa-solid-900.woff2 → frontend/static/fontawesome/fa-solid-900.woff2 View File


static/style.css → frontend/static/style.css View File


+ 3
- 6
main.go View File

@@ -35,12 +35,9 @@ func main() {
migrate(db)
router := gin.Default()

router.StaticFile("/class", "static/index.html")
router.StaticFile("/", "static/landing.html")
router.StaticFile("/vue.js", "static/vue.js")
router.StaticFile("/style.css", "static/style.css")
router.StaticFile("/fontawesome-all.css", "static/css/fontawesome-all.css")
router.Static("/webfonts", "static/webfonts/")
router.StaticFile("/class", "frontend/dist/index.html")
router.StaticFile("/", "frontend/dist/index.html")
router.Static("/static/", "frontend/dist/static/")

router.GET("/api/getVotes/:user/:class", func(c *gin.Context) {
getUserTable(c, db)

+ 0
- 177
static/index.html View File

@@ -1,177 +0,0 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Votierungstracker | zottelchin.de</title>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css">
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
<link rel="stylesheet" href="/fontawesome-all.css">
<script src="vue.js"></script>
<script src="//cdn.jsdelivr.net/npm/vue-resource@1.5.0"></script>
<script src="//unpkg.com/vue-router"></script>
</head>

<body>
<div id="wrapper" class="container">
<a href="/"><h1>Votierungstracker</h1></a>
<div id="app" class="row">

<div class="column">
<table>
<thead>
<tr>
<th v-for="key in gridColumns">
{{ key }}
</th>
<th class="small"></th>
</tr>
</thead>
<tbody>
<tr v-for="(entry, index) in gridData">
<td >
{{ entry['task'] }}
</td>
<td>
{{ entry['points'] }}
</td>
<td>
{{ entry['maxPoints'] }}
</td>
<td>
{{ entry['pres'] }}
</td>
<td class="small">
<i class="fas fa-edit" @click="edit(entry)"></i>
<i class="fas fa-trash-alt" @click="deleteItem(index, entry['id'])"></i>
</td>
</tr>
<tr>
<td>
<b>Gesamt</b>
</td>
<td>
<b>{{ gesPoints }}</b>
</td>
<td>
<b>{{ gesMaxPoints }}</b>
</td>
<td>
<b>{{ gesPres }}</b>
</td>
<td>
{{ gesPerc }}
</td>
</tr>
</tbody>
</table>
</div>
<div class="column column-33">
<fieldset>
<label for="Aufgabe">Aufgabe</label>
<input id="Aufgabe" type="text" v-model="editData.task">
<label for="punkte">Punkte</label>
<input id="punkte" type="number" v-model="editData.points">
<label for="maxPoints">m&ouml;gliche Punkte</label>
<input id="maxPoints" type="number" v-model="editData.maxPoints">
<label for="pres">Vortr&auml;ge</label>
<input id="pres" type="number" v-model="editData.pres">
<button class="button" type="button" @click="addTask()" v-if="isNew">Hinzuf&uuml;gen</button>
<button class="button" type="button" @click="saveEditTask()" v-else="isNew">&Auml;ndern hochladen</button>
</fieldset>
</div>
</div>
</div>

<script>
var router = new VueRouter({
mode: 'history',
routes: []
});

// bootstrap the demo
var demo = new Vue({
router,
el: '#app',
data: {
gridColumns: ['Aufgabe', 'Punkte', 'mögliche Punkte', 'Vorträge'],
gridColumnsShort: ['task', 'points', 'maxPoints', "pres"],
gridData: [],
editData: { maxPoints: 0, points: 0, task: "", pres: 0, id: 0 },
isNew: true,
user: "",
clas: "",
},
created: function(){
this.user = this.$route.query.user
this.clas = this.$route.query.class
this.$http.get('/api/getVotes/' + this.user + '/' + this.clas).then(function(response) {
this.gridData = response.data.items ? response.data.items : []
})
},
methods: {
addTask: async function () {
var res = await this.$http.get('/api/addVotes/' + this.user + '/' + this.clas + '/' + this.editData.task + '/' + this.editData.points + '/' + this.editData.maxPoints + '/' + this.editData.pres)
this.gridData.push({id: Number(res.data.created), task: this.editData.task, points: Number(this.editData.points), maxPoints: Number(this.editData.maxPoints), pres: Number(this.editData.pres)})
this.editData = { maxPoints: 0, points: 0, task: "", pres: 0}

},
deleteItem: function(delId, id) {
this.gridData.splice(delId, 1)
this.$http.get('/api/deleteVotes/' + id)
//TODO: Im Backend löschen
},
edit: function(row){
this.isNew = false
this.editData.id = Number(row.id)
this.editData.task = row.task
this.editData.points = Number(row.points)
this.editData.maxPoints = Number(row.maxPoints)
this.editData.pres = Number(row.pres)
},
saveEditTask:function(){
//Upload changes
this.isNew = true
this.editData = { maxPoints: 0, points: 0, task: "", pres: 0, id: 0 }
}
},
computed: {
gesPoints: function() {
res = 0
for (let index in this.gridData){
res += this.gridData[index]['points']
}
return res
},
gesMaxPoints: function() {
res = 0
for (let index in this.gridData){
res += this.gridData[index]['maxPoints']
}
return res
},
gesPres: function() {
res = 0
for (let index in this.gridData){
res += Number(this.gridData[index]['pres'])
}
return res
},
gesPerc: function() {
return this.gesPoints ? Math.round(this.gesPoints/this.gesMaxPoints * 1000)/10 + '%' : 0 + '%'
}
}
})
</script>

</body>

</html>

+ 0
- 51
static/landing.html View File

@@ -1,51 +0,0 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>Votierungstracker | zottelchin.de</title>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="//cdn.rawgit.com/necolas/normalize.css/master/normalize.css">
<link rel="stylesheet" href="//cdn.rawgit.com/milligram/milligram/master/dist/milligram.min.css">
<link rel="stylesheet" href="/fontawesome-all.css">
<script src="vue.js"></script>
<script src="//cdn.jsdelivr.net/npm/vue-resource@1.5.0"></script>
</head>

<body>
<h1>Votierungstracker</h1>
<div id="app">
<label for="user"></label>
<input type="text" id="user" v-model="username">
<button @click="searchUser">Suchen</button>

<ul>
<li v-for="entry in userClasses">
<a :href=getLink(entry)>{{ entry.class }}</a>
</li>
</ul>

</div>

<script>
var app = new Vue({
el: '#app',
data: {
username: "",
userClasses: []
},
methods: {
searchUser: function () {
this.$http.get('/api/getUser/' + this.username).then(function (response) {
this.userClasses = response.data.items ? response.data.items : []
})
console.log("yaaa")
},
getLink: function (entry) {
return "/class?user=" + entry.user + "&class=" + entry.class
}
}
})
</script>

</body>

+ 0
- 10940
static/vue.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save