mirror of https://github.com/jumpserver/jumpserver
Bugfix (#3007)
* [Bugfix] 修复英文时间时期的bug * [bugfix] 修复session时间日期的问题 * [Bugfix] 修改时间日志格式化错误 * [Update] 修改函数名称 * [Update] 修改函数顺序 * [Update] 注释部分迁移文件内容pull/3009/head
parent
5f59c729b7
commit
5db704f793
|
@ -51,7 +51,7 @@ function initAssetUserTable() {
|
|||
} else {
|
||||
innerHtml = '<i class="fa fa-circle text-warning"></i>'
|
||||
}
|
||||
var dateManual = formatDateAsCN(cellData.datetime);
|
||||
var dateManual = toSafeLocalDateStr(cellData.datetime);
|
||||
var dataContent = testDatetime + dateManual;
|
||||
innerHtml = "<a data-toggle='popover' data-content='" + dataContent + "'" + 'data-placement="auto bottom"' + ">" + innerHtml + "</a>";
|
||||
$(td).html(innerHtml);
|
||||
|
@ -59,7 +59,7 @@ function initAssetUserTable() {
|
|||
},
|
||||
{
|
||||
targets: 6, createdCell: function (td, cellData) {
|
||||
var data = formatDateAsCN(cellData);
|
||||
var data = toSafeLocalDateStr(cellData);
|
||||
$(td).html(data);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -159,7 +159,7 @@ function initTable() {
|
|||
} else {
|
||||
innerHtml = '<i class="fa fa-circle text-warning"></i>'
|
||||
}
|
||||
var dateManual = formatDateAsCN(cellData.datetime);
|
||||
var dateManual = toSafeLocalDateStr(cellData.datetime);
|
||||
var dataContent = testDatetime + dateManual;
|
||||
innerHtml = "<a data-toggle='popover' data-content='" + dataContent + "'" + 'data-placement="auto bottom"' + ">" + innerHtml + "</a>";
|
||||
$(td).html(innerHtml);
|
||||
|
|
|
@ -82,7 +82,7 @@ function initTable() {
|
|||
select: [],
|
||||
columnDefs: [
|
||||
{targets: 1, createdCell: function (td, cellData, rowData) {
|
||||
var d = formatDateAsCN(cellData);
|
||||
var d = toSafeLocalDateStr(cellData);
|
||||
$(td).html(d);
|
||||
}},
|
||||
{targets: 2, createdCell: function (td, cellData) {
|
||||
|
|
|
@ -109,7 +109,7 @@ $(document).ready(function () {
|
|||
}
|
||||
}},
|
||||
{targets: 6, createdCell: function (td, cellData) {
|
||||
var d = formatDateAsCN(cellData);
|
||||
var d = toSafeLocalDateStr(cellData);
|
||||
$(td).html(d)
|
||||
}},
|
||||
{targets: 7, createdCell: function (td, cellData, rowData) {
|
||||
|
|
|
@ -88,7 +88,7 @@ function initTable() {
|
|||
select: [],
|
||||
columnDefs: [
|
||||
{targets: 1, createdCell: function (td, cellData, rowData) {
|
||||
var d = formatDateAsCN(cellData);
|
||||
var d = toSafeLocalDateStr(cellData);
|
||||
$(td).html(d);
|
||||
|
||||
}},
|
||||
|
|
|
@ -103,9 +103,9 @@ class Migration(migrations.Migration):
|
|||
name='nodes',
|
||||
field=models.ManyToManyField(blank=True, related_name='granted_by_permissions', to='assets.Node', verbose_name='Nodes'),
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=migrate_node_permissions,
|
||||
),
|
||||
# migrations.RunPython(
|
||||
# code=migrate_node_permissions,
|
||||
# ),
|
||||
migrations.RunPython(
|
||||
code=migrate_system_assets_relation,
|
||||
),
|
||||
|
|
|
@ -1091,7 +1091,7 @@ function objectAttrsIsList(obj, attrs) {
|
|||
|
||||
function objectAttrsIsDatetime(obj, attrs) {
|
||||
attrs.forEach(function (attr) {
|
||||
obj[attr] = formatDateAsCN(obj[attr]);
|
||||
obj[attr] = toSafeDateISOStr(obj[attr]);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1105,29 +1105,37 @@ function objectAttrsIsBool(obj, attrs) {
|
|||
})
|
||||
}
|
||||
|
||||
function cleanDate(d) {
|
||||
if (typeof d === 'number'){
|
||||
return d
|
||||
}
|
||||
if (typeof d === "string") {
|
||||
d = d.replaceAll('-', '/')
|
||||
}
|
||||
for (var i=0; i<2; i++) {
|
||||
if (isNaN(Date.parse(d))) {
|
||||
d = d.split('+')[0].trimRight();
|
||||
} else {
|
||||
return d
|
||||
function cleanDateStr(d) {
|
||||
for (var i=0;i<3;i++) {
|
||||
if (!isNaN(Date.parse(d))){
|
||||
return d;
|
||||
}
|
||||
if (!isNaN(Number(d))) {
|
||||
return d;
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
d = d.replaceAll('-', '/');
|
||||
break;
|
||||
case 1:
|
||||
d = d.split('+')[0].trimRight();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ''
|
||||
return null;
|
||||
}
|
||||
|
||||
function safeDate(s) {
|
||||
s = cleanDate(s);
|
||||
s = cleanDateStr(s);
|
||||
return new Date(s)
|
||||
}
|
||||
|
||||
function formatDateAsCN(d) {
|
||||
function toSafeDateISOStr(s) {
|
||||
var d = safeDate(s);
|
||||
return d.toISOString();
|
||||
}
|
||||
|
||||
function toSafeLocalDateStr(d) {
|
||||
var date = safeDate(d);
|
||||
var date_s = date.toLocaleString(navigator.language, {hour12: false});
|
||||
return date_s.split("/").join('-')
|
||||
|
@ -1149,7 +1157,7 @@ function getTimeUnits(u) {
|
|||
"m": "分",
|
||||
"s": "秒",
|
||||
};
|
||||
if (navigator.language || "zh-CN") {
|
||||
if (navigator.language === "zh-CN") {
|
||||
return units[u]
|
||||
}
|
||||
return u
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<script src="{% static "js/plugins/toastr/toastr.min.js" %}"></script>
|
||||
<script src="{% static "js/inspinia.js" %}"></script>
|
||||
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
|
||||
<script src="{% static "js/jumpserver.js" %}?v=1"></script>
|
||||
<script src="{% static "js/jumpserver.js" %}?v=2"></script>
|
||||
<script>
|
||||
activeNav();
|
||||
$(document).ready(function(){
|
||||
|
|
|
@ -193,7 +193,7 @@ function initTable() {
|
|||
$(td).html(data);
|
||||
}},
|
||||
{targets: 6, createdCell: function (td, cellData) {
|
||||
var data = formatDateAsCN(cellData*1000);
|
||||
var data = toSafeLocalDateStr(cellData*1000);
|
||||
$(td).html(data);
|
||||
}},
|
||||
],
|
||||
|
|
|
@ -104,8 +104,8 @@ var dateFrom = "{{ date_from.timestamp }}";
|
|||
var dateTo = "{{ date_to.timestamp }}";
|
||||
|
||||
function initTable() {
|
||||
dateFrom = formatDateAsCN(dateFrom * 1000);
|
||||
dateTo = formatDateAsCN(dateTo * 1000);
|
||||
dateFrom = toSafeDateISOStr(dateFrom * 1000);
|
||||
dateTo = toSafeDateISOStr(dateTo * 1000);
|
||||
sessionListUrl = setUrlParam(sessionListUrl, "date_from", dateFrom);
|
||||
sessionListUrl = setUrlParam(sessionListUrl, "date_to", dateTo);
|
||||
var options = {
|
||||
|
@ -121,7 +121,7 @@ function initTable() {
|
|||
$(td).html(data);
|
||||
}},
|
||||
{targets: 9, createdCell: function (td, cellData) {
|
||||
var data = formatDateAsCN(cellData);
|
||||
var data = toSafeLocalDateStr(cellData);
|
||||
$(td).html(data);
|
||||
}},
|
||||
{targets: 10, createdCell: function (td, cellData, rowData) {
|
||||
|
@ -201,7 +201,7 @@ $(document).ready(function() {
|
|||
return
|
||||
}
|
||||
var value = $(this).val() + ' 0:0:0';
|
||||
var date = formatDateAsCN(value);
|
||||
var date = toSafeDateISOStr(value);
|
||||
var url = table.ajax.url();
|
||||
url = setUrlParam(url, "date_from", date);
|
||||
table.ajax.url(url);
|
||||
|
@ -212,7 +212,7 @@ $(document).ready(function() {
|
|||
return
|
||||
}
|
||||
var value = $(this).val() + ' 23:59:59';
|
||||
var date = formatDateAsCN(value);
|
||||
var date = toSafeDateISOStr(value);
|
||||
var url = table.ajax.url();
|
||||
url = setUrlParam(url, "date_to", date);
|
||||
table.ajax.url(url);
|
||||
|
|
Loading…
Reference in New Issue