Max Red - Finally we did it! [skip ci]

This commit is contained in:
ivan 2017-01-05 18:01:56 -03:00
parent 1465a53616
commit 5ea4137e41
10 changed files with 241 additions and 79 deletions

View File

@ -1,4 +1,5 @@
import React from 'react';
import _ from 'lodash';
import {Link} from 'react-router';
import Icon from 'core-components/icon';
@ -8,15 +9,36 @@ import i18n from 'lib-app/i18n';
class ActivityRow extends React.Component {
static propTypes = {
mode: React.PropTypes.oneOf(['staff', 'system']),
type: React.PropTypes.oneOf([
'COMMENT',
'ASSIGN',
'UN_ASSIGN',
'CLOSE',
'CREATE_TICKET',
'RE_OPEN',
'DEPARTMENT_CHANGED',
'PRIORITY_CHANGED'
'PRIORITY_CHANGED',
'EDIT_SETTINGS',
'SIGNUP',
'ADD_TOPIC',
'ADD_ARTICLE',
'DELETE_TOPIC',
'DELETE_ARTICLE',
'EDIT_ARTICLE',
'ADD_STAFF',
'ADD_DEPARTMENT',
'DELETE_DEPARTMENT',
'EDIT_DEPARTMENT',
'ADD_CUSTOM_RESPONSE',
'DELETE_CUSTOM_RESPONSE',
'EDIT_CUSTOM_RESPONSE',
'BAN_USER',
'DELETE_USER',
'UN_BAN_USER'
]),
to: React.PropTypes.string,
ticketNumber: React.PropTypes.string,
author: React.PropTypes.shape({
name: React.PropTypes.string,
@ -26,6 +48,17 @@ class ActivityRow extends React.Component {
};
render() {
let ticketRelatedTypes = [
'COMMENT',
'ASSIGN',
'UN_ASSIGN',
'CLOSE',
'CREATE_TICKET',
'RE_OPEN',
'DEPARTMENT_CHANGED',
'PRIORITY_CHANGED'
];
return (
<div className="activity-row">
<Icon {...this.getIconProps()} className="activity-row__icon"/>
@ -35,16 +68,24 @@ class ActivityRow extends React.Component {
</Link>
</span>
<span className="activity-row__message"> {i18n('ACTIVITY_' + this.props.type)} </span>
<span>
<Link className="activity-row__ticket-link" to={'/admin/panel/tickets/view-ticket/' + this.props.ticketNumber}>
#{this.props.ticketNumber}
</Link>
</span>
{_.includes(ticketRelatedTypes, this.props.type) ? this.renderTicketNumber() : null}
<span className="separator" />
</div>
);
}
renderTicketNumber() {
let ticketNumber = (this.props.mode === 'staff') ? this.props.ticketNumber : this.props.to;
return (
<span>
<Link className="activity-row__ticket-link" to={'/admin/panel/tickets/view-ticket/' + ticketNumber}>
#{ticketNumber}
</Link>
</span>
);
}
getNameLinkDestination() {
return (this.props.author.staff ? '/admin/panel/staff/view-staff/' : '/admin/panel/users/view-user/') + this.props.author.id;
}
@ -55,9 +96,28 @@ class ActivityRow extends React.Component {
'ASSIGN': 'user',
'UN_ASSIGN': 'user-times',
'CLOSE': 'lock',
'CREATE_TICKET': 'ticket',
'RE_OPEN': 'unlock-alt',
'DEPARTMENT_CHANGED': 'exchange',
'PRIORITY_CHANGED': 'exclamation'
'PRIORITY_CHANGED': 'exclamation',
'EDIT_SETTINGS': 'wrench',
'SIGNUP': 'user-plus',
'ADD_TOPIC': 'book',
'ADD_ARTICLE': 'book',
'DELETE_TOPIC': 'book',
'DELETE_ARTICLE': 'book',
'EDIT_ARTICLE': 'book',
'ADD_STAFF': 'id-card',
'ADD_DEPARTMENT': 'university',
'DELETE_DEPARTMENT': 'university',
'EDIT_DEPARTMENT': 'university',
'ADD_CUSTOM_RESPONSE': 'file',
'DELETE_CUSTOM_RESPONSE': 'file',
'EDIT_CUSTOM_RESPONSE': 'file',
'BAN_USER': 'user-times',
'DELETE_USER': 'user-times',
'UN_BAN_USER': 'user'
};
return {

View File

@ -74,7 +74,7 @@ class ActivityList extends React.Component {
data: {
page: this.state.page
}
}).then(this.onRetrieveSuccess.bind(this)).catch(this.onRetrieveFail.bind(this))
}).then(this.onRetrieveSuccess.bind(this));
}
onRetrieveSuccess(result) {
@ -85,10 +85,6 @@ class ActivityList extends React.Component {
loading: false
});
}
onRetrieveFail() {
}
}
export default ActivityList;

View File

@ -1,20 +1,43 @@
import React from 'react';
import API from 'lib-app/api-call';
import i18n from 'lib-app/i18n';
import ActivityRow from 'app-components/activity-row';
import Header from 'core-components/header';
import Menu from 'core-components/menu';
import ActivityList from 'app/admin/panel/dashboard/activity-list';
import SubmitButton from 'core-components/submit-button';
class AdminPanelActivity extends React.Component {
static childContextTypes = {
loading: React.PropTypes.bool
};
getChildContext() {
return {
loading: this.state.loading
};
}
state = {
activities: [],
page: 1,
limit: false,
loading: false,
mode: 'staff'
};
componentDidMount() {
this.retrieveNextPage();
}
render() {
return (
<div className="admin-panel-activity">
<Header title={i18n('LAST_ACTIVITY')} />
<Menu {...this.getMenuProps()} />
<ActivityList />
{this.renderList()}
</div>
);
}
@ -22,6 +45,7 @@ class AdminPanelActivity extends React.Component {
getMenuProps() {
return {
className: 'admin-panel-activity__menu',
onItemClick: this.onMenuItemClick.bind(this),
type: 'horizontal-list-bright',
items: [
{
@ -35,6 +59,67 @@ class AdminPanelActivity extends React.Component {
]
}
}
renderList() {
if (this.state.mode === 'staff') {
return (
<div>
{this.state.activities.map(this.renderRow.bind(this))}
{(!this.state.limit) ? this.renderButton() : null}
</div>
);
}
else {
return (
<div>
{this.state.activities.map(this.renderRow.bind(this))}
{(!this.state.limit) ? this.renderButton() : null}
</div>
);
}
}
renderButton() {
return (
<SubmitButton type="secondary" onClick={this.retrieveNextPage.bind(this)}>
{i18n('LOAD_MORE')}
</SubmitButton>
);
}
renderRow(row, index) {
return (
<ActivityRow key={index} {...row} mode={this.state.mode} />
);
}
onMenuItemClick(index) {
this.setState({
page: 0,
mode: (index === 0) ? 'staff' : 'system',
activities: []
}, this.retrieveNextPage.bind(this));
}
retrieveNextPage() {
this.setState({loading: true});
API.call({
path: (this.state.mode === 'staff') ? '/staff/last-events' : '/system/get-logs',
data: {
page: this.state.page
}
}).then(this.onRetrieveSuccess.bind(this));
}
onRetrieveSuccess(result) {
this.setState({
activities: this.state.activities.concat(result.data),
page: this.state.page + 1,
limit: (result.data.length !== 10),
loading: false
});
}
}
export default AdminPanelActivity;

View File

@ -162,96 +162,96 @@ module.exports = [
time: 30,
response: function() {
return {
status: 'success',
data: [
"status": "success",
"data": [
{
"type": "COMMENT",
"ticketNumber": "683061",
"type": "EDIT_SETTINGS",
"to": null,
"author": {
"name": "Julieta Lannister",
"staff": false,
"id": "10"
"name": "Emilia Clarke",
"id": "1",
"staff": true
}
},
{
"type": "RE_OPEN",
"ticketNumber": "683061",
"type": "SIGNUP",
"to": null,
"author": {
"name": "Elizabelth Lannister",
"staff": false,
"id": "10"
"name": "Steve Jobs",
"id": "1",
"staff": false
}
},
{
"type": "CLOSE",
"ticketNumber": "683061",
"type": "SIGNUP",
"to": null,
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "steve jobs",
"id": "2",
"staff": false
}
},
{
"type": "DEPARTMENT_CHANGED",
"ticketNumber": "683061",
"type": "SIGNUP",
"to": null,
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "steve jobs",
"id": "3",
"staff": false
}
},
{
"type": "PRIORITY_CHANGED",
"ticketNumber": "683061",
"type": "SIGNUP",
"to": null,
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "Creator",
"id": "5",
"staff": false
}
},
{
"type": "ASSIGN",
"ticketNumber": "683061",
"type": "CREATE_TICKET",
"to": "739228",
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "Creator",
"id": "5",
"staff": false
}
},
{
"type": "UN_ASSIGN",
"ticketNumber": "683061",
"type": "CREATE_TICKET",
"to": "915839",
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "Creator",
"id": "5",
"staff": false
}
},
{
"type": "COMMENT",
"ticketNumber": "683061",
"type": "CREATE_TICKET",
"to": "192450",
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "Creator",
"id": "5",
"staff": false
}
},
{
"type": "ASSIGN",
"ticketNumber": "683061",
"type": "CREATE_TICKET",
"to": "369061",
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "Creator",
"id": "5",
"staff": false
}
},
{
"type": "PRIORITY_CHANGED",
"ticketNumber": "608120",
"type": "SIGNUP",
"to": null,
"author": {
"name": "Emilia Clarker",
"staff": true,
"id": "1"
"name": "Commenter",
"id": "6",
"staff": false
}
}
]

View File

@ -142,16 +142,37 @@ export default {
'BOXED': 'Boxed',
'FULL_WIDTH': 'Full width',
'LOAD_MORE': 'Load More',
'ACTIVITY_COMMENT': 'commented',
'ACTIVITY_ASSIGN': 'assigned',
'ACTIVITY_UN_ASSIGN': 'unassigned',
'ACTIVITY_CLOSE': 'closed',
'ACTIVITY_RE_OPEN': 'reopened',
'ACTIVITY_DEPARTMENT_CHANGED': 'changed department of',
'ACTIVITY_PRIORITY_CHANGED': 'changed priority of',
'MY_NOTIFICATIONS': 'My notifications',
'ALL_NOTIFICATIONS': 'All notifications',
//ACTIVITIES
'ACTIVITY_COMMENT': 'commented ticket',
'ACTIVITY_ASSIGN': 'assigned ticket',
'ACTIVITY_UN_ASSIGN': 'unassigned ticket',
'ACTIVITY_CLOSE': 'closed ticket',
'ACTIVITY_CREATE_TICKET': 'created ticket',
'ACTIVITY_RE_OPEN': 'reopened ticket',
'ACTIVITY_DEPARTMENT_CHANGED': 'changed department of ticket',
'ACTIVITY_PRIORITY_CHANGED': 'changed priority of ticket',
'ACTIVITY_EDIT_SETTINGS': 'edited settings',
'ACTIVITY_SIGNUP': 'signed up',
'ACTIVITY_ADD_TOPIC': 'added topic',
'ACTIVITY_ADD_ARTICLE': 'added article',
'ACTIVITY_DELETE_TOPIC': 'deleted topic',
'ACTIVITY_DELETE_ARTICLE': 'deleted article',
'ACTIVITY_EDIT_ARTICLE': 'edited article',
'ACTIVITY_ADD_STAFF': 'added staff',
'ACTIVITY_ADD_DEPARTMENT': 'added department',
'ACTIVITY_DELETE_DEPARTMENT': 'deleted department',
'ACTIVITY_EDIT_DEPARTMENT': 'edited department',
'ACTIVITY_ADD_CUSTOM_RESPONSE': 'added custom response',
'ACTIVITY_DELETE_CUSTOM_RESPONSE': 'deleted custom response',
'ACTIVITY_EDIT_CUSTOM_RESPONSE': 'edited custom response',
'ACTIVITY_BAN_USER': 'banned user',
'ACTIVITY_DELETE_USER': 'deleted user',
'ACTIVITY_UN_BAN_USER': 'banned user',
//VIEW DESCRIPTIONS
'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.',
'TICKET_LIST_DESCRIPTION': 'Here you can find a list of all tickets you have sent to our support team.',

View File

@ -44,7 +44,7 @@ class ChangeDepartmentController extends Controller {
$ticket->unread = true;
$ticket->store();
Log::createLog('CHANGE_DEPARTMENT', $ticket->ticketNumber);
Log::createLog('DEPARTMENT_CHANGED', $ticket->ticketNumber);
Response::respondSuccess();
}

View File

@ -38,7 +38,7 @@ class ChangePriorityController extends Controller {
$ticket->addEvent($event);
$ticket->store();
Log::createLog('CHANGE_PRIORITY', $ticket->ticketNumber);
Log::createLog('PRIORITY_CHANGED', $ticket->ticketNumber);
Response::respondSuccess();
} else {
Response::respondError(ERRORS::NO_PERMISSION);

View File

@ -33,7 +33,7 @@ class CloseController extends Controller {
$this->ticket->store();
Log::createLog('CLOSE_TICKET', $this->ticket->ticketNumber);
Log::createLog('CLOSE', $this->ticket->ticketNumber);
Response::respondSuccess();
}

View File

@ -31,7 +31,7 @@ class CommentController extends Controller {
if ($session->isLoggedWithId($this->ticket->author->id) || Controller::isStaffLogged()) {
$this->storeComment();
Log::createLog('COMMENT_TICKET', $this->ticket->ticketNumber);
Log::createLog('COMMENT', $this->ticket->ticketNumber);
Response::respondSuccess();
} else {

View File

@ -32,7 +32,7 @@ class ReOpenController extends Controller {
$this->ticket->store();
Log::createLog('RE_OPEN_TICKET', $this->ticket->ticketNumber);
Log::createLog('RE_OPEN', $this->ticket->ticketNumber);
Response::respondSuccess();
}