diff --git a/community_server/src/Model/Table/TransactionsTable.php b/community_server/src/Model/Table/TransactionsTable.php index 5169129d7..3bccb7bbf 100644 --- a/community_server/src/Model/Table/TransactionsTable.php +++ b/community_server/src/Model/Table/TransactionsTable.php @@ -184,7 +184,10 @@ class TransactionsTable extends Table $current = $su_transaction; //echo "decay between " . $prev->transaction_id . " and " . $current->transaction_id . "
"; $calculated_decay = $stateBalancesTable->calculateDecay($prev->balance, $prev->balance_date, $current->balance_date, true); - + $balance = floatval($prev->balance - $diff_amount); + // skip small decays (smaller than 0,00 GDD) + + if(abs($balance) >= 100) { //echo $interval->format('%R%a days'); //echo "prev balance: " . $prev->balance . ", diff_amount: $diff_amount, summe: " . (-intval($prev->balance - $diff_amount)) . "
"; $final_transactions[] = [ @@ -195,6 +198,7 @@ class TransactionsTable extends Table ]; } } + } // sender or receiver when user has sended money // group name if creation @@ -265,6 +269,8 @@ class TransactionsTable extends Table if($decay_start_date > $su_transaction->balance_date) { $duration = $decay_start_date->timeAgoInWords(); } + $balance = floatval($su_transaction->balance - $state_balance->decay); + if($balance > 100) { $final_transactions[] = [ 'type' => 'decay', 'balance' => floatval($su_transaction->balance - $calculated_decay['balance']), @@ -273,6 +279,7 @@ class TransactionsTable extends Table ]; } } + } return $final_transactions; diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 412341955..8c410feba 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -3,28 +3,24 @@ module.exports = { env: { browser: true, node: true, - jest: true + jest: true, }, parserOptions: { - parser: 'babel-eslint' + parser: 'babel-eslint', }, - extends: [ - 'plugin:vue/essential', - 'plugin:prettier/recommended' - ], + extends: ['standard', 'plugin:vue/essential', 'plugin:prettier/recommended'], // required to lint *.vue files - plugins: [ - 'vue', - 'prettier', - 'jest' - ], + plugins: ['vue', 'prettier', 'jest'], // add your custom rules here rules: { 'no-console': ['error'], 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', 'vue/component-name-in-template-casing': ['error', 'kebab-case'], - 'prettier/prettier': ['error', { - htmlWhitespaceSensitivity: 'ignore' - }], - } + 'prettier/prettier': [ + 'error', + { + htmlWhitespaceSensitivity: 'ignore', + }, + ], + }, } diff --git a/frontend/jest.config.js b/frontend/jest.config.js index f1082faad..dc44ca43e 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -3,7 +3,7 @@ module.exports = { collectCoverageFrom: ['src/**/*.{js,vue}', '!**/node_modules/**', '!**/?(*.)+(spec|test).js?(x)'], moduleFileExtensions: [ 'js', - //'jsx', + // 'jsx', 'json', 'vue', ], diff --git a/frontend/package.json b/frontend/package.json index a7f59eaa1..53e5fdbcb 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -31,7 +31,7 @@ "dropzone": "^5.5.1", "element-ui": "2.4.11", "es6-promise": "^4.1.1", - "eslint": "^5.16.0", + "eslint": "^7.25.0", "eslint-config-prettier": "^8.1.0", "eslint-config-standard": "^16.0.2", "eslint-loader": "^4.0.2", @@ -40,7 +40,6 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-prettier": "^3.3.1", "eslint-plugin-promise": "^4.3.1", - "eslint-plugin-standard": "^5.0.0", "eslint-plugin-vue": "^7.8.0", "express": "^4.17.1", "flatpickr": "^4.5.7", diff --git a/frontend/run/server.js b/frontend/run/server.js index 470acdc4e..8a3f54557 100644 --- a/frontend/run/server.js +++ b/frontend/run/server.js @@ -7,6 +7,7 @@ const port = process.env.PORT || 3000 // Express Server const app = express() +// eslint-disable-next-line node/no-path-concat app.use(serveStatic(__dirname + '/../dist')) app.listen(port) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f0b7e513c..b47b9caf0 100755 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -36,11 +36,6 @@ export default { DashboardLayout, AuthLayoutGDD, }, - data() { - return { - language: 'en', - } - }, data() { return { config: { diff --git a/frontend/src/apis/communityAPI.js b/frontend/src/apis/communityAPI.js index d2e71439c..5d56f4a1b 100644 --- a/frontend/src/apis/communityAPI.js +++ b/frontend/src/apis/communityAPI.js @@ -32,17 +32,17 @@ const apiPost = async (url, payload) => { } const communityAPI = { - balance: async (session_id) => { - return apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + session_id) + balance: async (sessionId) => { + return apiGet(CONFIG.COMMUNITY_API_URL + 'getBalance/' + sessionId) }, - transactions: async (session_id, firstPage = 1, items = 25, order = 'DESC') => { + transactions: async (sessionId, firstPage = 1, items = 25, order = 'DESC') => { return apiGet( - `${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${session_id}`, + `${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${sessionId}`, ) }, - /*create: async (session_id, email, amount, memo, target_date = new Date() ) => { + /* create: async (sessionId, email, amount, memo, target_date = new Date() ) => { const payload = { - session_id, + sessionId, email, amount, target_date, @@ -50,14 +50,14 @@ const communityAPI = { auto_sign: true, } return apiPost(CONFIG.COMMUNITY_API__URL + 'createCoins/', payload) - },*/ - send: async (session_id, email, amount, memo, target_date) => { + }, */ + send: async (sessionId, email, amount, memo, targetDate) => { const payload = { - session_id, + session_id: sessionId, email, amount, memo, - target_date, + target_date: targetDate, auto_sign: true, } return apiPost(CONFIG.COMMUNITY_API_URL + 'sendCoins/', payload) diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index a31a4062e..f5b0c57f5 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -29,7 +29,7 @@ const apiPost = async (url, payload) => { throw new Error('HTTP Status Error ' + result.status) } if (result.data.state === 'warning') { - return { success: true, result: error } + return { success: true, result: result.error } } if (result.data.state !== 'success') { throw new Error(result.data.msg) @@ -48,15 +48,15 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'unsecureLogin', payload) }, - logout: async (session_id) => { - const payload = { session_id } + logout: async (sessionId) => { + const payload = { session_id: sessionId } return apiPost(CONFIG.LOGIN_API_URL + 'logout', payload) }, - create: async (email, first_name, last_name, password) => { + create: async (email, firstName, lastName, password) => { const payload = { email, - first_name, - last_name, + first_name: firstName, + last_name: lastName, password, emailType: EMAIL_TYPE.DEFAULT, login_after_register: true, @@ -76,9 +76,9 @@ const loginAPI = { CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin, ) }, - changePassword: async (session_id, email, password) => { + changePassword: async (sessionId, email, password) => { const payload = { - session_id, + session_id: sessionId, email, update: { 'User.password': password, diff --git a/frontend/src/components/BaseAlert.vue b/frontend/src/components/BaseAlert.vue index 3349bde50..fe17428a2 100644 --- a/frontend/src/components/BaseAlert.vue +++ b/frontend/src/components/BaseAlert.vue @@ -42,7 +42,7 @@ export default { FadeTransition, }, created() { - //console.log('base-alert gesetzt in =>', this.$route.path) + // console.log('base-alert gesetzt in =>', this.$route.path) }, props: { type: { diff --git a/frontend/src/components/BaseSlider.vue b/frontend/src/components/BaseSlider.vue index 754bea355..14180674a 100644 --- a/frontend/src/components/BaseSlider.vue +++ b/frontend/src/components/BaseSlider.vue @@ -62,7 +62,7 @@ export default { }) const slider = this.$el.noUiSlider slider.on('slide', () => { - let value = slider.get() + const value = slider.get() if (value !== this.value) { this.$emit('input', value) } diff --git a/frontend/src/components/Charts/config.js b/frontend/src/components/Charts/config.js index 5da4578f0..694a036b5 100644 --- a/frontend/src/components/Charts/config.js +++ b/frontend/src/components/Charts/config.js @@ -2,7 +2,7 @@ import { parseOptions } from '@/components/Charts/optionHelpers' import Chart from 'chart.js' export const Charts = { - mode: 'light', //(themeMode) ? themeMode : 'light'; + mode: 'light', // (themeMode) ? themeMode : 'light'; fonts: { base: 'Open Sans', }, @@ -34,9 +34,9 @@ export const Charts = { } function chartOptions() { - let { colors, mode, fonts } = Charts + const { colors, mode, fonts } = Charts // Options - let options = { + const options = { defaults: { global: { responsive: true, @@ -59,21 +59,21 @@ function chartOptions() { elements: { point: { radius: 0, - backgroundColor: colors.theme['primary'], + backgroundColor: colors.theme.primary, }, line: { tension: 0.4, borderWidth: 4, - borderColor: colors.theme['primary'], + borderColor: colors.theme.primary, backgroundColor: colors.transparent, borderCapStyle: 'rounded', }, rectangle: { - backgroundColor: colors.theme['warning'], + backgroundColor: colors.theme.warning, }, arc: { - backgroundColor: colors.theme['primary'], - borderColor: mode == 'dark' ? colors.gray[800] : colors.white, + backgroundColor: colors.theme.primary, + borderColor: mode === 'dark' ? colors.gray[800] : colors.white, borderWidth: 4, }, }, @@ -94,11 +94,11 @@ function chartOptions() { }, cutoutPercentage: 83, legendCallback: function (chart) { - let data = chart.data + const data = chart.data let content = '' data.labels.forEach(function (label, index) { - let bgColor = data.datasets[0].backgroundColor[index] + const bgColor = data.datasets[0].backgroundColor[index] content += '' content += @@ -172,7 +172,7 @@ export const basicOptions = { }, responsive: true, } -export let blueChartOptions = { +export const blueChartOptions = { scales: { yAxes: [ { @@ -185,7 +185,7 @@ export let blueChartOptions = { }, } -export let lineChartOptionsBlue = { +export const lineChartOptionsBlue = { ...basicOptions, tooltips: { backgroundColor: '#f5f5f5', diff --git a/frontend/src/components/Charts/optionHelpers.js b/frontend/src/components/Charts/optionHelpers.js index 4caa22367..5b4630b73 100644 --- a/frontend/src/components/Charts/optionHelpers.js +++ b/frontend/src/components/Charts/optionHelpers.js @@ -1,6 +1,6 @@ // Parse global options export function parseOptions(parent, options) { - for (let item in options) { + for (const item in options) { if (typeof options[item] !== 'object') { parent[item] = options[item] } else { diff --git a/frontend/src/components/Charts/roundedCornersExtension.js b/frontend/src/components/Charts/roundedCornersExtension.js index ae7f84ce8..2ef8fd1d2 100644 --- a/frontend/src/components/Charts/roundedCornersExtension.js +++ b/frontend/src/components/Charts/roundedCornersExtension.js @@ -4,13 +4,13 @@ // import Chart from 'chart.js' Chart.elements.Rectangle.prototype.draw = function () { - let ctx = this._chart.ctx - let vm = this._view - let left, right, top, bottom, signX, signY, borderSkipped, radius + const ctx = this._chart.ctx + const vm = this._view + let left, right, top, bottom, signX, signY, borderSkipped let borderWidth = vm.borderWidth // Set Radius Here // If radius is large enough to cause drawing errors a max radius is imposed - let cornerRadius = 6 + const cornerRadius = 6 if (!vm.horizontal) { // bar @@ -36,14 +36,14 @@ Chart.elements.Rectangle.prototype.draw = function () { // adjust the sizes to fit if we're setting a stroke on the line if (borderWidth) { // borderWidth shold be less than bar width and bar height. - let barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom)) + const barSize = Math.min(Math.abs(left - right), Math.abs(top - bottom)) borderWidth = borderWidth > barSize ? barSize : borderWidth - let halfStroke = borderWidth / 2 + const halfStroke = borderWidth / 2 // Adjust borderWidth when bar top position is near vm.base(zero). - let borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0) - let borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0) - let borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0) - let borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0) + const borderLeft = left + (borderSkipped !== 'left' ? halfStroke * signX : 0) + const borderRight = right + (borderSkipped !== 'right' ? -halfStroke * signX : 0) + const borderTop = top + (borderSkipped !== 'top' ? halfStroke * signY : 0) + const borderBottom = bottom + (borderSkipped !== 'bottom' ? -halfStroke * signY : 0) // not become a vertical line? if (borderLeft !== borderRight) { top = borderTop @@ -64,7 +64,7 @@ Chart.elements.Rectangle.prototype.draw = function () { // Corner points, from bottom-left to bottom-right clockwise // | 1 2 | // | 0 3 | - let corners = [ + const corners = [ [left, bottom], [left, top], [right, top], @@ -72,7 +72,7 @@ Chart.elements.Rectangle.prototype.draw = function () { ] // Find first (starting) corner with fallback to 'bottom' - let borders = ['bottom', 'left', 'top', 'right'] + const borders = ['bottom', 'left', 'top', 'right'] let startCorner = borders.indexOf(borderSkipped, 0) if (startCorner === -1) { startCorner = 0 @@ -89,16 +89,14 @@ Chart.elements.Rectangle.prototype.draw = function () { for (let i = 1; i < 4; i++) { corner = cornerAt(i) let nextCornerId = i + 1 - if (nextCornerId == 4) { + if (nextCornerId === 4) { nextCornerId = 0 } - let nextCorner = cornerAt(nextCornerId) - - let width = corners[2][0] - corners[1][0] - let height = corners[0][1] - corners[1][1] - let x = corners[1][0] - let y = corners[1][1] + const width = corners[2][0] - corners[1][0] + const height = corners[0][1] - corners[1][1] + const x = corners[1][0] + const y = corners[1][1] let radius = cornerRadius diff --git a/frontend/src/components/CloseButton.spec.js b/frontend/src/components/CloseButton.spec.js index 7bf4d52de..b92422df8 100644 --- a/frontend/src/components/CloseButton.spec.js +++ b/frontend/src/components/CloseButton.spec.js @@ -6,7 +6,7 @@ const localVue = global.localVue describe('CloseButton', () => { let wrapper - let propsData = { + const propsData = { target: 'Target', expanded: false, } diff --git a/frontend/src/components/Collapse/CollapseItem.vue b/frontend/src/components/Collapse/CollapseItem.vue index 80a0cbe49..7d6b8ded1 100644 --- a/frontend/src/components/Collapse/CollapseItem.vue +++ b/frontend/src/components/Collapse/CollapseItem.vue @@ -70,7 +70,7 @@ export default { }, methods: { activate() { - let wasActive = this.active + const wasActive = this.active if (!this.multipleActive) { this.deactivateAll() } diff --git a/frontend/src/components/Inputs/BaseInput.vue b/frontend/src/components/Inputs/BaseInput.vue index c4e323696..c43e0a265 100644 --- a/frontend/src/components/Inputs/BaseInput.vue +++ b/frontend/src/components/Inputs/BaseInput.vue @@ -170,7 +170,7 @@ export default { }, methods: { updateValue(evt) { - let value = evt.target.value + const value = evt.target.value this.$emit('input', value) }, onFocus(evt) { diff --git a/frontend/src/components/Modal-OLD.vue b/frontend/src/components/Modal-OLD.vue index 4e2ea3cae..515b510a0 100644 --- a/frontend/src/components/Modal-OLD.vue +++ b/frontend/src/components/Modal-OLD.vue @@ -60,7 +60,7 @@ export default { type: String, default: '', validator(value) { - let acceptedValues = ['', 'notice', 'mini'] + const acceptedValues = ['', 'notice', 'mini'] return acceptedValues.indexOf(value) !== -1 }, description: 'Modal type (notice|mini|"") ', @@ -73,7 +73,7 @@ export default { type: String, description: 'Modal size', validator(value) { - let acceptedValues = ['', 'sm', 'lg'] + const acceptedValues = ['', 'sm', 'lg'] return acceptedValues.indexOf(value) !== -1 }, }, diff --git a/frontend/src/components/Modal.vue b/frontend/src/components/Modal.vue index 88bcd1e6f..c43bf6c67 100644 --- a/frontend/src/components/Modal.vue +++ b/frontend/src/components/Modal.vue @@ -39,7 +39,7 @@ export default { submittedNames: [], } }, - /*Modal*/ + /* Modal */ checkFormValidity() { const valid = this.$refs.form.checkValidity() this.nameState = valid diff --git a/frontend/src/components/Navbar/BaseNav.vue b/frontend/src/components/Navbar/BaseNav.vue index a656648e5..778f550fc 100644 --- a/frontend/src/components/Navbar/BaseNav.vue +++ b/frontend/src/components/Navbar/BaseNav.vue @@ -90,8 +90,8 @@ export default { }, computed: { classes() { - let color = `bg-${this.type}` - let classes = [ + const color = `bg-${this.type}` + const classes = [ { 'navbar-transparent': this.transparent }, { [`navbar-expand-${this.expand}`]: this.expand }, ] diff --git a/frontend/src/components/NotificationPlugin/Notification.vue b/frontend/src/components/NotificationPlugin/Notification.vue index 20251d9fa..e36985036 100644 --- a/frontend/src/components/NotificationPlugin/Notification.vue +++ b/frontend/src/components/NotificationPlugin/Notification.vue @@ -59,7 +59,7 @@ export default { type: String, default: 'top', validator: (value) => { - let acceptedValues = ['top', 'bottom'] + const acceptedValues = ['top', 'bottom'] return acceptedValues.indexOf(value) !== -1 }, description: 'Vertical alignment of notification (top|bottom)', @@ -68,7 +68,7 @@ export default { type: String, default: 'right', validator: (value) => { - let acceptedValues = ['left', 'center', 'right'] + const acceptedValues = ['left', 'center', 'right'] return acceptedValues.indexOf(value) !== -1 }, description: 'Horizontal alignment of notification (left|center|right)', @@ -77,7 +77,7 @@ export default { type: String, default: 'info', validator: (value) => { - let acceptedValues = ['default', 'info', 'primary', 'danger', 'warning', 'success'] + const acceptedValues = ['default', 'info', 'primary', 'danger', 'warning', 'success'] return acceptedValues.indexOf(value) !== -1 }, description: @@ -129,8 +129,8 @@ export default { return `alert-${this.type}` }, customPosition() { - let initialMargin = 20 - let alertHeight = this.elmHeight + 10 + const initialMargin = 20 + const alertHeight = this.elmHeight + 10 let sameAlertsCount = this.$notifications.state.filter((alert) => { return ( alert.horizontalAlign === this.horizontalAlign && @@ -141,8 +141,8 @@ export default { if (this.$notifications.settings.overlap) { sameAlertsCount = 1 } - let pixels = (sameAlertsCount - 1) * alertHeight + initialMargin - let styles = {} + const pixels = (sameAlertsCount - 1) * alertHeight + initialMargin + const styles = {} if (this.verticalAlign === 'top') { styles.top = `${pixels}px` } else { diff --git a/frontend/src/components/NotificationPlugin/index.js b/frontend/src/components/NotificationPlugin/index.js index fbf48d214..5b6bbe67b 100644 --- a/frontend/src/components/NotificationPlugin/index.js +++ b/frontend/src/components/NotificationPlugin/index.js @@ -44,7 +44,7 @@ const NotificationStore = { const NotificationsPlugin = { install(Vue, options) { - let app = new Vue({ + const app = new Vue({ data: { notificationStore: NotificationStore, }, diff --git a/frontend/src/components/SearchUser.vue b/frontend/src/components/SearchUser.vue index ae06c6dd8..dd3fe34a6 100644 --- a/frontend/src/components/SearchUser.vue +++ b/frontend/src/components/SearchUser.vue @@ -5,7 +5,7 @@ import VueBootstrapTypeahead from 'vue-bootstrap-typeahead' // Global registration -//Vue.component('vue-bootstrap-typeahead', VueBootstrapTypeahead) +// Vue.component('vue-bootstrap-typeahead', VueBootstrapTypeahead) // OR diff --git a/frontend/src/components/SidebarPlugin/SideBar.vue b/frontend/src/components/SidebarPlugin/SideBar.vue index 6542bd23e..9e0885d3f 100755 --- a/frontend/src/components/SidebarPlugin/SideBar.vue +++ b/frontend/src/components/SidebarPlugin/SideBar.vue @@ -50,6 +50,7 @@ {{ $t('members_area') }} diff --git a/frontend/src/components/SidebarPlugin/SidebarItem.vue b/frontend/src/components/SidebarPlugin/SidebarItem.vue index 84a722aa3..309af33b0 100755 --- a/frontend/src/components/SidebarPlugin/SidebarItem.vue +++ b/frontend/src/components/SidebarPlugin/SidebarItem.vue @@ -110,7 +110,7 @@ export default { }, linkPrefix() { if (this.link.name) { - let words = this.link.name.split(' ') + const words = this.link.name.split(' ') return words.map((word) => word.substring(0, 1)).join('') } return '' @@ -120,7 +120,7 @@ export default { }, isActive() { if (this.$route && this.$route.path) { - let matchingRoute = this.children.find((c) => this.$route.path.startsWith(c.link.path)) + const matchingRoute = this.children.find((c) => this.$route.path.startsWith(c.link.path)) if (matchingRoute !== undefined) { return true } diff --git a/frontend/src/components/SidebarPlugin/index.js b/frontend/src/components/SidebarPlugin/index.js index cbe421862..ab59a9595 100755 --- a/frontend/src/components/SidebarPlugin/index.js +++ b/frontend/src/components/SidebarPlugin/index.js @@ -29,7 +29,7 @@ const SidebarPlugin = { if (options && options.sidebarLinks) { SidebarStore.sidebarLinks = options.sidebarLinks } - let app = new Vue({ + const app = new Vue({ data: { sidebarStore: SidebarStore, }, diff --git a/frontend/src/components/Tabs/Tabs.vue b/frontend/src/components/Tabs/Tabs.vue index 7ba788329..211c8d0cd 100644 --- a/frontend/src/components/Tabs/Tabs.vue +++ b/frontend/src/components/Tabs/Tabs.vue @@ -67,7 +67,7 @@ export default { type: String, default: 'primary', validator: (value) => { - let acceptedValues = ['primary', 'info', 'success', 'warning', 'danger'] + const acceptedValues = ['primary', 'info', 'success', 'warning', 'danger'] return acceptedValues.indexOf(value) !== -1 }, }, @@ -102,7 +102,7 @@ export default { }, methods: { findAndActivateTab(title) { - let tabToActivate = this.tabs.find((t) => t.title === title) + const tabToActivate = this.tabs.find((t) => t.title === title) if (tabToActivate) { this.activateTab(tabToActivate) } diff --git a/frontend/src/directives/click-ouside.js b/frontend/src/directives/click-ouside.js index 9661a4e16..be4afb4ce 100644 --- a/frontend/src/directives/click-ouside.js +++ b/frontend/src/directives/click-ouside.js @@ -2,7 +2,7 @@ export default { bind: function (el, binding, vnode) { el.clickOutsideEvent = function (event) { // here I check that click was outside the el and his childrens - if (!(el == event.target || el.contains(event.target))) { + if (!(el === event.target || el.contains(event.target))) { // and if it did, call method provided in attribute value vnode.context[binding.expression](event) } diff --git a/frontend/src/main.js b/frontend/src/main.js index f1b7ee0c2..bd57c6e57 100755 --- a/frontend/src/main.js +++ b/frontend/src/main.js @@ -2,7 +2,6 @@ import Vue from 'vue' import DashboardPlugin from './plugins/dashboard-plugin' import App from './App.vue' import i18n from './i18n.js' -import VeeValidate from './vee-validate.js' // store import { store } from './store/store' @@ -15,7 +14,7 @@ Vue.use(DashboardPlugin) Vue.config.productionTip = false router.beforeEach((to, from, next) => { - if (to.meta.requiresAuth && !store.state.session_id) { + if (to.meta.requiresAuth && !store.state.sessionId) { next({ path: '/login' }) } else { next() diff --git a/frontend/src/plugins/dashboard-plugin.js b/frontend/src/plugins/dashboard-plugin.js index 881fecf7d..6bafb569e 100755 --- a/frontend/src/plugins/dashboard-plugin.js +++ b/frontend/src/plugins/dashboard-plugin.js @@ -3,7 +3,7 @@ import '@/polyfills' // Notifications plugin. Used on Notifications page import Notifications from '@/components/NotificationPlugin' // Validation plugin used to validate forms -import { configure } from 'vee-validate' +import { configure, extend } from 'vee-validate' // A plugin file where you could register global components used across the app import GlobalComponents from './globalComponents' // A plugin file where you could register global directives @@ -14,7 +14,6 @@ import SideBar from '@/components/SidebarPlugin' // element ui language configuration import lang from 'element-ui/lib/locale/lang/en' import locale from 'element-ui/lib/locale' -locale.use(lang) // vue-bootstrap import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' @@ -22,7 +21,6 @@ import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' // asset imports import '@/assets/scss/argon.scss' import '@/assets/vendor/nucleo/css/nucleo.css' -import { extend } from 'vee-validate' import * as rules from 'vee-validate/dist/rules' import { messages } from 'vee-validate/dist/locale/en.json' @@ -40,6 +38,7 @@ import VueMoment from 'vue-moment' import Loading from 'vue-loading-overlay' // import the styles import 'vue-loading-overlay/dist/vue-loading.css' +locale.use(lang) Object.keys(rules).forEach((rule) => { extend(rule, { diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index 236cc15af..e9bcf38c8 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -21,20 +21,20 @@ const routes = [ requiresAuth: true, }, }, - //{ + // { // path: '/profileedit', // component: () => import('../views/Pages/UserProfileEdit.vue'), // meta: { // requiresAuth: true, // }, - //}, - //{ + // }, + // { // path: '/activity', // component: () => import('../views/Pages/UserProfileActivity.vue'), // meta: { // requiresAuth: true, // }, - //}, + // }, { path: '/transactions', component: () => import('../views/Pages/UserProfileTransactionList.vue'), diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 5c9e1bc1e..aed286bc6 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -1,7 +1,7 @@ import Vue from 'vue' import Vuex from 'vuex' -Vue.use(Vuex) import createPersistedState from 'vuex-persistedstate' +Vue.use(Vuex) export const mutations = { language: (state, language) => { @@ -10,18 +10,18 @@ export const mutations = { email: (state, email) => { state.email = email }, - session_id: (state, session_id) => { - state.session_id = session_id + sessionId: (state, sessionId) => { + state.sessionId = sessionId }, } export const actions = { login: ({ dispatch, commit }, data) => { - commit('session_id', data.session_id) + commit('sessionId', data.sessionId) commit('email', data.email) }, logout: ({ commit, state }) => { - commit('session_id', null) + commit('sessionId', null) commit('email', null) sessionStorage.clear() }, @@ -34,7 +34,7 @@ export const store = new Vuex.Store({ }), ], state: { - session_id: null, + sessionId: null, email: '', language: 'en', modals: false, diff --git a/frontend/src/store/store.test.js b/frontend/src/store/store.test.js index ccf59dfbf..655cca7a0 100644 --- a/frontend/src/store/store.test.js +++ b/frontend/src/store/store.test.js @@ -1,6 +1,6 @@ import { mutations, actions } from './store' -const { language, email, session_id } = mutations +const { language, email, sessionId } = mutations const { login, logout } = actions describe('Vuex store', () => { @@ -21,11 +21,11 @@ describe('Vuex store', () => { }) }) - describe('session_id', () => { - it('sets the state of session_id', () => { - const state = { session_id: null } - session_id(state, '1234') - expect(state.session_id).toEqual('1234') + describe('sessionId', () => { + it('sets the state of sessionId', () => { + const state = { sessionId: null } + sessionId(state, '1234') + expect(state.sessionId).toEqual('1234') }) }) }) @@ -36,17 +36,17 @@ describe('Vuex store', () => { const state = {} it('calls two commits', () => { - login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) + login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' }) expect(commit).toHaveBeenCalledTimes(2) }) - it('commits session_id', () => { - login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) - expect(commit).toHaveBeenNthCalledWith(1, 'session_id', 1234) + it('commits sessionId', () => { + login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' }) + expect(commit).toHaveBeenNthCalledWith(1, 'sessionId', 1234) }) it('commits email', () => { - login({ commit, state }, { session_id: 1234, email: 'someone@there.is' }) + login({ commit, state }, { sessionId: 1234, email: 'someone@there.is' }) expect(commit).toHaveBeenNthCalledWith(2, 'email', 'someone@there.is') }) }) @@ -60,9 +60,9 @@ describe('Vuex store', () => { expect(commit).toHaveBeenCalledTimes(2) }) - it('commits session_id', () => { + it('commits sessionId', () => { logout({ commit, state }) - expect(commit).toHaveBeenNthCalledWith(1, 'session_id', null) + expect(commit).toHaveBeenNthCalledWith(1, 'sessionId', null) }) it('commits email', () => { diff --git a/frontend/src/views/Layout/ContentFooter.spec.js b/frontend/src/views/Layout/ContentFooter.spec.js index ec4d3ff74..8d0c6dfbd 100644 --- a/frontend/src/views/Layout/ContentFooter.spec.js +++ b/frontend/src/views/Layout/ContentFooter.spec.js @@ -7,7 +7,7 @@ const localVue = global.localVue describe('ContentFooter', () => { let wrapper - let mocks = { + const mocks = { $i18n: { locale: 'en', }, @@ -98,6 +98,12 @@ describe('ContentFooter', () => { ) }) + it('links to the support', () => { + expect(wrapper.findAll('a.nav-link').at(4).attributes('href')).toEqual( + 'https://gradido.net/en/contact/', + ) + }) + describe('links are localized', () => { beforeEach(() => { mocks.$i18n.locale = 'de' @@ -132,6 +138,12 @@ describe('ContentFooter', () => { 'https://docs.google.com/document/d/1jZp-DiiMPI9ZPNXmjsvOQ1BtnfDFfx8BX7CDmA8KKjY/edit?usp=sharing', ) }) + + it('links to the German support-page when locale is de', () => { + expect(wrapper.findAll('a.nav-link').at(4).attributes('href')).toEqual( + 'https://gradido.net/de/contact/', + ) + }) }) }) }) diff --git a/frontend/src/views/Layout/ContentFooter.vue b/frontend/src/views/Layout/ContentFooter.vue index b261cafb3..09a2418fd 100755 --- a/frontend/src/views/Layout/ContentFooter.vue +++ b/frontend/src/views/Layout/ContentFooter.vue @@ -4,7 +4,11 @@