Skip to content

Commit a90e6d4

Browse files
author
Sascha Pfeiffer
committed
added parameter to bypass browser cache when querying VERSION.txt
Signed-off-by: Sascha Pfeiffer <sascha.pfeiffer@esaqa.com>
1 parent fec06ac commit a90e6d4

File tree

2 files changed

+100
-94
lines changed

2 files changed

+100
-94
lines changed

src/services/api-client.js

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/**
2-
* Client service for the psono web client
3-
*/
4-
5-
import axios from 'axios';
6-
import action from '../actions/boundActionCreators';
7-
import store from './store';
8-
9-
function get_version() {
10-
const client_url = store.getState().client.url;
11-
return axios.get(client_url + '/VERSION.txt');
12-
}
13-
14-
function set_url(url) {
15-
action.set_client_url(url);
16-
}
17-
18-
const service = {
19-
get_version,
20-
set_url
21-
};
22-
23-
export default service;
1+
/**
2+
* Client service for the psono web client
3+
*/
4+
5+
import axios from 'axios';
6+
import action from '../actions/boundActionCreators';
7+
import store from './store';
8+
9+
function get_version() {
10+
const client_url = store.getState().client.url;
11+
return axios.get(client_url + '/VERSION.txt?t=' + new Date().getTime());
12+
}
13+
14+
function set_url(url) {
15+
action.set_client_url(url);
16+
}
17+
18+
const service = {
19+
get_version,
20+
set_url,
21+
};
22+
23+
export default service;

src/views/Dashboard/Index.jsx

+77-71
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ class Dashboard extends React.Component {
6060
healthcheck: {
6161
db_read: {},
6262
db_sync: {},
63-
time_sync: {}
63+
time_sync: {},
6464
},
65-
tr: true
65+
tr: true,
6666
};
6767

6868
convert_tags_to_releases(tags) {
69-
tags.forEach(r => {
70-
Object.keys(r.commit).forEach(function(key) {
69+
tags.forEach((r) => {
70+
Object.keys(r.commit).forEach(function (key) {
7171
r[key] = r.commit[key];
7272
});
7373

74-
Object.keys(r.release).forEach(function(key) {
74+
Object.keys(r.release).forEach(function (key) {
7575
r[key] = r.release[key];
7676
});
7777
r.created_at = moment(r.created_at).format('YYYY-MM-DD HH:mm:ss');
@@ -97,65 +97,65 @@ class Dashboard extends React.Component {
9797
if (this.props.state.server.type === 'CE') {
9898
api_static
9999
.get('/gitlab.com/psono/psono-server/changelog.json')
100-
.then(response => {
100+
.then((response) => {
101101
this.convert_tags_to_releases(response.data);
102102
this.setState({
103103
server_tags: response.data,
104-
server_latest_version: response.data[0].name
104+
server_latest_version: response.data[0].name,
105105
});
106106
});
107107
} else {
108108
api_static
109109
.get('/gitlab.com/psono-enterprise/psono-server/changelog.json')
110-
.then(response => {
110+
.then((response) => {
111111
this.convert_tags_to_releases(response.data);
112112
this.setState({
113113
server_tags: response.data,
114-
server_latest_version: response.data[0].name
114+
server_latest_version: response.data[0].name,
115115
});
116116
});
117117
}
118118
api_static
119119
.get('/gitlab.com/psono/psono-client/changelog.json')
120-
.then(response => {
120+
.then((response) => {
121121
this.convert_tags_to_releases(response.data);
122122
this.setState({
123123
client_tags: response.data,
124-
client_latest_version: response.data[0].name
124+
client_latest_version: response.data[0].name,
125125
});
126126
});
127127
api_static
128128
.get('/gitlab.com/psono/psono-admin-client/changelog.json')
129-
.then(response => {
129+
.then((response) => {
130130
this.convert_tags_to_releases(response.data);
131131
this.setState({
132132
admin_client_tags: response.data,
133-
admin_client_latest_version: response.data[0].name
133+
admin_client_latest_version: response.data[0].name,
134134
});
135135
});
136136
api_static
137137
.get('/gitlab.com/psono/psono-fileserver/changelog.json')
138-
.then(response => {
138+
.then((response) => {
139139
this.convert_tags_to_releases(response.data);
140140
this.setState({
141141
fileserver_tags: response.data,
142-
fileserver_latest_version: response.data[0].name
142+
fileserver_latest_version: response.data[0].name,
143143
});
144144
});
145145

146146
psono_server.healthcheck().then(
147-
response => {
147+
(response) => {
148148
//healthy is reported as 200
149149
this.setState({
150-
healthcheck: response.data
150+
healthcheck: response.data,
151151
});
152152
},
153-
response => {
153+
(response) => {
154154
//error occured, could mean unhealthy...
155155
if (response.status === 400) {
156156
//unhealthy is reported as 400
157157
this.setState({
158-
healthcheck: response.data
158+
healthcheck: response.data,
159159
});
160160
}
161161
}
@@ -165,7 +165,7 @@ class Dashboard extends React.Component {
165165
this.props.state.user.token,
166166
this.props.state.user.session_secret_key
167167
)
168-
.then(response => {
168+
.then((response) => {
169169
response.data.info = JSON.parse(response.data.info);
170170

171171
let label_day = [];
@@ -176,7 +176,7 @@ class Dashboard extends React.Component {
176176

177177
let count_registrations_first_week = 0;
178178
let count_registrations_second_week = 0;
179-
response.data.registrations_over_day.forEach(function(r) {
179+
response.data.registrations_over_day.forEach(function (r) {
180180
count = count - 1;
181181
if (count > 13) {
182182
return;
@@ -196,18 +196,18 @@ class Dashboard extends React.Component {
196196
let label_month = [];
197197
let data_month_new = [];
198198
let data_month_total = [];
199-
response.data.registrations_over_month.forEach(function(r) {
199+
response.data.registrations_over_month.forEach(function (r) {
200200
label_month.push(r.month);
201201
data_month_new.push(r.count_new);
202202
data_month_total.push(r.count_total);
203203
});
204204

205205
let registrations = [];
206-
response.data.registrations.forEach(function(r) {
206+
response.data.registrations.forEach(function (r) {
207207
registrations.push({
208208
date: moment(r.date).format('YYYY-MM-DD HH:mm:ss'),
209209
username: r.username,
210-
active: r.active ? t('YES') : t('NO')
210+
active: r.active ? t('YES') : t('NO'),
211211
});
212212
});
213213

@@ -234,35 +234,38 @@ class Dashboard extends React.Component {
234234
label_month,
235235
data_month_new,
236236
data_month_total,
237-
registrations
237+
registrations,
238238
});
239239
psono_client.set_url(response.data.info.web_client);
240-
return psono_client.get_version().then(response => {
240+
return psono_client.get_version().then((response) => {
241241
this.setState({
242-
client_used_version: 'v' + response.data.split(' ')[0]
242+
client_used_version: 'v' + response.data.split(' ')[0],
243243
});
244244
});
245245
});
246246

247-
axios.get('/portal/VERSION.txt').then(response => {
248-
this.setState({
249-
admin_client_used_version: 'v' + response.data.split(' ')[0]
247+
axios
248+
.get('/portal/VERSION.txt?t=' + new Date().getTime())
249+
.then((response) => {
250+
this.setState({
251+
admin_client_used_version:
252+
'v' + response.data.split(' ')[0],
253+
});
250254
});
251-
});
252255
}
253256

254257
render() {
255258
const { t } = this.props;
256259
const {
257260
count_registrations_second_week,
258-
count_registrations_first_week
261+
count_registrations_first_week,
259262
} = this.state;
260263
const { files } = this.props.state.server;
261264
let registration_text;
262265
if (this.state.count_registrations_second_week) {
263266
let percentage = Math.round(
264-
this.state.count_registrations_second_week /
265-
this.state.count_registrations_first_week *
267+
(this.state.count_registrations_second_week /
268+
this.state.count_registrations_first_week) *
266269
100 -
267270
100
268271
);
@@ -354,16 +357,17 @@ class Dashboard extends React.Component {
354357
labels: this.state.label_day,
355358
series: [
356359
this.state.data_day_total,
357-
this.state.data_day_new
358-
]
360+
this.state.data_day_new,
361+
],
359362
}}
360363
type="Line"
361364
options={{
362-
lineSmooth: Chartist.Interpolation.cardinal(
363-
{
364-
tension: 0
365-
}
366-
),
365+
lineSmooth:
366+
Chartist.Interpolation.cardinal(
367+
{
368+
tension: 0,
369+
}
370+
),
367371
low: 0,
368372
high:
369373
Math.max(
@@ -375,7 +379,7 @@ class Dashboard extends React.Component {
375379
top: 0,
376380
right: 0,
377381
bottom: 10,
378-
left: 10
382+
left: 10,
379383
},
380384
plugins: [
381385
Chartist.plugins.ctAxisTitle({
@@ -386,21 +390,21 @@ class Dashboard extends React.Component {
386390
axisClass: 'ct-label',
387391
offset: {
388392
x: 0,
389-
y: 35
393+
y: 35,
390394
},
391-
textAnchor: 'middle'
395+
textAnchor: 'middle',
392396
},
393397
axisY: {
394398
axisTitle: t('USERS'),
395399
axisClass: 'ct-label',
396400
offset: {
397401
x: 10,
398-
y: -10
402+
y: -10,
399403
},
400-
flipTitle: false
401-
}
402-
})
403-
]
404+
flipTitle: false,
405+
},
406+
}),
407+
],
404408
}}
405409
listener={dailySalesChart.animation}
406410
/>
@@ -439,16 +443,17 @@ class Dashboard extends React.Component {
439443
labels: this.state.label_month,
440444
series: [
441445
this.state.data_month_total,
442-
this.state.data_month_new
443-
]
446+
this.state.data_month_new,
447+
],
444448
}}
445449
type="Line"
446450
options={{
447-
lineSmooth: Chartist.Interpolation.cardinal(
448-
{
449-
tension: 0
450-
}
451-
),
451+
lineSmooth:
452+
Chartist.Interpolation.cardinal(
453+
{
454+
tension: 0,
455+
}
456+
),
452457
low: 0,
453458
high:
454459
Math.max(
@@ -460,7 +465,7 @@ class Dashboard extends React.Component {
460465
top: 0,
461466
right: 0,
462467
bottom: 10,
463-
left: 10
468+
left: 10,
464469
},
465470
plugins: [
466471
Chartist.plugins.ctAxisTitle({
@@ -471,21 +476,21 @@ class Dashboard extends React.Component {
471476
axisClass: 'ct-label',
472477
offset: {
473478
x: 0,
474-
y: 35
479+
y: 35,
475480
},
476-
textAnchor: 'middle'
481+
textAnchor: 'middle',
477482
},
478483
axisY: {
479484
axisTitle: t('USERS'),
480485
axisClass: 'ct-label',
481486
offset: {
482487
x: 10,
483-
y: -10
488+
y: -10,
484489
},
485-
flipTitle: false
486-
}
487-
})
488-
]
490+
flipTitle: false,
491+
},
492+
}),
493+
],
489494
}}
490495
listener={dailySalesChart.animation}
491496
/>
@@ -582,12 +587,12 @@ class Dashboard extends React.Component {
582587
{ field: 'date', title: t('DATE') },
583588
{
584589
field: 'username',
585-
title: t('USERNAME')
590+
title: t('USERNAME'),
586591
},
587592
{
588593
field: 'active',
589-
title: t('ACTIVE')
590-
}
594+
title: t('ACTIVE'),
595+
},
591596
]}
592597
data={this.state.registrations}
593598
title={''}
@@ -603,9 +608,10 @@ class Dashboard extends React.Component {
603608
}
604609

605610
Dashboard.propTypes = {
606-
classes: PropTypes.object.isRequired
611+
classes: PropTypes.object.isRequired,
607612
};
608613

609-
export default compose(withTranslation(), withStyles(dashboardStyle))(
610-
Dashboard
611-
);
614+
export default compose(
615+
withTranslation(),
616+
withStyles(dashboardStyle)
617+
)(Dashboard);

0 commit comments

Comments
 (0)