Commit c2f78b11 authored by ibuler's avatar ibuler

[Update] 修改jumpserver,支持url前缀

parent 9870d3aa
...@@ -393,6 +393,7 @@ defaults = { ...@@ -393,6 +393,7 @@ defaults = {
'FLOWER_URL': "127.0.0.1:5555", 'FLOWER_URL': "127.0.0.1:5555",
'DEFAULT_ORG_SHOW_ALL_USERS': True, 'DEFAULT_ORG_SHOW_ALL_USERS': True,
'PERIOD_TASK_ENABLED': True, 'PERIOD_TASK_ENABLED': True,
'FORCE_SCRIPT_NAME': '',
} }
......
...@@ -18,6 +18,7 @@ def jumpserver_processor(request): ...@@ -18,6 +18,7 @@ def jumpserver_processor(request):
'COPYRIGHT': 'FIT2CLOUD 飞致云' + ' © 2014-2019', 'COPYRIGHT': 'FIT2CLOUD 飞致云' + ' © 2014-2019',
'SECURITY_COMMAND_EXECUTION': settings.SECURITY_COMMAND_EXECUTION, 'SECURITY_COMMAND_EXECUTION': settings.SECURITY_COMMAND_EXECUTION,
'SECURITY_MFA_VERIFY_TTL': settings.SECURITY_MFA_VERIFY_TTL, 'SECURITY_MFA_VERIFY_TTL': settings.SECURITY_MFA_VERIFY_TTL,
'FORCE_SCRIPT_NAME': settings.FORCE_SCRIPT_NAME,
} }
return context return context
......
...@@ -654,3 +654,4 @@ CHANNEL_LAYERS = { ...@@ -654,3 +654,4 @@ CHANNEL_LAYERS = {
# Enable internal period task # Enable internal period task
PERIOD_TASK_ENABLED = CONFIG.PERIOD_TASK_ENABLED PERIOD_TASK_ENABLED = CONFIG.PERIOD_TASK_ENABLED
FORCE_SCRIPT_NAME = CONFIG.FORCE_SCRIPT_NAME
...@@ -137,14 +137,18 @@ function setAjaxCSRFToken() { ...@@ -137,14 +137,18 @@ function setAjaxCSRFToken() {
}); });
} }
function activeNav() { function activeNav(prefix) {
var url_array = document.location.pathname.split("/"); var path = document.location.pathname;
var app = url_array[1]; if (prefix) {
var resource = url_array[2]; path = path.replace(prefix, '');
}
var urlArray = path.split("/");
var app = urlArray[1];
var resource = urlArray[2];
if (app === '') { if (app === '') {
$('#index').addClass('active'); $('#index').addClass('active');
} else if (app === 'xpack' && resource === 'cloud') { } else if (app === 'xpack' && resource === 'cloud') {
var item = url_array[3]; var item = urlArray[3];
$("#" + app).addClass('active'); $("#" + app).addClass('active');
$('#' + app + ' #' + resource).addClass('active'); $('#' + app + ' #' + resource).addClass('active');
$('#' + app + ' #' + resource + ' #' + item + ' a').css('color', '#ffffff'); $('#' + app + ' #' + resource + ' #' + item + ' a').css('color', '#ffffff');
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script> <script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
<script src="{% static "js/jumpserver.js" %}?v=4"></script> <script src="{% static "js/jumpserver.js" %}?v=4"></script>
<script> <script>
activeNav(); activeNav("{{ FORCE_SCRIPT_NAME }}");
$(document).ready(function(){ $(document).ready(function(){
setAjaxCSRFToken(); setAjaxCSRFToken();
$('textarea').attr('rows', 5); $('textarea').attr('rows', 5);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment