fixed Web UI Notification Error
parent
79c76e3419
commit
af332baa3c
|
@ -367,7 +367,7 @@ class WebMessageItem:
|
||||||
if 'status' not in new_values['data'].keys() or \
|
if 'status' not in new_values['data'].keys() or \
|
||||||
not isinstance(new_values['data']['status'], str) or \
|
not isinstance(new_values['data']['status'], str) or \
|
||||||
len(str.strip(new_values['data']['status'])) == 0 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',
|
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||||
description='API.INVALID_STATUS')
|
description='API.INVALID_STATUS')
|
||||||
status = str.strip(new_values['data']['status'])
|
status = str.strip(new_values['data']['status'])
|
||||||
|
|
|
@ -128,7 +128,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
|
|
||||||
const subjectFormatter = (dataField, { url }) => (
|
const subjectFormatter = (dataField, { url }) => (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<a href={`${url}`}>{dataField}</a>
|
<span>{dataField}</span>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -143,16 +143,16 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
let icon = '';
|
let icon = '';
|
||||||
let text = '';
|
let text = '';
|
||||||
switch (status) {
|
switch (status) {
|
||||||
|
case 'acknowledged':
|
||||||
|
color = 'success';
|
||||||
|
icon = 'envelope-open';
|
||||||
|
text = t('Notification Acknowledged');
|
||||||
|
break;
|
||||||
case 'read':
|
case 'read':
|
||||||
color = 'success';
|
color = 'success';
|
||||||
icon = 'envelope-open';
|
icon = 'envelope-open';
|
||||||
text = t('Notification Read');
|
text = t('Notification Read');
|
||||||
break;
|
break;
|
||||||
case 'unread':
|
|
||||||
color = 'primary';
|
|
||||||
icon = 'envelope';
|
|
||||||
text = t('Notification Unread');
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
color = 'primary';
|
color = 'primary';
|
||||||
icon = 'envelope';
|
icon = 'envelope';
|
||||||
|
@ -175,9 +175,9 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
</DropdownToggle>
|
</DropdownToggle>
|
||||||
<DropdownMenu right className="border py-2">
|
<DropdownMenu right className="border py-2">
|
||||||
<DropdownItem onClick={() => handleRead(id)}>{t('Notification Mark As Read')}</DropdownItem>
|
<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 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>
|
</DropdownMenu>
|
||||||
</UncontrolledDropdown>
|
</UncontrolledDropdown>
|
||||||
);
|
);
|
||||||
|
@ -251,6 +251,41 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
const handleRead = (id, ) => {
|
const handleRead = (id, ) => {
|
||||||
console.log('Mark As Read: ', id)
|
console.log('Mark As Read: ', id)
|
||||||
let isResponseOK = false;
|
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, {
|
fetch(APIBaseURL + '/webmessages/' + id, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
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 (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
@ -294,7 +359,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => {
|
||||||
<CustomInput type="select" id="bulk-select">
|
<CustomInput type="select" id="bulk-select">
|
||||||
<option>{t('Bulk actions')}</option>
|
<option>{t('Bulk actions')}</option>
|
||||||
<option value="MarkAsRead">{t('Notification Mark As Read')}</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>
|
<option value="Delete">{t('Notification Delete')}</option>
|
||||||
</CustomInput>
|
</CustomInput>
|
||||||
<Button color="falcon-default" size="sm" className="ml-2">
|
<Button color="falcon-default" size="sm" className="ml-2">
|
||||||
|
|
|
@ -95,7 +95,7 @@ const NotificationDropdown = ({ t }) => {
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
"data": {
|
"data": {
|
||||||
"status": 'acknowledged',
|
"status": 'read',
|
||||||
"reply": 'ok'
|
"reply": 'ok'
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -1864,8 +1864,10 @@ const resources = {
|
||||||
'Notification Message': '内容',
|
'Notification Message': '内容',
|
||||||
'Notification Status': '状态',
|
'Notification Status': '状态',
|
||||||
'Notification Mark As Read': '标记为已读',
|
'Notification Mark As Read': '标记为已读',
|
||||||
|
'Notification Mark As Acknowledged': '确认',
|
||||||
'Notification Unread': '未读',
|
'Notification Unread': '未读',
|
||||||
'Notification Read': '已读',
|
'Notification Read': '已读',
|
||||||
|
'Notification Acknowledged': '已确认',
|
||||||
'Notification Archive': '存档',
|
'Notification Archive': '存档',
|
||||||
'Notification Delete': '删除',
|
'Notification Delete': '删除',
|
||||||
'Notification Apply': '应用',
|
'Notification Apply': '应用',
|
||||||
|
|
Loading…
Reference in New Issue