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

Support basepath configuration #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Dependency-Track</title>
<link rel="shortcut icon" href="./favicon.ico">
</head>
<body class="sidebar-minimized">
<noscript>
Expand Down
33 changes: 20 additions & 13 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import 'core-js/es7/array'
import Vue from 'vue'
import BootstrapVue from 'bootstrap-vue'
import App from './App'
import router from './router'
import props from './routes'
import i18n from './i18n'
import './validation'
import './plugins/table.js'
import axios from 'axios'
import Router from 'vue-router'
import VueAxios from 'vue-axios'
import VueShowdown from 'vue-showdown'
import vueDebounce from 'vue-debounce'
Expand All @@ -30,13 +31,31 @@ Vue.use(VueToastr, {
});
Vue.use(VueShowdown, { flavor: 'github' });
Vue.use(vueDebounce, { defaultTime: '750ms' });
Vue.use(Router);

Vue.prototype.$api = api;

axios.get("static/config.json").then(response => {
Vue.prototype.$api.BASE_URL = response.data.API_BASE_URL;
if('UI_BASE_PATH' in response.data) {
props.base = response.data.UI_BASE_PATH;
}
}).catch(function (error) {
console.log("Cannot retrieve static/config.json from host. This is expected behavior in development environments.")
}).finally(function () {

Vue.prototype.$version = version;

new Vue({
el: '#app',
router: new Router(props),
template: '<App/>',
components: {
App,
}
,i18n
});

/*
Register global $dtrack variable which will be the response body from /api/version.
$dtrack can then be used anywhere in the app to get information about the server,
Expand All @@ -48,15 +67,3 @@ axios.get("static/config.json").then(response => {
}
);
});

Vue.prototype.$version = version;

new Vue({
el: '#app',
router,
template: '<App/>',
components: {
App,
}
,i18n
});
9 changes: 2 additions & 7 deletions src/router/index.js → src/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import Vue from 'vue'
import Router from 'vue-router'

// Containers
const DefaultContainer = () => import('@/containers/DefaultContainer');

Expand All @@ -23,8 +20,6 @@ const Login = () => import('@/views/pages/Login');
const PasswordForceChange = () => import('@/views/pages/PasswordForceChange');
const Page404 = () => import('@/views/pages/Page404');

Vue.use(Router);

function configRoutes() {
return [
{
Expand Down Expand Up @@ -213,9 +208,9 @@ function configRoutes() {
]
}

export default new Router({
export default {
mode: 'history', // https://router.vuejs.org/api/#mode
linkActiveClass: 'open active',
scrollBehavior: () => ({ y: 0 }),
routes: configRoutes()
});
}