Skip to content

Commit 482e490

Browse files
authored
#363 Detect browser incompability (#41)
* added browser check lib * browser check component * browser-check component * new js build * pr refactor * better browser version check
1 parent 5c526e6 commit 482e490

File tree

14 files changed

+99
-27
lines changed

14 files changed

+99
-27
lines changed

django_project_base/account/rest/impersonate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ImpersonateUserDialogSerializer(serializers.Serializer):
3131
}
3232

3333
# TODO: Trenutno je narejena samo komponenta. HTML dialog pa ne... ali je to v redu?
34-
form_template = 'accounts/impersonate_dialog.html'
34+
form_template = 'accounts/impersonate-dialog.html'
3535

3636
# TODO: Placeholderja še ni... je samo predviden v komponentah... ampak se še nikjer ne definira
3737
# TODO: Trenutno se polje na roko definira na custom layoutu. Treba je podpreti, da bo tudi standardni input

django_project_base/js_app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
},
1010
"dependencies": {
1111
"@babel/polyfill": "^7.12.1",
12-
"bootstrap": "^4.6.0",
1312
"axios": "^0.21.1",
13+
"bootstrap": "^4.6.0",
14+
"browser-update": "^3.3.37",
1415
"core-js": "^3.6.5",
1516
"dynamicforms": "^0.1.0",
1617
"es6-promise": "^4.2.8",

django_project_base/js_app/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
<!-- built files will be auto injected -->
2020
</body>
2121
<script>
22-
createApp('app', '<TitleBar :projectlistVisible="true"/>', 'modal-app');
22+
createApp('app', '<BrowserCheck :hidePageIfUnSupportedBrowser="false"><TitleBar v-slot:content :projectlistVisible="true"/></BrowserCheck>', 'modal-app');
2323
</script>
2424
</html>

django_project_base/js_app/src/apps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Login from './components/bootstrap/login.vue';
1212
import ProjectList from './components/bootstrap/projectlist.vue';
1313
import TitleBar from './components/bootstrap/titlebar.vue';
1414
import UserProfile from './components/bootstrap/userprofile.vue';
15+
import BrowserCheck from './components/browser-check.vue';
1516
import Notification from './components/notification.vue';
1617

1718
const componentsConfig = {
@@ -21,6 +22,7 @@ const componentsConfig = {
2122
ProjectList,
2223
UserProfile,
2324
Notification,
25+
BrowserCheck,
2426
};
2527

2628
const createApp = (elementId, template, modalId) => {

django_project_base/js_app/src/components/bootstrap/impersonate_dialog.vue renamed to django_project_base/js_app/src/components/bootstrap/impersonate-dialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import _ from 'lodash';
3333
import { apiClient as ApiClient } from '../../apiClient';
3434
3535
export default {
36-
name: 'accounts-impersonate_dialog.html', // eslint-disable-line vue/component-definition-name-casing
36+
name: 'accounts-impersonate-dialog.html', // eslint-disable-line vue/component-definition-name-casing
3737
props: {
3838
uuid: { type: String, required: true },
3939
record: { type: Object, required: true },

django_project_base/js_app/src/components/bootstrap/userprofile.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import ProjectBaseData from '../../projectBaseData';
5353
import { Session } from '../../session';
5454
import { Store } from '../../store';
5555
56-
import ImpersonateDialog from './impersonate_dialog.vue';
56+
import ImpersonateDialog from './impersonate-dialog.vue';
5757
5858
Vue.component(ImpersonateDialog.name, ImpersonateDialog);
5959
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<template>
2+
<div v-if="!pageHidden">
3+
<slot/>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import browserUpdate from 'browser-update';
9+
10+
export default {
11+
name: 'BrowserCheck',
12+
props: {
13+
hidePageIfUnSupportedBrowser: {
14+
type: Boolean,
15+
default: false,
16+
},
17+
},
18+
data() {
19+
return {
20+
pageHidden: false,
21+
checkInterval: null,
22+
};
23+
},
24+
beforeDestroy() {
25+
this.clearCheck();
26+
this.pageHidden = false;
27+
},
28+
mounted() {
29+
browserUpdate({
30+
required: {
31+
e: -4, f: -4, o: -4, s: -4, c: -4,
32+
},
33+
insecure: true,
34+
unsupported: true,
35+
reminder: 0,
36+
reminderClosed: 1,
37+
noclose: true,
38+
}, false);
39+
this.checkInterval = setInterval(() => {
40+
if (this.hidePageIfUnSupportedBrowser && this.isBrowserNotificationShown() && !this.pageHidden) {
41+
this.pageHidden = true;
42+
}
43+
}, 250);
44+
setTimeout(() => {
45+
this.clearCheck();
46+
}, 10000);
47+
},
48+
methods: {
49+
isBrowserNotificationShown() {
50+
return !!document.getElementById('buorg');
51+
},
52+
clearCheck() {
53+
if (this.checkInterval) {
54+
clearInterval(this.checkInterval);
55+
this.checkInterval = null;
56+
}
57+
},
58+
},
59+
};
60+
</script>

django_project_base/static/django-project-base/css/django-project-base-vendor.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

django_project_base/static/django-project-base/css/django-project-base.css

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

django_project_base/static/django-project-base/js/django-project-base-vendors.js

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

0 commit comments

Comments
 (0)