Skip to content

Commit 5adab5d

Browse files
committed
Fix: age-chart for touch devices - QoL changes to the server
1 parent dbd2ab4 commit 5adab5d

File tree

11 files changed

+1787
-2023
lines changed

11 files changed

+1787
-2023
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Unreleased
22

3+
# Release v1.1.8
4+
5+
### Changes
6+
7+
- Trigger Age-chart re-render when using a touch device
8+
- Updated dependencies
9+
- QoL changes to the server
10+
311
# Release v1.1.7
412
### About this version
513
There was a critical security vulnerability with axios and some changes to sentry

package-lock.json

Lines changed: 1733 additions & 1968 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,48 @@
2020
"@sentry/vue": "^5.29.2",
2121
"canvas": "^2.6.1",
2222
"canvg": "^3.0.7",
23-
"core-js": "^3.8.2",
23+
"core-js": "^3.8.3",
2424
"d3": "^5.16.0",
2525
"d3-svg-legend": "^2.25.6",
2626
"d3-textwrap": "^3.0.0",
27-
"jsdom": "^16.4.0",
2827
"leaflet": "^1.7.1",
2928
"leaflet-gesture-handling": "^1.2.1",
3029
"nodemon": "^2.0.7",
3130
"save-svg-as-png": "^1.4.17",
3231
"vue": "^2.6.12",
3332
"vue-analytics": "^5.22.1",
34-
"vue-dragscroll": "^2.1.0",
35-
"vue-i18n": "^8.22.2",
33+
"vue-dragscroll": "^2.1.3",
34+
"vue-i18n": "^8.22.4",
3635
"vue-meta": "^2.4.0",
3736
"vue-resize": "^1.0.0",
38-
"vue-router": "^3.4.9",
37+
"vue-router": "^3.5.1",
3938
"vue-skip-to": "^1.0.6",
4039
"vue2-leaflet": "^2.6.0",
41-
"vuex": "^3.6.0",
40+
"vuex": "^3.6.2",
4241
"whatwg-fetch": "^3.5.0",
4342
"xlsx": "^0.16.9",
4443
"xmldom": "^0.4.0"
4544
},
4645
"devDependencies": {
47-
"@vue/cli-plugin-babel": "^4.5.10",
48-
"@vue/cli-plugin-eslint": "^4.5.10",
49-
"@vue/cli-plugin-router": "^4.5.10",
50-
"@vue/cli-plugin-unit-jest": "^4.5.10",
51-
"@vue/cli-plugin-vuex": "^4.5.10",
52-
"@vue/cli-service": "^4.5.10",
46+
"@vue/cli-plugin-babel": "^4.5.11",
47+
"@vue/cli-plugin-eslint": "^4.5.11",
48+
"@vue/cli-plugin-router": "^4.5.11",
49+
"@vue/cli-plugin-unit-jest": "^4.5.11",
50+
"@vue/cli-plugin-vuex": "^4.5.11",
51+
"@vue/cli-service": "^4.5.11",
5352
"@vue/eslint-config-airbnb": "^5.3.0",
5453
"@vue/eslint-config-prettier": "^6.0.0",
55-
"@vue/test-utils": "^1.1.2",
54+
"@vue/test-utils": "^1.1.3",
5655
"babel-core": "7.0.0-bridge.0",
5756
"babel-eslint": "^10.1.0",
5857
"env-cmd": "^10.1.0",
59-
"eslint": "^7.17.0",
58+
"eslint": "^7.19.0",
6059
"eslint-plugin-prettier": "^3.3.1",
61-
"eslint-plugin-vue": "^7.4.1",
60+
"eslint-plugin-vue": "^7.5.0",
6261
"node-sass": "^5.0.0",
6362
"prettier": "^2.2.1",
64-
"sass-loader": "^10.1.0",
65-
"stylelint": "^13.8.0",
63+
"sass-loader": "^10.1.1",
64+
"stylelint": "^13.9.0",
6665
"stylelint-config-rational-order": "^0.1.2",
6766
"stylelint-config-standard": "^20.0.0",
6867
"stylelint-order": "^4.1.0",

server/auth/accessToken.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
'use strict';
2-
31
const isDate = require('date-fns/isDate');
42
const addSeconds = require('date-fns/addSeconds');
53
const isAfter = require('date-fns/isAfter');
64

7-
const parseToken = token => {
5+
const parseToken = (token) => {
86
const parsedTokenProps = {};
97

108
if ('expires_in' in token) {
@@ -19,10 +17,10 @@ const parseToken = token => {
1917
}
2018
}
2119

22-
return Object.assign({}, token, parsedTokenProps);
20+
return { ...token, ...parsedTokenProps };
2321
};
2422

25-
const isTokenExpired = expired => {
23+
const isTokenExpired = (expired) => {
2624
return isAfter(new Date(), expired);
2725
};
2826

server/auth/api.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
'use strict';
2-
31
const axios = require('axios');
42
const querystring = require('querystring');
53

64
const envs = {
75
access_token_url: `${process.env.KEYCLOAK_SERVER_URL}/auth/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/token`,
86
};
97

10-
const request = params => {
8+
const request = (params) => {
119
return axios({
1210
method: 'post',
1311
url: envs.access_token_url,
@@ -16,10 +14,10 @@ const request = params => {
1614
'Content-Type': 'application/x-www-form-urlencoded',
1715
},
1816
})
19-
.then(response => {
17+
.then((response) => {
2018
return Promise.resolve(response.data);
2119
})
22-
.catch(error => {
20+
.catch((error) => {
2321
if (error.errno === 'ETIMEDOUT') {
2422
return Promise.reject(new Error('Timeout'));
2523
}

server/auth/index.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,32 @@ const logErrors = (error, refresh) => {
2626
module.exports = () => {
2727
return (req, res, next) => {
2828
if (accessToken === null || isTokenExpired(accessToken.refresh_expires_at)) {
29-
const params = Object.assign({}, data, {
30-
grant_type: process.env.KEYCLOAK_GRANT_TYPE_CLIENT,
31-
});
29+
const params = { ...data, grant_type: process.env.KEYCLOAK_GRANT_TYPE_CLIENT };
3230

33-
return request(params)
34-
.then(response => {
31+
request(params)
32+
.then((response) => {
3533
accessToken = parseToken(response);
3634
req.headers.authorization = `Bearer ${accessToken.access_token}`;
3735
next();
3836
})
39-
.catch(error => {
37+
.catch((error) => {
4038
logErrors(error);
4139
return res.status(error.status);
4240
});
4341
} else if (isTokenExpired(accessToken.expires_at)) {
44-
const params = Object.assign({}, data, {
42+
const params = {
43+
...data,
4544
grant_type: process.env.KEYCLOAK_GRANT_TYPE_REFRESH,
4645
refresh_token: accessToken.refresh_token,
47-
});
46+
};
4847

49-
return request(params)
50-
.then(response => {
48+
request(params)
49+
.then((response) => {
5150
accessToken = parseToken(response);
5251
req.headers.authorization = `Bearer ${accessToken.access_token}`;
5352
next();
5453
})
55-
.catch(error => {
54+
.catch((error) => {
5655
logErrors(error, true);
5756
return res.status(error.status);
5857
});

server/routes.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const api = process.env.BYDELSFAKTA_API_URL;
1010
const API_URL = api.slice(-1) === '/' ? api : `${api}/`;
1111
const get = API_URL[4] === 's' ? https.get : http.get;
1212

13-
module.exports = app => {
13+
module.exports = (app) => {
1414
app.use('/', express.static(path.join(__dirname, '../docs/')));
1515

1616
app.get('/health', (req, res) => {
@@ -30,9 +30,10 @@ module.exports = app => {
3030
{
3131
headers,
3232
},
33-
proxyRes => {
34-
const { statusCode, headers } = proxyRes;
35-
const contentType = headers['content-type'];
33+
(proxyRes) => {
34+
const { statusCode } = proxyRes;
35+
const newHeaders = proxyRes.headers;
36+
const contentType = newHeaders['content-type'];
3637

3738
if (statusCode !== 200) {
3839
console.error('Unexpected status:', statusCode);
@@ -41,7 +42,7 @@ module.exports = app => {
4142
console.error('Unexpected content-type:', contentType);
4243
}
4344

44-
res.writeHead(statusCode, headers);
45+
res.writeHead(statusCode, newHeaders);
4546
proxyRes.pipe(res);
4647
}
4748
);
@@ -51,7 +52,7 @@ module.exports = app => {
5152

5253
const allConfiguredRoutes = () => {
5354
const routes = [];
54-
app._router.stack.forEach(layer => {
55+
app._router.stack.forEach((layer) => {
5556
if (layer && layer.route) {
5657
routes.push(layer.route.path);
5758
}

src/components/GraphCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ export default {
362362
this.$ga.event({
363363
eventCategory: 'Card',
364364
eventAction: 'Change tab',
365-
eventLabel: this.settings.tabs[index].label,
365+
eventLabel: this.settings.tabs[index - 1].label,
366366
});
367367
},
368368

src/components/TheNavigationDrawer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
import { mapState, mapActions, mapGetters } from 'vuex';
122122
import allDistricts from '../config/allDistricts';
123123
import predefinedOptions from '../config/predefinedOptions';
124-
import OsloLogo from '../assets/oslo-logo.svg'; //
124+
import OsloLogo from '../assets/oslo-logo.svg';
125125
126126
export default {
127127
name: 'TheNavigationDrawer',

src/router.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,30 @@ import Router from 'vue-router';
44
import { topicNames, disabledTopics } from './config/topics';
55
import allDistricts from './config/allDistricts';
66

7-
const District = () => import('./views/District');
8-
const Topic = () => import('./views/Topic');
9-
const NotFound = () => import('./views/NotFound');
10-
117
Vue.use(Router);
128

139
export const routes = [
1410
{
1511
path: '/',
1612
name: 'Home',
17-
component: District,
13+
component: () => import('./views/District'),
1814
},
1915
{
2016
path: '/bydel/:district?',
2117
name: 'District',
22-
component: District,
18+
component: () => import('./views/District'),
2319
props: true,
2420
},
2521
{
2622
path: '/bydel/:district/:topic',
2723
name: 'Topic',
28-
component: Topic,
24+
component: () => import('./views/Topic'),
2925
props: true,
3026
},
3127
{
3228
path: '*',
3329
name: 'NotFound',
34-
component: NotFound,
30+
component: () => import('./views/NotFound'),
3531
},
3632
];
3733

src/util/graph-templates/templateAgeDistribution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Template(svg) {
3232
.handleSize(21)
3333
.on('brush', updateHandlePositions.bind(this))
3434
.on('end', () => {
35-
if (d3.event.sourceEvent instanceof MouseEvent) {
35+
if (d3.event.sourceEvent instanceof MouseEvent || d3.event.sourceEvent instanceof TouchEvent) {
3636
this.dropDownParent.select('select').node().value = '';
3737
this.extent = d3.event.selection
3838
? d3.event.selection.map((val) => Math.round(this.age.invert(val)))

0 commit comments

Comments
 (0)