mirror of https://github.com/jumpserver/jumpserver
[Update] 修改term大小
parent
3a10fd4160
commit
82a6369568
|
@ -67,6 +67,8 @@ class AssetUserManager:
|
||||||
return AssetUserQuerySet(instances)
|
return AssetUserQuerySet(instances)
|
||||||
|
|
||||||
def get(self, username, asset, **kwargs):
|
def get(self, username, asset, **kwargs):
|
||||||
|
print(username)
|
||||||
|
print(asset)
|
||||||
instances = self.filter(username, assets=[asset], **kwargs)
|
instances = self.filter(username, assets=[asset], **kwargs)
|
||||||
if len(instances) == 1:
|
if len(instances) == 1:
|
||||||
return instances[0]
|
return instances[0]
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<title>{% trans 'Task log' %}</title>
|
<title>{% trans 'Task log' %}</title>
|
||||||
<script src="{% static 'js/jquery-3.1.1.min.js' %}"></script>
|
<script src="{% static 'js/jquery-3.1.1.min.js' %}"></script>
|
||||||
<script src="{% static 'js/plugins/xterm/xterm.js' %}"></script>
|
<script src="{% static 'js/plugins/xterm/xterm.js' %}"></script>
|
||||||
|
<script src="{% static 'js/plugins/xterm/addons/fit/fit.js' %}"></script>
|
||||||
<link rel="stylesheet" href="{% static 'js/plugins/xterm/xterm.css' %}" />
|
<link rel="stylesheet" href="{% static 'js/plugins/xterm/xterm.css' %}" />
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
|
@ -40,7 +41,7 @@
|
||||||
disableStdin: true
|
disableStdin: true
|
||||||
});
|
});
|
||||||
term.open(document.getElementById('term'));
|
term.open(document.getElementById('term'));
|
||||||
term.resize(120, 30);
|
window.fit.fit(term);
|
||||||
|
|
||||||
ws = new WebSocket(wsURL);
|
ws = new WebSocket(wsURL);
|
||||||
ws.onmessage = function(e) {
|
ws.onmessage = function(e) {
|
||||||
|
@ -61,5 +62,7 @@
|
||||||
term.write("Connect websocket server error")
|
term.write("Connect websocket server error")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).on('resize', window, function () {
|
||||||
|
window.fit.fit(term);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -104,41 +104,6 @@
|
||||||
var url = null;
|
var url = null;
|
||||||
var treeUrl = "{% url 'api-perms:my-nodes-with-assets-as-tree' %}?cache_policy=1";
|
var treeUrl = "{% url 'api-perms:my-nodes-with-assets-as-tree' %}?cache_policy=1";
|
||||||
|
|
||||||
function proposeGeometry(term) {
|
|
||||||
if (!term.element.parentElement) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var parentElementStyle = window.getComputedStyle(term.element.parentElement);
|
|
||||||
var parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height'));
|
|
||||||
var parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')));
|
|
||||||
var elementStyle = window.getComputedStyle(term.element);
|
|
||||||
var elementPadding = {
|
|
||||||
top: parseInt(elementStyle.getPropertyValue('padding-top')),
|
|
||||||
bottom: parseInt(elementStyle.getPropertyValue('padding-bottom')),
|
|
||||||
right: parseInt(elementStyle.getPropertyValue('padding-right')),
|
|
||||||
left: parseInt(elementStyle.getPropertyValue('padding-left'))
|
|
||||||
};
|
|
||||||
var elementPaddingVer = elementPadding.top + elementPadding.bottom;
|
|
||||||
var elementPaddingHor = elementPadding.right + elementPadding.left;
|
|
||||||
var availableHeight = parentElementHeight - elementPaddingVer;
|
|
||||||
var availableWidth = parentElementWidth - elementPaddingHor - term._core.viewport.scrollBarWidth;
|
|
||||||
var geometry = {
|
|
||||||
cols: Math.floor(availableWidth / term._core.renderer.dimensions.actualCellWidth),
|
|
||||||
rows: Math.floor(availableHeight / term._core.renderer.dimensions.actualCellHeight)
|
|
||||||
};
|
|
||||||
return geometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fit(term) {
|
|
||||||
var geometry = proposeGeometry(term);
|
|
||||||
if (geometry) {
|
|
||||||
if (term.rows !== geometry.rows || term.cols !== geometry.cols) {
|
|
||||||
term._core.renderer.clear();
|
|
||||||
term.resize(geometry.cols, geometry.rows);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function initTree() {
|
function initTree() {
|
||||||
$('#assetTree').html("{% trans 'Loading' %}" + '..');
|
$('#assetTree').html("{% trans 'Loading' %}" + '..');
|
||||||
if (systemUserId) {
|
if (systemUserId) {
|
||||||
|
@ -159,12 +124,6 @@
|
||||||
enable: true
|
enable: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async: {
|
|
||||||
enable: true,
|
|
||||||
url: url,
|
|
||||||
autoParam: ["id=key", "name=n", "level=lv"],
|
|
||||||
type: 'get'
|
|
||||||
},
|
|
||||||
edit: {
|
edit: {
|
||||||
enable: true,
|
enable: true,
|
||||||
showRemoveBtn: false,
|
showRemoveBtn: false,
|
||||||
|
@ -254,7 +213,8 @@
|
||||||
});
|
});
|
||||||
term.open(document.getElementById('term'));
|
term.open(document.getElementById('term'));
|
||||||
var msg = "{% trans 'Select the left asset, select the running system user, execute command in batch' %}" + "\r\n";
|
var msg = "{% trans 'Select the left asset, select the running system user, execute command in batch' %}" + "\r\n";
|
||||||
fit(term);
|
window.fit.fit(term);
|
||||||
|
{#fit(term);#}
|
||||||
term.write(msg);
|
term.write(msg);
|
||||||
|
|
||||||
var scheme = document.location.protocol === "https:" ? "wss" : "ws";
|
var scheme = document.location.protocol === "https:" ? "wss" : "ws";
|
||||||
|
|
|
@ -62,10 +62,10 @@ asset_permission_urlpatterns = [
|
||||||
path('user-groups/<uuid:pk>/assets/<uuid:asset_id>/system-users/', api.UserGroupGrantedAssetSystemUsersApi.as_view(), name='user-group-asset-system-users'),
|
path('user-groups/<uuid:pk>/assets/<uuid:asset_id>/system-users/', api.UserGroupGrantedAssetSystemUsersApi.as_view(), name='user-group-asset-system-users'),
|
||||||
|
|
||||||
# 用户和资产授权变更
|
# 用户和资产授权变更
|
||||||
path('asset-permissions/<uuid:pk>/user/remove/', api.AssetPermissionRemoveUserApi.as_view(), name='asset-permission-remove-user'),
|
path('asset-permissions/<uuid:pk>/users/remove/', api.AssetPermissionRemoveUserApi.as_view(), name='asset-permission-remove-user'),
|
||||||
path('asset-permissions/<uuid:pk>/user/add/', api.AssetPermissionAddUserApi.as_view(), name='asset-permission-add-user'),
|
path('asset-permissions/<uuid:pk>/users/add/', api.AssetPermissionAddUserApi.as_view(), name='asset-permission-add-user'),
|
||||||
path('asset-permissions/<uuid:pk>/asset/remove/', api.AssetPermissionRemoveAssetApi.as_view(), name='asset-permission-remove-asset'),
|
path('asset-permissions/<uuid:pk>/assets/remove/', api.AssetPermissionRemoveAssetApi.as_view(), name='asset-permission-remove-asset'),
|
||||||
path('asset-permissions/<uuid:pk>/asset/add/', api.AssetPermissionAddAssetApi.as_view(), name='asset-permission-add-asset'),
|
path('asset-permissions/<uuid:pk>/assets/add/', api.AssetPermissionAddAssetApi.as_view(), name='asset-permission-add-asset'),
|
||||||
|
|
||||||
# 授权规则中授权的资产
|
# 授权规则中授权的资产
|
||||||
path('asset-permissions/<uuid:pk>/assets/', api.AssetPermissionAssetsApi.as_view(), name='asset-permission-assets'),
|
path('asset-permissions/<uuid:pk>/assets/', api.AssetPermissionAssetsApi.as_view(), name='asset-permission-assets'),
|
||||||
|
@ -75,7 +75,7 @@ asset_permission_urlpatterns = [
|
||||||
path('asset-permissions/user/actions/', api.GetUserAssetPermissionActionsApi.as_view(), name='get-user-asset-permission-actions'),
|
path('asset-permissions/user/actions/', api.GetUserAssetPermissionActionsApi.as_view(), name='get-user-asset-permission-actions'),
|
||||||
|
|
||||||
# 刷新缓存
|
# 刷新缓存
|
||||||
path('asset-permissions/user/cache/refresh/', api.RefreshAssetPermissionCacheApi.as_view(), name='refresh-asset-permission-cache'),
|
path('asset-permissions/cache/refresh/', api.RefreshAssetPermissionCacheApi.as_view(), name='refresh-asset-permission-cache'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,10 +99,10 @@ remote_app_permission_urlpatterns = [
|
||||||
path('remote-app-permissions/user/validate/', api.ValidateUserRemoteAppPermissionApi.as_view(), name='validate-user-remote-app-permission'),
|
path('remote-app-permissions/user/validate/', api.ValidateUserRemoteAppPermissionApi.as_view(), name='validate-user-remote-app-permission'),
|
||||||
|
|
||||||
# 用户和RemoteApp变更
|
# 用户和RemoteApp变更
|
||||||
path('remote-app-permissions/<uuid:pk>/user/add/', api.RemoteAppPermissionAddUserApi.as_view(), name='remote-app-permission-add-user'),
|
path('remote-app-permissions/<uuid:pk>/users/add/', api.RemoteAppPermissionAddUserApi.as_view(), name='remote-app-permission-add-user'),
|
||||||
path('remote-app-permissions/<uuid:pk>/user/remove/', api.RemoteAppPermissionRemoveUserApi.as_view(), name='remote-app-permission-remove-user'),
|
path('remote-app-permissions/<uuid:pk>/users/remove/', api.RemoteAppPermissionRemoveUserApi.as_view(), name='remote-app-permission-remove-user'),
|
||||||
path('remote-app-permissions/<uuid:pk>/remote-app/remove/', api.RemoteAppPermissionRemoveRemoteAppApi.as_view(), name='remote-app-permission-remove-remote-app'),
|
path('remote-app-permissions/<uuid:pk>/remote-apps/remove/', api.RemoteAppPermissionRemoveRemoteAppApi.as_view(), name='remote-app-permission-remove-remote-app'),
|
||||||
path('remote-app-permissions/<uuid:pk>/remote-app/add/', api.RemoteAppPermissionAddRemoteAppApi.as_view(), name='remote-app-permission-add-remote-app'),
|
path('remote-app-permissions/<uuid:pk>/remote-apps/add/', api.RemoteAppPermissionAddRemoteAppApi.as_view(), name='remote-app-permission-add-remote-app'),
|
||||||
]
|
]
|
||||||
|
|
||||||
old_version_urlpatterns = [
|
old_version_urlpatterns = [
|
||||||
|
|
Loading…
Reference in New Issue