Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement first step of modular #25

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ Iframe can still be set with defining `legacy-url` attribute, style can also be

Attributes available :

| Attribute | Description | Example | For new header | For legacy |
| ----------- |-------------------------------------------------------------------------------------------------------------| ----------------------------------------------------------- | -------------- | ---------- |
| active-app | Use this attribute to set the active class in menu | `<geor-header active-app='console'>` | | v |
| config-file | Use this attribute to set the config file for the new header (not legacy one). See [CONFIG.md](./CONFIG.md) | `<geor-header config-file="/config.json">` | v | |
| stylesheet | adds this stylesheet to the new header (not legacy one). | `<geor-header stylesheet="mystylesheet.css"></geor-header>` | v | |
| Attribute | Description | Example | For new header | For legacy header (iframe) |
|-------------|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------| -------------- |----------------------------|
| active-app | Use this attribute to set the active class in menu | `<geor-header active-app='console'>` | | v |
| config-file | Use this attribute to set the config file for the new header (not legacy one). See [CONFIG.md](./CONFIG.md) | `<geor-header config-file="/config.json">` | v | |
| stylesheet | adds this stylesheet to the new header (not legacy one). | `<geor-header stylesheet="mystylesheet.css"></geor-header>` | v | |
| height | sets the height of the header (in pixels) | `<geor-header height="80"></geor-header>` | v | v |

3. Provide a custom stylesheet

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<title>geOrchestra header</title>
</head>
<body style="margin: 0">
<geor-header config-file="/sample-config.json" stylesheet=""></geor-header>
<geor-header config-file="/sample-config.json" stylesheet="" height="80"></geor-header>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
13 changes: 1 addition & 12 deletions public/sample-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,5 @@
}
]
}
],
"i18n": {
"en": {
"customi18n": "WMS/WFS service"
},
"fr": {
"customi18n": "Service WMS/WFS"
},
"es": {
"customi18n": "Servicio WMS/WFS"
}
}
]
}
2 changes: 0 additions & 2 deletions src/config-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export interface Config {
logoTitle?: string
//Whether to hide the login button
hideLogin?: boolean
//Custom style to apply to the header
style?: string
//Custom stylesheet to apply to the header
stylesheet?: string
//Link to icons url. Tested with https://cdn.jsdelivr.net/gh/iconoir-icons/iconoir@main/css/iconoir.css
Expand Down
1 change: 0 additions & 1 deletion src/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"legacyHeader": false,
"legacyUrl": "/header/",
"hideLogin": false,
"style": "",
"adminRoles": [
"ROLE_SUPERUSER",
"ROLE_ORGADMIN",
Expand Down
15 changes: 7 additions & 8 deletions src/header.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const props = defineProps<{
activeApp?: string
configFile?: string
stylesheet?: string
height?: number
}>()

const state = reactive({
Expand Down Expand Up @@ -107,9 +108,9 @@ function allNodes(obj: any, key: string, array?: any[]): string[] {
return array
}

function setI18nAndActiveApp(i18n: any) {
function setI18nAndActiveApp(i18n?: any) {
state.lang3 = getI18n(
i18n,
i18n || {},
state.config.lang || navigator.language.substring(0, 2) || 'en'
)
determineActiveApp()
Expand All @@ -132,9 +133,7 @@ onMounted(() => {
console.log(state.config)
setI18nAndActiveApp(json.i18n)
})
else {
setI18nAndActiveApp({})
}
else setI18nAndActiveApp()
if (user.roles.some(role => state.config.adminRoles.includes(role))) {
getPlatformInfos().then(
platformInfos => (state.platformInfos = platformInfos)
Expand All @@ -150,13 +149,13 @@ onMounted(() => {
v-bind:src="`${state.config.legacyUrl}${
props.activeApp ? `?active=${props.activeApp}` : ''
}`"
v-bind:style="state.config.style"
:style="`height:${props.height}px;width:100%;border:0;`"
></iframe>
</div>
<header
v-else-if="state.loaded"
class="host h-[80px] text-base"
v-bind:style="state.config.style"
class="host h-[80px] text-base ${props.height}"
Copy link
Member

@landryb landryb Dec 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt that be ${props.height} here again instead of 80px ? i know nothing to css classes but it feels strange.

:style="`height:${props.height}px`"
>
<link
rel="stylesheet"
Expand Down