Skip to content

Commit

Permalink
Fix administration page
Browse files Browse the repository at this point in the history
  • Loading branch information
fvclaus committed Jul 6, 2023
1 parent d9d2dba commit 5884254
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 41 deletions.
File renamed without changes.
49 changes: 8 additions & 41 deletions src/main/web/configuration.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Vue from 'vue';
import LicensesPage from './configuration/licenses-page';
import DependencyMappingsPage from './configuration/dependency-mappings-page';
import LicenseMappingsPage from './configuration/license-mappings-page';
import ProjectLicensesPage from './configuration/project-licenses-page';
import ModalDialog from './modal-dialog';
import Configuration from './configuration/configuration.vue';
import VueSVGIcon from 'vue-svgicon'

Vue.use(VueSVGIcon)
Expand All @@ -13,44 +10,14 @@ window.registerExtension('licensecheck/configuration', function (options) {
Vue.component('modal-dialog', ModalDialog);
const app = new Vue({
el: options.el,
data: () => {
return {
currentRoute: 'licenses'
}
},
methods: {
activateCategory(event, route) {
event.preventDefault();
this.currentRoute = route;
window.history.pushState({}, document.title, `?category=${route}`)
},
routeListener() {
const result = window.location.search.match(/category=([^&=]*)/);
if (result && result.length > 1) {
this.currentRoute = result[1];
} else {
this.currentRoute = 'licenses';
// Cannot use `template`. Eval is blocked by CSP
render(createElement) {
return createElement(Configuration, {
props: {
options
}
}
},
components: { LicensesPage, DependencyMappingsPage, LicenseMappingsPage, ProjectLicensesPage},
template: `<div class="page page-limited">
<ul class="tabs">
<li><a href="?category=licenses" :class="{selected: currentRoute==='licenses'}" @click="activateCategory($event, 'licenses')">Licenses</a></li>
<li><a href="?category=license-mappings" :class="{selected: currentRoute==='license-mappings'}" @click="activateCategory($event, 'license-mappings')">License Mappings</a></li>
<li><a href="?category=dependency-mappings" :class="{selected: currentRoute==='dependency-mappings'}" @click="activateCategory($event, 'dependency-mappings')">Dependency Mappings</a></li>
<li><a href="?category=project-licenses" :class="{selected: currentRoute==='project-licenses'}" @click="activateCategory($event, 'project-licenses')">Project Licenses</a></li>
</ul>
<br>
<licenses-page v-if="currentRoute === 'licenses'">
</licenses-page>
<dependency-mappings-page v-if="currentRoute === 'dependency-mappings'">
</dependency-mappings-page>
<license-mappings-page v-if="currentRoute === 'license-mappings'">
</license-mappings-page>
<project-licenses-page v-if="currentRoute === 'project-licenses'">
</project-licenses-page>
</div>`
});
}
});

window.addEventListener('popstate', app.routeListener);
Expand Down
52 changes: 52 additions & 0 deletions src/main/web/configuration/configuration.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<template>
<div class="page page-limited">
<ul class="tabs">
<li><a href="?category=licenses" :class="{selected: currentRoute==='licenses'}" @click="activateCategory($event, 'licenses')">Licenses</a></li>
<li><a href="?category=license-mappings" :class="{selected: currentRoute==='license-mappings'}" @click="activateCategory($event, 'license-mappings')">License Mappings</a></li>
<li><a href="?category=dependency-mappings" :class="{selected: currentRoute==='dependency-mappings'}" @click="activateCategory($event, 'dependency-mappings')">Dependency Mappings</a></li>
<li><a href="?category=project-licenses" :class="{selected: currentRoute==='project-licenses'}" @click="activateCategory($event, 'project-licenses')">Project Licenses</a></li>
</ul>
<br>
<licenses-page v-if="currentRoute === 'licenses'">
</licenses-page>
<dependency-mappings-page v-if="currentRoute === 'dependency-mappings'">
</dependency-mappings-page>
<license-mappings-page v-if="currentRoute === 'license-mappings'">
</license-mappings-page>
<project-licenses-page v-if="currentRoute === 'project-licenses'">
</project-licenses-page>
</div>
</template>

<script>
import LicensesPage from './licenses-page';
import DependencyMappingsPage from './dependency-mappings-page';
import LicenseMappingsPage from './license-mappings-page';
import ProjectLicensesPage from './project-licenses-page';
export default {
data: () => {
return {
currentRoute: 'licenses'
}
},
methods: {
activateCategory(event, route) {
event.preventDefault();
this.currentRoute = route;
window.history.pushState({}, document.title, `?category=${route}`)
},
routeListener() {
const result = window.location.search.match(/category=([^&=]*)/);
if (result && result.length > 1) {
this.currentRoute = result[1];
} else {
this.currentRoute = 'licenses';
}
}
},
components: { LicensesPage, DependencyMappingsPage, LicenseMappingsPage, ProjectLicensesPage},
}
</script>

0 comments on commit 5884254

Please sign in to comment.