Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
feat: Image menu (#2182)
Browse files Browse the repository at this point in the history
* Image support in the company

* Minimal changes
  • Loading branch information
elsiosanchez authored Apr 25, 2024
1 parent a8b4a5e commit aef83c3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
54 changes: 53 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<script>
// components and mixins
import ModalIdle from '@/components/ADempiere/ModalIdle'
// Utils and Helper Methods
import { getResourcePath } from '@/utils/ADempiere/resource'
// Constants
import { config } from '@/utils/ADempiere/config'
export default {
name: 'App',
Expand All @@ -21,9 +25,38 @@ export default {
},
isSession() {
return this.$store.getters['user/getIsSession']
},
getRole() {
return this.$store.getters['user/getRole']
},
getResourceName() {
return this.$store.getters['user/getRole'].client.logo
}
},
watch: {
getResourceName(value) {
this.loadImage()
}
},
mounted() {
async mounted() {
const { client } = this.getRole
if (client.logo) {
const fileName = await getResourcePath({
clientId: client.id,
containerId: '109',
containerType: 'window',
columnName: 'Logo_ID',
recordId: client.id,
tableName: 'AD_ClientInfo',
resourceName: client.logo
})
const link = document.createElement('link')
link.rel = 'shortcut icon'
link.type = 'image/x-icon'
link.href = config.adempiere.resource.url + fileName
document.head.appendChild(link)
}
this.$nextTick(() => {
window.addEventListener('resize', this.getWindowWidth)
window.addEventListener('resize', this.getWindowHeight)
Expand All @@ -37,6 +70,25 @@ export default {
window.removeEventListener('resize', this.getWindowHeight)
},
methods: {
async loadImage() {
const { client } = this.getRole
if (client.logo) {
const fileName = await getResourcePath({
clientId: client.id,
containerId: '109',
containerType: 'window',
columnName: 'Logo_ID',
recordId: client.id,
tableName: 'AD_ClientInfo',
resourceName: client.logo
})
const link = document.createElement('link')
link.rel = 'shortcut icon'
link.type = 'image/x-icon'
link.href = config.adempiere.resource.url + fileName
document.head.appendChild(link)
}
},
getWindowWidth(event) {
this.$store.dispatch('setWidth', document.documentElement.clientWidth)
},
Expand Down
11 changes: 9 additions & 2 deletions src/layout/components/Sidebar/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@
{{ getRole.name }} | {{ getRole.client.name }} | {{ storedOrganization.name }}
</div>
<img v-if="clientLogo" :src="clientLogo" class="sidebar-logo" style="height: 50px;width: 50px;">
<svg-icon v-else icon-class="AD" class="standard-logo" />
<img v-else src="https://avatars1.githubusercontent.com/u/1263359?s=200&v=4" class="sidebar-logo" style="height: 50px;width: 50px;">
<!-- <svg-icon v-else icon-class="AD" class="standard-logo" /> -->
<b style="margin-left: 5px;">{{ title }}</b>
</el-tooltip>
</router-link>

<span v-else>
<p key="expand" style="display: flex;text-align: center;width: 100%;padding: 0px 15px;margin-top: 0px;">
<img v-if="clientLogo" :src="clientLogo" class="sidebar-logo" style="height: 50px;width: 50px;" @click="dashboard()">
<svg-icon v-else icon-class="AD" class="standard-logo" />
<img v-else src="https://avatars1.githubusercontent.com/u/1263359?s=200&v=4" class="sidebar-logo" style="height: 50px;width: 50px;" @click="dashboard()">
<!-- <svg-icon v-else icon-class="AD" class="standard-logo" /> -->
<b style="color: white;font-size: 18px;padding-top: 15px;cursor: pointer; margin-left: 5px;" @click="dashboard()">
{{ systemName }}
</b>
Expand All @@ -49,6 +51,7 @@

<script>
import { defineComponent, computed, ref } from '@vue/composition-api'
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'

import router from '@/router'
import store from '@/store'
Expand Down Expand Up @@ -102,6 +105,10 @@ export default defineComponent({
tableName: 'AD_ClientInfo',
resourceName: client.logo
})
if (isEmptyValue(fileName)) {
clientLogo.value = 'https://avatars1.githubusercontent.com/u/1263359?s=200&v=4'
return
}
clientLogo.value = config.adempiere.resource.url + fileName
}
}
Expand Down
1 change: 1 addition & 0 deletions src/views/profile/components/RolesNavbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default {
})
.finally(() => {
this.refreshRouter()
location.reload(true)
})
},
changeOrganization(organizationId) {
Expand Down

0 comments on commit aef83c3

Please sign in to comment.