Merge branch 'PR' into develop

pull/123/head
13621160019@163.com 2022-02-12 14:47:23 +08:00
commit 12843792f1
4 changed files with 79 additions and 12 deletions

View File

@ -367,7 +367,7 @@ class WebMessageItem:
if 'status' not in new_values['data'].keys() or \
not isinstance(new_values['data']['status'], str) or \
len(str.strip(new_values['data']['status'])) == 0 or \
str.strip(new_values['data']['status']) not in ('new', 'acknowledged', 'timeout'):
str.strip(new_values['data']['status']) not in ('new', 'acknowledged', 'timeout', 'read'):
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
description='API.INVALID_STATUS')
status = str.strip(new_values['data']['status'])

View File

@ -128,7 +128,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
const subjectFormatter = (dataField, { url }) => (
<Fragment>
<a href={`${url}`}>{dataField}</a>
<span>{dataField}</span>
</Fragment>
);
@ -143,16 +143,16 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
let icon = '';
let text = '';
switch (status) {
case 'acknowledged':
color = 'success';
icon = 'envelope-open';
text = t('Notification Acknowledged');
break;
case 'read':
color = 'success';
icon = 'envelope-open';
text = t('Notification Read');
break;
case 'unread':
color = 'primary';
icon = 'envelope';
text = t('Notification Unread');
break;
default:
color = 'primary';
icon = 'envelope';
@ -175,9 +175,9 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
</DropdownToggle>
<DropdownMenu right className="border py-2">
<DropdownItem onClick={() => handleRead(id)}>{t('Notification Mark As Read')}</DropdownItem>
<DropdownItem onClick={() => console.log('Archive: ', id)}>{t('Notification Archive')}</DropdownItem>
<DropdownItem onClick={() => handleAcknowledged(id)}>{t('Notification Mark As Acknowledged')}</DropdownItem>
<DropdownItem divider />
<DropdownItem onClick={() => console.log('Delete: ', id)} className="text-danger">{t('Notification Delete')}</DropdownItem>
<DropdownItem onClick={() => handledelete(id)} className="text-danger">{t('Notification Delete')}</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>
);
@ -251,6 +251,41 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
const handleRead = (id, ) => {
console.log('Mark As Read: ', id)
let isResponseOK = false;
fetch(APIBaseURL + '/webmessages/' + id, {
method: 'PUT',
headers: {
"Content-type": "application/json",
"User-UUID": getCookieValue('user_uuid'),
"Token": getCookieValue('token')
},
body: JSON.stringify({
"data": {
"status": 'read',
"reply": 'ok'
}
}),
}).then(response => {
if (response.ok) {
isResponseOK = true;
return null;
} else {
return response.json();
}
}).then(json => {
console.log(isResponseOK);
if (isResponseOK) {
} else {
toast.error(json.description)
}
}).catch(err => {
console.log(err);
});
};
const handleAcknowledged = (id, ) => {
console.log('Mark As Acknowledged: ', id)
let isResponseOK = false;
fetch(APIBaseURL + '/webmessages/' + id, {
method: 'PUT',
headers: {
@ -283,6 +318,36 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
});
};
const handledelete = (id, ) => {
console.log('Delete: ', id)
let isResponseOK = false;
fetch(APIBaseURL + '/webmessages/' + id, {
method: 'DELETE',
headers: {
"Content-type": "application/json",
"User-UUID": getCookieValue('user_uuid'),
"Token": getCookieValue('token')
},
body: null,
}).then(response => {
if (response.ok) {
isResponseOK = true;
return null;
} else {
return response.json();
}
}).then(json => {
console.log(isResponseOK);
if (isResponseOK) {
} else {
toast.error(json.description)
}
}).catch(err => {
console.log(err);
});
};
return (
<Fragment>
@ -294,7 +359,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
<CustomInput type="select" id="bulk-select">
<option>{t('Bulk actions')}</option>
<option value="MarkAsRead">{t('Notification Mark As Read')}</option>
<option value="Archive">{t('Notification Archive')}</option>
<option value="MarkAsAcknowledged">{t('Notification Mark As Acknowledged')}</option>
<option value="Delete">{t('Notification Delete')}</option>
</CustomInput>
<Button color="falcon-default" size="sm" className="ml-2">

View File

@ -95,7 +95,7 @@ const NotificationDropdown = ({ t }) => {
},
body: JSON.stringify({
"data": {
"status": 'acknowledged',
"status": 'read',
"reply": 'ok'
}
}),

View File

@ -1864,8 +1864,10 @@ const resources = {
'Notification Message': '内容',
'Notification Status': '状态',
'Notification Mark As Read': '标记为已读',
'Notification Mark As Acknowledged': '确认',
'Notification Unread': '未读',
'Notification Read': '已读',
'Notification Acknowledged': '已确认',
'Notification Archive': '存档',
'Notification Delete': '删除',
'Notification Apply': '应用',