diff --git a/client/src/app-components/activity-row.js b/client/src/app-components/activity-row.js
index f42734af..dab5d581 100644
--- a/client/src/app-components/activity-row.js
+++ b/client/src/app-components/activity-row.js
@@ -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 (
@@ -35,16 +68,24 @@ class ActivityRow extends React.Component {
{i18n('ACTIVITY_' + this.props.type)}
-
-
- #{this.props.ticketNumber}
-
-
+ {_.includes(ticketRelatedTypes, this.props.type) ? this.renderTicketNumber() : null}
);
}
+ renderTicketNumber() {
+ let ticketNumber = (this.props.mode === 'staff') ? this.props.ticketNumber : this.props.to;
+
+ return (
+
+
+ #{ticketNumber}
+
+
+ );
+ }
+
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 {
diff --git a/client/src/app/admin/panel/dashboard/activity-list.js b/client/src/app/admin/panel/dashboard/activity-list.js
index a1f65461..9a125793 100644
--- a/client/src/app/admin/panel/dashboard/activity-list.js
+++ b/client/src/app/admin/panel/dashboard/activity-list.js
@@ -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;
\ No newline at end of file
diff --git a/client/src/app/admin/panel/dashboard/admin-panel-activity.js b/client/src/app/admin/panel/dashboard/admin-panel-activity.js
index 0bac4788..145a393f 100644
--- a/client/src/app/admin/panel/dashboard/admin-panel-activity.js
+++ b/client/src/app/admin/panel/dashboard/admin-panel-activity.js
@@ -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 (
);
}
@@ -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 (
+
+ {this.state.activities.map(this.renderRow.bind(this))}
+ {(!this.state.limit) ? this.renderButton() : null}
+
+ );
+ }
+ else {
+ return (
+
+ {this.state.activities.map(this.renderRow.bind(this))}
+ {(!this.state.limit) ? this.renderButton() : null}
+
+ );
+ }
+ }
+
+ renderButton() {
+ return (
+
+ {i18n('LOAD_MORE')}
+
+ );
+ }
+
+ renderRow(row, index) {
+ return (
+
+ );
+ }
+
+ 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;
\ No newline at end of file
diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js
index f5b82d40..cb530394 100644
--- a/client/src/data/fixtures/system-fixtures.js
+++ b/client/src/data/fixtures/system-fixtures.js
@@ -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
}
}
]
diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js
index efa33276..3f193dd2 100644
--- a/client/src/data/languages/en.js
+++ b/client/src/data/languages/en.js
@@ -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.',
diff --git a/server/controllers/ticket/change-department.php b/server/controllers/ticket/change-department.php
index 398fde51..ac2e78da 100644
--- a/server/controllers/ticket/change-department.php
+++ b/server/controllers/ticket/change-department.php
@@ -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();
}
diff --git a/server/controllers/ticket/change-priority.php b/server/controllers/ticket/change-priority.php
index 1fbfcdb1..2e671a57 100644
--- a/server/controllers/ticket/change-priority.php
+++ b/server/controllers/ticket/change-priority.php
@@ -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);
diff --git a/server/controllers/ticket/close.php b/server/controllers/ticket/close.php
index f7829c1e..ed983a35 100644
--- a/server/controllers/ticket/close.php
+++ b/server/controllers/ticket/close.php
@@ -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();
}
diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php
index dd0792f5..b51414c2 100644
--- a/server/controllers/ticket/comment.php
+++ b/server/controllers/ticket/comment.php
@@ -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 {
diff --git a/server/controllers/ticket/re-open.php b/server/controllers/ticket/re-open.php
index cf6bd9a6..b2754256 100644
--- a/server/controllers/ticket/re-open.php
+++ b/server/controllers/ticket/re-open.php
@@ -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();
}