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

Adds LEGACY_CHARTS configuration to display a link into the past #199

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions src/MetricQWebView.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as Error from '@/errors'

export function createGlobalMetricQWebview (paramParentEle, paramMetricNamesArr, paramStartTime, paramStopTime, store, metricqBackendConfig) {
window.MetricQWebView = new MetricQWebView(paramParentEle, paramMetricNamesArr, paramStartTime, paramStopTime, store, metricqBackendConfig)
store.commit('setLegacyLink', metricqBackendConfig.legacyCharts)
store.commit('setIsWebviewLoaded', true)
}

Expand Down
3 changes: 3 additions & 0 deletions src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import jquery from 'jquery'

const METRICQ_BACKEND = process.env.VUE_APP_METRICQ_BACKEND
const [METRICQ_BACKEND_USER, METRICQ_BACKEND_PASSWORD] = process.env.VUE_APP_METRICQ_BACKEND_AUTH === undefined ? [undefined, undefined] : process.env.VUE_APP_METRICQ_BACKEND_AUTH.split(':')
const LEGACY_CHARTS = process.env.VUE_APP_LEGACY_CHARTS

class MetricQBackendConfig {
constructor () {
this.backend = METRICQ_BACKEND
this.user = METRICQ_BACKEND_USER
this.password = METRICQ_BACKEND_PASSWORD
this.legacyCharts = LEGACY_CHARTS
}
}

Expand All @@ -24,6 +26,7 @@ export async function getMetricQBackendConfig () {
config.backend = json.backend
config.user = json.user
config.password = json.password
config.legacyCharts = json.legacyCharts
} catch (exc) {
console.log('Could not load backend config.')
console.log(exc)
Expand Down
11 changes: 10 additions & 1 deletion src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default new Vuex.Store({
raw: 0
},
toastConfiguration: new ToastConfig(),
isWebviewLoaded: false
isWebviewLoaded: false,
legacyLink: undefined
},
mutations: {
setStartTime (state, time) {
Expand Down Expand Up @@ -75,9 +76,17 @@ export default new Vuex.Store({
},
setIsWebviewLoaded (state, newValue) {
state.isWebviewLoaded = newValue
},
setLegacyLink (state, newValue) {
state.legacyLink = newValue
}
},
actions: {},
getters: {
getLegacyLink: (state) => () => {
return state.legacyLink
}
},
modules: {
metrics
},
Expand Down
4 changes: 3 additions & 1 deletion src/ui/export-popup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
</div>
</div>
<div class="modal-footer">
<legacy-link-button class="text-align-left" />
<button
class="btn btn-primary"
:disabled="!analyzeTableReady && selectedFileformat === 'pdf' && exportAnalyze"
Expand Down Expand Up @@ -133,9 +134,10 @@ import { veil } from './veil.js'
import PopupHeader from './popup-header.vue'
import { mapState } from 'vuex'
import AnalyzeTable from '.././components/analyzeTable.vue'
import LegacyLinkButton from './legacy-link-button.vue'

export default {
components: { PopupHeader, AnalyzeTable },
components: { PopupHeader, AnalyzeTable, LegacyLinkButton },
props: {},
data () {
return {
Expand Down
44 changes: 44 additions & 0 deletions src/ui/legacy-link-button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<a
v-if="hasLegacyLink"
:href="legacyLink"
class="btn btn-primary"
>
<span>
<b-icon-graph-down />
<span class="m-1">In Legacy Charts öffnen</span>
</span>
</a>
</template>

<script>

import JSURL from 'jsurl'

export default {
computed: {
hasLegacyLink () {
return this.$store.getters.getLegacyLink() !== undefined
},
legacyLink () {
const startTime = window.MetricQWebView.handler.startTime.getValue()
const endTime = window.MetricQWebView.handler.stopTime.getValue()

const target = {
cntr: [],
start: startTime,
stop: endTime
}

for (const metricKey of this.$store.getters['metrics/getAllKeys']()) {
target.cntr.push(metricKey)
}

return this.$store.getters.getLegacyLink() + '#' + JSURL.stringify(target)
}
}
}
</script>

<style scoped>
</style>
Loading