Migrate project to django backend and vue frontend
This commit is contained in:
parent
18d67b9950
commit
3415608f95
|
@ -0,0 +1,15 @@
|
|||
[[source]]
|
||||
name = "pypi"
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[packages]
|
||||
django = "*"
|
||||
djangorestframework = "*"
|
||||
markdown = "*"
|
||||
djangorestframework-simplejwt = "*"
|
||||
|
||||
[requires]
|
||||
python_version = "3.7"
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "a08b9adab76e6720d013fec10cc335a3a771bc09d385694eecbe7fe9cbbaca6c"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {
|
||||
"python_version": "3.7"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"name": "pypi",
|
||||
"url": "https://pypi.org/simple",
|
||||
"verify_ssl": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"default": {
|
||||
"django": {
|
||||
"hashes": [
|
||||
"sha256:275bec66fd2588dd517ada59b8bfb23d4a9abc5a362349139ddda3c7ff6f5ade",
|
||||
"sha256:939652e9d34d7d53d74d5d8ef82a19e5f8bb2de75618f7e5360691b6e9667963"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.1.7"
|
||||
},
|
||||
"djangorestframework": {
|
||||
"hashes": [
|
||||
"sha256:8a435df9007c8b7d8e69a21ef06650e3c0cbe0d4b09e55dd1bd74c89a75a9fcd",
|
||||
"sha256:f7a266260d656e1cf4ca54d7a7349609dc8af4fe2590edd0ecd7d7643ea94a17"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.9.2"
|
||||
},
|
||||
"djangorestframework-simplejwt": {
|
||||
"hashes": [
|
||||
"sha256:03c145cc790bdf7265e2361e95a01bd182d241fbd6ed22c8e6f17d1ebe87ead0",
|
||||
"sha256:d88875f47063b7e7bd5ad30f399e6a1e7044d22e9809beda9e3541f9a58de695"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==4.1.0"
|
||||
},
|
||||
"markdown": {
|
||||
"hashes": [
|
||||
"sha256:c00429bd503a47ec88d5e30a751e147dcb4c6889663cd3e2ba0afe858e009baa",
|
||||
"sha256:d02e0f9b04c500cde6637c11ad7c72671f359b87b9fe924b2383649d8841db7c"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.0.1"
|
||||
},
|
||||
"pyjwt": {
|
||||
"hashes": [
|
||||
"sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e",
|
||||
"sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96"
|
||||
],
|
||||
"version": "==1.7.1"
|
||||
},
|
||||
"pytz": {
|
||||
"hashes": [
|
||||
"sha256:32b0891edff07e28efe91284ed9c31e123d84bea3fd98e1f72be2508f43ef8d9",
|
||||
"sha256:d5f05e487007e29e03409f9398d074e158d920d36eb82eaf66fb1136b0c5374c"
|
||||
],
|
||||
"version": "==2018.9"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'perktree.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
|
@ -0,0 +1,132 @@
|
|||
"""
|
||||
Django settings for perktree project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 2.1.7.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.1/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.1/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = '^j_x7a7u_#9ruh3p^h=*my_k+asoqob&xq@5n^2n2f(7$#dk(#'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
'perktree.localhost'
|
||||
]
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'rest_framework',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'perktree.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'perktree.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
# {
|
||||
# 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
# },
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.1/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
|
||||
REST_FRAMEWORK = {
|
||||
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||
'PAGE_SIZE': 10,
|
||||
'DEFAULT_AUTHENTICATION_CLASSES': (
|
||||
'rest_framework_simplejwt.authentication.JWTAuthentication',
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
"""perktree URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see
|
||||
https://docs.djangoproject.com/en/2.1/topics/http/urls/
|
||||
Examples
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
from rest_framework_simplejwt.views import (
|
||||
TokenObtainPairView,
|
||||
TokenRefreshView,
|
||||
TokenVerifyView,
|
||||
)
|
||||
|
||||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('api/', include([
|
||||
path('admin/', admin.site.urls),
|
||||
path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
|
||||
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
|
||||
path('token/verify/', TokenVerifyView.as_view(), name='token_verify'),
|
||||
]))
|
||||
]
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
WSGI config for perktree project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'perktree.settings')
|
||||
|
||||
application = get_wsgi_application()
|
44
css/app.css
44
css/app.css
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* app.css
|
||||
* Copyright (C) 2019 pavle
|
||||
*
|
||||
* Distributed under terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
|
||||
body {
|
||||
width: 960px;
|
||||
margin: auto;
|
||||
margin-top: 2rem;
|
||||
font: 12px sans-serif;
|
||||
background: #282828;
|
||||
}
|
||||
|
||||
#chart {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.node rect {
|
||||
fill-opacity: .9;
|
||||
shape-rendering: crispEdges;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.node text {
|
||||
pointer-events: none;
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
fill: white;
|
||||
}
|
||||
|
||||
.link {
|
||||
fill: none;
|
||||
stroke: #000;
|
||||
stroke-opacity: .4;
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
stroke-opacity: .8;
|
||||
stroke: #888;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
> 1%
|
||||
last 2 versions
|
||||
not ie <= 8
|
|
@ -0,0 +1,5 @@
|
|||
[*.{js,jsx,ts,tsx,vue}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
|
@ -0,0 +1,267 @@
|
|||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
'extends': [
|
||||
'plugin:vue/essential',
|
||||
'eslint:recommended',
|
||||
],
|
||||
parserOptions: {
|
||||
parser: 'babel-eslint',
|
||||
},
|
||||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'accessor-pairs': 'error',
|
||||
'array-bracket-newline': 'error',
|
||||
'array-bracket-spacing': 'error',
|
||||
'array-callback-return': 'error',
|
||||
'array-element-newline': 'error',
|
||||
'arrow-body-style': 'off',
|
||||
'arrow-parens': ['error'],
|
||||
'arrow-spacing': [
|
||||
'error',
|
||||
{
|
||||
'after': true,
|
||||
'before': true,
|
||||
},
|
||||
],
|
||||
'block-scoped-var': 'error',
|
||||
'block-spacing': 'error',
|
||||
'brace-style': 'error',
|
||||
'callback-return': 'error',
|
||||
'camelcase': 'off',
|
||||
'capitalized-comments': 'off',
|
||||
'class-methods-use-this': 'off',
|
||||
'comma-dangle': [
|
||||
'error',
|
||||
'always-multiline',
|
||||
],
|
||||
'comma-spacing': 'error',
|
||||
'comma-style': [
|
||||
'error',
|
||||
'last',
|
||||
],
|
||||
'complexity': 'error',
|
||||
'computed-property-spacing': 'error',
|
||||
'consistent-return': 'error',
|
||||
'consistent-this': 'error',
|
||||
'curly': 'error',
|
||||
'default-case': 'error',
|
||||
'dot-location': [2, 'property'],
|
||||
'dot-notation': 'off',
|
||||
'eol-last': 'error',
|
||||
'eqeqeq': 'error',
|
||||
'for-direction': 'error',
|
||||
'func-call-spacing': 'error',
|
||||
'func-name-matching': 'error',
|
||||
'func-names': 'error',
|
||||
'func-style': 'error',
|
||||
'function-paren-newline': 'error',
|
||||
'generator-star-spacing': 'error',
|
||||
'getter-return': 'error',
|
||||
'global-require': 'error',
|
||||
'guard-for-in': 'error',
|
||||
'handle-callback-err': 'error',
|
||||
'id-blacklist': 'error',
|
||||
'id-length': 'off',
|
||||
'id-match': 'error',
|
||||
'indent': 'off',
|
||||
'indent-legacy': 'off',
|
||||
'init-declarations': 'error',
|
||||
'jsx-quotes': 'error',
|
||||
'key-spacing': 'error',
|
||||
'keyword-spacing': 'error',
|
||||
'line-comment-position': 'off',
|
||||
'linebreak-style': [
|
||||
'error',
|
||||
'unix',
|
||||
],
|
||||
'lines-around-comment': 'off',
|
||||
'lines-around-directive': 'error',
|
||||
'max-depth': 'error',
|
||||
'max-len': 'off',
|
||||
'max-lines': 'off',
|
||||
'max-nested-callbacks': 'off',
|
||||
'max-params': 'off',
|
||||
'max-statements': 'off',
|
||||
'max-statements-per-line': 'error',
|
||||
'multiline-ternary': 'off',
|
||||
'new-cap': 'error',
|
||||
'new-parens': 'error',
|
||||
'newline-after-var': 'off',
|
||||
'newline-before-return': 'off',
|
||||
'newline-per-chained-call': 'off',
|
||||
'no-alert': 'error',
|
||||
'no-array-constructor': 'error',
|
||||
'no-await-in-loop': 'error',
|
||||
'no-bitwise': 'error',
|
||||
'no-buffer-constructor': 'error',
|
||||
'no-caller': 'error',
|
||||
'no-catch-shadow': 'error',
|
||||
'no-confusing-arrow': 'error',
|
||||
'no-continue': 'error',
|
||||
'no-div-regex': 'error',
|
||||
'no-duplicate-imports': 'error',
|
||||
'no-else-return': 'error',
|
||||
'no-empty-function': 'error',
|
||||
'no-eq-null': 'error',
|
||||
'no-eval': 'error',
|
||||
'no-extend-native': 'error',
|
||||
'no-extra-bind': 'error',
|
||||
'no-extra-label': 'error',
|
||||
'no-extra-parens': 'off',
|
||||
'no-floating-decimal': 'error',
|
||||
'no-implicit-coercion': 'error',
|
||||
'no-implicit-globals': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-inline-comments': 'off',
|
||||
'no-invalid-this': 'error',
|
||||
'no-iterator': 'error',
|
||||
'no-label-var': 'error',
|
||||
'no-labels': 'error',
|
||||
'no-lone-blocks': 'error',
|
||||
'no-lonely-if': 'error',
|
||||
'no-loop-func': 'error',
|
||||
'no-magic-numbers': 'off',
|
||||
'no-mixed-operators': 'error',
|
||||
'no-mixed-requires': 'error',
|
||||
'no-multi-assign': 'error',
|
||||
'no-multi-spaces': 'error',
|
||||
'no-multi-str': 'error',
|
||||
'no-multiple-empty-lines': 'off',
|
||||
'no-native-reassign': 'error',
|
||||
'no-negated-condition': 'off',
|
||||
'no-negated-in-lhs': 'error',
|
||||
'no-nested-ternary': 'error',
|
||||
'no-new': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-new-object': 'error',
|
||||
'no-new-require': 'error',
|
||||
'no-new-wrappers': 'error',
|
||||
'no-octal-escape': 'error',
|
||||
'no-param-reassign': 'error',
|
||||
'no-path-concat': 'error',
|
||||
'no-plusplus': 'off',
|
||||
'no-process-env': 'off',
|
||||
'no-process-exit': 'error',
|
||||
'no-proto': 'error',
|
||||
'no-prototype-builtins': 'error',
|
||||
'no-restricted-globals': 'error',
|
||||
'no-restricted-imports': 'error',
|
||||
'no-restricted-modules': 'error',
|
||||
'no-restricted-properties': 'error',
|
||||
'no-restricted-syntax': 'error',
|
||||
'no-return-assign': 'error',
|
||||
'no-return-await': 'error',
|
||||
'no-script-url': 'error',
|
||||
'no-self-compare': 'error',
|
||||
'no-sequences': 'error',
|
||||
'no-shadow': 'off',
|
||||
'no-shadow-restricted-names': 'error',
|
||||
'no-spaced-func': 'error',
|
||||
'no-sync': 'error',
|
||||
'no-tabs': 'off',
|
||||
'no-template-curly-in-string': 'error',
|
||||
'no-ternary': 'off',
|
||||
'no-throw-literal': 'error',
|
||||
'no-trailing-spaces': 'error',
|
||||
'no-undef-init': 'error',
|
||||
'no-undefined': 'error',
|
||||
'no-underscore-dangle': 'error',
|
||||
'no-unmodified-loop-condition': 'error',
|
||||
'no-unneeded-ternary': 'error',
|
||||
'no-unused-expressions': 'warn',
|
||||
'no-unused-vars': 'warn',
|
||||
'no-use-before-define': 'error',
|
||||
'no-useless-call': 'error',
|
||||
'no-useless-computed-key': 'error',
|
||||
'no-useless-concat': 'error',
|
||||
'no-useless-constructor': 'error',
|
||||
'no-useless-rename': 'error',
|
||||
'no-useless-return': 'error',
|
||||
'no-var': 'error',
|
||||
'no-void': 'error',
|
||||
'no-warning-comments': 'warn',
|
||||
'no-whitespace-before-property': 'error',
|
||||
'no-with': 'error',
|
||||
'nonblock-statement-body-position': 'error',
|
||||
'object-curly-newline': [
|
||||
'off',
|
||||
{
|
||||
'ObjectExpression': 'never',
|
||||
'ObjectPattern': { 'multiline': true, 'minProperties': 3, 'consistent': true },
|
||||
},
|
||||
],
|
||||
'object-curly-spacing': [
|
||||
'error',
|
||||
'always',
|
||||
],
|
||||
'object-property-newline': 'off',
|
||||
'object-shorthand': 'error',
|
||||
'one-var': 'off',
|
||||
'one-var-declaration-per-line': 'error',
|
||||
'operator-assignment': 'error',
|
||||
'operator-linebreak': 'error',
|
||||
'padded-blocks': [
|
||||
'error',
|
||||
'never',
|
||||
],
|
||||
'padding-line-between-statements': 'error',
|
||||
'prefer-arrow-callback': 'error',
|
||||
'prefer-const': 'error',
|
||||
'prefer-destructuring': 'off',
|
||||
'prefer-numeric-literals': 'error',
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
'prefer-reflect': 'error',
|
||||
'prefer-rest-params': 'error',
|
||||
'prefer-spread': 'error',
|
||||
'prefer-template': 'off',
|
||||
'quote-props': 'off',
|
||||
'quotes': [
|
||||
'error',
|
||||
'single',
|
||||
],
|
||||
'radix': 'error',
|
||||
'require-await': 'error',
|
||||
'require-jsdoc': 'error',
|
||||
'rest-spread-spacing': 'error',
|
||||
'semi': 'error',
|
||||
'semi-spacing': 'error',
|
||||
'semi-style': [
|
||||
'error',
|
||||
'last',
|
||||
],
|
||||
'sort-imports': 'off',
|
||||
'sort-keys': 'off',
|
||||
'sort-vars': 'error',
|
||||
'space-before-blocks': 'error',
|
||||
'space-before-function-paren': 'off',
|
||||
'space-in-parens': [
|
||||
'error',
|
||||
'never',
|
||||
],
|
||||
'space-infix-ops': 'error',
|
||||
'space-unary-ops': 'error',
|
||||
'spaced-comment': [
|
||||
'error',
|
||||
'always',
|
||||
],
|
||||
'strict': 'error',
|
||||
'switch-colon-spacing': 'error',
|
||||
'symbol-description': 'error',
|
||||
'template-curly-spacing': 'error',
|
||||
'template-tag-spacing': 'error',
|
||||
'unicode-bom': [
|
||||
'error',
|
||||
'never',
|
||||
],
|
||||
'valid-jsdoc': 'error',
|
||||
'vars-on-top': 'error',
|
||||
'wrap-iife': 'error',
|
||||
'wrap-regex': 'error',
|
||||
'yield-star-spacing': 'error',
|
||||
'yoda': 'error',
|
||||
},
|
||||
};
|
|
@ -0,0 +1,21 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/dist
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.*.local
|
||||
|
||||
# Log files
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw*
|
|
@ -0,0 +1,29 @@
|
|||
# perktree
|
||||
|
||||
## Project setup
|
||||
```
|
||||
yarn install
|
||||
```
|
||||
|
||||
### Compiles and hot-reloads for development
|
||||
```
|
||||
yarn run serve
|
||||
```
|
||||
|
||||
### Compiles and minifies for production
|
||||
```
|
||||
yarn run build
|
||||
```
|
||||
|
||||
### Run your tests
|
||||
```
|
||||
yarn run test
|
||||
```
|
||||
|
||||
### Lints and fixes files
|
||||
```
|
||||
yarn run lint
|
||||
```
|
||||
|
||||
### Customize configuration
|
||||
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"name": "perktree",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"d3.chart.sankey": "^0.4.0",
|
||||
"lodash": "^4.17.11",
|
||||
"material-design-icons-iconfont": "^3.0.3",
|
||||
"roboto-fontface": "*",
|
||||
"vue": "^2.6.6",
|
||||
"vue-router": "^3.0.2",
|
||||
"vuetify": "^1.5.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@vue/cli-plugin-eslint": "^3.5.0",
|
||||
"@vue/cli-service": "^3.5.0",
|
||||
"@vue/eslint-config-standard": "^4.0.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"eslint": "^5.8.0",
|
||||
"eslint-plugin-vue": "^5.0.0",
|
||||
"stylus": "^0.54.5",
|
||||
"stylus-loader": "^3.0.2",
|
||||
"vue-cli-plugin-vuetify": "^0.5.0",
|
||||
"vue-template-compiler": "^2.5.21"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
plugins: {
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -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>perktree</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but perktree 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>
|
|
@ -0,0 +1,47 @@
|
|||
<template>
|
||||
<v-app dark>
|
||||
<!-- <v-toolbar class="teal darken-2" dark dense fixed clipped-left app> -->
|
||||
<!-- <v-toolbar-title> -->
|
||||
<!-- <v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon> -->
|
||||
<!-- </v-toolbar-title> -->
|
||||
|
||||
<!-- <v-spacer></v-spacer> -->
|
||||
|
||||
<!-- <v-toolbar-items class="hidden-xs-only"> -->
|
||||
<!-- <template v-if="admin"> -->
|
||||
<!-- <v-btn -->
|
||||
<!-- v-for="item in toolbarItems['admin']" -->
|
||||
<!-- :key="item.text" -->
|
||||
<!-- :to="item.path" -->
|
||||
<!-- flat -->
|
||||
<!-- > -->
|
||||
<!-- <v-icon left>{{ item.icon }}</v-icon> -->
|
||||
<!-- {{ item.text }} -->
|
||||
<!-- </v-btn> -->
|
||||
<!-- </template> -->
|
||||
<!-- <v-btn -->
|
||||
<!-- flat -->
|
||||
<!-- v-for="item in toolbarItems[authStatus]" -->
|
||||
<!-- :key="item.text" -->
|
||||
<!-- :to="item.path" -->
|
||||
<!-- > -->
|
||||
<!-- <v-icon left>{{ item.icon }}</v-icon> -->
|
||||
<!-- {{ item.text }} -->
|
||||
<!-- </v-btn> -->
|
||||
<!-- </v-toolbar-items> -->
|
||||
<!-- </v-toolbar> -->
|
||||
<v-content>
|
||||
<router-view></router-view>
|
||||
</v-content>
|
||||
</v-app>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'App',
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang=stylus>
|
||||
</style>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import Axios from 'axios';
|
||||
|
||||
const ENDPOINTS = {
|
||||
LOGIN: '/token/',
|
||||
REFRESH: '/token/refresh/',
|
||||
USER: '/user/',
|
||||
};
|
||||
const AUTH_HEADER = 'Authorization';
|
||||
|
||||
export default class AuthApiService {
|
||||
static setAuthHeader() {
|
||||
Axios.defaults.headers.common[AUTH_HEADER] = `Bearer ${localStorage.getItem('access_token')}`;
|
||||
}
|
||||
|
||||
static login(data) {
|
||||
return Axios.post(ENDPOINTS.LOGIN, data);
|
||||
}
|
||||
|
||||
static signup(data) {
|
||||
return Axios.post(ENDPOINTS.USER, data);
|
||||
}
|
||||
|
||||
static changePassword(data) {
|
||||
return Axios.patch(ENDPOINTS.USER, data);
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 6.7 KiB |
|
@ -0,0 +1 @@
|
|||
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 87.5 100"><defs><style>.cls-1{fill:#1697f6;}.cls-2{fill:#7bc6ff;}.cls-3{fill:#1867c0;}.cls-4{fill:#aeddff;}</style></defs><title>Artboard 46</title><polyline class="cls-1" points="43.75 0 23.31 0 43.75 48.32"/><polygon class="cls-2" points="43.75 62.5 43.75 100 0 14.58 22.92 14.58 43.75 62.5"/><polyline class="cls-3" points="43.75 0 64.19 0 43.75 48.32"/><polygon class="cls-4" points="64.58 14.58 87.5 14.58 43.75 100 43.75 62.5 64.58 14.58"/></svg>
|
After Width: | Height: | Size: 539 B |
|
@ -0,0 +1,34 @@
|
|||
<template>
|
||||
<v-layout>
|
||||
<v-flex md12 lg6 offset-lg3>
|
||||
<v-card class="admin-form-card">
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import AuthController from '../../controllers/auth.controller';
|
||||
|
||||
export default {
|
||||
name: 'admin-panel',
|
||||
data() {
|
||||
return {
|
||||
username: '',
|
||||
password: '',
|
||||
passwordConfirm: '',
|
||||
admin: false,
|
||||
messages: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
/*@import '../../stylus/helpers/messages.styl'*/
|
||||
|
||||
.admin-form-card
|
||||
padding 2rem
|
||||
</style>
|
|
@ -0,0 +1,72 @@
|
|||
<template>
|
||||
<v-layout>
|
||||
<v-flex md12 lg6 offset-lg3>
|
||||
<v-card class="login-form-card">
|
||||
<h2>Login</h2>
|
||||
<form @submit="submit">
|
||||
<v-text-field
|
||||
v-model="username"
|
||||
name="username"
|
||||
label="Username"
|
||||
type="text"
|
||||
></v-text-field>
|
||||
<v-text-field
|
||||
v-model="password"
|
||||
name="password"
|
||||
label="Password"
|
||||
type="password"
|
||||
></v-text-field>
|
||||
<p
|
||||
v-for="(error, index) in loginErrors"
|
||||
:key="index"
|
||||
class="login-errors"
|
||||
>{{ error.description }}</p>
|
||||
<v-btn type="submit">Login</v-btn>
|
||||
</form>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AuthController from '../../controllers/auth.controller';
|
||||
|
||||
export default {
|
||||
name: 'login',
|
||||
data() {
|
||||
return {
|
||||
username: '',
|
||||
password: '',
|
||||
loginErrors: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit(event) {
|
||||
event.preventDefault();
|
||||
this.loginErrors = [];
|
||||
const data = {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
};
|
||||
|
||||
AuthController.login(data).then(() => {
|
||||
this.$router.push({ name: 'index' });
|
||||
this.$store.dispatch('fetchFormData');
|
||||
}).catch((error) => {
|
||||
if (error.response.status === 401) {
|
||||
this.loginErrors.push(error.response.data);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
.login-form-card
|
||||
padding 2rem
|
||||
margin-top 5rem
|
||||
|
||||
.login-errors
|
||||
color red
|
||||
</style>
|
|
@ -0,0 +1,90 @@
|
|||
<template>
|
||||
<v-layout>
|
||||
<v-flex md12 lg6 offset-lg3 >
|
||||
<v-card class="signup-form-card">
|
||||
<h3>Sign up</h3>
|
||||
<form @submit="submit">
|
||||
<v-text-field
|
||||
v-model="username"
|
||||
name="username"
|
||||
label="Username"
|
||||
type="text"
|
||||
v-validate="'required|max:255'"
|
||||
data-vv-name="username"
|
||||
required>
|
||||
</v-text-field>
|
||||
<v-text-field
|
||||
v-model="password"
|
||||
name="password"
|
||||
label="Password"
|
||||
type="password"
|
||||
v-validate="'required|min:8|max:20'"
|
||||
data-vv-name="password"
|
||||
required>
|
||||
</v-text-field>
|
||||
<v-text-field
|
||||
v-model="passwordConfirm"
|
||||
name="passwordConfirm"
|
||||
label="Confirm password"
|
||||
type="password"
|
||||
v-validate="'required|min:8|max:20'"
|
||||
data-vv-name="passwordConfirm"
|
||||
required>
|
||||
</v-text-field>
|
||||
<p v-for="(error, index) in signupErrors"
|
||||
:key="index"
|
||||
class="signup-errors">
|
||||
{{ error }}
|
||||
</p>
|
||||
|
||||
<v-btn type="submit">Signup</v-btn>
|
||||
</form>
|
||||
</v-card>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AuthController from '../../controllers/auth.controller';
|
||||
|
||||
export default {
|
||||
name: 'signup',
|
||||
data() {
|
||||
return {
|
||||
username: '',
|
||||
password: '',
|
||||
passwordConfirm: '',
|
||||
signupErrors: [],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit(event) {
|
||||
event.preventDefault();
|
||||
if (this.password !== this.passwordConfirm) {
|
||||
this.signupErrors.push('Лозинке нису исте');
|
||||
return;
|
||||
}
|
||||
|
||||
const data = {
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
};
|
||||
AuthController.register(data).then(() => {
|
||||
this.$router.push({ name: 'index' });
|
||||
}).catch((error) => {
|
||||
if (error.response.status === 401) {
|
||||
this.signupErrors.push(error.response.data);
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="stylus">
|
||||
.signup-form-card
|
||||
padding 2rem
|
||||
|
||||
.login-errors
|
||||
color red
|
||||
</style>
|
|
@ -0,0 +1,21 @@
|
|||
<template>
|
||||
<v-content>
|
||||
arst
|
||||
</v-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: 'Index',
|
||||
components: {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<template>
|
||||
<v-content>
|
||||
<div id="stuff"></div>
|
||||
</v-content>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Graph from '../helpers/perk-tree.helper.js';
|
||||
|
||||
export default {
|
||||
name: 'Perks',
|
||||
components: {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
},
|
||||
mounted() {
|
||||
const g = new Graph();
|
||||
console.log(g);
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
const API_ROUTE = '/api';
|
||||
|
||||
const ENVIRONMENTS = {
|
||||
'perktree.localhost': 'dev',
|
||||
'perktree.theedgeofrage.com': 'prod',
|
||||
};
|
||||
|
||||
const BACKEND_HOSTNAMES = {
|
||||
'dev': 'http://perktree.localhost',
|
||||
'prod': 'https://perktree.theedgeofrage.com',
|
||||
};
|
||||
|
||||
export {
|
||||
API_ROUTE,
|
||||
ENVIRONMENTS,
|
||||
BACKEND_HOSTNAMES,
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
import {
|
||||
API_ROUTE,
|
||||
ENVIRONMENTS,
|
||||
BACKEND_HOSTNAMES,
|
||||
} from './constants';
|
||||
|
||||
const config = {
|
||||
getEnv() {
|
||||
return ENVIRONMENTS[window.location.hostname] || 'dev';
|
||||
},
|
||||
|
||||
getHostName() {
|
||||
return BACKEND_HOSTNAMES[this.getEnv()];
|
||||
},
|
||||
|
||||
getApiUrl() {
|
||||
return this.getHostName() + API_ROUTE;
|
||||
},
|
||||
};
|
||||
|
||||
export { config };
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
import * as _ from 'lodash';
|
||||
|
||||
import AuthApiService from '../api-services/auth-api-services';
|
||||
|
||||
export default class AuthController {
|
||||
static setLocalStorageAuthData(data) {
|
||||
console.log(data);
|
||||
localStorage.setItem('refresh', data.refresh);
|
||||
localStorage.setItem('access', data.access);
|
||||
}
|
||||
|
||||
static checkLocalStorage() {
|
||||
const userData = JSON.parse(localStorage.getItem('user'));
|
||||
|
||||
if (userData) {
|
||||
AuthApiService.setAuthHeader();
|
||||
}
|
||||
|
||||
return userData;
|
||||
}
|
||||
|
||||
static updateUserInLocalStorage(newUserData) {
|
||||
const userData = JSON.parse(localStorage.getItem('user'));
|
||||
_.assign(userData, newUserData);
|
||||
localStorage.setItem('user', JSON.stringify(userData));
|
||||
}
|
||||
|
||||
static login(data) {
|
||||
return AuthApiService.login(data).then((response) => {
|
||||
this.setLocalStorageAuthData(response.data);
|
||||
AuthApiService.setAuthHeader();
|
||||
});
|
||||
}
|
||||
|
||||
static register(data) {
|
||||
return AuthApiService.register(data);
|
||||
}
|
||||
|
||||
static logout() {
|
||||
this.setLocalStorageAuthData({
|
||||
token: null,
|
||||
user: null,
|
||||
});
|
||||
|
||||
AuthApiService.setAuthHeader();
|
||||
}
|
||||
|
||||
static changePassword(data) {
|
||||
return AuthApiService.changePassword(data);
|
||||
}
|
||||
|
||||
static checkAuthStatus() {
|
||||
return Boolean(this.checkLocalStorage());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* perk-tree.helper.js
|
||||
* Copyright (C) 2019 pavle <pavle.portic@tilda.center>
|
||||
*
|
||||
* Distributed under terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
import * as d3 from 'd3';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
const loadGraph = () => {
|
||||
d3.json('/static/perks/Dexterity.json', (error, json) => {
|
||||
const chart = d3.select('#chart').append('svg').chart('Sankey');
|
||||
const color = d3.scale.category10();
|
||||
const nodes = json.nodes;
|
||||
|
||||
chart.nodeWidth(20)
|
||||
.nodePadding(5)
|
||||
.colorNodes((name, node) => {
|
||||
return color(node.colour);
|
||||
}).on('node:click', (node) => {
|
||||
const clicked_node = _.find(nodes, (n) => {
|
||||
return n.name === node.name;
|
||||
});
|
||||
console.log(clicked_node);
|
||||
}).draw(json);
|
||||
});
|
||||
};
|
||||
|
||||
export default loadGraph;
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import Axios from 'axios';
|
||||
import Vue from 'vue';
|
||||
import './plugins/vuetify';
|
||||
|
||||
import App from './App.vue';
|
||||
import { config } from './config';
|
||||
import router from './router';
|
||||
|
||||
import 'roboto-fontface/css/roboto/roboto-fontface.css';
|
||||
import 'material-design-icons-iconfont/dist/material-design-icons.css';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
const configureHttp = () => {
|
||||
Axios.defaults.baseURL = config.getApiUrl();
|
||||
Axios.defaults.headers.Accept = 'application/json';
|
||||
// Axios.defaults.headers['Access-Control-Allow-Origin'] = '*';
|
||||
Axios.interceptors.response.use(
|
||||
(response) => {
|
||||
return response;
|
||||
},
|
||||
(error) => {
|
||||
if (error.response && error.response.status === 401) {
|
||||
router.push({
|
||||
name: 'logout',
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
configureHttp();
|
||||
|
||||
new Vue({
|
||||
router,
|
||||
render (h) {
|
||||
return h(App);
|
||||
},
|
||||
}).$mount('#app');
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
import Vue from 'vue';
|
||||
import Vuetify from 'vuetify';
|
||||
import colors from 'vuetify/es5/util/colors';
|
||||
import 'vuetify/dist/vuetify.min.css';
|
||||
|
||||
Vue.use(Vuetify, {
|
||||
theme: {
|
||||
primary: colors.teal,
|
||||
secondary: '#424242',
|
||||
accent: '#82B1FF',
|
||||
error: '#FF5252',
|
||||
info: '#2196F3',
|
||||
success: '#4CAF50',
|
||||
warning: '#FFC107',
|
||||
},
|
||||
iconfont: 'md',
|
||||
});
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
/*
|
||||
* router.js
|
||||
* Copyright (C) 2019 pavle <pavle.portic@tilda.center>
|
||||
*
|
||||
* Distributed under terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
import Vue from 'vue';
|
||||
import Router from 'vue-router';
|
||||
|
||||
import Index from './components/index.component';
|
||||
import Login from './components/auth/login.component';
|
||||
import Signup from './components/auth/signup.component';
|
||||
|
||||
import AuthController from './controllers/auth.controller';
|
||||
|
||||
Vue.use(Router);
|
||||
|
||||
const router = new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'index',
|
||||
component: Index,
|
||||
meta: {
|
||||
guest: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: Login,
|
||||
meta: {
|
||||
guest: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/signup',
|
||||
name: 'signpu',
|
||||
component: Signup,
|
||||
meta: {
|
||||
guest: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/logout',
|
||||
name: 'logout',
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'admin-panel',
|
||||
component: () => import(/* webpackChunkName: "admin" */ './components/auth/admin-panel.component'),
|
||||
},
|
||||
{
|
||||
path: '/perks',
|
||||
name: 'perks',
|
||||
component: () => import(/* webpackChunkName: "perks" */ './components/perks.component'),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
router.isCurrentRoute = (routeName) => {
|
||||
return router.currentRoute.name === routeName;
|
||||
};
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.guest && AuthController.checkAuthStatus()) {
|
||||
return next(to.meta.guest_redirect || '/');
|
||||
}
|
||||
|
||||
if (!to.meta.guest && !AuthController.checkAuthStatus()) {
|
||||
return next({ name: 'login' });
|
||||
}
|
||||
|
||||
if (to.name === 'logout' && AuthController.checkAuthStatus()) {
|
||||
AuthController.logout();
|
||||
return next({ name: 'login' });
|
||||
}
|
||||
|
||||
return next();
|
||||
});
|
||||
|
||||
export default router;
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* vue.config.js
|
||||
* Copyright (C) 2019 pavle <pavle.portic@tilda.center>
|
||||
*
|
||||
* Distributed under terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
devServer: {
|
||||
disableHostCheck: true,
|
||||
public: 'perktree.localhost',
|
||||
},
|
||||
};
|
File diff suppressed because it is too large
Load Diff
19
index.html
19
index.html
|
@ -1,19 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>d3.chart.sankey (energy demo)</title>
|
||||
|
||||
<link rel="stylesheet" href="css/app.css">
|
||||
|
||||
<script src="//d3js.org/d3.v3.min.js"></script>
|
||||
<script src="//cdn.rawgit.com/newrelic-forks/d3-plugins-sankey/master/sankey.js"></script>
|
||||
<script src="//cdn.rawgit.com/misoproject/d3.chart/master/d3.chart.min.js"></script>
|
||||
<script src="//cdn.rawgit.com/q-m/d3.chart.sankey/master/d3.chart.sankey.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.11/lodash.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="chart"></div>
|
||||
<script src="js/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
24
js/app.js
24
js/app.js
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* app.js
|
||||
* Copyright (C) 2019 pavle <pavle.portic@tilda.center>
|
||||
*
|
||||
* Distributed under terms of the BSD-3-Clause license.
|
||||
*/
|
||||
|
||||
|
||||
d3.json("perks/Strength.json", (error, json) => {
|
||||
let chart = d3.select("#chart").append("svg").chart('Sankey');
|
||||
const color = d3.scale.category10();
|
||||
const nodes = json.nodes;
|
||||
|
||||
chart.nodeWidth(20)
|
||||
.nodePadding(5)
|
||||
.colorNodes((name, node) => { return color(node.colour); })
|
||||
.on('node:click', (node) => {
|
||||
clicked_node = _.find(nodes, (n) => {
|
||||
return n.name == node.name
|
||||
});
|
||||
console.log(clicked_node);
|
||||
})
|
||||
.draw(json);
|
||||
});
|
Can't render this file because it has a wrong number of fields in line 3.
|
Reference in New Issue