From 6a22ba711ecc9cbb24dc615231cfd36705a35549 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 13 Jan 2017 15:17:43 -0300 Subject: [PATCH 01/35] Max Red - WIP first layout [skip ci] --- client/package.json | 2 + .../dashboard/admin-panel-stats-chart.js | 18 ++++++++ .../panel/dashboard/admin-panel-stats.js | 33 ++++++++++++++- client/src/app/demo/components-demo-page.js | 42 ++++++++++++++++++- client/src/data/fixtures/system-fixtures.js | 9 ++++ client/src/data/languages/en.js | 1 + 6 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js diff --git a/client/package.json b/client/package.json index 21e3f053..3caab38d 100644 --- a/client/package.json +++ b/client/package.json @@ -54,6 +54,7 @@ }, "dependencies": { "app-module-path": "^1.0.3", + "chart.js": "^1.1.1", "classnames": "^2.1.3", "draft-js": "^0.8.1", "draft-js-export-html": "^0.4.0", @@ -63,6 +64,7 @@ "lodash": "^3.10.0", "messageformat": "^0.2.2", "react": "^15.0.1", + "react-chartjs": "^0.8.0", "react-document-title": "^1.0.2", "react-dom": "^15.0.1", "react-google-recaptcha": "^0.5.2", diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js new file mode 100644 index 00000000..d4dfabfa --- /dev/null +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -0,0 +1,18 @@ +import React from 'react'; + +class StatsChart extends React.Component { + + static propTypes = { + strokes: React.PropTypes.arrayOf(React.PropTypes.shape({ + + })) + }; + + render() { + return ( +
Shit go home!
+ ); + } +} + +export default StatsChart; \ No newline at end of file diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 020264e4..76fd68d6 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -1,14 +1,45 @@ import React from 'react'; +import i18n from 'lib-app/i18n'; + +import Header from 'core-components/header'; +import DropDown from 'core-components/drop-down'; +import StatsChart from 'app/admin/panel/dashboard/admin-panel-stats-chart'; + class AdminPanelStats extends React.Component { render() { return (
- /admin/panel/stats +
+ +
); } + + getDropDownProps() { + return { + items: [ + { + content: 'Last 7 days', + icon: '' + }, + { + content: 'Last 30 days', + icon: '' + }, + { + content: 'Last 90 days', + icon: '' + }, + { + content: 'Last 365 days', + icon: '' + } + ] + } + } } export default AdminPanelStats; \ No newline at end of file diff --git a/client/src/app/demo/components-demo-page.js b/client/src/app/demo/components-demo-page.js index 5244975c..4a69a807 100644 --- a/client/src/app/demo/components-demo-page.js +++ b/client/src/app/demo/components-demo-page.js @@ -1,6 +1,7 @@ 'use strict'; const React = require('react'); +const LineChart = require("react-chartjs").Line; const _ = require('lodash'); const DocumentTitle = require('react-document-title'); @@ -16,8 +17,41 @@ const Menu = require('core-components/menu'); const Tooltip = require('core-components/tooltip'); const Table = require('core-components/table'); const InfoTooltip = require('core-components/info-tooltip'); -const ToggleButton = require('app-components/toggle-button'); +function rand(min, max, num) { + var rtn = []; + while (rtn.length < num) { + rtn.push((Math.random() * (max - min)) + min); + } + return rtn; +} + +let chartData = { + labels: ["January", "February", "March", "April", "", "May", "June", "July"], + datasets: [ + { + label: "My First dataset", + fillColor: "rgba(0,0,0,0)", + strokeColor: "rgba(1,2,3,1)", + pointColor: "rgba(3,2,1,1)", + pointStrokeColor: "#333", + pointHighlightFill: "#999", + pointHighlightStroke: "rgba(220,220,220,1)", + data: rand(32, 100, 8) + }, + { + label: "My Second dataset", + fillColor: "rgba(0,0,0,0)", + strokeColor: "rgba(151,187,205,1)", + pointColor: "rgba(151,187,205,1)", + pointStrokeColor: "#fff", + pointHighlightFill: "#fff", + pointHighlightStroke: "rgba(151,187,205,1)", + data: rand(32, 100, 8) + } + ] +}; +let chartOptions = {}; let dropDownItems = [{content: 'English'}, {content: 'Spanish'}, {content: 'German'}, {content: 'Portuguese'}, {content: 'Japanese'}]; let secondaryMenuItems = [ {content: 'My Tickets', icon: 'file-text'}, @@ -176,6 +210,12 @@ let DemoPage = React.createClass({ render: ( ) + }, + { + title: 'LineChart', + render: ( + + ) } ], diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index b67d450f..8626a24b 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -157,6 +157,15 @@ module.exports = [ }; } }, + { + path: '/system/get-stats', + time: 200, + response: function() { + return { + + }; + } + }, { path: '/system/get-logs', time: 300, diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 67a36e64..98b136a9 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -150,6 +150,7 @@ export default { 'LOAD_MORE': 'Load More', 'MY_NOTIFICATIONS': 'My notifications', 'ALL_NOTIFICATIONS': 'All notifications', + 'TICKET_ACTIVITY': 'Ticket Activity', //ACTIVITIES 'ACTIVITY_COMMENT': 'commented ticket', From 8221a06048174f02523aa44399fd088301aaa88f Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 13 Jan 2017 17:06:52 -0300 Subject: [PATCH 02/35] Max Red - WIP second layout [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 68 ++++++- .../panel/dashboard/admin-panel-stats.js | 76 +++++++- client/src/data/fixtures/system-fixtures.js | 172 +++++++++++++++++- 3 files changed, 311 insertions(+), 5 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index d4dfabfa..21758266 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -1,18 +1,80 @@ import React from 'react'; +import {Line} from 'react-chartjs'; class StatsChart extends React.Component { static propTypes = { strokes: React.PropTypes.arrayOf(React.PropTypes.shape({ - - })) + name: React.PropTypes.string, + values: React.PropTypes.arrayOf(React.PropTypes.shape({ + date: React.PropTypes.number, + value: React.PropTypes.number + })) + })), + display: React.PropTypes.number }; render() { return ( -
Shit go home!
+
+ +
); } + + shouldBeDeleted(min, max, num) { + var rtn = []; + while (rtn.length < num) { + rtn.push((Math.random() * (max - min)) + min + ((Math.random() > 0.95) ? 1 : 0)); + } + return rtn; + } + + getChartData() { + let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + + let labels = [], i; + for (i = 0; i < this.props.display; i++) { + console.log(this.props.strokes[0].values[i].date); + let idx = this.props.strokes[0].values[i].date.slice(4, 6) - 1; + labels.push( this.props.strokes[0].values[i].date.slice(6, 8) + ' ' + months[idx]); + } + console.log(labels); + + return { + labels: labels, + datasets: [ + { + label: "My First dataset", + fillColor: "rgba(0,0,0,0)", + strokeColor: "rgba(1,2,3,1)", + pointColor: "rgba(3,2,1,1)", + pointStrokeColor: "#333", + pointHighlightFill: "#999", + pointHighlightStroke: "rgba(220,220,220,1)", + data: this.shouldBeDeleted(32, 36, 365) + }, + { + label: "My Second dataset", + fillColor: "rgba(0,0,0,0)", + strokeColor: "rgba(151,187,205,1)", + pointColor: "rgba(151,187,205,1)", + pointStrokeColor: "#fff", + pointHighlightFill: "#fff", + pointHighlightStroke: "rgba(151,187,205,1)", + data: this.shouldBeDeleted(32, 36, 365) + } + ] + }; + } + + getChartOptions() { + return { + + }; + } + } + export default StatsChart; \ No newline at end of file diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 76fd68d6..e861e6fd 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -13,7 +13,7 @@ class AdminPanelStats extends React.Component {
- +
); } @@ -40,6 +40,80 @@ class AdminPanelStats extends React.Component { ] } } + + getStatsChartProps() { + return { + display: 7, + strokes: [ + { + name: 'new-tickets', + values: [ + { + date: "20160420", + value: 17 + }, + { + date: "20160421", + value: 15 + }, + { + date: "20160422", + value: 12 + }, + { + date: "20160423", + value: 19 + }, + { + date: "20160424", + value: 14 + }, + { + date: "20160425", + value: 13 + }, + { + date: "20160426", + value: 19 + } + ] + }, + { + name: 'closed-tickets', + values: [ + { + date: "20160420", + value: 20 + }, + { + date: "20160421", + value: 15 + }, + { + date: "20160422", + value: 13 + }, + { + date: "20160423", + value: 15 + }, + { + date: "20160424", + value: 12 + }, + { + date: "20160425", + value: 19 + }, + { + date: "20160426", + value: 23 + } + ] + } + ] + } + } } export default AdminPanelStats; \ 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 8626a24b..57db8e0a 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -162,7 +162,177 @@ module.exports = [ time: 200, response: function() { return { - + status: "success", + data: [ + { + "date": "20170112", + "type": "COMMENT", + "general": "1", + "value": "8" + }, + { + "date": "20170112", + "type": "SIGNUP", + "general": "1", + "value": "1" + }, + { + "date": "20170112", + "type": "CLOSE", + "general": "1", + "value": "5" + }, + { + "date": "20170112", + "type": "CREATE_TICKET", + "general": "1", + "value": "2" + }, + { + "date": "20170111", + "type": "COMMENT", + "general": "1", + "value": "3" + }, + { + "date": "20170111", + "type": "SIGNUP", + "general": "1", + "value": "8" + }, + { + "date": "20170111", + "type": "CLOSE", + "general": "1", + "value": "10" + }, + { + "date": "20170111", + "type": "CREATE_TICKET", + "general": "1", + "value": "3" + }, + { + "date": "20170110", + "type": "COMMENT", + "general": "1", + "value": "3" + }, + { + "date": "20170110", + "type": "SIGNUP", + "general": "1", + "value": "6" + }, + { + "date": "20170110", + "type": "CLOSE", + "general": "1", + "value": "2" + }, + { + "date": "20170110", + "type": "CREATE_TICKET", + "general": "1", + "value": "1" + }, + { + "date": "20170109", + "type": "COMMENT", + "general": "1", + "value": "0" + }, + { + "date": "20170109", + "type": "SIGNUP", + "general": "1", + "value": "0" + }, + { + "date": "20170109", + "type": "CLOSE", + "general": "1", + "value": "0" + }, + { + "date": "20170109", + "type": "CREATE_TICKET", + "general": "1", + "value": "0" + }, + { + "date": "20170108", + "type": "COMMENT", + "general": "1", + "value": "0" + }, + { + "date": "20170108", + "type": "SIGNUP", + "general": "1", + "value": "0" + }, + { + "date": "20170108", + "type": "CLOSE", + "general": "1", + "value": "0" + }, + { + "date": "20170108", + "type": "CREATE_TICKET", + "general": "1", + "value": "0" + }, + { + "date": "20170107", + "type": "COMMENT", + "general": "1", + "value": "0" + }, + { + "date": "20170107", + "type": "SIGNUP", + "general": "1", + "value": "0" + }, + { + "date": "20170107", + "type": "CLOSE", + "general": "1", + "value": "0" + }, + { + "date": "20170107", + "type": "CREATE_TICKET", + "general": "1", + "value": "0" + }, + { + "date": "20170106", + "type": "COMMENT", + "general": "1", + "value": "0" + }, + { + "date": "20170106", + "type": "SIGNUP", + "general": "1", + "value": "0" + }, + { + "date": "20170106", + "type": "CLOSE", + "general": "1", + "value": "0" + }, + { + "date": "20170106", + "type": "CREATE_TICKET", + "general": "1", + "value": "0" + } + ] }; } }, From 4f7118c2e5bff0df05b6935d97ee5931ac2ddcde Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 01:45:21 -0300 Subject: [PATCH 03/35] Max Red - Abstracting StatsChart, modified demo page [skip ci] --- client/package.json | 4 +- .../dashboard/admin-panel-stats-chart.js | 92 ++++++++++++------- .../panel/dashboard/admin-panel-stats.js | 51 ++++++++-- client/src/app/demo/components-demo-page.js | 31 ++++--- 4 files changed, 120 insertions(+), 58 deletions(-) diff --git a/client/package.json b/client/package.json index 3caab38d..0033b6df 100644 --- a/client/package.json +++ b/client/package.json @@ -54,7 +54,7 @@ }, "dependencies": { "app-module-path": "^1.0.3", - "chart.js": "^1.1.1", + "chart.js": "^2.4.0", "classnames": "^2.1.3", "draft-js": "^0.8.1", "draft-js-export-html": "^0.4.0", @@ -64,7 +64,7 @@ "lodash": "^3.10.0", "messageformat": "^0.2.2", "react": "^15.0.1", - "react-chartjs": "^0.8.0", + "react-chartjs-2": "^2.0.0", "react-document-title": "^1.0.2", "react-dom": "^15.0.1", "react-google-recaptcha": "^0.5.2", diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 21758266..2ff937b3 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Line} from 'react-chartjs'; +import {Line} from 'react-chartjs-2'; class StatsChart extends React.Component { @@ -7,7 +7,7 @@ class StatsChart extends React.Component { strokes: React.PropTypes.arrayOf(React.PropTypes.shape({ name: React.PropTypes.string, values: React.PropTypes.arrayOf(React.PropTypes.shape({ - date: React.PropTypes.number, + date: React.PropTypes.string, value: React.PropTypes.number })) })), @@ -22,10 +22,10 @@ class StatsChart extends React.Component { ); } - shouldBeDeleted(min, max, num) { + shouldBeDeleted(min, max, num, type) { var rtn = []; while (rtn.length < num) { - rtn.push((Math.random() * (max - min)) + min + ((Math.random() > 0.95) ? 1 : 0)); + rtn.push(Math.floor((Math.random() * (max - min)) + min + ((Math.random() > 0.1) ? type * 3 : 0))); } return rtn; } @@ -33,44 +33,70 @@ class StatsChart extends React.Component { getChartData() { let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - let labels = [], i; - for (i = 0; i < this.props.display; i++) { - console.log(this.props.strokes[0].values[i].date); - let idx = this.props.strokes[0].values[i].date.slice(4, 6) - 1; - labels.push( this.props.strokes[0].values[i].date.slice(6, 8) + ' ' + months[idx]); + let labels = []; + for (let i = 0; i < this.props.display; i++) { + if(i % 2 == 0 && this.props.display > 20){ + labels.push(''); + continue; + } + let firstList = this.props.strokes[0]; + let idx = firstList.values[i].date.slice(4, 6) - 1; + labels.push( firstList.values[i].date.slice(6, 8) + ' ' + months[idx]); + } + + let color = { + 'CREATE_TICKET': 'rgba(150, 20, 20)', + 'CLOSE': 'rgba(20, 150, 20)', + 'SIGNUP': 'rgba(20, 20, 150)', + 'COMMENT': 'rgba(150, 150, 20)' + }; + + let datasets = []; + + for (let i = 0; i < this.props.strokes.length; i++) { + let stroke = this.props.strokes[i]; + + let dataset = {}; + dataset.label = stroke.name; + dataset.data = []; + dataset.fill = false; + + console.log('FUCK THIS PITCH BEF ' + stroke.values.length); + for (let j = 0; j < stroke.values.length; j++) { + console.log('OH YEAH: ' + stroke.values[j].value); + dataset.data.push(stroke.values[j].value); + console.log('OH YEAH x2'); + } + console.log('FUCK THIS PITCH AFT'); + + dataset.borderWidth = 4; + dataset.borderColor = color[stroke.name]; + dataset.pointRadius = 0; + dataset.lineTension = 0.2; + dataset.hitRadius = this.hitRadius(); + + datasets.push(dataset); } - console.log(labels); return { labels: labels, - datasets: [ - { - label: "My First dataset", - fillColor: "rgba(0,0,0,0)", - strokeColor: "rgba(1,2,3,1)", - pointColor: "rgba(3,2,1,1)", - pointStrokeColor: "#333", - pointHighlightFill: "#999", - pointHighlightStroke: "rgba(220,220,220,1)", - data: this.shouldBeDeleted(32, 36, 365) - }, - { - label: "My Second dataset", - fillColor: "rgba(0,0,0,0)", - strokeColor: "rgba(151,187,205,1)", - pointColor: "rgba(151,187,205,1)", - pointStrokeColor: "#fff", - pointHighlightFill: "#fff", - pointHighlightStroke: "rgba(151,187,205,1)", - data: this.shouldBeDeleted(32, 36, 365) - } - ] + datasets: datasets }; } + hitRadius(name) { + /// SHOULD AJUSTAR THIS VALUES + if (this.props.display === 7) return 20; + if (this.props.display === 30) return 15; + if (this.props.display === 90) return 10; + return 3; + } + getChartOptions() { return { - + legend: { + display: false + } }; } diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index e861e6fd..992fda02 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -46,40 +46,40 @@ class AdminPanelStats extends React.Component { display: 7, strokes: [ { - name: 'new-tickets', + name: 'CREATE_TICKET', values: [ { date: "20160420", - value: 17 + value: 71 }, { date: "20160421", - value: 15 + value: 21 }, { date: "20160422", - value: 12 + value: 4 }, { date: "20160423", - value: 19 + value: 9 }, { date: "20160424", - value: 14 + value: 12 }, { date: "20160425", - value: 13 + value: 14 }, { date: "20160426", - value: 19 + value: 22 } ] }, { - name: 'closed-tickets', + name: 'CLOSE', values: [ { date: "20160420", @@ -110,6 +110,39 @@ class AdminPanelStats extends React.Component { value: 23 } ] + }, + { + name: 'SIGNUP', + values: [ + { + date: "20160420", + value: 3 + }, + { + date: "20160421", + value: 5 + }, + { + date: "20160422", + value: 3 + }, + { + date: "20160423", + value: 4 + }, + { + date: "20160424", + value: 5 + }, + { + date: "20160425", + value: 5 + }, + { + date: "20160426", + value: 6 + } + ] } ] } diff --git a/client/src/app/demo/components-demo-page.js b/client/src/app/demo/components-demo-page.js index 4a69a807..0a367022 100644 --- a/client/src/app/demo/components-demo-page.js +++ b/client/src/app/demo/components-demo-page.js @@ -1,7 +1,7 @@ 'use strict'; const React = require('react'); -const LineChart = require("react-chartjs").Line; +const LineChart = require("react-chartjs-2").Line; const _ = require('lodash'); const DocumentTitle = require('react-document-title'); @@ -27,27 +27,30 @@ function rand(min, max, num) { } let chartData = { - labels: ["January", "February", "March", "April", "", "May", "June", "July"], + labels: ["January", "February", "March", "April", "May", "June"], datasets: [ - { - label: "My First dataset", - fillColor: "rgba(0,0,0,0)", - strokeColor: "rgba(1,2,3,1)", - pointColor: "rgba(3,2,1,1)", - pointStrokeColor: "#333", - pointHighlightFill: "#999", - pointHighlightStroke: "rgba(220,220,220,1)", - data: rand(32, 100, 8) - }, { label: "My Second dataset", - fillColor: "rgba(0,0,0,0)", + fill: false, strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", pointHighlightStroke: "rgba(151,187,205,1)", - data: rand(32, 100, 8) + borderWidth: 3, + data: rand(32, 100, 6), + pointRadius: 0 + }, + { + label: "My Second dataset", + fill: false, + strokeColor: "rgba(151,187,205,1)", + pointColor: "rgba(151,187,205,1)", + pointStrokeColor: "#fff", + pointHighlightFill: "#fff", + pointHighlightStroke: "rgba(151,187,205,1)", + borderWidth: 3, + data: rand(32, 100, 6) } ] }; From d12194cd34ece2a1df3510d57c39b0f9a3458dbe Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 14:00:02 -0300 Subject: [PATCH 04/35] Max Red - beautify code and add functionality [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 85 ++++++++++--------- .../panel/dashboard/admin-panel-stats.js | 3 + client/src/app/demo/components-demo-page.js | 2 - client/src/data/languages/en.js | 5 ++ 4 files changed, 53 insertions(+), 42 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 2ff937b3..6f36e39c 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -1,6 +1,8 @@ import React from 'react'; import {Line} from 'react-chartjs-2'; +import i18n from 'lib-app/i18n'; + class StatsChart extends React.Component { static propTypes = { @@ -8,6 +10,7 @@ class StatsChart extends React.Component { name: React.PropTypes.string, values: React.PropTypes.arrayOf(React.PropTypes.shape({ date: React.PropTypes.string, + show: React.PropTypes.bool, value: React.PropTypes.number })) })), @@ -17,7 +20,7 @@ class StatsChart extends React.Component { render() { return (
- +
); } @@ -31,9 +34,48 @@ class StatsChart extends React.Component { } getChartData() { - let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + let labels = this.getLabels(); + let color = { + 'CREATE_TICKET': 'rgba(150, 20, 20, 0.8)', + 'CLOSE': 'rgba(20, 150, 20, 0.8)', + 'SIGNUP': 'rgba(20, 20, 150, 0.8)', + 'COMMENT': 'rgba(150, 150, 20, 0.8)' + }; + + let datasets = []; + + for (let i = 0; i < this.props.strokes.length; i++) { + let stroke = this.props.strokes[i]; + console.log(color[stroke.name]); + + let dataset = { + label: i18n('CHART_' + stroke.name), + data: stroke.values.map((val) => val.value), + fill: false, + borderWidth: 4, + borderColor: color[stroke.name], + pointBorderColor: color[stroke.name], + pointRadius: 0, + lineTension: 0.2, + pointHoverBackgroundColor: color[stroke.name], + hitRadius: this.hitRadius(), + showLine: stroke.show + }; + + datasets.push(dataset); + } + + return { + labels: labels, + datasets: datasets + }; + } + + getLabels() { + let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; let labels = []; + for (let i = 0; i < this.props.display; i++) { if(i % 2 == 0 && this.props.display > 20){ labels.push(''); @@ -44,44 +86,7 @@ class StatsChart extends React.Component { labels.push( firstList.values[i].date.slice(6, 8) + ' ' + months[idx]); } - let color = { - 'CREATE_TICKET': 'rgba(150, 20, 20)', - 'CLOSE': 'rgba(20, 150, 20)', - 'SIGNUP': 'rgba(20, 20, 150)', - 'COMMENT': 'rgba(150, 150, 20)' - }; - - let datasets = []; - - for (let i = 0; i < this.props.strokes.length; i++) { - let stroke = this.props.strokes[i]; - - let dataset = {}; - dataset.label = stroke.name; - dataset.data = []; - dataset.fill = false; - - console.log('FUCK THIS PITCH BEF ' + stroke.values.length); - for (let j = 0; j < stroke.values.length; j++) { - console.log('OH YEAH: ' + stroke.values[j].value); - dataset.data.push(stroke.values[j].value); - console.log('OH YEAH x2'); - } - console.log('FUCK THIS PITCH AFT'); - - dataset.borderWidth = 4; - dataset.borderColor = color[stroke.name]; - dataset.pointRadius = 0; - dataset.lineTension = 0.2; - dataset.hitRadius = this.hitRadius(); - - datasets.push(dataset); - } - - return { - labels: labels, - datasets: datasets - }; + return labels; } hitRadius(name) { diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 992fda02..2feb50f7 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -47,6 +47,7 @@ class AdminPanelStats extends React.Component { strokes: [ { name: 'CREATE_TICKET', + show: true, values: [ { date: "20160420", @@ -80,6 +81,7 @@ class AdminPanelStats extends React.Component { }, { name: 'CLOSE', + show: true, values: [ { date: "20160420", @@ -113,6 +115,7 @@ class AdminPanelStats extends React.Component { }, { name: 'SIGNUP', + show: true, values: [ { date: "20160420", diff --git a/client/src/app/demo/components-demo-page.js b/client/src/app/demo/components-demo-page.js index 0a367022..68042fd4 100644 --- a/client/src/app/demo/components-demo-page.js +++ b/client/src/app/demo/components-demo-page.js @@ -32,7 +32,6 @@ let chartData = { { label: "My Second dataset", fill: false, - strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", @@ -44,7 +43,6 @@ let chartData = { { label: "My Second dataset", fill: false, - strokeColor: "rgba(151,187,205,1)", pointColor: "rgba(151,187,205,1)", pointStrokeColor: "#fff", pointHighlightFill: "#fff", diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 61e8ec37..ceda9f35 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -154,6 +154,11 @@ export default { 'VERIFY_FAILED': 'Could not verify', 'TICKET_ACTIVITY': 'Ticket Activity', + 'CHART_CREATE_TICKET': 'Tickets created', + 'CHART_CLOSE': 'Tickets closed', + 'CHART_SIGNUP': 'Signups', + 'CHART_COMMENT': 'Replies', + //ACTIVITIES 'ACTIVITY_COMMENT': 'commented ticket', 'ACTIVITY_ASSIGN': 'assigned ticket', From 1e69e6f4f85e3ee9ff21b7f8b414024463ec258a Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 14:17:35 -0300 Subject: [PATCH 05/35] Max Red - Finished StatsChart component, started full component [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 16 +-- .../panel/dashboard/admin-panel-stats.js | 102 +++++++++++------- 2 files changed, 63 insertions(+), 55 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 6f36e39c..b5582017 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -25,14 +25,6 @@ class StatsChart extends React.Component { ); } - shouldBeDeleted(min, max, num, type) { - var rtn = []; - while (rtn.length < num) { - rtn.push(Math.floor((Math.random() * (max - min)) + min + ((Math.random() > 0.1) ? type * 3 : 0))); - } - return rtn; - } - getChartData() { let labels = this.getLabels(); @@ -47,7 +39,6 @@ class StatsChart extends React.Component { for (let i = 0; i < this.props.strokes.length; i++) { let stroke = this.props.strokes[i]; - console.log(color[stroke.name]); let dataset = { label: i18n('CHART_' + stroke.name), @@ -77,10 +68,6 @@ class StatsChart extends React.Component { let labels = []; for (let i = 0; i < this.props.display; i++) { - if(i % 2 == 0 && this.props.display > 20){ - labels.push(''); - continue; - } let firstList = this.props.strokes[0]; let idx = firstList.values[i].date.slice(4, 6) - 1; labels.push( firstList.values[i].date.slice(6, 8) + ' ' + months[idx]); @@ -89,8 +76,7 @@ class StatsChart extends React.Component { return labels; } - hitRadius(name) { - /// SHOULD AJUSTAR THIS VALUES + hitRadius() { if (this.props.display === 7) return 20; if (this.props.display === 30) return 15; if (this.props.display === 90) return 10; diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 2feb50f7..a7ae93dc 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -4,6 +4,8 @@ import i18n from 'lib-app/i18n'; import Header from 'core-components/header'; import DropDown from 'core-components/drop-down'; +import ToggleList from 'core-components/toggle-list'; + import StatsChart from 'app/admin/panel/dashboard/admin-panel-stats-chart'; class AdminPanelStats extends React.Component { @@ -13,11 +15,31 @@ class AdminPanelStats extends React.Component {
+
); } + getToggleListProps() { + return { + items: [ + { + content:
+ }, + { + content:
+ }, + { + content:
+ }, + { + content:
+ } + ] + }; + } + getDropDownProps() { return { items: [ @@ -51,15 +73,15 @@ class AdminPanelStats extends React.Component { values: [ { date: "20160420", - value: 71 + value: 17 }, { date: "20160421", - value: 21 + value: 15 }, { date: "20160422", - value: 4 + value: 12 }, { date: "20160423", @@ -67,49 +89,15 @@ class AdminPanelStats extends React.Component { }, { date: "20160424", - value: 12 + value: 10 }, { date: "20160425", - value: 14 + value: 7 }, { date: "20160426", - value: 22 - } - ] - }, - { - name: 'CLOSE', - show: true, - values: [ - { - date: "20160420", - value: 20 - }, - { - date: "20160421", - value: 15 - }, - { - date: "20160422", - value: 13 - }, - { - date: "20160423", - value: 15 - }, - { - date: "20160424", - value: 12 - }, - { - date: "20160425", - value: 19 - }, - { - date: "20160426", - value: 23 + value: 5 } ] }, @@ -146,6 +134,40 @@ class AdminPanelStats extends React.Component { value: 6 } ] + }, + { + name: 'CLOSE', + show: true, + values: [ + { + date: "20160420", + value: 4 + }, + { + date: "20160421", + value: 7 + }, + { + date: "20160422", + value: 4 + }, + { + date: "20160423", + value: 7 + }, + { + date: "20160424", + value: 9 + }, + { + date: "20160425", + value: 11 + }, + { + date: "20160426", + value: 13 + } + ] } ] } From 8c50cc97c91f04ba3fee33d00fed15388e9d78b9 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 15:15:26 -0300 Subject: [PATCH 06/35] Max Red - Create stats state, and display correct values in the toggle list [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 6 +- .../panel/dashboard/admin-panel-stats.js | 61 +++++++++++++++++-- client/src/data/languages/en.js | 1 + 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index b5582017..d62cc729 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -29,10 +29,10 @@ class StatsChart extends React.Component { let labels = this.getLabels(); let color = { - 'CREATE_TICKET': 'rgba(150, 20, 20, 0.8)', - 'CLOSE': 'rgba(20, 150, 20, 0.8)', + 'CLOSE': 'rgba(150, 20, 20, 0.8)', + 'CREATE_TICKET': 'rgba(20, 150, 20, 0.8)', 'SIGNUP': 'rgba(20, 20, 150, 0.8)', - 'COMMENT': 'rgba(150, 150, 20, 0.8)' + 'COMMENT': 'rgba(20, 200, 200, 0.8)' }; let datasets = []; diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index a7ae93dc..5b24047a 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -1,6 +1,7 @@ import React from 'react'; import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; import Header from 'core-components/header'; import DropDown from 'core-components/drop-down'; @@ -10,6 +11,19 @@ import StatsChart from 'app/admin/panel/dashboard/admin-panel-stats-chart'; class AdminPanelStats extends React.Component { + state = { + stats: { + 'CLOSE': 0, + 'CREATE_TICKET': 0, + 'SIGNUP': 0, + 'COMMENT': 0 + } + }; + + componentDidMount() { + this.retrieve(); + } + render() { return (
@@ -22,19 +36,36 @@ class AdminPanelStats extends React.Component { } getToggleListProps() { + console.log('LALA: ' + this.state.stats); return { items: [ { - content:
+ content: +
+ {this.state.stats['CREATE_TICKET']} +
{i18n('CHART_CREATE_TICKET')}
+
}, { - content:
+ content: +
+ {this.state.stats['CLOSE']} +
{i18n('CHART_CLOSE')}
+
}, { - content:
+ content: +
+ {this.state.stats['SIGNUP']} +
{i18n('CHART_SIGNUP')}
+
}, { - content:
+ content: +
+ {this.state.stats['COMMENT']} +
{i18n('CHART_COMMENT')}
+
} ] }; @@ -68,7 +99,7 @@ class AdminPanelStats extends React.Component { display: 7, strokes: [ { - name: 'CREATE_TICKET', + name: 'COMMENT', show: true, values: [ { @@ -172,6 +203,26 @@ class AdminPanelStats extends React.Component { ] } } + + retrieve() { + API.call({ + path: '/system/get-stats', + data: {} + }).then(this.onRetrieveSuccess.bind(this)); + } + + onRetrieveSuccess(result) { + let newState = { + 'CLOSE': 0, + 'CREATE_TICKET': 0, + 'SIGNUP': 0, + 'COMMENT': 0 + }; + for (let i = 0; i < result.data.length; i++) { + newState[result.data[i].type] += result.data[i].value * 1; + } + this.setState({stats: newState}); + } } export default AdminPanelStats; \ No newline at end of file diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index ceda9f35..cb576806 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -154,6 +154,7 @@ export default { 'VERIFY_FAILED': 'Could not verify', 'TICKET_ACTIVITY': 'Ticket Activity', + 'CHART_CREATE_TICKET': 'Tickets created', 'CHART_CLOSE': 'Tickets closed', 'CHART_SIGNUP': 'Signups', From 7022dfeabfa0eabe1995cf0c28e4326e26964e12 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 17:20:04 -0300 Subject: [PATCH 07/35] Max Red - Showing real data in graph taken from fixtures [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 14 ++-- .../panel/dashboard/admin-panel-stats.js | 78 +++++++++++++++++-- client/src/data/fixtures/system-fixtures.js | 28 +++---- 3 files changed, 93 insertions(+), 27 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index d62cc729..3e6c582b 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -8,13 +8,13 @@ class StatsChart extends React.Component { static propTypes = { strokes: React.PropTypes.arrayOf(React.PropTypes.shape({ name: React.PropTypes.string, + show: React.PropTypes.bool, values: React.PropTypes.arrayOf(React.PropTypes.shape({ date: React.PropTypes.string, - show: React.PropTypes.bool, value: React.PropTypes.number })) })), - display: React.PropTypes.number + period: React.PropTypes.number }; render() { @@ -56,7 +56,7 @@ class StatsChart extends React.Component { datasets.push(dataset); } - + return { labels: labels, datasets: datasets @@ -67,7 +67,7 @@ class StatsChart extends React.Component { let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; let labels = []; - for (let i = 0; i < this.props.display; i++) { + for (let i = 0; i < this.props.period; i++) { let firstList = this.props.strokes[0]; let idx = firstList.values[i].date.slice(4, 6) - 1; labels.push( firstList.values[i].date.slice(6, 8) + ' ' + months[idx]); @@ -77,9 +77,9 @@ class StatsChart extends React.Component { } hitRadius() { - if (this.props.display === 7) return 20; - if (this.props.display === 30) return 15; - if (this.props.display === 90) return 10; + if (this.props.period === 7) return 20; + if (this.props.period === 30) return 15; + if (this.props.period === 90) return 10; return 3; } diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 5b24047a..74843f6a 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -1,4 +1,5 @@ import React from 'react'; +import _ from 'lodash'; import i18n from 'lib-app/i18n'; import API from 'lib-app/api-call'; @@ -17,7 +18,30 @@ class AdminPanelStats extends React.Component { 'CREATE_TICKET': 0, 'SIGNUP': 0, 'COMMENT': 0 - } + }, + strokes: [ + { + name: 'CLOSE', + show: true, + values: [] + }, + { + name: 'CREATE_TICKET', + show: true, + values: [] + }, + { + name: 'SIGNUP', + show: true, + values: [] + }, + { + name: 'COMMENT', + show: true, + values: [] + } + ], + period: 0 }; componentDidMount() { @@ -36,7 +60,6 @@ class AdminPanelStats extends React.Component { } getToggleListProps() { - console.log('LALA: ' + this.state.stats); return { items: [ { @@ -95,9 +118,14 @@ class AdminPanelStats extends React.Component { } getStatsChartProps() { + + console.log('This is the shit'); + console.log(this.state.strokes); + return { - display: 7, - strokes: [ + period: this.state.period, + strokes: this.state.strokes + /*strokes: [ { name: 'COMMENT', show: true, @@ -200,7 +228,7 @@ class AdminPanelStats extends React.Component { } ] } - ] + ]*/ } } @@ -212,16 +240,54 @@ class AdminPanelStats extends React.Component { } onRetrieveSuccess(result) { + let newState = { 'CLOSE': 0, 'CREATE_TICKET': 0, 'SIGNUP': 0, 'COMMENT': 0 }; + + let ID = { + 'CLOSE': 0, + 'CREATE_TICKET': 1, + 'SIGNUP': 2, + 'COMMENT': 3 + }; + + let newStrokes = [ + { + name: 'CLOSE', + show: true, + values: [] + }, + { + name: 'CREATE_TICKET', + show: true, + values: [] + }, + { + name: 'SIGNUP', + show: true, + values: [] + }, + { + name: 'COMMENT', + show: true, + values: [] + } + ]; + for (let i = 0; i < result.data.length; i++) { newState[result.data[i].type] += result.data[i].value * 1; + + newStrokes[ ID[result.data[i].type] ].values.push({ + date: result.data[i].date, + value: result.data[i].value * 1 + }); } - this.setState({stats: newState}); + + this.setState({stats: newState, strokes: newStrokes, period: 7}); } } diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 57db8e0a..76200c6c 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -246,55 +246,55 @@ module.exports = [ "date": "20170109", "type": "SIGNUP", "general": "1", - "value": "0" + "value": "7" }, { "date": "20170109", "type": "CLOSE", "general": "1", - "value": "0" + "value": "4" }, { "date": "20170109", "type": "CREATE_TICKET", "general": "1", - "value": "0" + "value": "9" }, { "date": "20170108", "type": "COMMENT", "general": "1", - "value": "0" + "value": "8" }, { "date": "20170108", "type": "SIGNUP", "general": "1", - "value": "0" + "value": "4" }, { "date": "20170108", "type": "CLOSE", "general": "1", - "value": "0" + "value": "5" }, { "date": "20170108", "type": "CREATE_TICKET", "general": "1", - "value": "0" + "value": "6" }, { "date": "20170107", "type": "COMMENT", "general": "1", - "value": "0" + "value": "4" }, { "date": "20170107", "type": "SIGNUP", "general": "1", - "value": "0" + "value": "1" }, { "date": "20170107", @@ -306,31 +306,31 @@ module.exports = [ "date": "20170107", "type": "CREATE_TICKET", "general": "1", - "value": "0" + "value": "2" }, { "date": "20170106", "type": "COMMENT", "general": "1", - "value": "0" + "value": "7" }, { "date": "20170106", "type": "SIGNUP", "general": "1", - "value": "0" + "value": "4" }, { "date": "20170106", "type": "CLOSE", "general": "1", - "value": "0" + "value": "5" }, { "date": "20170106", "type": "CREATE_TICKET", "general": "1", - "value": "0" + "value": "5" } ] }; From 6eae5f929989032fce606f048b52cac559845269 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Sat, 14 Jan 2017 18:19:21 -0300 Subject: [PATCH 08/35] Guillermo - csv import [skip ci] --- server/controllers/system.php | 2 ++ server/controllers/system/csv-import.php | 46 ++++++++++++++++++++++++ server/controllers/user/signup.php | 31 +++++++++------- server/index.php | 2 ++ server/libs/Controller.php | 17 +++++++-- 5 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 server/controllers/system/csv-import.php diff --git a/server/controllers/system.php b/server/controllers/system.php index 2f2c65c6..78163f11 100644 --- a/server/controllers/system.php +++ b/server/controllers/system.php @@ -16,6 +16,7 @@ require_once 'system/add-api-key.php'; require_once 'system/delete-api-key.php'; require_once 'system/get-all-keys.php'; require_once 'system/delete-all-users.php'; +require_once 'system/csv-import.php'; $systemControllerGroup = new ControllerGroup(); $systemControllerGroup->setGroupPath('/system'); @@ -37,5 +38,6 @@ $systemControllerGroup->addController(new AddAPIKeyController); $systemControllerGroup->addController(new DeleteAPIKeyController); $systemControllerGroup->addController(new GetAllKeyController); $systemControllerGroup->addController(new DeleteAllUsersController); +$systemControllerGroup->addController(new CSVImportController); $systemControllerGroup->finalize(); \ No newline at end of file diff --git a/server/controllers/system/csv-import.php b/server/controllers/system/csv-import.php new file mode 100644 index 00000000..daa0a99a --- /dev/null +++ b/server/controllers/system/csv-import.php @@ -0,0 +1,46 @@ + 'staff_3', + 'requestData' => [] + ]; + } + + public function handler() { + $file = fopen("Hoja1.csv","r"); + $errors = []; + + while(!feof($file)) { + $userList = fgetcsv($file); + + Controller::setDataRequester(function ($key) use ($userList) { + switch ($key) { + case 'email': + return $userList[0]; + case 'password': + return $userList[1]; + case 'name': + return $userList[2]; + } + + return null; + }); + + $signupController = new SignUpController(true); + + try { + $signupController->validate(); + $signupController->handler(); + } catch (\Exception $exception) { + $errors[] = $exception->getMessage() . ' in email ' . $userList[0]; + } + } + + fclose($file); + Response::respondSuccess($errors); + } +} \ No newline at end of file diff --git a/server/controllers/user/signup.php b/server/controllers/user/signup.php index cee72f1b..567c7b21 100644 --- a/server/controllers/user/signup.php +++ b/server/controllers/user/signup.php @@ -10,9 +10,14 @@ class SignUpController extends Controller { private $userName; private $userPassword; private $verificationToken; + private $csvImported; + + public function __construct($csvImported = false) { + $this->csvImported = $csvImported; + } public function validations() { - return [ + $validations = [ 'permission' => 'any', 'requestData' => [ 'name' => [ @@ -26,13 +31,18 @@ class SignUpController extends Controller { 'password' => [ 'validation' => DataValidator::length(5, 200), 'error' => ERRORS::INVALID_PASSWORD - ], - 'captcha' => [ - 'validation' => DataValidator::captcha(), - 'error' => ERRORS::INVALID_CAPTCHA ] ] ]; + + if(!$this->csvImported) { + $validations['requestData']['captcha'] = [ + 'validation' => DataValidator::captcha(), + 'error' => ERRORS::INVALID_CAPTCHA + ]; + } + + return $validations; } public function handler() { @@ -42,19 +52,16 @@ class SignUpController extends Controller { $existentUser = User::getUser($this->userEmail, 'email'); if (!$existentUser->isNull()) { - Response::respondError(ERRORS::USER_EXISTS); - return; + throw new Exception(ERRORS::USER_EXISTS); } $banRow = Ban::getDataStore($this->userEmail,'email'); if (!$banRow->isNull()) { - Response::respondError(ERRORS::ALREADY_BANNED); - return; + throw new Exception(ERRORS::ALREADY_BANNED); } - if (!Setting::getSetting('registration')->value && $apiKey->isNull() ) { - Response::respondError(ERRORS::NO_PERMISSION); - return; + if (!Setting::getSetting('registration')->value && $apiKey->isNull() && !$this->csvImported) { + throw new Exception(ERRORS::NO_PERMISSION); } $userId = $this->createNewUserAndRetrieveId(); diff --git a/server/index.php b/server/index.php index a9056e1e..040d3680 100644 --- a/server/index.php +++ b/server/index.php @@ -19,6 +19,8 @@ include_once 'libs/MailSender.php'; include_once 'libs/Date.php'; include_once 'libs/DataStoreList.php'; +Controller::init(); + // LOAD DATA spl_autoload_register(function ($class) { $classPath = "data/{$class}.php"; diff --git a/server/libs/Controller.php b/server/libs/Controller.php index 3c8a3ca9..b3bfdef8 100644 --- a/server/libs/Controller.php +++ b/server/libs/Controller.php @@ -3,6 +3,7 @@ require_once 'libs/Validator.php'; require_once 'models/Session.php'; abstract class Controller { + private static $dataRequester; /** * Instance-related stuff @@ -28,10 +29,20 @@ abstract class Controller { $validator->validate($this->validations()); } - public static function request($key) { - $app = self::getAppInstance(); + public static function init() { + self::$dataRequester = function ($key) { + $app = self::getAppInstance(); - return $app->request()->post($key); + return $app->request()->post($key); + }; + } + + public static function setDataRequester($dataRequester) { + self::$dataRequester = $dataRequester; + } + + public static function request($key) { + return call_user_func(self::$dataRequester, $key); } public static function getLoggedUser() { From 9861bfb0234f1b74ebfa22d35ac765228667158a Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 18:41:19 -0300 Subject: [PATCH 09/35] Max Red - Added functionality to dropdown [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 4 +- .../panel/dashboard/admin-panel-stats.js | 162 +++++------------- client/src/data/fixtures/system-fixtures.js | 48 +++++- 3 files changed, 93 insertions(+), 121 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 3e6c582b..52d25748 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -44,7 +44,7 @@ class StatsChart extends React.Component { label: i18n('CHART_' + stroke.name), data: stroke.values.map((val) => val.value), fill: false, - borderWidth: 4, + borderWidth: 4, // ESTO PODRIA CAMBIAR DEPENDIENDO DEL PERIOD, MIENTRA MAS HALLA, DEBERIA SER MAS FINO borderColor: color[stroke.name], pointBorderColor: color[stroke.name], pointRadius: 0, @@ -80,7 +80,7 @@ class StatsChart extends React.Component { if (this.props.period === 7) return 20; if (this.props.period === 30) return 15; if (this.props.period === 90) return 10; - return 3; + return 1; } getChartOptions() { diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 74843f6a..f84956a2 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -45,7 +45,7 @@ class AdminPanelStats extends React.Component { }; componentDidMount() { - this.retrieve(); + this.retrieve(7); } render() { @@ -90,10 +90,15 @@ class AdminPanelStats extends React.Component {
{i18n('CHART_COMMENT')}
} - ] + ], + onChange: this.onToggleListChange.bind(this) }; } + onToggleListChange(data) { + + } + getDropDownProps() { return { items: [ @@ -113,133 +118,58 @@ class AdminPanelStats extends React.Component { content: 'Last 365 days', icon: '' } - ] + ], + onChange: this.onDropDownChange.bind(this) } } + onDropDownChange(event) { + console.log('DROP DOWN HAS CHANGED'); + let val = [7, 30, 90, 365]; + + this.retrieve(val[event.index]); + } + getStatsChartProps() { - - console.log('This is the shit'); - console.log(this.state.strokes); - return { period: this.state.period, strokes: this.state.strokes - /*strokes: [ - { - name: 'COMMENT', - show: true, - values: [ - { - date: "20160420", - value: 17 - }, - { - date: "20160421", - value: 15 - }, - { - date: "20160422", - value: 12 - }, - { - date: "20160423", - value: 9 - }, - { - date: "20160424", - value: 10 - }, - { - date: "20160425", - value: 7 - }, - { - date: "20160426", - value: 5 - } - ] - }, - { - name: 'SIGNUP', - show: true, - values: [ - { - date: "20160420", - value: 3 - }, - { - date: "20160421", - value: 5 - }, - { - date: "20160422", - value: 3 - }, - { - date: "20160423", - value: 4 - }, - { - date: "20160424", - value: 5 - }, - { - date: "20160425", - value: 5 - }, - { - date: "20160426", - value: 6 - } - ] - }, - { - name: 'CLOSE', - show: true, - values: [ - { - date: "20160420", - value: 4 - }, - { - date: "20160421", - value: 7 - }, - { - date: "20160422", - value: 4 - }, - { - date: "20160423", - value: 7 - }, - { - date: "20160424", - value: 9 - }, - { - date: "20160425", - value: 11 - }, - { - date: "20160426", - value: 13 - } - ] - } - ]*/ } } - retrieve() { + retrieve(period) { + console.log('THIS SHOULD NOT BE DISPLAYED'); + + let periodName; + switch (period) { + case 30: + periodName = 'MONTH'; + break; + case 90: + periodName = 'QUARTER'; + break; + case 365: + periodName = 'YEAR'; + break; + default: + periodName = 'WEEK'; + } + + console.log('--------------------------------------------period: ' + this.state.period); + console.log('--------------------------------------------PERIOD NAME: ' + periodName); + API.call({ path: '/system/get-stats', - data: {} - }).then(this.onRetrieveSuccess.bind(this)); + data: { + period: periodName + } + }).then(this.onRetrieveSuccess.bind(this, period)); } - onRetrieveSuccess(result) { + onRetrieveSuccess(period, result) { + + console.log('This is the shit you SHOULD look at!'); + console.log(result); let newState = { 'CLOSE': 0, @@ -287,7 +217,7 @@ class AdminPanelStats extends React.Component { }); } - this.setState({stats: newState, strokes: newStrokes, period: 7}); + this.setState({stats: newState, strokes: newStrokes, period: period}); } } diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 76200c6c..06b087fd 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -160,10 +160,52 @@ module.exports = [ { path: '/system/get-stats', time: 200, - response: function() { + response: function(_data) { + let ID = { + 'WEEK': 7, + 'MONTH': 30, + 'QUARTER': 90, + 'YEAR': 365 + }; + + let k = ID[_data.period]; + let DATA = []; + + for (let i = 0; i < k; i++) { + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'COMMENT', + general: 1, + value: (4 + i + Math.floor(Math.random() * 2)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'SIGNUP', + general: 1, + value: (9 + i + Math.floor(Math.random() * (i / 15))).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CLOSE', + general: 1, + value: (8 + i + Math.floor(Math.random() * i)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CREATE_TICKET', + general: 1, + value: (10 + Math.floor(Math.random() * 4)).toString() + }); + } + + console.log('DATA:'); + console.log(DATA); + console.log(k); + return { status: "success", - data: [ + data: DATA + /*data: [ { "date": "20170112", "type": "COMMENT", @@ -332,7 +374,7 @@ module.exports = [ "general": "1", "value": "5" } - ] + ]*/ }; } }, From 19f25657ef324ea6b85f43d32103ba7a859f930b Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 18:47:04 -0300 Subject: [PATCH 10/35] Max Red - Corrected to work even if the response of system/get-stats is not the full week/month/year etc.. [skip ci] --- .../admin/panel/dashboard/admin-panel-stats-chart.js | 12 ++++++++---- .../app/admin/panel/dashboard/admin-panel-stats.js | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 52d25748..64b0df74 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -44,7 +44,7 @@ class StatsChart extends React.Component { label: i18n('CHART_' + stroke.name), data: stroke.values.map((val) => val.value), fill: false, - borderWidth: 4, // ESTO PODRIA CAMBIAR DEPENDIENDO DEL PERIOD, MIENTRA MAS HALLA, DEBERIA SER MAS FINO + borderWidth: this.getBorderWidth(), borderColor: color[stroke.name], pointBorderColor: color[stroke.name], pointRadius: 0, @@ -63,6 +63,10 @@ class StatsChart extends React.Component { }; } + getBorderWidth() { + return (this.props.period <= 90) ? 4 : 2; + } + getLabels() { let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; let labels = []; @@ -77,9 +81,9 @@ class StatsChart extends React.Component { } hitRadius() { - if (this.props.period === 7) return 20; - if (this.props.period === 30) return 15; - if (this.props.period === 90) return 10; + if (this.props.period <= 7) return 20; + if (this.props.period <= 30) return 15; + if (this.props.period <= 90) return 10; return 1; } diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index f84956a2..ab5d1d5f 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -208,6 +208,8 @@ class AdminPanelStats extends React.Component { } ]; + let realPeriod = result.data.length / 4; + for (let i = 0; i < result.data.length; i++) { newState[result.data[i].type] += result.data[i].value * 1; @@ -217,7 +219,7 @@ class AdminPanelStats extends React.Component { }); } - this.setState({stats: newState, strokes: newStrokes, period: period}); + this.setState({stats: newState, strokes: newStrokes, period: realPeriod}); } } From fd2c20ac9fccbbaf3c9403141e6d1672b0de9b90 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2017 21:31:02 -0300 Subject: [PATCH 11/35] Max Red - Added all functionality to the component [skip ci] --- .../dashboard/admin-panel-stats-chart.js | 17 ++++-- .../panel/dashboard/admin-panel-stats.js | 59 ++++++++++--------- client/src/core-components/toggle-list.js | 10 +++- client/src/data/fixtures/system-fixtures.js | 4 +- 4 files changed, 50 insertions(+), 40 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js index 64b0df74..8ff25b1f 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js @@ -8,19 +8,19 @@ class StatsChart extends React.Component { static propTypes = { strokes: React.PropTypes.arrayOf(React.PropTypes.shape({ name: React.PropTypes.string, - show: React.PropTypes.bool, values: React.PropTypes.arrayOf(React.PropTypes.shape({ date: React.PropTypes.string, value: React.PropTypes.number })) })), + //showed: React.PropTypes.arrayOf(React.PropTypes.bool), period: React.PropTypes.number }; render() { return (
- +
); } @@ -48,10 +48,10 @@ class StatsChart extends React.Component { borderColor: color[stroke.name], pointBorderColor: color[stroke.name], pointRadius: 0, + pointHoverRadius: 3, lineTension: 0.2, pointHoverBackgroundColor: color[stroke.name], - hitRadius: this.hitRadius(), - showLine: stroke.show + hitRadius: this.hitRadius(i) }; datasets.push(dataset); @@ -72,6 +72,10 @@ class StatsChart extends React.Component { let labels = []; for (let i = 0; i < this.props.period; i++) { + if (!this.props.strokes.length){ + labels.push(''); + continue; + } let firstList = this.props.strokes[0]; let idx = firstList.values[i].date.slice(4, 6) - 1; labels.push( firstList.values[i].date.slice(6, 8) + ' ' + months[idx]); @@ -80,11 +84,12 @@ class StatsChart extends React.Component { return labels; } - hitRadius() { + hitRadius(index) { + //if (!this.props.showed[index]) return 0; if (this.props.period <= 7) return 20; if (this.props.period <= 30) return 15; if (this.props.period <= 90) return 10; - return 1; + return 3; } getChartOptions() { diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index ab5d1d5f..16a97c5b 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -14,33 +14,30 @@ class AdminPanelStats extends React.Component { state = { stats: { - 'CLOSE': 0, 'CREATE_TICKET': 0, + 'CLOSE': 0, 'SIGNUP': 0, 'COMMENT': 0 }, strokes: [ { - name: 'CLOSE', - show: true, + name: 'CREATE_TICKET', values: [] }, { - name: 'CREATE_TICKET', - show: true, + name: 'CLOSE', values: [] }, { name: 'SIGNUP', - show: true, values: [] }, { name: 'COMMENT', - show: true, values: [] } ], + showed: [0], period: 0 }; @@ -61,6 +58,7 @@ class AdminPanelStats extends React.Component { getToggleListProps() { return { + values: this.state.showed, items: [ { content: @@ -95,8 +93,10 @@ class AdminPanelStats extends React.Component { }; } - onToggleListChange(data) { - + onToggleListChange(event) { + this.setState({ + showed: event.target.value + }); } getDropDownProps() { @@ -124,22 +124,23 @@ class AdminPanelStats extends React.Component { } onDropDownChange(event) { - console.log('DROP DOWN HAS CHANGED'); let val = [7, 30, 90, 365]; this.retrieve(val[event.index]); } getStatsChartProps() { + let showed = this.getShowedArray(); + return { period: this.state.period, - strokes: this.state.strokes - } + strokes: _.filter(this.state.strokes, (s, i) => showed[i]) + //strokes: this.state.strokes, + //showed: this.getShowedArray() + }; } retrieve(period) { - console.log('THIS SHOULD NOT BE DISPLAYED'); - let periodName; switch (period) { case 30: @@ -155,9 +156,6 @@ class AdminPanelStats extends React.Component { periodName = 'WEEK'; } - console.log('--------------------------------------------period: ' + this.state.period); - console.log('--------------------------------------------PERIOD NAME: ' + periodName); - API.call({ path: '/system/get-stats', data: { @@ -168,42 +166,35 @@ class AdminPanelStats extends React.Component { onRetrieveSuccess(period, result) { - console.log('This is the shit you SHOULD look at!'); - console.log(result); - let newState = { - 'CLOSE': 0, 'CREATE_TICKET': 0, + 'CLOSE': 0, 'SIGNUP': 0, 'COMMENT': 0 }; let ID = { - 'CLOSE': 0, - 'CREATE_TICKET': 1, + 'CREATE_TICKET': 0, + 'CLOSE': 1, 'SIGNUP': 2, 'COMMENT': 3 }; let newStrokes = [ { - name: 'CLOSE', - show: true, + name: 'CREATE_TICKET', values: [] }, { - name: 'CREATE_TICKET', - show: true, + name: 'CLOSE', values: [] }, { name: 'SIGNUP', - show: true, values: [] }, { name: 'COMMENT', - show: true, values: [] } ]; @@ -221,6 +212,16 @@ class AdminPanelStats extends React.Component { this.setState({stats: newState, strokes: newStrokes, period: realPeriod}); } + + getShowedArray() { + let showed = [false, false, false, false]; + + for (let i = 0; i < showed.length; i++) { + showed[this.state.showed[i]] = true; + } + + return showed; + } } export default AdminPanelStats; \ No newline at end of file diff --git a/client/src/core-components/toggle-list.js b/client/src/core-components/toggle-list.js index 8dba39a7..b38defe0 100644 --- a/client/src/core-components/toggle-list.js +++ b/client/src/core-components/toggle-list.js @@ -35,16 +35,16 @@ class ToggleList extends React.Component { let classes = { 'toggle-list__item': true, 'toggle-list__first-item': (index === 0), - 'toggle-list__selected': _.includes(this.state.selected, index) + 'toggle-list__selected': _.includes(this.getSelectedList(), index) }; return classNames(classes); } selectItem(index) { - let newSelected = _.clone(this.state.selected); + let newSelected = _.clone(this.getSelectedList()); - _.includes(this.state.selected, index) ? _.remove(newSelected, _index => _index == index) : newSelected.push(index); + _.includes(this.getSelectedList(), index) ? _.remove(newSelected, _index => _index == index) : newSelected.push(index); this.setState({ selected: newSelected @@ -58,6 +58,10 @@ class ToggleList extends React.Component { }); } } + + getSelectedList() { + return (this.props.values === undefined) ? this.state.selected : this.props.values; + } } export default ToggleList; diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 06b087fd..9d329319 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -182,13 +182,13 @@ module.exports = [ date: '201701' + (i + 10) % 100, type: 'SIGNUP', general: 1, - value: (9 + i + Math.floor(Math.random() * (i / 15))).toString() + value: (9 + i + Math.floor(Math.random() * (i * 15))).toString() }); DATA.push({ date: '201701' + (i + 10) % 100, type: 'CLOSE', general: 1, - value: (8 + i + Math.floor(Math.random() * i)).toString() + value: (8 + i + Math.floor(Math.random() * i * i * i * i)).toString() }); DATA.push({ date: '201701' + (i + 10) % 100, From 1f6e3ae0286a02a84529bc84e86703c02072c462 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 00:07:02 -0300 Subject: [PATCH 12/35] Max Red - Added basic scss [skip ci] --- .../app/admin/panel/dashboard/admin-panel-stats.js | 10 ++++++---- .../app/admin/panel/dashboard/admin-panel-stats.scss | 11 +++++++++++ client/src/core-components/toggle-list.js | 11 ++++++++++- client/src/data/fixtures/system-fixtures.js | 8 ++++---- 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 client/src/app/admin/panel/dashboard/admin-panel-stats.scss diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 16a97c5b..84790d04 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -47,7 +47,7 @@ class AdminPanelStats extends React.Component { render() { return ( -
+
@@ -59,6 +59,8 @@ class AdminPanelStats extends React.Component { getToggleListProps() { return { values: this.state.showed, + className: 'admin-panel-stats__toggle-list', + onChange: this.onToggleListChange.bind(this), items: [ { content: @@ -88,8 +90,7 @@ class AdminPanelStats extends React.Component {
{i18n('CHART_COMMENT')}
} - ], - onChange: this.onToggleListChange.bind(this) + ] }; } @@ -119,7 +120,8 @@ class AdminPanelStats extends React.Component { icon: '' } ], - onChange: this.onDropDownChange.bind(this) + onChange: this.onDropDownChange.bind(this), + className: 'admin-panel-stats__dropdown' } } diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.scss b/client/src/app/admin/panel/dashboard/admin-panel-stats.scss new file mode 100644 index 00000000..d020a3a5 --- /dev/null +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.scss @@ -0,0 +1,11 @@ +.admin-panel-stats { + + &__dropdown { + margin-left: auto; + margin-bottom: 20px; + } + + &__toggle-list { + margin-bottom: 20px; + } +} \ No newline at end of file diff --git a/client/src/core-components/toggle-list.js b/client/src/core-components/toggle-list.js index b38defe0..e5e70fbc 100644 --- a/client/src/core-components/toggle-list.js +++ b/client/src/core-components/toggle-list.js @@ -16,12 +16,21 @@ class ToggleList extends React.Component { render() { return ( -
+
{this.props.items.map(this.renderItem.bind(this))}
); } + getClass() { + let classes = { + 'toggle-list': true, + [this.props.className]: (this.props.className) + }; + + return classNames(classes); + } + renderItem(obj, index) { return ( diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 9d329319..38ff3062 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -176,25 +176,25 @@ module.exports = [ date: '201701' + (i + 10) % 100, type: 'COMMENT', general: 1, - value: (4 + i + Math.floor(Math.random() * 2)).toString() + value: (Math.floor(Math.random() * i)).toString() }); DATA.push({ date: '201701' + (i + 10) % 100, type: 'SIGNUP', general: 1, - value: (9 + i + Math.floor(Math.random() * (i * 15))).toString() + value: (Math.floor(Math.random() * i * i / 365)).toString() }); DATA.push({ date: '201701' + (i + 10) % 100, type: 'CLOSE', general: 1, - value: (8 + i + Math.floor(Math.random() * i * i * i * i)).toString() + value: (Math.floor(Math.random() * i * i * i / 365 / 365)).toString() }); DATA.push({ date: '201701' + (i + 10) % 100, type: 'CREATE_TICKET', general: 1, - value: (10 + Math.floor(Math.random() * 4)).toString() + value: (Math.floor(Math.random()*Math.random()*Math.random()*Math.random()*Math.random()*1.05**i)).toString() }); } From 0500666174a4a30f6111a5fd3810f5492941121e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 15:07:07 -0300 Subject: [PATCH 13/35] Max Red - Added even more basic scss [skip ci] --- .../admin/panel/dashboard/admin-panel-stats.js | 13 +++++++++++-- .../admin/panel/dashboard/admin-panel-stats.scss | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 84790d04..2252dc37 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -61,7 +61,16 @@ class AdminPanelStats extends React.Component { values: this.state.showed, className: 'admin-panel-stats__toggle-list', onChange: this.onToggleListChange.bind(this), - items: [ + items: ['CREATE_TICKET', 'CLOSE', 'SIGNUP', 'COMMENT'].map((name) => { + return { + content: +
+
{this.state.stats[name]}
+
{i18n('CHART_' + name)}
+
+ } + }) + /*sitems: [ { content:
@@ -90,7 +99,7 @@ class AdminPanelStats extends React.Component {
{i18n('CHART_COMMENT')}
} - ] + ]*/ }; } diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.scss b/client/src/app/admin/panel/dashboard/admin-panel-stats.scss index d020a3a5..2a20db81 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.scss +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.scss @@ -1,3 +1,5 @@ +@import "../../../../scss/vars"; + .admin-panel-stats { &__dropdown { @@ -7,5 +9,19 @@ &__toggle-list { margin-bottom: 20px; + + &-item { + + &-value { + font-size: $font-size--lg; + line-height: 80px; + } + + &-name { + font-size: $font-size--md; + line-height: 20px; + } + } } + } \ No newline at end of file From 30f1526f1ccb4e53406b96739e26a0f627ba40cf Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 15:47:13 -0300 Subject: [PATCH 14/35] Max Red - Added even even more more basic scss [skip ci] --- client/src/core-components/toggle-list.js | 1 + client/src/core-components/toggle-list.scss | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/core-components/toggle-list.js b/client/src/core-components/toggle-list.js index e5e70fbc..d057a6f1 100644 --- a/client/src/core-components/toggle-list.js +++ b/client/src/core-components/toggle-list.js @@ -44,6 +44,7 @@ class ToggleList extends React.Component { let classes = { 'toggle-list__item': true, 'toggle-list__first-item': (index === 0), + 'toggle-list__last-item': (index === this.props.items.length - 1), 'toggle-list__selected': _.includes(this.getSelectedList(), index) }; diff --git a/client/src/core-components/toggle-list.scss b/client/src/core-components/toggle-list.scss index 7bf244cb..a016f8a3 100644 --- a/client/src/core-components/toggle-list.scss +++ b/client/src/core-components/toggle-list.scss @@ -8,14 +8,19 @@ width: 180px; height: 120px; display: inline-block; - transition: background-color 0.4s ease; + transition: box-shadow 0.2s ease-in-out; } &__selected { - background-color: $light-grey; + box-shadow: inset 0 -5px 40px 10px rgba(0, 0, 0, 0.05); } &__first-item { border: 1px $light-grey solid; + border-radius: 4px 0 0 4px; + } + + &__last-item { + border-radius: 0 4px 4px 0; } } From ebb3516df370135c153b63a31ac2cbaa4170e578 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 17:20:48 -0300 Subject: [PATCH 15/35] Max Red - Starting refactoring of component stats [skip ci] --- .../stats-chart.js} | 2 - client/src/app-components/stats.js | 211 +++++++++++++++++ client/src/app-components/stats.scss | 0 .../panel/dashboard/admin-panel-stats.js | 224 +----------------- client/src/data/fixtures/system-fixtures.js | 174 +------------- 5 files changed, 216 insertions(+), 395 deletions(-) rename client/src/{app/admin/panel/dashboard/admin-panel-stats-chart.js => app-components/stats-chart.js} (96%) create mode 100644 client/src/app-components/stats.js create mode 100644 client/src/app-components/stats.scss diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js b/client/src/app-components/stats-chart.js similarity index 96% rename from client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js rename to client/src/app-components/stats-chart.js index 8ff25b1f..18604cae 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -13,7 +13,6 @@ class StatsChart extends React.Component { value: React.PropTypes.number })) })), - //showed: React.PropTypes.arrayOf(React.PropTypes.bool), period: React.PropTypes.number }; @@ -85,7 +84,6 @@ class StatsChart extends React.Component { } hitRadius(index) { - //if (!this.props.showed[index]) return 0; if (this.props.period <= 7) return 20; if (this.props.period <= 30) return 15; if (this.props.period <= 90) return 10; diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js new file mode 100644 index 00000000..9283e22b --- /dev/null +++ b/client/src/app-components/stats.js @@ -0,0 +1,211 @@ +import React from 'react'; +import _ from 'lodash'; + +import i18n from 'lib-app/i18n'; +import API from 'lib-app/api-call'; + +import DropDown from 'core-components/drop-down'; +import ToggleList from 'core-components/toggle-list'; + +import StatsChart from 'app-components/stats-chart'; + +const generalStrokes = ['CREATE_TICKET', 'CLOSE', 'SIGNUP', 'COMMENT']; +const staffStrokes = ['ASSIGN', 'CLOSE']; + +class Stats extends React.Component { + + static propTypes = { + type: React.PropTypes.string + }; + + state = { + stats: { + 'CREATE_TICKET': 0, + 'CLOSE': 0, + 'SIGNUP': 0, + 'COMMENT': 0 + }, + strokes: [ + { + name: 'CREATE_TICKET', + values: [] + }, + { + name: 'CLOSE', + values: [] + }, + { + name: 'SIGNUP', + values: [] + }, + { + name: 'COMMENT', + values: [] + } + ], + showed: [0], + period: 0 + }; + + componentDidMount() { + this.retrieve(7); + } + + render() { + return ( +
+ + + +
+ ); + } + + getToggleListProps() { + return { + values: this.state.showed, + className: 'admin-panel-stats__toggle-list', + onChange: this.onToggleListChange.bind(this), + items: ['CREATE_TICKET', 'CLOSE', 'SIGNUP', 'COMMENT'].map((name) => { + return { + content: +
+
{this.state.stats[name]}
+
{i18n('CHART_' + name)}
+
+ } + }) + }; + } + + onToggleListChange(event) { + this.setState({ + showed: event.target.value + }); + } + + getDropDownProps() { + return { + items: [ + { + content: 'Last 7 days', + icon: '' + }, + { + content: 'Last 30 days', + icon: '' + }, + { + content: 'Last 90 days', + icon: '' + }, + { + content: 'Last 365 days', + icon: '' + } + ], + onChange: this.onDropDownChange.bind(this), + className: 'admin-panel-stats__dropdown' + } + } + + onDropDownChange(event) { + let val = [7, 30, 90, 3 65]; + + this.retrieve(val[event.index]); + } + + getStatsChartProps() { + let showed = this.getShowedArray(); + + return { + period: this.state.period, + strokes: _.filter(this.state.strokes, (s, i) => showed[i]) + }; + } + + retrieve(period) { + let periodName; + switch (period) { + case 30: + periodName = 'MONTH'; + break; + case 90: + periodName = 'QUARTER'; + break; + case 365: + periodName = 'YEAR'; + break; + default: + periodName = 'WEEK'; + } + + API.call({ + path: '/system/get-stats', + data: { + period: periodName + } + }).then(this.onRetrieveSuccess.bind(this, period)); + } + + onRetrieveSuccess(period, result) { + + let newStats = { + 'CREATE_TICKET': 0, + 'CLOSE': 0, + 'SIGNUP': 0, + 'COMMENT': 0 + }; + + let ID = { + 'CREATE_TICKET': 0, + 'CLOSE': 1, + 'SIGNUP': 2, + 'COMMENT': 3 + }; + + let newStrokes = [ + { + name: 'CREATE_TICKET', + values: [] + }, + { + name: 'CLOSE', + values: [] + }, + { + name: 'SIGNUP', + values: [] + }, + { + name: 'COMMENT', + values: [] + } + ]; + + let realPeriod = result.data.length / 4; + + for (let i = 0; i < result.data.length; i++) { + newStats[result.data[i].type] += result.data[i].value * 1; + + newStrokes[ ID[result.data[i].type] ].values.push({ + date: result.data[i].date, + value: result.data[i].value * 1 + }); + } + + this.setState({stats: newStats, strokes: newStrokes, period: realPeriod}); + } + + getShowedArray() { + let showed = [false, false, false, false]; + + for (let i = 0; i < showed.length; i++) { + showed[this.state.showed[i]] = true; + } + + return showed; + } +} + +export default Stats; \ No newline at end of file diff --git a/client/src/app-components/stats.scss b/client/src/app-components/stats.scss new file mode 100644 index 00000000..e69de29b diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 2252dc37..5e992ffb 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -1,238 +1,20 @@ import React from 'react'; -import _ from 'lodash'; import i18n from 'lib-app/i18n'; -import API from 'lib-app/api-call'; - +import Stats from 'app-components/stats'; import Header from 'core-components/header'; -import DropDown from 'core-components/drop-down'; -import ToggleList from 'core-components/toggle-list'; - -import StatsChart from 'app/admin/panel/dashboard/admin-panel-stats-chart'; class AdminPanelStats extends React.Component { - state = { - stats: { - 'CREATE_TICKET': 0, - 'CLOSE': 0, - 'SIGNUP': 0, - 'COMMENT': 0 - }, - strokes: [ - { - name: 'CREATE_TICKET', - values: [] - }, - { - name: 'CLOSE', - values: [] - }, - { - name: 'SIGNUP', - values: [] - }, - { - name: 'COMMENT', - values: [] - } - ], - showed: [0], - period: 0 - }; - - componentDidMount() { - this.retrieve(7); - } - render() { return (
- - - +
); } - - getToggleListProps() { - return { - values: this.state.showed, - className: 'admin-panel-stats__toggle-list', - onChange: this.onToggleListChange.bind(this), - items: ['CREATE_TICKET', 'CLOSE', 'SIGNUP', 'COMMENT'].map((name) => { - return { - content: -
-
{this.state.stats[name]}
-
{i18n('CHART_' + name)}
-
- } - }) - /*sitems: [ - { - content: -
- {this.state.stats['CREATE_TICKET']} -
{i18n('CHART_CREATE_TICKET')}
-
- }, - { - content: -
- {this.state.stats['CLOSE']} -
{i18n('CHART_CLOSE')}
-
- }, - { - content: -
- {this.state.stats['SIGNUP']} -
{i18n('CHART_SIGNUP')}
-
- }, - { - content: -
- {this.state.stats['COMMENT']} -
{i18n('CHART_COMMENT')}
-
- } - ]*/ - }; - } - - onToggleListChange(event) { - this.setState({ - showed: event.target.value - }); - } - - getDropDownProps() { - return { - items: [ - { - content: 'Last 7 days', - icon: '' - }, - { - content: 'Last 30 days', - icon: '' - }, - { - content: 'Last 90 days', - icon: '' - }, - { - content: 'Last 365 days', - icon: '' - } - ], - onChange: this.onDropDownChange.bind(this), - className: 'admin-panel-stats__dropdown' - } - } - - onDropDownChange(event) { - let val = [7, 30, 90, 365]; - - this.retrieve(val[event.index]); - } - - getStatsChartProps() { - let showed = this.getShowedArray(); - - return { - period: this.state.period, - strokes: _.filter(this.state.strokes, (s, i) => showed[i]) - //strokes: this.state.strokes, - //showed: this.getShowedArray() - }; - } - - retrieve(period) { - let periodName; - switch (period) { - case 30: - periodName = 'MONTH'; - break; - case 90: - periodName = 'QUARTER'; - break; - case 365: - periodName = 'YEAR'; - break; - default: - periodName = 'WEEK'; - } - - API.call({ - path: '/system/get-stats', - data: { - period: periodName - } - }).then(this.onRetrieveSuccess.bind(this, period)); - } - - onRetrieveSuccess(period, result) { - - let newState = { - 'CREATE_TICKET': 0, - 'CLOSE': 0, - 'SIGNUP': 0, - 'COMMENT': 0 - }; - - let ID = { - 'CREATE_TICKET': 0, - 'CLOSE': 1, - 'SIGNUP': 2, - 'COMMENT': 3 - }; - - let newStrokes = [ - { - name: 'CREATE_TICKET', - values: [] - }, - { - name: 'CLOSE', - values: [] - }, - { - name: 'SIGNUP', - values: [] - }, - { - name: 'COMMENT', - values: [] - } - ]; - - let realPeriod = result.data.length / 4; - - for (let i = 0; i < result.data.length; i++) { - newState[result.data[i].type] += result.data[i].value * 1; - - newStrokes[ ID[result.data[i].type] ].values.push({ - date: result.data[i].date, - value: result.data[i].value * 1 - }); - } - - this.setState({stats: newState, strokes: newStrokes, period: realPeriod}); - } - - getShowedArray() { - let showed = [false, false, false, false]; - - for (let i = 0; i < showed.length; i++) { - showed[this.state.showed[i]] = true; - } - - return showed; - } + } export default AdminPanelStats; \ 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 38ff3062..797398bd 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -182,7 +182,7 @@ module.exports = [ date: '201701' + (i + 10) % 100, type: 'SIGNUP', general: 1, - value: (Math.floor(Math.random() * i * i / 365)).toString() + value: (Math.floor(Math.random() * (i - 180) * (i - 185) / (1.027**i) )).toString() }); DATA.push({ date: '201701' + (i + 10) % 100, @@ -194,7 +194,7 @@ module.exports = [ date: '201701' + (i + 10) % 100, type: 'CREATE_TICKET', general: 1, - value: (Math.floor(Math.random()*Math.random()*Math.random()*Math.random()*Math.random()*1.05**i)).toString() + value: (Math.floor(Math.random()*Math.random()*Math.random()*Math.random()*Math.random()*1.027**i)).toString() }); } @@ -205,176 +205,6 @@ module.exports = [ return { status: "success", data: DATA - /*data: [ - { - "date": "20170112", - "type": "COMMENT", - "general": "1", - "value": "8" - }, - { - "date": "20170112", - "type": "SIGNUP", - "general": "1", - "value": "1" - }, - { - "date": "20170112", - "type": "CLOSE", - "general": "1", - "value": "5" - }, - { - "date": "20170112", - "type": "CREATE_TICKET", - "general": "1", - "value": "2" - }, - { - "date": "20170111", - "type": "COMMENT", - "general": "1", - "value": "3" - }, - { - "date": "20170111", - "type": "SIGNUP", - "general": "1", - "value": "8" - }, - { - "date": "20170111", - "type": "CLOSE", - "general": "1", - "value": "10" - }, - { - "date": "20170111", - "type": "CREATE_TICKET", - "general": "1", - "value": "3" - }, - { - "date": "20170110", - "type": "COMMENT", - "general": "1", - "value": "3" - }, - { - "date": "20170110", - "type": "SIGNUP", - "general": "1", - "value": "6" - }, - { - "date": "20170110", - "type": "CLOSE", - "general": "1", - "value": "2" - }, - { - "date": "20170110", - "type": "CREATE_TICKET", - "general": "1", - "value": "1" - }, - { - "date": "20170109", - "type": "COMMENT", - "general": "1", - "value": "0" - }, - { - "date": "20170109", - "type": "SIGNUP", - "general": "1", - "value": "7" - }, - { - "date": "20170109", - "type": "CLOSE", - "general": "1", - "value": "4" - }, - { - "date": "20170109", - "type": "CREATE_TICKET", - "general": "1", - "value": "9" - }, - { - "date": "20170108", - "type": "COMMENT", - "general": "1", - "value": "8" - }, - { - "date": "20170108", - "type": "SIGNUP", - "general": "1", - "value": "4" - }, - { - "date": "20170108", - "type": "CLOSE", - "general": "1", - "value": "5" - }, - { - "date": "20170108", - "type": "CREATE_TICKET", - "general": "1", - "value": "6" - }, - { - "date": "20170107", - "type": "COMMENT", - "general": "1", - "value": "4" - }, - { - "date": "20170107", - "type": "SIGNUP", - "general": "1", - "value": "1" - }, - { - "date": "20170107", - "type": "CLOSE", - "general": "1", - "value": "0" - }, - { - "date": "20170107", - "type": "CREATE_TICKET", - "general": "1", - "value": "2" - }, - { - "date": "20170106", - "type": "COMMENT", - "general": "1", - "value": "7" - }, - { - "date": "20170106", - "type": "SIGNUP", - "general": "1", - "value": "4" - }, - { - "date": "20170106", - "type": "CLOSE", - "general": "1", - "value": "5" - }, - { - "date": "20170106", - "type": "CREATE_TICKET", - "general": "1", - "value": "5" - } - ]*/ }; } }, From 565c60c1988ee8c6e384580a79c10bf00b682176 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Sun, 15 Jan 2017 17:33:33 -0300 Subject: [PATCH 16/35] Guillermo - csv import [skip ci] --- server/controllers/system/csv-import.php | 7 ++++++- server/controllers/ticket/comment.php | 2 +- server/controllers/ticket/create.php | 2 +- server/libs/Controller.php | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/server/controllers/system/csv-import.php b/server/controllers/system/csv-import.php index daa0a99a..e415c6f1 100644 --- a/server/controllers/system/csv-import.php +++ b/server/controllers/system/csv-import.php @@ -11,7 +11,9 @@ class CSVImportController extends Controller { } public function handler() { - $file = fopen("Hoja1.csv","r"); + $fileUploader = $this->uploadFile(); + + $file = fopen($fileUploader->getFullFilePath(),'r'); $errors = []; while(!feof($file)) { @@ -41,6 +43,9 @@ class CSVImportController extends Controller { } fclose($file); + + unlink($fileUploader->getFullFilePath()); + Response::respondSuccess($errors); } } \ No newline at end of file diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index 6a043757..2b5c90b9 100644 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -50,7 +50,7 @@ class CommentController extends Controller { $comment = Ticketevent::getEvent(Ticketevent::COMMENT); $comment->setProperties(array( 'content' => $this->content, - 'file' => $this->uploadFile(), + 'file' => $this->uploadFile()->getFileName(), 'date' => Date::getCurrentDate() )); diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index fbcd9203..1a07a0cb 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -60,7 +60,7 @@ class CreateController extends Controller { 'language' => $this->language, 'author' => $author, 'department' => $department, - 'file' => $this->uploadFile(), + 'file' => $this->uploadFile()->getFileName(), 'date' => Date::getCurrentDate(), 'unread' => false, 'unreadStaff' => true, diff --git a/server/libs/Controller.php b/server/libs/Controller.php index d24cb1af..632d758d 100644 --- a/server/libs/Controller.php +++ b/server/libs/Controller.php @@ -88,7 +88,7 @@ abstract class Controller { $fileQuantity->value++; $fileQuantity->store(); - return $fileUploader->getFileName(); + return $fileUploader; } else { throw new Exception(ERRORS::INVALID_FILE); } From da928f9b6f022a46521191047c6454bd696eca76 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 18:33:00 -0300 Subject: [PATCH 17/35] Max Red - Added abstraction to the component in order to work in view-staff page [skip ci] --- client/src/app-components/stats-chart.js | 3 +- client/src/app-components/stats.js | 128 ++++++++++---------- client/src/data/fixtures/system-fixtures.js | 66 ++++++---- client/src/data/languages/en.js | 1 + 4 files changed, 106 insertions(+), 92 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index 18604cae..ca6ddb1c 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -31,7 +31,8 @@ class StatsChart extends React.Component { 'CLOSE': 'rgba(150, 20, 20, 0.8)', 'CREATE_TICKET': 'rgba(20, 150, 20, 0.8)', 'SIGNUP': 'rgba(20, 20, 150, 0.8)', - 'COMMENT': 'rgba(20, 200, 200, 0.8)' + 'COMMENT': 'rgba(20, 200, 200, 0.8)', + 'ASSIGN': 'rgba(200, 200, 20, 0.8)' }; let datasets = []; diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js index 9283e22b..408376a1 100644 --- a/client/src/app-components/stats.js +++ b/client/src/app-components/stats.js @@ -11,38 +11,29 @@ import StatsChart from 'app-components/stats-chart'; const generalStrokes = ['CREATE_TICKET', 'CLOSE', 'SIGNUP', 'COMMENT']; const staffStrokes = ['ASSIGN', 'CLOSE']; +const ID = { + 'CREATE_TICKET': 0, + 'ASSIGN': 0, + 'CLOSE': 1, + 'SIGNUP': 2, + 'COMMENT': 3 +}; class Stats extends React.Component { static propTypes = { - type: React.PropTypes.string + type: React.PropTypes.string, + staffId: React.PropTypes.number }; state = { - stats: { - 'CREATE_TICKET': 0, - 'CLOSE': 0, - 'SIGNUP': 0, - 'COMMENT': 0 - }, - strokes: [ - { - name: 'CREATE_TICKET', + stats: this.getDefaultStats(), + strokes: this.getStrokes().map((name) => { + return { + name: name, values: [] - }, - { - name: 'CLOSE', - values: [] - }, - { - name: 'SIGNUP', - values: [] - }, - { - name: 'COMMENT', - values: [] - } - ], + } + }), showed: [0], period: 0 }; @@ -64,14 +55,14 @@ class Stats extends React.Component { getToggleListProps() { return { values: this.state.showed, - className: 'admin-panel-stats__toggle-list', + className: this.getClassPrefix() + '__toggle-list', onChange: this.onToggleListChange.bind(this), - items: ['CREATE_TICKET', 'CLOSE', 'SIGNUP', 'COMMENT'].map((name) => { + items: this.getStrokes().map((name) => { return { content: -
-
{this.state.stats[name]}
-
{i18n('CHART_' + name)}
+
+
{this.state.stats[name]}
+
{i18n('CHART_' + name)}
} }) @@ -105,12 +96,12 @@ class Stats extends React.Component { } ], onChange: this.onDropDownChange.bind(this), - className: 'admin-panel-stats__dropdown' + className: this.getClassPrefix() + '__dropdown' } } onDropDownChange(event) { - let val = [7, 30, 90, 3 65]; + let val = [7, 30, 90, 365]; this.retrieve(val[event.index]); } @@ -126,6 +117,7 @@ class Stats extends React.Component { retrieve(period) { let periodName; + switch (period) { case 30: periodName = 'MONTH'; @@ -142,48 +134,24 @@ class Stats extends React.Component { API.call({ path: '/system/get-stats', - data: { + data: this.getApiCallData(periodName) + /*data: { period: periodName - } + }*/ }).then(this.onRetrieveSuccess.bind(this, period)); } onRetrieveSuccess(period, result) { + let newStats = this.getDefaultStats(); - let newStats = { - 'CREATE_TICKET': 0, - 'CLOSE': 0, - 'SIGNUP': 0, - 'COMMENT': 0 - }; + let newStrokes = this.getStrokes().map((name) => { + return { + name: name, + values: [] + }; + }); - let ID = { - 'CREATE_TICKET': 0, - 'CLOSE': 1, - 'SIGNUP': 2, - 'COMMENT': 3 - }; - - let newStrokes = [ - { - name: 'CREATE_TICKET', - values: [] - }, - { - name: 'CLOSE', - values: [] - }, - { - name: 'SIGNUP', - values: [] - }, - { - name: 'COMMENT', - values: [] - } - ]; - - let realPeriod = result.data.length / 4; + let realPeriod = result.data.length / this.getStrokes().length; for (let i = 0; i < result.data.length; i++) { newStats[result.data[i].type] += result.data[i].value * 1; @@ -198,7 +166,7 @@ class Stats extends React.Component { } getShowedArray() { - let showed = [false, false, false, false]; + let showed = this.getStrokes().map(() => false); for (let i = 0; i < showed.length; i++) { showed[this.state.showed[i]] = true; @@ -206,6 +174,32 @@ class Stats extends React.Component { return showed; } + + getStrokes() { + return this.props.type === 'general' ? generalStrokes : staffStrokes; + } + + getDefaultStats() { + return this.props.type === 'general' ? + { + 'CREATE_TICKET': 0, + 'CLOSE': 0, + 'SIGNUP': 0, + 'COMMENT': 0 + } : + { + 'ASSIGN': 0, + 'CLOSE': 0 + }; + } + + getClassPrefix() { + return this.props.type === 'general' ? 'admin-panel-stats' : 'ANOTHER_ONE'; /// IMPORTANTE... + } + + getApiCallData(periodName) { + return this.props.type === 'general' ? {period: periodName} : {period: periodName, staffId: this.props.staffId}; + } } export default Stats; \ 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 797398bd..bf5b7c3d 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -161,6 +161,8 @@ module.exports = [ path: '/system/get-stats', time: 200, response: function(_data) { + let generalVal = _data.staffId; + let ID = { 'WEEK': 7, 'MONTH': 30, @@ -172,30 +174,46 @@ module.exports = [ let DATA = []; for (let i = 0; i < k; i++) { - DATA.push({ - date: '201701' + (i + 10) % 100, - type: 'COMMENT', - general: 1, - value: (Math.floor(Math.random() * i)).toString() - }); - DATA.push({ - date: '201701' + (i + 10) % 100, - type: 'SIGNUP', - general: 1, - value: (Math.floor(Math.random() * (i - 180) * (i - 185) / (1.027**i) )).toString() - }); - DATA.push({ - date: '201701' + (i + 10) % 100, - type: 'CLOSE', - general: 1, - value: (Math.floor(Math.random() * i * i * i / 365 / 365)).toString() - }); - DATA.push({ - date: '201701' + (i + 10) % 100, - type: 'CREATE_TICKET', - general: 1, - value: (Math.floor(Math.random()*Math.random()*Math.random()*Math.random()*Math.random()*1.027**i)).toString() - }); + if(generalVal){ + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'ASSIGN', + general: generalVal, + value: (Math.floor((Math.random() + 17) * i)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CLOSE', + general: generalVal, + value: (Math.floor((Math.random() + 12) * i )).toString() + }); + } + else { + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'COMMENT', + general: generalVal, + value: (Math.floor((Math.random() + 5) * i)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'SIGNUP', + general: generalVal, + value: (Math.floor(Math.random() * (i - 180) * (i - 185) / 400)).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CLOSE', + general: generalVal, + value: (Math.floor((Math.random() + 12) * i )).toString() + }); + DATA.push({ + date: '201701' + (i + 10) % 100, + type: 'CREATE_TICKET', + general: generalVal, + value: (Math.floor((Math.random() + 7) * i)).toString() + }); + } } console.log('DATA:'); diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index cb576806..94a18a34 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -159,6 +159,7 @@ export default { 'CHART_CLOSE': 'Tickets closed', 'CHART_SIGNUP': 'Signups', 'CHART_COMMENT': 'Replies', + 'CHART_ASSIGN': 'Assigned', //ACTIVITIES 'ACTIVITY_COMMENT': 'commented ticket', From 371b7973b21fc1ea9b90d4d668c56919f138d367 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 19:46:08 -0300 Subject: [PATCH 18/35] Max Red - Ivan changed some things (problems with userId in my-account) and I kept abstacting the component, and applied it to staff-editor [skip ci] --- client/src/app-components/stats-chart.js | 2 +- client/src/app-components/stats.js | 27 ++++++---- client/src/app-components/stats.scss | 53 +++++++++++++++++++ .../panel/dashboard/admin-panel-my-account.js | 1 + .../src/app/admin/panel/staff/staff-editor.js | 4 +- .../app/admin/panel/staff/staff-editor.scss | 9 ++++ client/src/core-components/toggle-list.js | 4 +- client/src/core-components/toggle-list.scss | 9 +++- client/src/data/fixtures/system-fixtures.js | 12 ++--- client/src/data/languages/en.js | 1 + client/src/reducers/session-reducer.js | 6 ++- 11 files changed, 106 insertions(+), 22 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index ca6ddb1c..9b0d9111 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -64,7 +64,7 @@ class StatsChart extends React.Component { } getBorderWidth() { - return (this.props.period <= 90) ? 4 : 2; + return (this.props.period <= 90) ? 3 : 2; } getLabels() { diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js index 408376a1..c112cd7f 100644 --- a/client/src/app-components/stats.js +++ b/client/src/app-components/stats.js @@ -1,5 +1,6 @@ import React from 'react'; import _ from 'lodash'; +import classNames from 'classnames'; import i18n from 'lib-app/i18n'; import API from 'lib-app/api-call'; @@ -44,7 +45,7 @@ class Stats extends React.Component { render() { return ( -
+
@@ -52,17 +53,27 @@ class Stats extends React.Component { ); } + getClass() { + let classes = { + 'stats': true, + 'stats_staff': this.props.type === 'staff' + }; + + return classNames(classes); + } + getToggleListProps() { return { values: this.state.showed, - className: this.getClassPrefix() + '__toggle-list', + className: 'stats__toggle-list', onChange: this.onToggleListChange.bind(this), + type: this.props.type === 'general' ? 'default' : 'small', items: this.getStrokes().map((name) => { return { content: -
-
{this.state.stats[name]}
-
{i18n('CHART_' + name)}
+
+
{this.state.stats[name]}
+
{i18n('CHART_' + name)}
} }) @@ -96,7 +107,7 @@ class Stats extends React.Component { } ], onChange: this.onDropDownChange.bind(this), - className: this.getClassPrefix() + '__dropdown' + className: 'stats__dropdown' } } @@ -193,10 +204,6 @@ class Stats extends React.Component { }; } - getClassPrefix() { - return this.props.type === 'general' ? 'admin-panel-stats' : 'ANOTHER_ONE'; /// IMPORTANTE... - } - getApiCallData(periodName) { return this.props.type === 'general' ? {period: periodName} : {period: periodName, staffId: this.props.staffId}; } diff --git a/client/src/app-components/stats.scss b/client/src/app-components/stats.scss index e69de29b..f7539577 100644 --- a/client/src/app-components/stats.scss +++ b/client/src/app-components/stats.scss @@ -0,0 +1,53 @@ +@import '../scss/vars'; + +.stats { + + &__dropdown { + margin-left: auto; + margin-bottom: 20px; + } + + &__toggle-list { + margin-bottom: 20px; + + &-item { + + &-value { + font-size: $font-size--lg; + line-height: 80px; + } + + &-name { + font-size: $font-size--md; + line-height: 20px; + } + } + } + + &_staff { + .stats__dropdown { + margin-left: auto; + margin-bottom: 20px; + float: left; + } + + .stats__toggle-list { + margin-bottom: 20px; + float: right; + + &-item { + + &-value { + font-size: $font-size--md; + line-height: 40px; + } + + &-name { + font-size: $font-size--sm; + line-height: 20px; + } + } + } + } + +} \ No newline at end of file diff --git a/client/src/app/admin/panel/dashboard/admin-panel-my-account.js b/client/src/app/admin/panel/dashboard/admin-panel-my-account.js index 0cd165e3..165db779 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-my-account.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-my-account.js @@ -23,6 +23,7 @@ class AdminPanelMyAccount extends React.Component { getEditorProps() { return { myAccount: true, + staffId: this.props.userId, name: this.props.userName, email: this.props.userEmail, profilePic: this.props.userProfilePic, diff --git a/client/src/app/admin/panel/staff/staff-editor.js b/client/src/app/admin/panel/staff/staff-editor.js index fdca49f0..1581698f 100644 --- a/client/src/app/admin/panel/staff/staff-editor.js +++ b/client/src/app/admin/panel/staff/staff-editor.js @@ -6,6 +6,7 @@ import API from 'lib-app/api-call'; import SessionStore from 'lib-app/session-store'; import TicketList from 'app-components/ticket-list'; import AreYouSure from 'app-components/are-you-sure'; +import Stats from 'app-components/stats'; import Form from 'core-components/form'; import FormField from 'core-components/form-field'; @@ -97,7 +98,8 @@ class StaffEditor extends React.Component {
- ACTIVITY +
{i18n('ACTIVITY')}
+
diff --git a/client/src/app/admin/panel/staff/staff-editor.scss b/client/src/app/admin/panel/staff/staff-editor.scss index 8e29ab3c..2f601ddd 100644 --- a/client/src/app/admin/panel/staff/staff-editor.scss +++ b/client/src/app/admin/panel/staff/staff-editor.scss @@ -156,4 +156,13 @@ color: $dark-grey; } } + + &__activity { + + &-title { + margin-bottom: 10px; + text-align: left; + } + } + } \ No newline at end of file diff --git a/client/src/core-components/toggle-list.js b/client/src/core-components/toggle-list.js index d057a6f1..edf16ada 100644 --- a/client/src/core-components/toggle-list.js +++ b/client/src/core-components/toggle-list.js @@ -7,7 +7,8 @@ class ToggleList extends React.Component { items: React.PropTypes.arrayOf(React.PropTypes.shape({ content: React.PropTypes.node })), - onChange: React.PropTypes.func + onChange: React.PropTypes.func, + type: React.PropTypes.oneOf(['default', 'small']) }; state = { @@ -25,6 +26,7 @@ class ToggleList extends React.Component { getClass() { let classes = { 'toggle-list': true, + 'toggle-list_small': this.props.type == 'small', [this.props.className]: (this.props.className) }; diff --git a/client/src/core-components/toggle-list.scss b/client/src/core-components/toggle-list.scss index a016f8a3..1fdd82e5 100644 --- a/client/src/core-components/toggle-list.scss +++ b/client/src/core-components/toggle-list.scss @@ -12,7 +12,7 @@ } &__selected { - box-shadow: inset 0 -5px 40px 10px rgba(0, 0, 0, 0.05); + box-shadow: inset 0 -5px 40px 10px rgba(0, 0, 0, 0.08); } &__first-item { @@ -23,4 +23,11 @@ &__last-item { border-radius: 0 4px 4px 0; } + + &_small { + .toggle-list__item { + height: 80px; + width: 120px; + } + } } diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index bf5b7c3d..658e4ad7 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -176,13 +176,13 @@ module.exports = [ for (let i = 0; i < k; i++) { if(generalVal){ DATA.push({ - date: '201701' + (i + 10) % 100, + date: '201701' + (i + 103) % 100, type: 'ASSIGN', general: generalVal, value: (Math.floor((Math.random() + 17) * i)).toString() }); DATA.push({ - date: '201701' + (i + 10) % 100, + date: '201701' + (i + 109) % 100, type: 'CLOSE', general: generalVal, value: (Math.floor((Math.random() + 12) * i )).toString() @@ -190,25 +190,25 @@ module.exports = [ } else { DATA.push({ - date: '201701' + (i + 10) % 100, + date: '201701' + (i + 107) % 100, type: 'COMMENT', general: generalVal, value: (Math.floor((Math.random() + 5) * i)).toString() }); DATA.push({ - date: '201701' + (i + 10) % 100, + date: '201701' + (i + 104) % 100, type: 'SIGNUP', general: generalVal, value: (Math.floor(Math.random() * (i - 180) * (i - 185) / 400)).toString() }); DATA.push({ - date: '201701' + (i + 10) % 100, + date: '201701' + (i + 103) % 100, type: 'CLOSE', general: generalVal, value: (Math.floor((Math.random() + 12) * i )).toString() }); DATA.push({ - date: '201701' + (i + 10) % 100, + date: '201701' + (i + 99) % 100, type: 'CREATE_TICKET', general: generalVal, value: (Math.floor((Math.random() + 7) * i)).toString() diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 94a18a34..c79a2ae8 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -153,6 +153,7 @@ export default { 'VERIFY_SUCCESS': 'User verified', 'VERIFY_FAILED': 'Could not verify', 'TICKET_ACTIVITY': 'Ticket Activity', + 'ACTIVITY': 'Activity', 'CHART_CREATE_TICKET': 'Tickets created', diff --git a/client/src/reducers/session-reducer.js b/client/src/reducers/session-reducer.js index be4323cc..c1eca34f 100644 --- a/client/src/reducers/session-reducer.js +++ b/client/src/reducers/session-reducer.js @@ -44,7 +44,8 @@ class SessionReducer extends Reducer { logged: true, pending: false, failed: false, - staff: payload.data.staff + staff: payload.data.staff, + userId: payload.data.userId }); } @@ -75,7 +76,8 @@ class SessionReducer extends Reducer { initDone: true, logged: true, pending: false, - failed: false + failed: false, + userId: payload.data.userId }); } From 8584be092441b6d16460f8e95c82d5f4fa228a0f Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Jan 2017 20:10:02 -0300 Subject: [PATCH 19/35] Max Red - Changed colors [skip ci] --- client/src/app-components/stats-chart.js | 10 +++++----- client/src/app-components/stats.js | 3 --- client/src/app-components/stats.scss | 1 + 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index 9b0d9111..f50d2d71 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -28,11 +28,11 @@ class StatsChart extends React.Component { let labels = this.getLabels(); let color = { - 'CLOSE': 'rgba(150, 20, 20, 0.8)', - 'CREATE_TICKET': 'rgba(20, 150, 20, 0.8)', - 'SIGNUP': 'rgba(20, 20, 150, 0.8)', - 'COMMENT': 'rgba(20, 200, 200, 0.8)', - 'ASSIGN': 'rgba(200, 200, 20, 0.8)' + 'CLOSE': 'rgba(150, 20, 20, 0.6)', + 'CREATE_TICKET': 'rgba(20, 150, 20, 0.6)', + 'SIGNUP': 'rgba(20, 20, 150, 0.6)', + 'COMMENT': 'rgba(20, 200, 200, 0.6)', + 'ASSIGN': 'rgba(20, 150, 20, 0.6)' }; let datasets = []; diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js index c112cd7f..e0b84f42 100644 --- a/client/src/app-components/stats.js +++ b/client/src/app-components/stats.js @@ -146,9 +146,6 @@ class Stats extends React.Component { API.call({ path: '/system/get-stats', data: this.getApiCallData(periodName) - /*data: { - period: periodName - }*/ }).then(this.onRetrieveSuccess.bind(this, period)); } diff --git a/client/src/app-components/stats.scss b/client/src/app-components/stats.scss index f7539577..c1557e9e 100644 --- a/client/src/app-components/stats.scss +++ b/client/src/app-components/stats.scss @@ -9,6 +9,7 @@ &__toggle-list { margin-bottom: 20px; + user-select: none; &-item { From 7c19ef17165adcef939220f835a819271546fd77 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Jan 2017 12:04:47 -0300 Subject: [PATCH 20/35] Max Red - Beautify code, replacing a for using .map [skip ci] --- client/src/app-components/stats-chart.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index f50d2d71..5e4704b7 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -35,12 +35,9 @@ class StatsChart extends React.Component { 'ASSIGN': 'rgba(20, 150, 20, 0.6)' }; - let datasets = []; - - for (let i = 0; i < this.props.strokes.length; i++) { - let stroke = this.props.strokes[i]; - - let dataset = { + let strokes = this.props.strokes.slice(); + let datasets = strokes.map((stroke, index) => { + return { label: i18n('CHART_' + stroke.name), data: stroke.values.map((val) => val.value), fill: false, @@ -51,12 +48,10 @@ class StatsChart extends React.Component { pointHoverRadius: 3, lineTension: 0.2, pointHoverBackgroundColor: color[stroke.name], - hitRadius: this.hitRadius(i) - }; + hitRadius: this.hitRadius(index) + } + }); - datasets.push(dataset); - } - return { labels: labels, datasets: datasets From 9fbf53d586f2c36a6ff4f1dc52793a95fa8f4fba Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Jan 2017 12:20:22 -0300 Subject: [PATCH 21/35] Max Red - Beautify code, replacing another for using .map [skip ci] --- client/src/app-components/stats.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js index e0b84f42..337bf446 100644 --- a/client/src/app-components/stats.js +++ b/client/src/app-components/stats.js @@ -88,24 +88,12 @@ class Stats extends React.Component { getDropDownProps() { return { - items: [ - { - content: 'Last 7 days', + items: ['Last 7 days', 'Last 30 days', 'Last 90 days', 'Last 365 days'].map((name) => { + return { + content: name, icon: '' - }, - { - content: 'Last 30 days', - icon: '' - }, - { - content: 'Last 90 days', - icon: '' - }, - { - content: 'Last 365 days', - icon: '' - } - ], + }; + }), onChange: this.onDropDownChange.bind(this), className: 'stats__dropdown' } From 1019b4ff967ec8477611d2a7ad567617b2c41dc1 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Jan 2017 12:39:07 -0300 Subject: [PATCH 22/35] Max Red - Delete redundant css [skip ci] --- .../panel/dashboard/admin-panel-stats.scss | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.scss b/client/src/app/admin/panel/dashboard/admin-panel-stats.scss index 2a20db81..e69de29b 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.scss +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.scss @@ -1,27 +0,0 @@ -@import "../../../../scss/vars"; - -.admin-panel-stats { - - &__dropdown { - margin-left: auto; - margin-bottom: 20px; - } - - &__toggle-list { - margin-bottom: 20px; - - &-item { - - &-value { - font-size: $font-size--lg; - line-height: 80px; - } - - &-name { - font-size: $font-size--md; - line-height: 20px; - } - } - } - -} \ No newline at end of file From a70778db9cd4ae07e949beacfb8dc13f8944a826 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 16 Jan 2017 16:06:19 -0300 Subject: [PATCH 23/35] Max Red - disable registration and fixed a message in en.js[skip ci] --- client/src/app/App.js | 16 ++++++++++------ client/src/app/main/main-layout-header.js | 2 +- client/src/data/fixtures/system-fixtures.js | 1 + client/src/data/languages/en.js | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/src/app/App.js b/client/src/app/App.js index d52ea248..6d327fa8 100644 --- a/client/src/app/App.js +++ b/client/src/app/App.js @@ -86,20 +86,24 @@ class App extends React.Component { browserHistory.push('/admin/panel'); } - if (this.props.session.userLevel && !this.isPathAvailableForStaff()) { + if (props.session.userLevel && !this.isPathAvailableForStaff(props)) { browserHistory.push('/admin/panel'); } + + if (!props.config.registration && _.includes(props.location.pathname, 'signup')) { + browserHistory.push('/'); + } } - isPathAvailableForStaff() { - let pathForLevel2 = _.findIndex(level2Paths, path => _.includes(this.props.location.pathname, path)) !== -1; - let pathForLevel3 = _.findIndex(level3Paths, path => _.includes(this.props.location.pathname, path)) !== -1; + isPathAvailableForStaff(props) { + let pathForLevel2 = _.findIndex(level2Paths, path => _.includes(props.location.pathname, path)) !== -1; + let pathForLevel3 = _.findIndex(level3Paths, path => _.includes(props.location.pathname, path)) !== -1; - if (this.props.session.userLevel === 1) { + if (props.session.userLevel === 1) { return !pathForLevel2 && !pathForLevel3; } - if (this.props.session.userLevel === 2) { + if (props.session.userLevel === 2) { return !pathForLevel3; } diff --git a/client/src/app/main/main-layout-header.js b/client/src/app/main/main-layout-header.js index dd031535..2254590c 100644 --- a/client/src/app/main/main-layout-header.js +++ b/client/src/app/main/main-layout-header.js @@ -32,7 +32,7 @@ class MainLayoutHeader extends React.Component { result = (
- + {this.props.config === true ? : null}
); } diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index ac2a5bbd..ecf3916e 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -20,6 +20,7 @@ module.exports = [ 'smtp-user': 'Wesa', 'maintenance-mode': false, 'allow-attachments': true, + 'registration': false, 'max-size': 500, 'departments': [ {id: 1, name: 'Sales Support', owners: 2}, diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 8e69269c..a7ec1983 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -186,7 +186,7 @@ export default { 'TICKET_LIST_DESCRIPTION': 'Here you can find a list of all tickets you have sent to our support team.', 'TICKETS_DESCRIPTION': 'Send ticket through our support center and get response of your doubts, suggestions and issues.', 'ARTICLES_DESCRIPTION': 'Take a look to our articles about common issues, guides and documentation.', - 'ACCOUNT_DESCRIPTION': 'All your tickets are stored in your accounts\'s profile. Keep track off all your tickets you send to our staff team.', + 'ACCOUNT_DESCRIPTION': 'All your tickets are stored in your account\'s profile. Keep track of all your tickets you send to our staff team.', 'SUPPORT_CENTER_DESCRIPTION': 'Welcome to our support center. You can contact us through a tickets system. Your tickets will be answered by our staff.', 'CUSTOM_RESPONSES_DESCRIPTION': 'Custom responses are automated responses for common problems', 'MY_TICKETS_DESCRIPTION': 'Here you can view the tickets you are responsible for.', From fdd35ed2c17d8e23536c2829fddadc958418df69 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 16 Jan 2017 16:07:53 -0300 Subject: [PATCH 24/35] Guillermo - disable-user-system [skip ci] --- server/controllers/article/get-all.php | 2 +- server/controllers/system.php | 4 + .../system/disable-user-system.php | 57 ++++++++++++++ .../system/enabled-user-system.php | 74 +++++++++++++++++++ server/controllers/system/get-settings.php | 3 +- server/controllers/system/init-settings.php | 3 +- server/controllers/ticket/comment.php | 22 +++++- server/controllers/ticket/create.php | 27 ++++++- server/controllers/ticket/get.php | 31 +++++++- server/controllers/user/delete.php | 4 + server/controllers/user/get-user.php | 5 ++ server/controllers/user/get-users.php | 4 + server/controllers/user/login.php | 7 +- server/controllers/user/recover-password.php | 4 + .../user/send-recover-password.php | 4 + server/controllers/user/signup.php | 4 + server/controllers/user/verify.php | 4 + server/data/ERRORS.php | 3 + server/data/InitialMails.php | 20 +++++ .../user-system-disabled-en.html | 3 + .../user-system-disabled-es.html | 3 + .../user-system-enabled-en.html | 4 + .../user-system-enabled-es.html | 3 + server/libs/Controller.php | 4 + server/models/MailTemplate.php | 2 + server/models/Ticket.php | 8 +- tests/init.rb | 1 + tests/system/get-mail-templates.rb | 2 +- 28 files changed, 293 insertions(+), 19 deletions(-) create mode 100644 server/controllers/system/disable-user-system.php create mode 100644 server/controllers/system/enabled-user-system.php create mode 100644 server/data/mail-templates/user-system-disabled-en.html create mode 100644 server/data/mail-templates/user-system-disabled-es.html create mode 100644 server/data/mail-templates/user-system-enabled-en.html create mode 100644 server/data/mail-templates/user-system-enabled-es.html diff --git a/server/controllers/article/get-all.php b/server/controllers/article/get-all.php index 9d90e152..40a49efc 100644 --- a/server/controllers/article/get-all.php +++ b/server/controllers/article/get-all.php @@ -7,7 +7,7 @@ class GetAllArticlesController extends Controller { public function validations() { return [ - 'permission' => 'user', + 'permission' => (Controller::isUserSystemEnabled()) ? 'user' : 'any', 'requestData' => [] ]; } diff --git a/server/controllers/system.php b/server/controllers/system.php index e5423a5a..e1250709 100644 --- a/server/controllers/system.php +++ b/server/controllers/system.php @@ -11,6 +11,8 @@ require_once 'system/edit-mail-template.php'; require_once 'system/recover-mail-template.php'; require_once 'system/disable-registration.php'; require_once 'system/enable-registration.php'; +require_once 'system/disable-user-system.php'; +require_once 'system/enabled-user-system.php'; $systemControllerGroup = new ControllerGroup(); $systemControllerGroup->setGroupPath('/system'); @@ -27,5 +29,7 @@ $systemControllerGroup->addController(new EditMailTemplateController); $systemControllerGroup->addController(new RecoverMailTemplateController); $systemControllerGroup->addController(new DisableRegistrationController); $systemControllerGroup->addController(new EnableRegistrationController); +$systemControllerGroup->addController(new DisableUserSystemController); +$systemControllerGroup->addController(new EnabledUserSystemController); $systemControllerGroup->finalize(); \ No newline at end of file diff --git a/server/controllers/system/disable-user-system.php b/server/controllers/system/disable-user-system.php new file mode 100644 index 00000000..cc1eee83 --- /dev/null +++ b/server/controllers/system/disable-user-system.php @@ -0,0 +1,57 @@ + 'staff_3', + 'requestData' => [] + ]; + } + + public function handler() { + $password = Controller::request('password'); + + if(!Hashing::verifyPassword($password, Controller::getLoggedUser()->password)) { + throw new Exception(ERRORS::INVALID_PASSWORD); + + } + + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::SYSTEM_USER_IS_ALREADY_DISABLED); + } + + $userSystemEnabled = Setting::getSetting('user-system-enabled'); + $userSystemEnabled->value = 0 ; + $userSystemEnabled->store(); + + $userList = User::getAll(); + + foreach($userList as $user) { + $ticketNumberList = []; + + foreach($user->sharedTicketList as $ticket) { + $ticket->authorEmail = $user->email; + $ticket->authorName = $user->name; + $ticket->author = null; + + $ticketNumberList[] = $ticket->ticketNumber; + $ticket->store(); + } + + $mailSender = new MailSender(); + + $mailSender->setTemplate(MailTemplate::USER_SYSTEM_DISABLED, [ + 'to' => $user->email, + 'name' => $user->name, + 'tickets' => json_encode($ticketNumberList) + ]); + + $mailSender->send(); + + $user->delete(); + } + Response::respondSuccess(); + } +} \ No newline at end of file diff --git a/server/controllers/system/enabled-user-system.php b/server/controllers/system/enabled-user-system.php new file mode 100644 index 00000000..fb6b2d3a --- /dev/null +++ b/server/controllers/system/enabled-user-system.php @@ -0,0 +1,74 @@ + 'staff_3', + 'requestData' => [] + ]; + } + + public function handler() { + $password = Controller::request('password'); + + if(!Hashing::verifyPassword($password, Controller::getLoggedUser()->password)) { + throw new Exception(ERRORS::INVALID_PASSWORD); + + } + + if(Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::SYSTEM_USER_IS_ALREADY_ENABLED); + } + + $userSystemEnabled = Setting::getSetting('user-system-enabled'); + $userSystemEnabled->value = 1 ; + $userSystemEnabled->store(); + + $ticketList = Ticket::getAll(); + + foreach($ticketList as $ticket) { + + $userRow = User::getDataStore($ticket->authorEmail, 'email'); + + if($userRow->isNull()) { + $userInstance = new User(); + + $password = Hashing::generateRandomToken(); + + $userInstance->setProperties([ + 'name' => $ticket->authorName, + 'signupDate' => Date::getCurrentDate(), + 'tickets' => 1, + 'email' => $ticket->authorEmail, + 'password' => Hashing::hashPassword($password), + 'verificationToken' => null + ]); + + $userInstance->store(); + + $mailSender = new MailSender(); + $mailSender->setTemplate(MailTemplate::USER_SYSTEM_ENABLED, [ + 'to' => $ticket->authorEmail, + 'name' => $ticket->authorName, + 'password' => $password + ]); + $mailSender->send(); + + } else { + $userRow->tickets = $userRow->tickets + 1; + $userRow->sharedTicketList->add($ticket); + $userRow->store(); + } + + $actualUserRow = User::getDataStore($ticket->authorEmail,'email'); + $ticket->author = $actualUserRow; + $ticket->authorName = null; + $ticket->authorEmail = null; + $ticket->store(); + } + + Response::respondSuccess(); + } +} \ No newline at end of file diff --git a/server/controllers/system/get-settings.php b/server/controllers/system/get-settings.php index 9cddb302..41e2299d 100644 --- a/server/controllers/system/get-settings.php +++ b/server/controllers/system/get-settings.php @@ -46,7 +46,8 @@ class GetSettingsController extends Controller { 'registration' => Setting::getSetting('registration')->getValue(), 'departments' => Department::getDepartmentNames(), 'supportedLanguages' => Language::getSupportedLanguages(), - 'allowedLanguages' => Language::getAllowedLanguages() + 'allowedLanguages' => Language::getAllowedLanguages(), + 'user-system-enabled' => Setting::getSetting('user-system-enabled')->getValue() ]; } diff --git a/server/controllers/system/init-settings.php b/server/controllers/system/init-settings.php index 47f83893..67d0df5f 100644 --- a/server/controllers/system/init-settings.php +++ b/server/controllers/system/init-settings.php @@ -41,7 +41,8 @@ class InitSettingsController extends Controller { 'max-size' => 0, 'title' => 'Support Center', 'url' => 'http://www.opensupports.com/support', - 'registration' => true + 'registration' => true, + 'user-system-enabled' => true ]); } diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index b51414c2..72f9dc94 100644 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -9,7 +9,7 @@ class CommentController extends Controller { private $content; public function validations() { - return [ + $validations = [ 'permission' => 'user', 'requestData' => [ 'content' => [ @@ -22,13 +22,23 @@ class CommentController extends Controller { ] ] ]; + + if(!Controller::isUserSystemEnabled()) { + $validations['permission'] = 'any'; + $validations['requestData']['email'] = [ + 'validation' => DataValidator::email(), + 'error' => ERRORS::INVALID_EMAIL + ]; + } + + return $validations; } public function handler() { $session = Session::getInstance(); $this->requestData(); - if ($session->isLoggedWithId($this->ticket->author->id) || Controller::isStaffLogged()) { + if (!Controller::isUserSystemEnabled() || $session->isLoggedWithId($this->ticket->author->id) || Controller::isStaffLogged()) { $this->storeComment(); Log::createLog('COMMENT', $this->ticket->ticketNumber); @@ -41,9 +51,13 @@ class CommentController extends Controller { private function requestData() { $ticketNumber = Controller::request('ticketNumber'); - + $email = Controller::request('email'); $this->ticket = Ticket::getByTicketNumber($ticketNumber); $this->content = Controller::request('content'); + + if(!Controller::isUserSystemEnabled() && $this->ticket->authorEmail !== $email && !Controller::isStaffLogged()) { + throw new Exception(ERRORS::NO_PERMISSION); + } } private function storeComment() { @@ -56,7 +70,7 @@ class CommentController extends Controller { if(Controller::isStaffLogged()) { $this->ticket->unread = true; $comment->authorStaff = Controller::getLoggedUser(); - } else { + } else if(Controller::isUserSystemEnabled()) { $this->ticket->unreadStaff = true; $comment->authorUser = Controller::getLoggedUser(); } diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index ac9f4c53..c1f0e077 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -10,9 +10,11 @@ class CreateController extends Controller { private $departmentId; private $language; private $ticketNumber; + private $email; + private $name; public function validations() { - return [ + $validations = [ 'permission' => 'user', 'requestData' => [ 'title' => [ @@ -33,6 +35,16 @@ class CreateController extends Controller { ] ] ]; + + if(!Controller::isUserSystemEnabled()) { + $validations['permission'] = 'any'; + $validations['requestData']['captcha'] = [ + 'validation' => DataValidator::captcha(), + 'error' => ERRORS::INVALID_CAPTCHA + ]; + } + + return $validations; } public function handler() { @@ -40,6 +52,8 @@ class CreateController extends Controller { $this->content = Controller::request('content'); $this->departmentId = Controller::request('departmentId'); $this->language = Controller::request('language'); + $this->email = Controller::request('email'); + $this->name = Controller::request('name'); $this->storeTicket(); @@ -65,12 +79,17 @@ class CreateController extends Controller { 'unread' => false, 'unreadStaff' => true, 'closed' => false, + 'authorName' => $this->name, + 'authorEmail' => $this->email )); - $author->sharedTicketList->add($ticket); - $author->tickets++; + if(Controller::isUserSystemEnabled()) { + $author->sharedTicketList->add($ticket); + $author->tickets++; + + $author->store(); + } - $author->store(); $ticket->store(); $this->ticketNumber = $ticket->ticketNumber; diff --git a/server/controllers/ticket/get.php b/server/controllers/ticket/get.php index 36ef3f8b..6e2a6758 100644 --- a/server/controllers/ticket/get.php +++ b/server/controllers/ticket/get.php @@ -8,7 +8,7 @@ class TicketGetController extends Controller { private $ticket; public function validations() { - return [ + $validations = [ 'permission' => 'user', 'requestData' => [ 'ticketNumber' => [ @@ -17,13 +17,38 @@ class TicketGetController extends Controller { ] ] ]; + + if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) { + $validations['permission'] = 'any'; + $validations['requestData']['email'] = [ + 'validation' => DataValidator::email(), + 'error' => ERRORS::INVALID_EMAIL + ]; + $validations['requestData']['captcha'] = [ + 'validation' => DataValidator::captcha(), + 'error' => ERRORS::INVALID_CAPTCHA + ]; + } + + return $validations; } public function handler() { + $email = Controller::request('email'); + $this->ticket = Ticket::getByTicketNumber(Controller::request('ticketNumber')); + if(!Controller::isUserSystemEnabled() && !Controller::isStaffLogged()) { + if($this->ticket->authorEmail === $email) { + Response::respondSuccess($this->ticket->toArray()); + return; + } else { + throw new Exception(ERRORS::NO_PERMISSION); + } + } + if ($this->shouldDenyPermission()) { - Response::respondError(ERRORS::NO_PERMISSION); + throw new Exception(ERRORS::NO_PERMISSION); } else { Response::respondSuccess($this->ticket->toArray()); } @@ -32,7 +57,7 @@ class TicketGetController extends Controller { private function shouldDenyPermission() { $user = Controller::getLoggedUser(); - return (!Controller::isStaffLogged() && $this->ticket->author->id !== $user->id) || + return (!Controller::isStaffLogged() && (Controller::isUserSystemEnabled() && $this->ticket->author->id !== $user->id)) || (Controller::isStaffLogged() && $this->ticket->owner && $this->ticket->owner->id !== $user->id); } } \ No newline at end of file diff --git a/server/controllers/user/delete.php b/server/controllers/user/delete.php index 75cf7dfc..b17ed8a4 100644 --- a/server/controllers/user/delete.php +++ b/server/controllers/user/delete.php @@ -20,6 +20,10 @@ class DeleteUserController extends Controller { } public function handler() { + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $userId = Controller::request('userId'); $user = User::getDataStore($userId); diff --git a/server/controllers/user/get-user.php b/server/controllers/user/get-user.php index 8ea55c09..ae9b4f9e 100644 --- a/server/controllers/user/get-user.php +++ b/server/controllers/user/get-user.php @@ -18,6 +18,11 @@ class GetUserByIdController extends Controller { } public function handler() { + + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $userId = Controller::request('userId'); $user = User::getDataStore($userId); $staff = Controller::getLoggedUser(); diff --git a/server/controllers/user/get-users.php b/server/controllers/user/get-users.php index eadd6922..5d8daf28 100644 --- a/server/controllers/user/get-users.php +++ b/server/controllers/user/get-users.php @@ -21,6 +21,10 @@ class GetUsersController extends Controller { } public function handler() { + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $userList = $this->getUserList(); $userListArray = []; diff --git a/server/controllers/user/login.php b/server/controllers/user/login.php index 7eada075..ebd55c30 100644 --- a/server/controllers/user/login.php +++ b/server/controllers/user/login.php @@ -14,9 +14,12 @@ class LoginController extends Controller { } public function handler() { + if(!Controller::isUserSystemEnabled() && !Controller::request('staff')) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + if ($this->isAlreadyLoggedIn()) { - Response::respondError(ERRORS::SESSION_EXISTS); - return; + throw new Exception(ERRORS::SESSION_EXISTS); } if ($this->checkInputCredentials() || $this->checkRememberToken()) { diff --git a/server/controllers/user/recover-password.php b/server/controllers/user/recover-password.php index c5cec698..ac3ceef2 100644 --- a/server/controllers/user/recover-password.php +++ b/server/controllers/user/recover-password.php @@ -27,6 +27,10 @@ class RecoverPasswordController extends Controller { } public function handler() { + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $this->requestData(); $this->changePassword(); } diff --git a/server/controllers/user/send-recover-password.php b/server/controllers/user/send-recover-password.php index e92d1ae6..c59eebb1 100644 --- a/server/controllers/user/send-recover-password.php +++ b/server/controllers/user/send-recover-password.php @@ -21,6 +21,10 @@ class SendRecoverPasswordController extends Controller { } public function handler() { + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $email = Controller::request('email'); $this->user = User::getUser($email,'email'); diff --git a/server/controllers/user/signup.php b/server/controllers/user/signup.php index 48e6e1c6..8b4937ca 100644 --- a/server/controllers/user/signup.php +++ b/server/controllers/user/signup.php @@ -36,6 +36,10 @@ class SignUpController extends Controller { } public function handler() { + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $this->storeRequestData(); $existentUser = User::getUser($this->userEmail, 'email'); diff --git a/server/controllers/user/verify.php b/server/controllers/user/verify.php index 616d3b92..aa2dd31d 100644 --- a/server/controllers/user/verify.php +++ b/server/controllers/user/verify.php @@ -17,6 +17,10 @@ class VerifyController extends Controller{ } public function handler() { + if(!Controller::isUserSystemEnabled()) { + throw new Exception(ERRORS::USER_SYSTEM_DISABLED); + } + $email = Controller::request('email'); $token = Controller::request('token'); diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php index e0052543..b6b86d63 100644 --- a/server/data/ERRORS.php +++ b/server/data/ERRORS.php @@ -35,4 +35,7 @@ class ERRORS { const INVALID_TEMPLATE = 'INVALID_TEMPLATE'; const INVALID_SUBJECT = 'INVALID_SUBJECT'; const INVALID_BODY = 'INVALID_BODY'; + const USER_SYSTEM_DISABLED= 'USER_SYSTEM_DISABLED'; + const SYSTEM_USER_IS_ALREADY_DISABLED= 'SYSTEM_USER_IS_ALREADY_DISABLED'; + const SYSTEM_USER_IS_ALREADY_ENABLED= 'SYSTEM_USER_IS_ALREADY_ENABLED'; } diff --git a/server/data/InitialMails.php b/server/data/InitialMails.php index 899d9af3..7be66192 100644 --- a/server/data/InitialMails.php +++ b/server/data/InitialMails.php @@ -53,6 +53,26 @@ class InitialMails { 'body' => file_get_contents('data/mail-templates/user-recovered-password-es.html') ] ], + 'USER_SYSTEM_DISABLED' => [ + 'en' => [ + 'subject' => 'Account has been deleted - OpenSupports', + 'body' => file_get_contents('data/mail-templates/user-system-disabled-en.html') + ], + 'es' => [ + 'subject' => 'cuanta borrada - OpenSupports', + 'body' => file_get_contents('data/mail-templates/user-system-disabled-es.html') + ] + ], + 'USER_SYSTEM_ENABLED' => [ + 'en' => [ + 'subject' => 'account has been created - OpenSupports', + 'body' => file_get_contents('data/mail-templates/user-system-enabled-en.html') + ], + 'es' => [ + 'subject' => 'se te ha creado una cuenta - OpenSupports', + 'body' => file_get_contents('data/mail-templates/user-system-enabled-es.html') + ] + ] ]; } } \ No newline at end of file diff --git a/server/data/mail-templates/user-system-disabled-en.html b/server/data/mail-templates/user-system-disabled-en.html new file mode 100644 index 00000000..d42819c1 --- /dev/null +++ b/server/data/mail-templates/user-system-disabled-en.html @@ -0,0 +1,3 @@ +
+ Hi {{name}} the system user has been deleted this is the list of your tickets {{tickets}} +
\ No newline at end of file diff --git a/server/data/mail-templates/user-system-disabled-es.html b/server/data/mail-templates/user-system-disabled-es.html new file mode 100644 index 00000000..fb4f3603 --- /dev/null +++ b/server/data/mail-templates/user-system-disabled-es.html @@ -0,0 +1,3 @@ +
+ hoola {{name}} the system user has been deleted this is the list of your tickets {{tickets}} +
\ No newline at end of file diff --git a/server/data/mail-templates/user-system-enabled-en.html b/server/data/mail-templates/user-system-enabled-en.html new file mode 100644 index 00000000..5b2bd906 --- /dev/null +++ b/server/data/mail-templates/user-system-enabled-en.html @@ -0,0 +1,4 @@ +
+ hi {{name}} the system user has been Created this is your new password {{password}} , you can change it if you want + maxi puto +
\ No newline at end of file diff --git a/server/data/mail-templates/user-system-enabled-es.html b/server/data/mail-templates/user-system-enabled-es.html new file mode 100644 index 00000000..a1081984 --- /dev/null +++ b/server/data/mail-templates/user-system-enabled-es.html @@ -0,0 +1,3 @@ +
+ hoola {{name}} el sistema de usuarios se ha creado este es tu contra {{password}} , puedes cambairla si quieres +
\ No newline at end of file diff --git a/server/libs/Controller.php b/server/libs/Controller.php index 3c8a3ca9..f58a93e4 100644 --- a/server/libs/Controller.php +++ b/server/libs/Controller.php @@ -60,4 +60,8 @@ abstract class Controller { public static function getAppInstance() { return \Slim\Slim::getInstance(); } + + public static function isUserSystemEnabled() { + return Setting::getSetting('user-system-enabled')->getValue(); + } } \ No newline at end of file diff --git a/server/models/MailTemplate.php b/server/models/MailTemplate.php index a2931061..0379693b 100644 --- a/server/models/MailTemplate.php +++ b/server/models/MailTemplate.php @@ -8,6 +8,8 @@ class MailTemplate extends DataStore { const USER_PASSWORD = 'USER_PASSWORD'; const PASSWORD_FORGOT = 'PASSWORD_FORGOT'; const PASSWORD_RECOVERED = 'PASSWORD_RECOVERED'; + const USER_SYSTEM_DISABLED = 'USER_SYSTEM_DISABLED'; + const USER_SYSTEM_ENABLED = 'USER_SYSTEM_ENABLED'; public static function getTemplate($type) { $globalLanguage = Setting::getSetting('language')->value; diff --git a/server/models/Ticket.php b/server/models/Ticket.php index 315434e8..0c743bec 100644 --- a/server/models/Ticket.php +++ b/server/models/Ticket.php @@ -20,7 +20,9 @@ class Ticket extends DataStore { 'owner', 'ownTicketeventList', 'unreadStaff', - 'language' + 'language', + 'authorEmail', + 'authorName' ); } @@ -80,7 +82,9 @@ class Ticket extends DataStore { 'priority' => $this->priority, 'author' => $this->authorToArray(), 'owner' => $this->ownerToArray(), - 'events' => $this->eventsToArray() + 'events' => $this->eventsToArray(), + 'authorEmail' => $this->authorEmail, + 'authorName' => $this->authorName ]; } diff --git a/tests/init.rb b/tests/init.rb index bb1cdbaa..14646c99 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -53,3 +53,4 @@ require './system/edit-mail-template.rb' require './system/recover-mail-template.rb' require './system/disable-registration.rb' require './system/enable-registration.rb' +require './system/disable-user-system.rb' diff --git a/tests/system/get-mail-templates.rb b/tests/system/get-mail-templates.rb index 8e067655..f6b4ab10 100644 --- a/tests/system/get-mail-templates.rb +++ b/tests/system/get-mail-templates.rb @@ -10,6 +10,6 @@ describe'system/get-mail-templates' do (result['status']).should.equal('success') - (result['data'].size).should.equal(10) + (result['data'].size).should.equal(14) end end From 8ce33a2e4091c4da25996ee79228d073d203a5f5 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 16 Jan 2017 17:11:45 -0300 Subject: [PATCH 25/35] Guillermo - disable-user-system [skip ci] --- server/controllers/system.php | 1 + server/controllers/system/init-settings.php | 3 +-- server/data/ERRORS.php | 4 ++-- tests/init.rb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/controllers/system.php b/server/controllers/system.php index 18f96ccc..99ae4d82 100644 --- a/server/controllers/system.php +++ b/server/controllers/system.php @@ -16,6 +16,7 @@ require_once 'system/enabled-user-system.php'; require_once 'system/add-api-key.php'; require_once 'system/delete-api-key.php'; require_once 'system/get-all-keys.php'; +require_once 'system/get-stats.php'; require_once 'system/delete-all-users.php'; require_once 'system/backup-database.php'; require_once 'system/download.php'; diff --git a/server/controllers/system/init-settings.php b/server/controllers/system/init-settings.php index 3ce00b75..808fafd5 100644 --- a/server/controllers/system/init-settings.php +++ b/server/controllers/system/init-settings.php @@ -42,8 +42,7 @@ class InitSettingsController extends Controller { 'title' => 'Support Center', 'url' => 'http://www.opensupports.com/support', 'registration' => true, - 'user-system-enabled' => true - 'registration' => true, + 'user-system-enabled' => true, 'last-stat-day' => '20170101', //TODO: get current date 'ticket-gap' => Hashing::generateRandomPrime(100000, 999999), 'file-gap' => Hashing::generateRandomPrime(100000, 999999), diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php index 6e2921b8..1f49d6de 100644 --- a/server/data/ERRORS.php +++ b/server/data/ERRORS.php @@ -36,8 +36,8 @@ class ERRORS { const INVALID_SUBJECT = 'INVALID_SUBJECT'; const INVALID_BODY = 'INVALID_BODY'; const USER_SYSTEM_DISABLED= 'USER_SYSTEM_DISABLED'; - const SYSTEM_USER_IS_ALREADY_DISABLED= 'SYSTEM_USER_IS_ALREADY_DISABLED'; - const SYSTEM_USER_IS_ALREADY_ENABLED= 'SYSTEM_USER_IS_ALREADY_ENABLED'; + const SYSTEM_USER_IS_ALREADY_DISABLED = 'SYSTEM_USER_IS_ALREADY_DISABLED'; + const SYSTEM_USER_IS_ALREADY_ENABLED = 'SYSTEM_USER_IS_ALREADY_ENABLED'; const INVALID_PERIOD = 'INVALID_PERIOD'; const NAME_ALREADY_USED = 'NAME_ALREADY_USED'; const INVALID_FILE = 'INVALID_FILE'; diff --git a/tests/init.rb b/tests/init.rb index 75c8b75e..90a63e4b 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -53,9 +53,9 @@ require './system/edit-mail-template.rb' require './system/recover-mail-template.rb' require './system/disable-registration.rb' require './system/enable-registration.rb' -require './system/disable-user-system.rb' require './system/get-stats.rb' require './system/add-api-key.rb' require './system/delete-api-key.rb' require './system/get-all-keys.rb' require './system/file-upload-download.rb' +require './system/disable-user-system.rb' From c4b63aab4347bc026069fd27189b23a5a7217073 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 16 Jan 2017 18:04:26 -0300 Subject: [PATCH 26/35] Guillermo - disable-user-system [skip ci] --- server/controllers/system/csv-import.php | 4 ++++ server/controllers/ticket/comment.php | 4 +++- server/controllers/ticket/create.php | 4 +++- tests/init.rb | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/controllers/system/csv-import.php b/server/controllers/system/csv-import.php index e415c6f1..ea3093b8 100644 --- a/server/controllers/system/csv-import.php +++ b/server/controllers/system/csv-import.php @@ -13,6 +13,10 @@ class CSVImportController extends Controller { public function handler() { $fileUploader = $this->uploadFile(); + if(!$fileUploader instanceof FileUploader) { + throw new Exception(ERRORS::INVALID_FILE); + } + $file = fopen($fileUploader->getFullFilePath(),'r'); $errors = []; diff --git a/server/controllers/ticket/comment.php b/server/controllers/ticket/comment.php index 2b5c90b9..9c27dc17 100644 --- a/server/controllers/ticket/comment.php +++ b/server/controllers/ticket/comment.php @@ -47,10 +47,12 @@ class CommentController extends Controller { } private function storeComment() { + $fileUploader = $this->uploadFile(); + $comment = Ticketevent::getEvent(Ticketevent::COMMENT); $comment->setProperties(array( 'content' => $this->content, - 'file' => $this->uploadFile()->getFileName(), + 'file' => ($fileUploader instanceof FileUploader) ? $fileUploader->getFileName() : null, 'date' => Date::getCurrentDate() )); diff --git a/server/controllers/ticket/create.php b/server/controllers/ticket/create.php index 1a07a0cb..4b761dc5 100644 --- a/server/controllers/ticket/create.php +++ b/server/controllers/ticket/create.php @@ -53,6 +53,8 @@ class CreateController extends Controller { $department = Department::getDataStore($this->departmentId); $author = Controller::getLoggedUser(); + $fileUploader = $this->uploadFile(); + $ticket = new Ticket(); $ticket->setProperties(array( 'title' => $this->title, @@ -60,7 +62,7 @@ class CreateController extends Controller { 'language' => $this->language, 'author' => $author, 'department' => $department, - 'file' => $this->uploadFile()->getFileName(), + 'file' => ($fileUploader instanceof FileUploader) ? $fileUploader->getFileName() : null, 'date' => Date::getCurrentDate(), 'unread' => false, 'unreadStaff' => true, diff --git a/tests/init.rb b/tests/init.rb index 1ecc936f..dad08d9a 100644 --- a/tests/init.rb +++ b/tests/init.rb @@ -59,3 +59,4 @@ require './system/add-api-key.rb' require './system/delete-api-key.rb' require './system/get-all-keys.rb' require './system/file-upload-download.rb' +require './system/csv-import.rb' From 78a98b9d0e3823e968f580ec91572792a7b40df2 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 16 Jan 2017 18:15:28 -0300 Subject: [PATCH 27/35] Guillermo - disable-user-system [skip ci] --- .../system/disable-user-system.php | 1 + .../system/enabled-user-system.php | 48 ++++++++++--------- server/controllers/system/init-settings.php | 2 +- server/data/ERRORS.php | 2 +- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/server/controllers/system/disable-user-system.php b/server/controllers/system/disable-user-system.php index cc1eee83..fc1cc0a1 100644 --- a/server/controllers/system/disable-user-system.php +++ b/server/controllers/system/disable-user-system.php @@ -52,6 +52,7 @@ class DisableUserSystemController extends Controller { $user->delete(); } + Response::respondSuccess(); } } \ No newline at end of file diff --git a/server/controllers/system/enabled-user-system.php b/server/controllers/system/enabled-user-system.php index fb6b2d3a..0139608a 100644 --- a/server/controllers/system/enabled-user-system.php +++ b/server/controllers/system/enabled-user-system.php @@ -33,28 +33,7 @@ class EnabledUserSystemController extends Controller { $userRow = User::getDataStore($ticket->authorEmail, 'email'); if($userRow->isNull()) { - $userInstance = new User(); - - $password = Hashing::generateRandomToken(); - - $userInstance->setProperties([ - 'name' => $ticket->authorName, - 'signupDate' => Date::getCurrentDate(), - 'tickets' => 1, - 'email' => $ticket->authorEmail, - 'password' => Hashing::hashPassword($password), - 'verificationToken' => null - ]); - - $userInstance->store(); - - $mailSender = new MailSender(); - $mailSender->setTemplate(MailTemplate::USER_SYSTEM_ENABLED, [ - 'to' => $ticket->authorEmail, - 'name' => $ticket->authorName, - 'password' => $password - ]); - $mailSender->send(); + $this->createUser($ticket->authorEmail,$ticket->authorName); } else { $userRow->tickets = $userRow->tickets + 1; @@ -71,4 +50,29 @@ class EnabledUserSystemController extends Controller { Response::respondSuccess(); } + public function createUser($email,$name) { + $userInstance = new User(); + + $password = Hashing::generateRandomToken(); + + $userInstance->setProperties([ + 'name' => $name, + 'signupDate' => Date::getCurrentDate(), + 'tickets' => 1, + 'email' => $email, + 'password' => Hashing::hashPassword($password), + 'verificationToken' => null + ]); + + $userInstance->store(); + + $mailSender = new MailSender(); + $mailSender->setTemplate(MailTemplate::USER_SYSTEM_ENABLED, [ + 'to' => $email, + 'name' => $name, + 'password' => $password + ]); + $mailSender->send(); + + } } \ No newline at end of file diff --git a/server/controllers/system/init-settings.php b/server/controllers/system/init-settings.php index 808fafd5..4106797b 100644 --- a/server/controllers/system/init-settings.php +++ b/server/controllers/system/init-settings.php @@ -38,7 +38,7 @@ class InitSettingsController extends Controller { 'maintenance-mode' => 0, 'layout' => 'boxed', 'allow-attachments' => 0, - 'max-size' => 0, + 'max-size' => 1024, 'title' => 'Support Center', 'url' => 'http://www.opensupports.com/support', 'registration' => true, diff --git a/server/data/ERRORS.php b/server/data/ERRORS.php index 1f49d6de..d75c7e2b 100644 --- a/server/data/ERRORS.php +++ b/server/data/ERRORS.php @@ -35,7 +35,7 @@ class ERRORS { const INVALID_TEMPLATE = 'INVALID_TEMPLATE'; const INVALID_SUBJECT = 'INVALID_SUBJECT'; const INVALID_BODY = 'INVALID_BODY'; - const USER_SYSTEM_DISABLED= 'USER_SYSTEM_DISABLED'; + const USER_SYSTEM_DISABLED = 'USER_SYSTEM_DISABLED'; const SYSTEM_USER_IS_ALREADY_DISABLED = 'SYSTEM_USER_IS_ALREADY_DISABLED'; const SYSTEM_USER_IS_ALREADY_ENABLED = 'SYSTEM_USER_IS_ALREADY_ENABLED'; const INVALID_PERIOD = 'INVALID_PERIOD'; From e44792c3de5cb723bfe4cf14176e9f02d837674b Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 16 Jan 2017 20:06:08 -0300 Subject: [PATCH 28/35] Ivan - Add csv file [skip ci] --- tests/system/csv-import.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/system/csv-import.rb diff --git a/tests/system/csv-import.rb b/tests/system/csv-import.rb new file mode 100644 index 00000000..61ac34ba --- /dev/null +++ b/tests/system/csv-import.rb @@ -0,0 +1,28 @@ +describe'system/csv-import' do + request('/user/logout') + Scripts.login($staff[:email], $staff[:password], true) + + it 'should create user with csv-import' do + + file = File.new('../server/files/test.csv', 'w+') + file.puts('prueba1@hotmail.com, contrasena1,ma') + file.puts('prueba2@hotmail.com,contrasena2,max') + file.puts('prueba3@hotmail.com,contrasena3,maxi') + file.close + result= request('/system/csv-import', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + file: File.open( "../server/files/test.csv") + }) + + (result['status']).should.equal('success') + row = $database.getRow('user', 'prueba1@hotmail.com', 'email') + (row['name']).should.equal('ma') + + row = $database.getRow('user', 'prueba2@hotmail.com', 'email') + (row['name']).should.equal('max') + + row = $database.getRow('user', 'prueba3@hotmail.com', 'email') + (row['name']).should.equal('maxi') + end +end From 6ff0dbdf6b995b17deb4f69d4b959d77aece9818 Mon Sep 17 00:00:00 2001 From: AntonyAntonio Date: Mon, 16 Jan 2017 21:05:11 -0300 Subject: [PATCH 29/35] Guillermo - Add user system test [skip ci] --- tests/system/disable-user-system.rb | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 tests/system/disable-user-system.rb diff --git a/tests/system/disable-user-system.rb b/tests/system/disable-user-system.rb new file mode 100644 index 00000000..076fdb23 --- /dev/null +++ b/tests/system/disable-user-system.rb @@ -0,0 +1,89 @@ +describe'system/disable-user-system' do + request('/user/logout') + Scripts.login($staff[:email], $staff[:password], true) + + it 'should disable the user system' do + result = request('/system/disable-user-system', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + password:$staff[:password] + }) + + puts result['message'] + (result['status']).should.equal('success') + + row = $database.getRow('setting', 'user-system-enabled', 'name') + + (row['value']).should.equal('0') + row = $database.getRow('user', 1, 'id') + (row).should.equal(nil) + + numberOftickets= $database.query("SELECT * FROM ticket WHERE author_id IS NULL AND author_email IS NOT NULL AND author_name IS NOT NULL") + + (numberOftickets.num_rows).should.equal(35) + + request('/user/logout') + + result = request('/user/signup', { + :name => 'test name', + :email => 'steve@mail.com', + :password => 'customm' + }) + + (result['status']).should.equal('fail') + (result['message']).should.equal('USER_SYSTEM_DISABLED') + + result = request('/user/login', { + email: @loginEmail, + password: @loginPass + }) + + (result['status']).should.equal('fail') + (result['message']).should.equal('USER_SYSTEM_DISABLED') + end + + it 'should not disable the user system if it is already disabled 'do + request('/user/logout') + Scripts.login($staff[:email], $staff[:password], true) + + result = request('/system/disable-user-system', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + password:$staff[:password] + }) + + (result['status']).should.equal('fail') + (result['message']).should.equal('SYSTEM_USER_IS_ALREADY_DISABLED') + end + + it 'should enabled the user system' do + result = request('/system/enabled-user-system', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + password:$staff[:password] + }) + + puts result['message'] + (result['status']).should.equal('success') + + row = $database.getRow('setting', 'user-system-enabled', 'name') + (row['value']).should.equal('1') + + numberOftickets= $database.query("SELECT * FROM ticket WHERE author_email IS NULL AND author_name IS NULL AND author_id IS NOT NULL" ) + + (numberOftickets.num_rows).should.equal(35) + + end + + it 'should not enabled the user system' do + result = request('/system/enabled-user-system', { + csrf_userid: $csrf_userid, + csrf_token: $csrf_token, + password:$staff[:password] + }) + + (result['status']).should.equal('fail') + (result['message']).should.equal('SYSTEM_USER_IS_ALREADY_ENABLED') + + end +end From a40121111efdaac2322cfe7230b1dc9a90a9749e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 14:58:28 -0300 Subject: [PATCH 30/35] Max Red - modified registration setting in fixtures [skip ci] --- client/src/data/fixtures/system-fixtures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index ecf3916e..ddff91bd 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -20,7 +20,7 @@ module.exports = [ 'smtp-user': 'Wesa', 'maintenance-mode': false, 'allow-attachments': true, - 'registration': false, + 'registration': true, 'max-size': 500, 'departments': [ {id: 1, name: 'Sales Support', owners: 2}, From 4fb1c32cbca114f2c515c340efdb49abaa0c4a86 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 15:09:00 -0300 Subject: [PATCH 31/35] Max Red - beautified code by replacing a for for a map (: [skip ci] --- client/src/app-components/stats-chart.js | 1 - client/src/app-components/stats.js | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index 5e4704b7..1ed7480e 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -93,7 +93,6 @@ class StatsChart extends React.Component { } }; } - } diff --git a/client/src/app-components/stats.js b/client/src/app-components/stats.js index 337bf446..a93e67dd 100644 --- a/client/src/app-components/stats.js +++ b/client/src/app-components/stats.js @@ -149,14 +149,14 @@ class Stats extends React.Component { let realPeriod = result.data.length / this.getStrokes().length; - for (let i = 0; i < result.data.length; i++) { - newStats[result.data[i].type] += result.data[i].value * 1; + result.data.map((item) => { + newStats[item.type] += item.value * 1; - newStrokes[ ID[result.data[i].type] ].values.push({ - date: result.data[i].date, - value: result.data[i].value * 1 + newStrokes[ ID[item.type] ].values.push({ + date: item.date, + value: item.value * 1 }); - } + }); this.setState({stats: newStats, strokes: newStrokes, period: realPeriod}); } From fda6e798a027682d93a6e6e7f541edfd7487386b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 15:26:18 -0300 Subject: [PATCH 32/35] Max Red - problems with displaying stats in admin-panel-my-account view, Ivan fixed it [skip ci] --- client/src/app/admin/panel/dashboard/admin-panel-stats.js | 2 +- client/src/data/languages/en.js | 1 + client/src/reducers/session-reducer.js | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index 5e992ffb..fbbd9f7e 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -9,7 +9,7 @@ class AdminPanelStats extends React.Component { render() { return (
-
+
); diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index c79a2ae8..3c086c8a 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -222,6 +222,7 @@ export default { 'SYSTEM_PREFERENCES_DESCRIPTION': 'Here you can edit the preferences of the system.', 'VERIFY_SUCCESS_DESCRIPTION': 'You user has been verified correctly. You can log in now.', 'VERIFY_FAILED_DESCRIPTION': 'The verification could not be done.', + 'TICKET_ACTIVITY_DESCRIPTION': 'Here you can view ', //ERRORS 'EMAIL_OR_PASSWORD': 'Email or password invalid', diff --git a/client/src/reducers/session-reducer.js b/client/src/reducers/session-reducer.js index c1eca34f..a51d7e67 100644 --- a/client/src/reducers/session-reducer.js +++ b/client/src/reducers/session-reducer.js @@ -119,6 +119,7 @@ class SessionReducer extends Reducer { onSessionChecked(state) { let userData = sessionStore.getUserData(); + let userId = sessionStore.getSessionData().userId; return _.extend({}, state, { initDone: true, @@ -129,7 +130,8 @@ class SessionReducer extends Reducer { userProfilePic: userData.profilePic, userLevel: userData.level, userDepartments: userData.departments, - userTickets: userData.tickets + userTickets: userData.tickets, + userId: userId }); } From f1c82dc38445915b1bd17c168376453959ead179 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 15:50:33 -0300 Subject: [PATCH 33/35] Max Red - beautified code a little bit more replacing another for for another map [skip ci] --- client/src/app-components/stats-chart.js | 17 +++++++++-------- client/src/app/admin/panel/admin-panel-menu.js | 2 +- .../admin/panel/dashboard/admin-panel-stats.js | 2 +- client/src/data/languages/en.js | 8 ++++---- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/client/src/app-components/stats-chart.js b/client/src/app-components/stats-chart.js index 1ed7480e..ca1a2d49 100644 --- a/client/src/app-components/stats-chart.js +++ b/client/src/app-components/stats-chart.js @@ -66,14 +66,15 @@ class StatsChart extends React.Component { let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; let labels = []; - for (let i = 0; i < this.props.period; i++) { - if (!this.props.strokes.length){ - labels.push(''); - continue; - } - let firstList = this.props.strokes[0]; - let idx = firstList.values[i].date.slice(4, 6) - 1; - labels.push( firstList.values[i].date.slice(6, 8) + ' ' + months[idx]); + if (!this.props.strokes.length) { + labels = Array.from('x'.repeat(this.props.period)); + } + else { + labels = this.props.strokes[0].values.map((item) => { + let idx = item.date.slice(4, 6) - 1; + + return item.date.slice(6, 8) + ' ' + months[idx]; + }); } return labels; diff --git a/client/src/app/admin/panel/admin-panel-menu.js b/client/src/app/admin/panel/admin-panel-menu.js index 7112320d..976d7c96 100644 --- a/client/src/app/admin/panel/admin-panel-menu.js +++ b/client/src/app/admin/panel/admin-panel-menu.js @@ -99,7 +99,7 @@ class AdminPanelMenu extends React.Component { level: 1, items: this.getItemsByFilteredByLevel([ { - name: i18n('TICKET_STATS'), + name: i18n('STATISTICS'), path: '/admin/panel/stats', level: 1 }, diff --git a/client/src/app/admin/panel/dashboard/admin-panel-stats.js b/client/src/app/admin/panel/dashboard/admin-panel-stats.js index fbbd9f7e..c5452e50 100644 --- a/client/src/app/admin/panel/dashboard/admin-panel-stats.js +++ b/client/src/app/admin/panel/dashboard/admin-panel-stats.js @@ -9,7 +9,7 @@ class AdminPanelStats extends React.Component { render() { return (
-
+
); diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js index 3c086c8a..b72a8e69 100644 --- a/client/src/data/languages/en.js +++ b/client/src/data/languages/en.js @@ -36,7 +36,7 @@ export default { 'DASHBOARD': 'Dashboard', 'USERS': 'Users', 'SETTINGS': 'Settings', - 'TICKET_STATS': 'Ticket Stats', + 'STATISTICS': 'Statistics', 'LAST_ACTIVITY': 'Last Activity', 'MY_TICKETS': 'My Tickets', 'NEW_TICKETS': 'New Tickets', @@ -152,7 +152,7 @@ export default { 'ALL_NOTIFICATIONS': 'All notifications', 'VERIFY_SUCCESS': 'User verified', 'VERIFY_FAILED': 'Could not verify', - 'TICKET_ACTIVITY': 'Ticket Activity', + 'STATISTICS': 'Statistics', 'ACTIVITY': 'Activity', @@ -211,7 +211,7 @@ export default { 'ADD_ARTICLE_DESCRIPTION': 'Here you can add an article that will be available for every user. It will be added inside the category {category}.', 'LIST_ARTICLES_DESCRIPTION': 'This is a list of articles that includes information about our services.', 'ADD_TOPIC_DESCRIPTION': 'Here you can add a topic that works as a category for articles.', - 'DELETE_ARTICLE_DESCRIPTION': 'You\'re going to delete this article for ever.', + 'DELETE_ARTICLE_DESCRIPTION': 'You\'re going to delete this article forever.', 'STAFF_MEMBERS_DESCRIPTION': 'Here you can see who are your staff members.', 'ADD_STAFF_DESCRIPTION': 'Here you can add staff members to your teams.', 'EDIT_STAFF_DESCRIPTION': 'Here you can edit information about a staff member.', @@ -222,7 +222,7 @@ export default { 'SYSTEM_PREFERENCES_DESCRIPTION': 'Here you can edit the preferences of the system.', 'VERIFY_SUCCESS_DESCRIPTION': 'You user has been verified correctly. You can log in now.', 'VERIFY_FAILED_DESCRIPTION': 'The verification could not be done.', - 'TICKET_ACTIVITY_DESCRIPTION': 'Here you can view ', + 'STATISTICS_DESCRIPTION': 'Here you can view statistics related to tickets and signups.', //ERRORS 'EMAIL_OR_PASSWORD': 'Email or password invalid', From 26d26320c927a26b426caf2c0bbd2c36069d8c8c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 15:52:12 -0300 Subject: [PATCH 34/35] Max Red - deleted console.logs from system-fixtures [skip ci] --- client/src/data/fixtures/system-fixtures.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js index 658e4ad7..51f64179 100644 --- a/client/src/data/fixtures/system-fixtures.js +++ b/client/src/data/fixtures/system-fixtures.js @@ -216,10 +216,6 @@ module.exports = [ } } - console.log('DATA:'); - console.log(DATA); - console.log(k); - return { status: "success", data: DATA From bce56d7b0503c6df80804b7993dc7818b1dff467 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Jan 2017 15:53:43 -0300 Subject: [PATCH 35/35] Max Red - make toggle list unselectable and not able to change cursor view [skip ci] --- client/src/core-components/toggle-list.scss | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/core-components/toggle-list.scss b/client/src/core-components/toggle-list.scss index 1fdd82e5..1ba34f67 100644 --- a/client/src/core-components/toggle-list.scss +++ b/client/src/core-components/toggle-list.scss @@ -9,6 +9,8 @@ height: 120px; display: inline-block; transition: box-shadow 0.2s ease-in-out; + user-select: none; + cursor: default; } &__selected {