Skip to content

Commit 8b0b79c

Browse files
committed
Merged in error-messages (pull request #24)
Error messages
2 parents 6df8a57 + 3ef5407 commit 8b0b79c

File tree

6 files changed

+178
-48
lines changed

6 files changed

+178
-48
lines changed

vue/src/assets/styles/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ a {
8080

8181
#snapshotnav {
8282
height: calc(100vh - var(--vh-offset, 0px)) !important;
83-
z-index: 9999; /* must be above mapbox interface */
83+
z-index: 100; /* must be above mapbox interface */
8484
}
8585

8686
#snapshotnavContent {
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!-- eslint-disable -->
2+
<i18n>
3+
{
4+
"de": {
5+
"title": "Fehler",
6+
"text": "Da ist was schiefgegangen...",
7+
"netwokerror.title": "Verbindungsfehler",
8+
"netwokerror.text": "Benötigte Daten konnten nicht geladen werden.",
9+
"button.ok": "OK",
10+
"button.retry": "Seite neu laden",
11+
"button.back": "Zur Startseite",
12+
"button.contact": "Problem melden"
13+
},
14+
"fr": {
15+
"title": "Fehler",
16+
"text": "Da ist was schiefgegangen...",
17+
"netwokerror.title": "Verbindungsfehler",
18+
"netwokerror.text": "Benötigte Daten konnten nicht geladen werden.",
19+
"button.ok": "OK",
20+
"button.retry": "Nochmals versuchen",
21+
"button.back": "Zur Startseite",
22+
"button.contact": "Problem melden"
23+
}
24+
}
25+
</i18n>
26+
<!-- eslint-enable -->
27+
28+
<template>
29+
<v-dialog persistent v-model="settings.open" class="errormessage" width="400">
30+
<v-card>
31+
<v-card-title>{{titleString}}</v-card-title>
32+
<v-card-text>{{textString}}</v-card-text>
33+
<v-card-actions class="pb-4 pr-4">
34+
<v-spacer></v-spacer>
35+
<v-btn depressed color="gray" @click="composeEmail">{{$t('button.contact')}}</v-btn>
36+
<v-btn depressed color="primary" class="ml-4" :to="'/' + $i18n.locale + '/'">
37+
{{$t('button.back')}}
38+
</v-btn>
39+
</v-card-actions>
40+
</v-card>
41+
</v-dialog>
42+
</template>
43+
44+
<style scoped>
45+
.errormessage {
46+
z-index: 666;
47+
}
48+
</style>
49+
50+
<script>
51+
export default {
52+
name: 'ErrorMessage',
53+
data() {
54+
return {
55+
};
56+
},
57+
props: {
58+
settings: Object
59+
},
60+
61+
computed: {
62+
titleString() {
63+
if (this.settings.title) {
64+
return this.settings.title;
65+
} if (this.settings.type) {
66+
return this.$t(`${this.settings.type}.title`);
67+
}
68+
return this.$t('title');
69+
},
70+
textString() {
71+
if (this.settings.text) {
72+
return this.settings.text;
73+
} if (this.settings.type) {
74+
return this.$t(`${this.settings.type}.text`);
75+
}
76+
return this.$t('text');
77+
}
78+
},
79+
methods: {
80+
forceReload() {
81+
window.location.reload();
82+
},
83+
composeEmail() {
84+
window.location.href = `mailto:[email protected]?subject=${this.titleString}&body=`;
85+
}
86+
}
87+
};
88+
</script>

vue/src/components/SnapshotMap.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ body,
7474
clip-path: circle(0% at 95% 90%);
7575
transition: clip-path 0.3s ease-out;
7676
pointer-events: none;
77-
z-index: 1000; /* must be above mapbox icons */
77+
z-index: 500; /* must be above mapbox icons */
7878
}
7979
8080
#mapinfo.open {

vue/src/views/Home.vue

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"Gemeindescan Schweiz",
1212
"h2.2": "Fallbeispiele",
1313
"p.3": "«Als Gemeindepräsident ist es mir wichtig, der Bevölkerung und dem Gemeinderat die Komplexität des Ortsplanungsprozesses und der Standortentwicklung verständlich und einfach zu übermitteln. Mit Hilfe von Daten und Visualisierungen über den Gemeindescan fällt es mir leichter, Lösungen und wichtige Entscheide zu fällen!»",
14-
"p.4": "Gemeindepräsident Wittenbach"
14+
"p.4": "Gemeindepräsident Wittenbach",
15+
"networkerror": "Die Gemeindesuche ist zZ nicht verfügbar."
1516
},
1617
"fr": {
1718
"h1.1": "Découvrez le potentiel en terme d'habitat de votre communauté.",
@@ -23,15 +24,15 @@
2324
"Le Gemeindescan Suisse",
2425
"h2.2": "Examples",
2526
"p.3": "«En tant que maire, il est important pour moi de communiquer la complexité du processus de planification locale et du développement urbain à la population et au conseil municipal de manière simple et compréhensible. Avec l'aide des données et des visualisations via les analyses de la communauté, il m'est plus facile de trouver des solutions et de prendre des décisions importantes!»",
26-
"p.4": "Le maire de la municipalité Wittenbach"
27+
"p.4": "Le maire de la municipalité Wittenbach",
28+
"networkerror": "Die Gemeindesuche ist zZ nicht verfügbar."
2729
}
2830
}
2931
</i18n>
3032
<!-- eslint-enable -->
3133

3234
<template>
3335
<div>
34-
<!-- eslint-disable max-len -->
3536
<v-container my-12 >
3637
<div class="gmdscn">
3738
<img :alt="$t('img.1.alt')" class="" width="100%"
@@ -47,7 +48,7 @@
4748
</v-row>
4849
</v-container>
4950

50-
<v-container class="center" fluid mb-12>
51+
<v-container v-if="!{networkError}" class="center" fluid mb-12>
5152
<v-row justify="center" >
5253
<v-col class="introtxt text-center">
5354
<h2>{{ $t('h2.2') }}</h2>
@@ -66,7 +67,9 @@
6667
<v-fade-transition>
6768
<v-overlay v-if="hover" color="primary" opacity="0.6" absolute
6869
style="text-transform: none; white-space: normal; hyphens: auto;">
69-
<h5 style="font-weight: bold; line-height: 1.2em; padding:0.3em;">{{snapshot.title}}</h5>
70+
<h5 style="font-weight: bold; line-height: 1.2em; padding:0.3em;">
71+
{{snapshot.title}}
72+
</h5>
7073
<span style="">{{snapshot.topic}}<br>-<br>{{snapshot.municipality.name}}</span>
7174
</v-overlay>
7275
</v-fade-transition>
@@ -75,11 +78,15 @@
7578
</v-btn>
7679
</div>
7780
</v-col>
78-
7981
</v-row>
80-
8182
</v-container>
8283

84+
<v-snackbar color="primary" v-model="snackbar" :timeout="9000">
85+
{{ $t('networkerror') }}
86+
<v-btn icon @click="snackbar=false" >
87+
<v-icon>mdi-close-circle-outline</v-icon>
88+
</v-btn>
89+
</v-snackbar>
8390
<!--
8491
<v-container class="" justify-center my-12>
8592
<v-row justify="center">
@@ -128,7 +135,9 @@ export default {
128135
data() {
129136
return {
130137
djangobaseurl: process.env.VUE_APP_DJANGOBASEURL,
131-
snapshotsExamples: []
138+
snapshotsExamples: [],
139+
networkError: false,
140+
snackbar: false
132141
};
133142
},
134143
created() {
@@ -157,10 +166,15 @@ export default {
157166
}
158167
}
159168
}`
169+
}).catch((error) => {
170+
console.log(error);
171+
this.snackbar = true;
160172
});
161-
const snapshots = result.data.snapshots.edges.map(snapshot => snapshot.node);
162-
// fake random, for more randomness, use https://www.npmjs.com/package/lodash.shuffle package
163-
this.snapshotsExamples = snapshots.sort(() => (Math.random() > 0.5 ? -1 : 1)).slice(0, 3);
173+
if (result) {
174+
const snapshots = result.data.snapshots.edges.map(snapshot => snapshot.node);
175+
// fake random, for more randomness, use https://www.npmjs.com/package/lodash.shuffle package
176+
this.snapshotsExamples = snapshots.sort(() => (Math.random() > 0.5 ? -1 : 1)).slice(0, 3);
177+
}
164178
}
165179
}
166180
};

vue/src/views/Snapshot.vue

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595
:geoboundsIn="geobounds"
9696
:predecessor="predecessor"
9797
/>
98+
99+
<error-message
100+
:settings="errorsettings"
101+
/>
98102
</div>
99103
</template>
100104

@@ -119,9 +123,11 @@ import Vue from 'vue';
119123
import gql from 'graphql-tag';
120124
import SnapshotList from '../components/SnapshotList.vue';
121125
import SnapshotMap from '../components/SnapshotMap.vue';
126+
import ErrorMessage from '../components/ErrorMessage.vue';
122127
123128
Vue.component('snapshot-list', SnapshotList);
124129
Vue.component('snapshot-map', SnapshotMap);
130+
Vue.component('error-message', ErrorMessage);
125131
126132
export default {
127133
data() {
@@ -136,7 +142,8 @@ export default {
136142
snapshotsMunicipality: [],
137143
predecessor: null,
138144
screenshotMode: this.$route.query.hasOwnProperty('screenshot'),
139-
screenshotIsThumbnail: this.$route.query.hasOwnProperty('thumbnail')
145+
screenshotIsThumbnail: this.$route.query.hasOwnProperty('thumbnail'),
146+
errorsettings: {}
140147
};
141148
},
142149
@@ -226,20 +233,28 @@ export default {
226233
variables: {
227234
hash: btoa(`SnapshotNode:${hash}`)
228235
}
236+
}).catch((error) => {
237+
this.errorsettings = { type: 'netwokerror', open: true, error };
229238
});
230-
if (result.data.hasOwnProperty('snapshot') && result.data.snapshot) {
231-
this.geojson = result.data.snapshot.data;
232-
this.municipalityName = result.data.snapshot.municipality.fullname;
233-
this.snapshotsMunicipality = result.data.snapshot.municipality.snapshots;
234-
const snapshotsIdExamplesExclude = this.snapshotsMunicipality.map(snapshot => snapshot.id);
235-
this.snapshotsExamples = result.data.snapshots.edges.map(snapshot => snapshot.node).filter(
236-
snapshot => !snapshotsIdExamplesExclude.includes(snapshot.id)
237-
);
238-
this.predecessor = (result.data.snapshot.predecessor);
239-
this.$store.commit('setBfsnumber', result.data.snapshot.municipality.bfsNumber);
240-
this.$store.commit('setBfsname', result.data.snapshot.municipality.fullname);
241-
} else {
242-
this.$router.push({ name: 'home' });
239+
if (result) {
240+
if (result.data.hasOwnProperty('snapshot') && result.data.snapshot) {
241+
this.geojson = result.data.snapshot.data;
242+
this.municipalityName = result.data.snapshot.municipality.fullname;
243+
this.snapshotsMunicipality = result.data.snapshot.municipality.snapshots;
244+
const snapshotsIdExamplesExclude = this.snapshotsMunicipality.map(
245+
snapshot => snapshot.id
246+
);
247+
this.snapshotsExamples = result.data.snapshots.edges.map(
248+
snapshot => snapshot.node
249+
).filter(
250+
snapshot => !snapshotsIdExamplesExclude.includes(snapshot.id)
251+
);
252+
this.predecessor = (result.data.snapshot.predecessor);
253+
this.$store.commit('setBfsnumber', result.data.snapshot.municipality.bfsNumber);
254+
this.$store.commit('setBfsname', result.data.snapshot.municipality.fullname);
255+
} else {
256+
this.$router.push({ name: 'home' });
257+
}
243258
}
244259
},
245260
@@ -278,13 +293,17 @@ export default {
278293
variables: {
279294
bfsNumber: btoa(`MunicipalityNode:${bfsNumber}`)
280295
}
296+
}).catch((error) => {
297+
this.errorsettings = { type: 'netwokerror', open: true, error };
281298
});
282-
this.municipalityName = result.data.municipality.fullname;
283-
this.geojson = result.data.municipality.perimeter;
284-
this.geobounds = result.data.municipality.perimeterBounds;
285-
this.snapshotsExamples = result.data.snapshots.edges.map(snapshot => snapshot.node);
286-
this.$store.commit('setBfsnumber', result.data.municipality.bfsNumber);
287-
this.$store.commit('setBfsname', result.data.municipality.fullname);
299+
if (result) {
300+
this.municipalityName = result.data.municipality.fullname;
301+
this.geojson = result.data.municipality.perimeter;
302+
this.geobounds = result.data.municipality.perimeterBounds;
303+
this.snapshotsExamples = result.data.snapshots.edges.map(snapshot => snapshot.node);
304+
this.$store.commit('setBfsnumber', result.data.municipality.bfsNumber);
305+
this.$store.commit('setBfsname', result.data.municipality.fullname);
306+
}
288307
}
289308
}
290309
};

vue/src/views/Workspace.vue

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
:geojson="geojson"
5656
:geoboundsIn="geobounds"
5757
/>
58-
58+
<error-message
59+
:settings="errorsettings"
60+
/>
5961
</div>
6062
</template>
6163

@@ -84,9 +86,11 @@ import Vue from 'vue';
8486
import gql from 'graphql-tag';
8587
import SnapshotList from '../components/SnapshotList.vue';
8688
import SnapshotMap from '../components/SnapshotMap.vue';
89+
import ErrorMessage from '../components/ErrorMessage.vue';
8790
8891
Vue.component('snapshot-list', SnapshotList);
8992
Vue.component('snapshot-map', SnapshotMap);
93+
Vue.component('error-message', ErrorMessage);
9094
9195
export default {
9296
data() {
@@ -98,7 +102,8 @@ export default {
98102
municipalityName: '',
99103
snapshotsWorkspace: [],
100104
title: '',
101-
description: ''
105+
description: '',
106+
errorsettings: {}
102107
};
103108
},
104109
@@ -170,22 +175,26 @@ export default {
170175
wshash: btoa(`WorkspaceNode:${this.wshash}`),
171176
hash: btoa(`SnapshotNode:${this.hash}`)
172177
}
178+
}).catch((error) => {
179+
this.errorsettings = { type: 'netwokerror', open: true, error };
173180
});
174-
if (result.data.hasOwnProperty('workspace') && result.data.workspace) {
175-
const workspace = result.data.workspace;
176-
const snapshot = result.data.snapshot;
177-
if (!workspace.snapshots.map(s => s.pk).includes(snapshot.pk)) {
181+
if (result) {
182+
if (result.data.hasOwnProperty('workspace') && result.data.workspace) {
183+
const workspace = result.data.workspace;
184+
const snapshot = result.data.snapshot;
185+
if (!workspace.snapshots.map(s => s.pk).includes(snapshot.pk)) {
186+
this.$router.push({ name: 'home' });
187+
}
188+
this.geojson = snapshot.data;
189+
this.municipalityName = snapshot.municipality.fullname;
190+
this.snapshotsWorkspace = workspace.snapshots;
191+
this.title = workspace.title;
192+
this.description = workspace.description;
193+
this.$store.commit('setBfsnumber', snapshot.municipality.bfsNumber);
194+
this.$store.commit('setBfsname', snapshot.municipality.fullname);
195+
} else {
178196
this.$router.push({ name: 'home' });
179197
}
180-
this.geojson = snapshot.data;
181-
this.municipalityName = snapshot.municipality.fullname;
182-
this.snapshotsWorkspace = workspace.snapshots;
183-
this.title = workspace.title;
184-
this.description = workspace.description;
185-
this.$store.commit('setBfsnumber', snapshot.municipality.bfsNumber);
186-
this.$store.commit('setBfsname', snapshot.municipality.fullname);
187-
} else {
188-
this.$router.push({ name: 'home' });
189198
}
190199
}
191200
}

0 commit comments

Comments
 (0)