Skip to content

Commit 7f81a54

Browse files
authored
Merge pull request #588 from MerginMaps/add-logo-customization
Add logic for setting custom web logos
2 parents 8215697 + 70a3aa4 commit 7f81a54

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

server/mergin/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class Configuration(object):
7979
MERGIN_BASE_URL = config("MERGIN_BASE_URL", default="")
8080
# for link to logo in emails
8181
MERGIN_LOGO_URL = config("MERGIN_LOGO_URL", default="")
82+
# for link to logos in EE branding
83+
DASHBOARD_LOGO_URL = config("DASHBOARD_LOGO_URL", default=MERGIN_LOGO_URL)
8284

8385
MERGIN_SUBSCRIPTIONS = config("MERGIN_SUBSCRIPTIONS", default=False, cast=bool)
8486
MERGIN_TESTING = config("MERGIN_TESTING", default=False, cast=bool)

web-app/packages/lib/src/common/components/AppOnboardingPage.vue

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77
{ 'onborading-page-logo': $slots.aside }
88
]"
99
>
10-
<slot name="logo">
11-
<img src="@/assets/mm-logo.svg" />
10+
<template v-if="brandingLogoUrl && !customLogoLoadFailed">
11+
<img
12+
class="logo-image"
13+
:src="brandingLogoUrl"
14+
@error="onCustomLogoError"
15+
alt="Not Found"
16+
/>
17+
</template>
18+
<slot v-else name="logo">
19+
<img class="logo-image" :src="defaultLogoUrl" alt="Not Found" />
1220
</slot>
1321
</aside>
1422

@@ -45,12 +53,35 @@
4553
</template>
4654

4755
<script setup lang="ts">
56+
import { ref, computed } from 'vue'
57+
58+
import defaultLogoUrl from '@/assets/mm-logo.svg'
59+
import { useInstanceStore } from '@/modules/instance/store'
60+
61+
const customLogoLoadFailed = ref(false)
62+
function onCustomLogoError(): void {
63+
customLogoLoadFailed.value = true
64+
}
65+
const instanceStore = useInstanceStore()
66+
const brandingLogoUrl = computed(
67+
() => instanceStore.configData?.['dashboard_logo_url'] as string
68+
)
69+
4870
withDefaults(defineProps<{ contentMaxWidth?: string }>(), {
4971
contentMaxWidth: '480px'
5072
})
5173
</script>
5274

5375
<style scoped lang="scss">
76+
.logo-image {
77+
display: block;
78+
width: auto;
79+
height: 24px;
80+
max-width: 129px;
81+
max-height: 24px;
82+
object-fit: contain;
83+
}
84+
5485
@media screen and (min-width: $md) {
5586
.onborading-page-logo {
5687
// reset background on tablet > screens

web-app/packages/lib/src/modules/layout/components/SideBarTemplate.vue

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
3535
/>
3636
</div>
3737

38-
<div class="flex justify-content-center">
39-
<img src="@/assets/mm-logo.svg" />
38+
<div class="logo flex justify-content-center">
39+
<img
40+
class="logo-image"
41+
:src="logoUrl"
42+
@error="onCustomLogoError"
43+
alt="Not Found"
44+
/>
4045
</div>
4146

4247
<div
@@ -79,16 +84,32 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-MerginMaps-Commercial
7984
</template>
8085

8186
<script setup lang="ts">
82-
import { computed } from 'vue'
87+
import { ref, computed } from 'vue'
8388
import { useRoute } from 'vue-router'
8489
8590
import { SideBarItemModel } from '../types'
8691
92+
import defaultLogoUrl from '@/assets/mm-logo.svg'
8793
import { DashboardRouteName, useUserStore } from '@/main'
94+
import { useInstanceStore } from '@/modules/instance/store'
8895
import SideBarItem from '@/modules/layout/components/SideBarItem.vue'
8996
import { useLayoutStore } from '@/modules/layout/store'
9097
import { ProjectRouteName } from '@/modules/project'
9198
99+
const customLogoLoadFailed = ref(false)
100+
function onCustomLogoError(): void {
101+
customLogoLoadFailed.value = true
102+
}
103+
const instanceStore = useInstanceStore()
104+
const brandingLogoUrl = computed(
105+
() => instanceStore.configData?.['dashboard_logo_url'] as string
106+
)
107+
const logoUrl = computed(() =>
108+
brandingLogoUrl.value && !customLogoLoadFailed.value
109+
? brandingLogoUrl.value
110+
: defaultLogoUrl
111+
)
112+
92113
const route = useRoute()
93114
const layoutStore = useLayoutStore()
94115
const userStore = useUserStore()
@@ -142,6 +163,18 @@ const onCloseClick = () => {
142163
);
143164
}
144165
}
166+
.logo {
167+
max-width: 100%;
168+
169+
&-image {
170+
display: block;
171+
width: auto;
172+
height: 24px;
173+
max-width: 129px;
174+
max-height: 24px;
175+
object-fit: contain;
176+
}
177+
}
145178
146179
@media screen and (max-width: $xl) {
147180
.sidebar {

0 commit comments

Comments
 (0)