-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontend: created a new button fullscreen mode
- Loading branch information
Showing
4 changed files
with
171 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
frontend/src/pages/webcomponent/_id/_version/fullscreen-mode.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<div id="twrap" style="max-height: 100vh"> | ||
<iframe | ||
id="tframe" | ||
class="full-height full-width" | ||
title="iframe-preview" | ||
frameborder="0" | ||
></iframe> | ||
</div> | ||
|
||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import { WebcomponentModel } from '~/domain/model/WebcomponentModel'; | ||
import { WebcomponentConfigurationModel } from '~/domain/model/WebcomponentConfigurationModel'; | ||
export default Vue.extend({ | ||
name: 'FullscreenMode', | ||
//if i delete this the footer get generated | ||
layout(context) { | ||
return 'fullscreen'; | ||
}, | ||
//the whole page become white | ||
data() { | ||
return { | ||
previewBaseURL: (this as any).$api.baseUrl, | ||
attribs: (this as any).$route.query.attribs, | ||
}; | ||
}, | ||
//the whole page become white | ||
async fetch() { | ||
this.$store.commit('webcomponent/SET_EDIT_MODE', true); | ||
await this.$store.dispatch('webcomponent/loadWebcomponent', { | ||
uuid: this.$route.params.id, | ||
version: this.$route.params.version, | ||
}); | ||
if (this.$route.query.attribs) { | ||
await this.$store.dispatch( | ||
'webcomponent/restoreSnippet', | ||
this.$route.query.attribs | ||
); | ||
} else { | ||
this.$store.commit('webcomponent/SET_EDIT_MODE', false); | ||
} | ||
}, | ||
//the whole page become white | ||
computed: { | ||
component(): WebcomponentModel { | ||
return this.$store.state.webcomponent.webcomponent; | ||
}, | ||
config(): WebcomponentConfigurationModel { | ||
return this.$store.state.webcomponent.configuration; | ||
}, | ||
selectedVersion(): string { | ||
return this.$store.state.webcomponent.versionTag; | ||
}, | ||
snippet(): string { | ||
return this.$store.state.webcomponent.snippet; | ||
}, | ||
externalPreviewUrl(): string { | ||
if (!this.component || !this.config) { | ||
return ''; | ||
} | ||
return ( | ||
this.previewBaseURL + | ||
'/preview/' + | ||
this.component.uuid + | ||
'/' + | ||
this.selectedVersion + | ||
'?attribs=' + | ||
this.$store.getters['webcomponent/transportString'] | ||
); | ||
}, | ||
}, | ||
//the whole page become white | ||
watch: { | ||
externalPreviewUrl(url) { | ||
if (url) { | ||
this.updatePreview(); | ||
} | ||
}, | ||
}, | ||
methods: { | ||
updatePreview() { | ||
const src = this.externalPreviewUrl; | ||
if (!src) { | ||
return; // probably not yet loaded | ||
} | ||
const oldElement = document.getElementById('tframe'); | ||
oldElement.parentNode.removeChild(oldElement); | ||
const width = document.documentElement.clientWidth; | ||
const newElement = document.createElement('iframe'); | ||
newElement.setAttribute('id', 'tframe'); | ||
newElement.setAttribute('class', 'full-height full-width'); | ||
if (width > 576) { | ||
newElement.setAttribute( | ||
'style', | ||
'min-height: 100vh; padding-bottom: 0px;' | ||
); | ||
} else { | ||
newElement.setAttribute( | ||
'style', | ||
'min-height: 100vh; padding-bottom: 45px;' | ||
); | ||
} | ||
newElement.setAttribute('frameborder', '0'); | ||
newElement.src = src; | ||
document.getElementById('twrap').appendChild(newElement); | ||
// newElement.contentDocument.write(this.snippet); | ||
newElement.contentDocument.close(); | ||
}, | ||
}, | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- | ||
SPDX-FileCopyrightText: NOI Techpark <[email protected]> | ||
SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<script> | ||
import wc from '~/pages/webcomponent/_id/_version/fullscreen-mode'; | ||
export default wc; | ||
</script> |