Skip to content

Commit

Permalink
add pwa support, ask mobile users to download app (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
SponsoredByPuma authored Feb 22, 2024
1 parent 512800d commit 5b2fbf0
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 17 deletions.
13 changes: 7 additions & 6 deletions docs/guide/architecture.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
tags:
- architecture
- frontend
- backend
- REST
- WebSocket
- architecture
- frontend
- backend
- REST
- WebSocket
---

# Software Architecture
Expand Down Expand Up @@ -85,6 +85,7 @@ frontend
| CardSetComponent | Card set selection in page "PrepareSession" |
| CopySessionIdPopup | Link including a popup with the functionalities: copy code or link to clipboard |
| EstimateTimer | Displays the timer and has the logic for the countdown |
| DownloadPWAModal | Modal to ask mobile users to download the app |
| JiraComponent | Component for the "Planning with Jira" tab. |
| JoinPageCard | Card for joining a Session in page "JoinPage" |
| LandingPageCard | Cards for "New Session"/"Join Session"/"Reconnect to Session" in page "LandingPage" |
Expand Down Expand Up @@ -143,7 +144,7 @@ backend
|---------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| WebSocketConfig | Configurations (e.g. prefixes, CORS) for Websockets |
| ----------- | |
| ConfigController | REST Controller for project configuration |
| ConfigController | REST Controller for project configuration |
| ControllerUtils | Helper functions for all controllers |
| ErrorMessages | All error messages which can be thrown in exceptions |
| ProjectManagementController | REST Controller for project management software (e.g. Jira) |
Expand Down
Binary file added frontend/public/img/icons/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/img/icons/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions frontend/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Diveni",
"short_name": "Diveni",
"theme_color": "#8cc04d",
"icons": [
{
"src": "./img/icons/logo192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "./img/icons/logo512.png",
"sizes": "512x512",
"type": "image/png"
},
{
"src": "./img/icons/logo192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "./img/icons/logo512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"start_url": ".",
"display": "standalone",
"background_color": "#000000"
}
68 changes: 68 additions & 0 deletions frontend/src/components/DownloadPWAModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<template>
<b-modal
v-model="checkIfNotInstalled"
class="test"
centered
title="Download Diveni"
@ok="install()"
@hide="closeModal()"
>
{{t('page.landing.install')}}
</b-modal>
</template>

<script lang="ts">
import {defineComponent, ref} from "vue";
import {useI18n} from "vue-i18n";
export default defineComponent({
name: "DownloadPWAModal",
setup() {
const deferredPrompt: any = ref();
const checkIfNotInstalled = false;
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault();
deferredPrompt.value = e;
});
window.addEventListener("appinstalled", () => {
deferredPrompt.value = null;
});
const { t } = useI18n();
return {deferredPrompt, checkIfNotInstalled, t};
},
computed: {
isMobile() {
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);
},
},
created() {
const isInStandaloneMode = () =>
(window.matchMedia('(display-mode: standalone)').matches) || document.referrer.includes('android-app://');
this.checkIfNotInstalled = this.isMobile && !isInStandaloneMode() && !localStorage.getItem('downloadPWA');
},
methods: {
closeModal() {
localStorage.setItem('downloadPWA', 'true');
},
async install() {
console.log("Installing...");
if (this.deferredPrompt) {
this.deferredPrompt.prompt();
this.deferredPrompt.userChoice.then((choiceResult: any) => {
if (choiceResult.outcome === 'accepted') {
console.log('User accepted the Diveni prompt');
} else {
console.log('User dismissed the Diveni prompt');
}
this.deferredPrompt = null;
});
}
},
},
});
</script>

<style scoped lang="scss"></style>
3 changes: 2 additions & 1 deletion frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
"label": "What's new"
}
}
}
},
"install": "Do you want to install Diveni on your Device?"
},
"join": {
"title": "Join the session",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/views/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<h1 class="mt-5">Connectors</h1>
</b-container>
<CarouselComponent class="py-5"></CarouselComponent>
<DownloadPWAModal/>
</div>
</template>

Expand All @@ -123,9 +124,11 @@ import AnalyticsDataComponent from "../components/AnalyticsDataComponent.vue";
import { useDiveniStore } from "@/store";
import { useI18n } from "vue-i18n";
import CarouselComponent from "@/components/CarouselComponent.vue";
import DownloadPWAModal from "@/components/DownloadPWAModal.vue";
export default defineComponent({
name: "LandingPage",
components: {
DownloadPWAModal,
LandingPageCard,
AnalyticsDataComponent,
CarouselComponent,
Expand Down
15 changes: 5 additions & 10 deletions frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
module.exports = {
pwa: {
manifestOptions: {
icons: [],
},
iconPaths: {
favicon32: "./favicon.ico",
favicon16: "./favicon.ico",
appleTouchIcon: "./icons/apple-touch-icon.png",
maskIcon: "./favicon.ico",
msTileImage: "./favicon.ico",
},
name: 'Diveni',
themeColor: '#8cc04d',
msTileColor: '#000000',
appleMobileWebAppCapable: 'yes',
appleMobileWebAppStatusBarStyle: 'black',
},
configureWebpack: {
optimization: {
Expand Down

0 comments on commit 5b2fbf0

Please sign in to comment.