feat(webui): add doc and version in navbar

This commit is contained in:
Antoine Caron 2019-08-12 17:48:04 +02:00 committed by Traefiker Bot
parent 0f32de4aa2
commit 6be390c795

View file

@ -10,12 +10,78 @@
height="28"
/>
</a>
<a
:class="{ 'is-active': isActive }"
role="button"
class="navbar-burger burger"
aria-label="menu"
aria-expanded="false"
data-target="navbarBasicExample"
@click="toggle"
>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div
:class="{ 'is-active': isActive }"
class="navbar-menu"
v-if="version.Version"
>
<div class="navbar-start">
<a class="navbar-item" :href="documentationUrl">
Documentation
</a>
</div>
<div class="navbar-end">
<div class="navbar-item">Version: {{ version.Version }}</div>
</div>
</div>
</nav>
<router-view />
</div>
</template>
<script>
export default {
name: "App",
data: () => ({
version: {},
isActive: false
}),
computed: {
parsedVersion() {
if (this.version.Version === "dev") {
return "master";
} else {
const matches = this.version.Version.match(/^(v?\d+\.\d+)/);
return matches ? matches[1] : "master";
}
},
documentationUrl() {
return `https://docs.traefik.io/${this.parsedVersion}`;
}
},
created() {
this.fetchVersion();
},
methods: {
fetchVersion() {
return fetch("/api/version")
.then(response => response.json())
.then(response => (this.version = response));
},
toggle() {
this.isActive = !this.isActive;
}
}
};
</script>
<style lang="sass">
@import 'styles/typography'