Skip to content

Commit

Permalink
feat: Dashboard widths in simwrapper-config.yaml; width: [100%|70rem]…
Browse files Browse the repository at this point in the history
… etc

Dashboard configuration in simwrapper-config.yaml now knows the

width: [...] parameter, where max width can be:

- A percentage of panel width such as 90%
- a hard value, such as 90rem

- Fixes simwrapper#120
  • Loading branch information
billyc committed Mar 17, 2022
1 parent 04f6a12 commit 131fca6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
4 changes: 4 additions & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default new Vuex.Store({
authAttempts: 0,
breadcrumbs: [] as BreadCrumb[],
credentials: { fake: 'fake' } as { [url: string]: string },
dashboardWidth: '',
isFullScreen: false,
isFullWidth: false,
isShowingLeftBar: false,
Expand Down Expand Up @@ -167,6 +168,9 @@ export default new Vuex.Store({
toggleShowLeftBar(state) {
state.isShowingLeftBar = !state.isShowingLeftBar
},
setDashboardWidth(state, value: string) {
state.dashboardWidth = value
},
setFullWidth(state, value: boolean) {
state.isFullWidth = value
},
Expand Down
13 changes: 10 additions & 3 deletions src/views/DashBoard.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="pug">
#dashboard.dashboard(:class="{wiide}")
.dashboard-content(:class="{wiide}")
.dashboard-content(:class="{wiide}" :style="dashWidthCalculator")
.dashboard-header(v-if="!fullScreenCardId" :class="{wiide}")
h2 {{ title }}
p {{ description }}
Expand Down Expand Up @@ -140,6 +140,13 @@ export default class VueComponent extends Vue {
window.removeEventListener('resize', this.resizeAllCards)
}
private get dashWidthCalculator() {
if (this.$store.state.dashboardWidth && this.$store.state.isFullWidth) {
return { maxWidth: this.$store.state.dashboardWidth }
}
return {}
}
/**
* This only gets triggered when a topsheet has some titles.
* Remove the dashboard titles and use the ones from the topsheet.
Expand Down Expand Up @@ -355,7 +362,7 @@ export default class VueComponent extends Vue {
}
.dashboard.wiide {
padding-left: 1rem;
padding-left: 2rem;
}
.dashboard-header {
Expand Down Expand Up @@ -439,7 +446,7 @@ export default class VueComponent extends Vue {
}
.dash-card-frame.wiide {
margin-right: 1rem;
margin-right: 2rem;
}
.dash-card {
Expand Down
27 changes: 19 additions & 8 deletions src/views/TabbedDashboardView.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<template lang="pug">
.tabbed-folder-view

.tabholder(v-show="!isZoomed" :class="{wiide}")
.tabholder(v-show="!isZoomed" :class="{wiide}" :style="dashWidthCalculator")
.tabholdercontainer(:class="{wiide}")
.project-header(v-if="header" v-html="header" :class="{wiide}")
.breadcrumbs(v-else)
h3 {{ pageHeader }}
h4 {{ root }}: {{ xsubfolder && xsubfolder.startsWith('/') ? '' : '/' }}{{ xsubfolder }}

.tabs.is-centered
b.up-link(:style="{marginLeft: wiide ? '0':'-0.75rem'}")
b.up-link(:style="{marginLeft: wiide ? '1rem':'-0.75rem'}")
a(@click="goUpOneFolder()") ^ UP

ul(:style="{marginRight: wiide ? '2rem':'4rem'}")
ul(:style="{marginRight: wiide ? '4rem':'4rem'}")
li(v-for="tab in Object.keys(dashboards)" :key="tab"
:class="{'is-active': tab===activeTab, 'is-not-active': tab!==activeTab}"
:style="{opacity: tab===activeTab ? 1.0 : 0.5}"
)
b: a(v-if="dashboards[tab].header" @click="switchTab(tab)") {{ dashboards[tab].header.tab }}


dash-board(v-if="dashboardTabWithDelay && dashboardTabWithDelay !== 'FILE__BROWSER' && dashboards[dashboardTabWithDelay] && dashboards[dashboardTabWithDelay].header.tab !== '...'"
:root="root"
:xsubfolder="xsubfolder"
Expand All @@ -40,7 +39,7 @@

p.load-error(v-show="loadErrorMessage" @click="authorizeAfterError"): b {{ loadErrorMessage }}

.tabholder(v-show="showFooter && !isZoomed" :class="{wiide}")
.tabholder(v-show="showFooter && !isZoomed" :class="{wiide}" :style="dashWidthCalculator")
.tabholdercontainer(:class="{wiide}")
.project-footer(v-if="footer" v-html="footer" :class="{wiide}")

Expand Down Expand Up @@ -94,6 +93,13 @@ export default class VueComponent extends Vue {
return this.$store.state.isFullWidth
}
private get dashWidthCalculator() {
if (this.$store.state.dashboardWidth && this.$store.state.isFullWidth) {
return { maxWidth: this.$store.state.dashboardWidth }
}
return {}
}
private beforeDestroy() {
if (this.dashboardDataManager) this.dashboardDataManager.clearCache()
this.clearStyles()
Expand Down Expand Up @@ -198,7 +204,12 @@ export default class VueComponent extends Vue {
this.$store.commit('setShowLeftBar', !!!yaml.hideLeftBar)
// set margins wide if requested to do so
if (yaml.fullWidth !== undefined) this.$store.commit('setFullWidth', yaml.fullWidth)
this.$store.commit('setFullWidth', !!yaml.fullWidth)
this.$store.commit('setDashboardWidth', '')
if (yaml.width !== undefined) {
this.$store.commit('setDashboardWidth', '' + yaml.width)
this.$store.commit('setFullWidth', true)
}
try {
if (yaml.css) {
Expand Down Expand Up @@ -468,7 +479,7 @@ li.is-not-active b a {
}
.project-header.wiide {
padding: 1rem 1rem;
padding: 1rem 2rem;
}
.project-footer {
Expand Down Expand Up @@ -503,7 +514,7 @@ li.is-not-active b a {
.project-footer.wiide {
margin: 3rem 0rem 1rem 0rem;
padding: 1rem 1rem;
padding: 1rem 2rem;
border-top: none;
background-color: #88888815;
color: var(--text);
Expand Down

0 comments on commit 131fca6

Please sign in to comment.