chore: update time format
This commit is contained in:
@@ -93,6 +93,11 @@ const (
|
|||||||
SendEmailToOthersDisallowed = 2
|
SendEmailToOthersDisallowed = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SaveMessageToDatabaseAllowed = 1
|
||||||
|
SaveMessageToDatabaseDisallowed = 2
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MessageSendStatusUnknown = 0
|
MessageSendStatusUnknown = 0
|
||||||
MessageSendStatusPending = 1
|
MessageSendStatusPending = 1
|
||||||
|
|||||||
+8
-3
@@ -635,6 +635,10 @@ func ManageUser(c *gin.Context) {
|
|||||||
user.SendEmailToOthers = common.SendEmailToOthersAllowed
|
user.SendEmailToOthers = common.SendEmailToOthersAllowed
|
||||||
case "disallow_send_email_to_others":
|
case "disallow_send_email_to_others":
|
||||||
user.SendEmailToOthers = common.SendEmailToOthersDisallowed
|
user.SendEmailToOthers = common.SendEmailToOthersDisallowed
|
||||||
|
case "allow_save_message_to_database":
|
||||||
|
user.SaveMessageToDatabase = common.SaveMessageToDatabaseAllowed
|
||||||
|
case "disallow_save_message_to_database":
|
||||||
|
user.SaveMessageToDatabase = common.SaveMessageToDatabaseDisallowed
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user.Update(false); err != nil {
|
if err := user.Update(false); err != nil {
|
||||||
@@ -645,9 +649,10 @@ func ManageUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
clearUser := model.User{
|
clearUser := model.User{
|
||||||
Role: user.Role,
|
Role: user.Role,
|
||||||
Status: user.Status,
|
Status: user.Status,
|
||||||
SendEmailToOthers: user.SendEmailToOthers,
|
SendEmailToOthers: user.SendEmailToOthers,
|
||||||
|
SaveMessageToDatabase: user.SaveMessageToDatabase,
|
||||||
}
|
}
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": true,
|
"success": true,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Button, Form, Label, Modal, Pagination, Table } from 'semantic-ui-react';
|
import { Button, Form, Label, Modal, Pagination, Table } from 'semantic-ui-react';
|
||||||
import { API, openPage, showError, showSuccess, showWarning } from '../helpers';
|
import { API, openPage, showError, showSuccess, showWarning, timestamp2string } from '../helpers';
|
||||||
|
|
||||||
import { ITEMS_PER_PAGE } from '../constants';
|
import { ITEMS_PER_PAGE } from '../constants';
|
||||||
|
|
||||||
@@ -70,13 +70,11 @@ function renderChannel(channel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderTimestamp(timestamp) {
|
function renderTimestamp(timestamp) {
|
||||||
const date = new Date(timestamp * 1000);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{date.getFullYear()}-{date.getMonth() + 1}-{date.getDate()}{' '}
|
{timestamp2string(timestamp)}
|
||||||
{date.getHours()}:{date.getMinutes()}:{date.getSeconds()}
|
|
||||||
</>
|
</>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderStatus(status) {
|
function renderStatus(status) {
|
||||||
|
|||||||
@@ -102,3 +102,41 @@ export function removeTrailingSlash(url) {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function timestamp2string(timestamp) {
|
||||||
|
let date = new Date(timestamp * 1000);
|
||||||
|
let year = date.getFullYear().toString();
|
||||||
|
let month = (date.getMonth() + 1).toString();
|
||||||
|
let day = date.getDate().toString();
|
||||||
|
let hour = date.getHours().toString();
|
||||||
|
let minute = date.getMinutes().toString();
|
||||||
|
let second = date.getSeconds().toString();
|
||||||
|
if (month.length === 1) {
|
||||||
|
month = '0' + month;
|
||||||
|
}
|
||||||
|
if (day.length === 1) {
|
||||||
|
day = '0' + day;
|
||||||
|
}
|
||||||
|
if (hour.length === 1) {
|
||||||
|
hour = '0' + hour;
|
||||||
|
}
|
||||||
|
if (minute.length === 1) {
|
||||||
|
minute = '0' + minute;
|
||||||
|
}
|
||||||
|
if (second.length === 1) {
|
||||||
|
second = '0' + second;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
year +
|
||||||
|
'-' +
|
||||||
|
month +
|
||||||
|
'-' +
|
||||||
|
day +
|
||||||
|
' ' +
|
||||||
|
hour +
|
||||||
|
':' +
|
||||||
|
minute +
|
||||||
|
':' +
|
||||||
|
second
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { Card, Grid, Header, Segment } from 'semantic-ui-react';
|
import { Card, Grid, Header, Segment } from 'semantic-ui-react';
|
||||||
import { API, showError, showNotice } from '../../helpers';
|
import { API, showError, showNotice, timestamp2string } from '../../helpers';
|
||||||
import { StatusContext } from '../../context/Status';
|
import { StatusContext } from '../../context/Status';
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
@@ -22,8 +22,7 @@ const Home = () => {
|
|||||||
|
|
||||||
const getStartTimeString = () => {
|
const getStartTimeString = () => {
|
||||||
const timestamp = statusState?.status?.start_time;
|
const timestamp = statusState?.status?.start_time;
|
||||||
const date = new Date(timestamp * 1000);
|
return timestamp2string(timestamp);
|
||||||
return date.toLocaleString();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user