fix development environment, fix resp vacaciones, add nodemon for dev, y prop-types packages

parent 411915d1
......@@ -4,6 +4,9 @@
dist
src/config
node_modules
.history
*.zip
.vagrant
/path.json
./path.json
.npminstall
......
1.5:5dc6ad1e-bcee-42fd-9310-3736c040cf90
\ No newline at end of file
5dc6ad1e-bcee-42fd-9310-3736c040cf90
\ No newline at end of file
c4c8e8aa02ab4bcfa7eb51a3b350c71e
\ No newline at end of file
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAmOtAU9rkxwDGG8ug6vkfOwJ+Gm4+9T2vzf//4DY48Ud7Oux8
1q2JOCT/usGqOYxZ7zwok5bb3wQAnglRCyWZmpw4Kxzq5U8FCaHGZFddAs6Yiqqr
amipsQSzSmzZ5V0ASKXe6vk/WmGoL+RQuoCBwxvAZd9NhjPRROcI+vjnHZ+dLnwq
QDgG5cJsrzhhfRowGomcoYnk2U0rKxWWMmAWcOYiAiiBbUjW/0FZeL6TJq9TbhmV
bPcSGWxi63NUPPwZ8YHRHMB/OqaIbBGQTfb+rwopq+yHj2uqoqy+w+95H0vt7QCe
DvHcOD2iknsna66vBiU6yQzHCa7q1FAo5/F98QIDAQABAoIBAQCBvV6nhpkBqktq
u7o8gb6Yf0XkQNMTmRG2klNStE5dj0sjNA+6yCMaynFZzwQQrV6EViMLDTxgm3G2
o6rp7S3EenRBR9iXUxKwGFxNN74HKqdLRwAGWORX9ufy5iV8rwoVmP1nmK7CjQZ4
E5rWkT8G/V2gUPPiP8Z2UhpRbKoRe9HM0grgBC0wvXEyQ2l0CZMU5o5bJBi/ed62
qZu9xL9/CAyKdVIfR2CDUWXi+yHgS3+9kKloZNwwLxeCWaJEGtxUsWpe2oc7fD6c
UK/unpJcjqdO0SDX+78XLQYnOjt+flqpKlzvhQW+FUk89TfWssC+XBIXKbaSFEMP
QthLXBqdAoGBAMej2Awx6ahseRF9goDk7Fa9xFH2kj7V3w8bNDOQ5xfq83fz1yQf
sGDt6X8dajUPSBD5LnjiLIL2fovQGEfTV7eiCJekNQXMNvGCeLEFUnovjRP9FfL1
J/bMmVQzaito6UVIyrl0Ehw0OKzlu9MAW6Ka5cPdZhwAFTxDkJJjDXvjAoGBAMQW
1e9Qqz72w03x7XDF/B63Q+qKeEN+L39+XzjIWzkdmUrFvD7HrLqxWnZnwX+ZDVxD
IM8Rud3gAMc4hZLMIuk4jRFXMFYfay7W7SFPLZg2R31G5Q6mvSAPUCbQg/cOUbXh
XvATAhcxeHlo7WdS7LrzDhHssnN+tvtGp9LlWm8bAoGAChYGAT+4TVEFoNOVd0uZ
gRxfQcDSTKhjd5DpRz2n3zZ4jHPeR63uLEd4x3pF9l5KRslABs1ucENhy1B9GYvc
36MpCfg60Ysqr3LnBBJ/wzqJxxu/MyIdncNib7WVRJItTtnJnCr4C0K8JkgJADUB
bCqlNwsFcJ60c/H56NtmP/8CgYBFxjpp5bKJvRTR73wl3M1RwLSSCKOyoHwWSclo
UyLit/2L9cB+Nl7oL6OY7mKUHMn8QoayKASTRtoACcS975Wcl1rbCMNSYeupxyCp
8ZqvxuC5Wzi2de5mMgy7QwcyKg45QfCeTKU5y4iq6wNO+Nrzyvj+t9Ln9fb2grXE
/YeocQKBgQCAU7aq4U6Fm6nWL9n8pzkn+A2YHWnk9TfwMsnY3Q91Gu6/PSOvO0Qj
4YI4Tm5kPnmxqCl9NTu81cS9+x5Pc6jFqXOIM1hoLYNsyxUSd223eugO9jNpEs3W
5infFbB4MO5fGUAfXYav0BNpI1o9EugP9A9iX2PgBMwMtG7sI3k8Ig==
-----END RSA PRIVATE KEY-----
{"virtualbox":{"/opt/zimbra/zimlets-deployed/_dev":{"guestpath":"/opt/zimbra/zimlets-deployed/_dev","hostpath":"/Applications/MAMP/htdocs/manager-react/src","disabled":false,"__vagrantfile":true},"/vagrant":{"guestpath":"/vagrant","hostpath":"/Applications/MAMP/htdocs/manager-react","disabled":false,"__vagrantfile":true}}}
\ No newline at end of file
......@@ -23,7 +23,13 @@ build: | install test
@npm run build
run: | install start-server
# comment out to avoid install every restart server
# run: | install start-server
# @echo Running ZBox Manager Webapp for development
# @npm run run &
run: | start-server
@echo Running ZBox Manager Webapp for development
@npm run run &
......
This diff is collapsed.
......@@ -19,6 +19,7 @@
"node-sass": "^3.8.0",
"nprogress": "^0.2.0",
"object-assign": "4.0.1",
"prop-types": "^15.6.1",
"react": "15.0.1",
"react-bootstrap": "0.29.2",
"react-bootstrap-datetimepicker": "0.0.22",
......@@ -31,10 +32,11 @@
"react-toastr": "^2.6.0",
"sweetalert": "^1.1.3",
"toastr": "^2.1.2",
"zimbra-admin-api-js": "ZBoxApp/zimbra-admin-api-js#manager"
"zimbra-admin-api-js": "git+https://github.com/ZBoxApp/zimbra-admin-api-js.git#manager"
},
"devDependencies": {
"assets-webpack-plugin": "^3.4.0",
"axios": "^0.18.0",
"babel-cli": "^6.18.0",
"babel-eslint": "6.0.4",
"babel-loader": "^6.2.7",
......@@ -44,7 +46,7 @@
"babel-preset-react": "6.5.0",
"babel-preset-stage-0": "6.5.0",
"babel-runtime": "^6.6.1",
"body-parser": "^1.15.0",
"body-parser": "^1.18.3",
"cookie-parser": "^1.4.1",
"copy-webpack-plugin": "2.1.3",
"cors": "^2.7.1",
......@@ -53,7 +55,8 @@
"eslint": "2.8.0",
"eslint-plugin-react": "5.0.1",
"exports-loader": "0.6.3",
"express": "^4.13.4",
"express": "^4.16.3",
"express-http-proxy": "^1.2.0",
"extract-text-webpack-plugin": "1.0.1",
"file-loader": "0.8.5",
"html-loader": "0.4.3",
......@@ -62,7 +65,10 @@
"imports-loader": "0.6.5",
"json-loader": "0.5.4",
"morgan": "^1.7.0",
"nodemon": "^1.17.5",
"npm-run-all": "^4.1.3",
"raw-loader": "0.5.1",
"request": "^2.87.0",
"sass-loader": "3.2.0",
"style-loader": "0.13.1",
"url-loader": "0.5.7",
......@@ -75,7 +81,8 @@
"run": "webpack --progress --watch",
"run-fullmap": "webpack --progress --watch",
"companies-service": "babel-node companies-service.js",
"server": "babel-node server.js",
"sales-service": "babel-node sales-services.js"
"server": "nodemon server.js",
"sales-service": "babel-node sales-services.js",
"start-webapp": "NODE_ENV=development npm-run-all --parallel run server"
}
}
module.exports = {"main":{"js":"/209210bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/996870bundle.js"}}
\ No newline at end of file
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
const proxy = require('express-http-proxy');
const env = typeof process.env.NODE_ENV === 'undefined' ? 'development' : process.env.NODE_ENV;
const configPath = env === 'development' ? './src/config/config.development.json' : './src/config/config.json';
const config = require(configPath);
const express = require('express');
const server = express();
const bodyParser = require('body-parser');
const port = process.env.PORT || 8000;
const http = require('http');
const fs = require('fs');
const path = require('path');
const httpProxy = require('http-proxy');
const config = require('./src/config/config.json');
const managerProxyURL = process.env.managerProxy || config.managerProxy; //eslint-disable-line no-process-env
const URlsToProxy = ['/zimbra_proxy', '/powerdns_proxy', '/folio'];
const mimes = {
js: 'text/javascript',
json: 'application/json',
css: 'text/css',
png: 'image/png',
jpg: 'image/jpg',
svg: 'image/svg+xml',
eot: 'application/vnd.ms-fontobject',
woff2: 'application/font-woff2',
woff: 'application/font-woff',
ttf: 'application/x-font-truetype'
};
server.use(bodyParser.json());
server.use(bodyParser.urlencoded({ extended: true }));
server.use(express.static(__dirname + '/dist'));
const proxy = httpProxy.createProxyServer({});
// server.post('/*', proxy(managerProxyURL));
const server = http.createServer((req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
const zimbraProxy = process.env.zimbra || config.zimbraProxy; //eslint-disable-line no-process-env
server.all('/*', (req, res) => {
const hasToBeProxied = URlsToProxy.find((endpoint) => req.url.toString().startsWith(endpoint));
if (req.url.indexOf('/service') === 0) {
return proxy.web(req, res, {target: zimbraProxy, secure: false});
if (hasToBeProxied) {
return proxy(managerProxyURL)(req, res);
}
const mime = (/^\/[a-zA-Z0-9\/]*\.(js|json|css|jpg|png|gif|svg|ttf|eot|woff|woff2)$/).exec(req.url.toString());
if (mime) {
const ext = mime[1];
const filename = path.join(__dirname, 'dist', req.url.toString().substring(1));
return sendFileContent(res, filename, mimes[ext]);
}
return sendFileContent(res, 'dist/index.html', 'text/html');
res.sendFile(__dirname + '/dist/index.html');
});
server.listen(8000);
server.on('listening', () => {
const addr = server.address();
const bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
console.info('ZBox Manager 2.0 Test Server listening on ' + bind); //eslint-disable-line no-console
server.listen(port, () => {
console.log("ZBox Manager 1.5 is running at port:", port);
});
function sendFileContent(response, fileName, contentType) {
fs.readFile(fileName, (err, data) => {
if (err) {
response.writeHead(404);
response.write('Not Found!');
} else {
response.writeHead(200, {'Content-Type': contentType});
response.write(data);
}
response.end();
});
}
import React from 'react';
import PropTypes from 'prop-types';
import * as Utils from '../../utils/utils.jsx';
......@@ -59,7 +60,7 @@ export default class NotFound404 extends React.Component {
}
NotFound404.propTypes = {
location: React.PropTypes.object
location: PropTypes.object
};
class ZBoxShip {
......
import React from 'react';
import PropTypes from 'prop-types';
export default class Alert extends React.Component {
constructor() {
......@@ -49,10 +50,10 @@ export default class Alert extends React.Component {
}
Alert.propTypes = {
className: React.PropTypes.string,
iconClass: React.PropTypes.string,
withClose: React.PropTypes.bool,
children: React.PropTypes.any
className: PropTypes.string,
iconClass: PropTypes.string,
withClose: PropTypes.bool,
children: PropTypes.any
};
Alert.defaultProps = {
......
import React from 'react';
import PropTypes from 'prop-types';
export default class Anchor extends React.Component {
render() {
......@@ -15,12 +16,12 @@ export default class Anchor extends React.Component {
}
Anchor.propTypes = {
badgeName: React.PropTypes.string,
isBadge: React.PropTypes.bool,
badgeClass: React.PropTypes.string,
url: React.PropTypes.string,
label: React.PropTypes.string,
attrs: React.PropTypes.object
badgeName: PropTypes.string,
isBadge: PropTypes.bool,
badgeClass: PropTypes.string,
url: PropTypes.string,
label: PropTypes.string,
attrs: PropTypes.object
};
Anchor.defaultProps = {
......
import React from 'react';
import PropTypes from 'prop-types';
export default class Button extends React.Component {
render() {
......@@ -9,9 +10,6 @@ export default class Button extends React.Component {
}
Button.propTypes = {
btnAttrs: React.PropTypes.object,
children: React.PropTypes.any
};
Button.defaultProps = {
btnAttrs: PropTypes.object,
children: PropTypes.any
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import MessageBar from '../message_bar.jsx';
......@@ -365,5 +366,5 @@ export default class Companies extends React.Component {
}
Companies.propTypes = {
location: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import _ from 'lodash';
import Promise from 'bluebird';
......@@ -191,6 +192,6 @@ export default class CompanyAdmins extends React.Component {
}
CompanyAdmins.propTypes = {
company: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired
company: PropTypes.object.isRequired,
location: PropTypes.object.isRequired
};
......@@ -4,6 +4,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import CompanyInfo from './company_info.jsx';
......@@ -217,6 +218,6 @@ export default class CompaniesDetails extends React.Component {
}
CompaniesDetails.propTypes = {
location: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired,
params: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import UserStore from '../../stores/user_store.jsx';
import ZimbraStore from '../../stores/zimbra_store.jsx';
......@@ -150,6 +151,6 @@ export default class CompanyDomains extends React.Component {
}
CompanyDomains.propTypes = {
company: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired
company: PropTypes.object.isRequired,
location: PropTypes.object.isRequired
};
......@@ -4,6 +4,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import Panel from '../panel.jsx';
......@@ -35,5 +36,5 @@ export default class CompanyInfo extends React.Component {
}
CompanyInfo.propTypes = {
company: React.PropTypes.object.isRequired
company: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import _ from 'lodash';
......@@ -27,35 +28,32 @@ export default class CompanyInvoices extends React.Component {
componentDidMount() {
this.getInvoices();
}
getInvoices() {
if (global.window.manager_config.companiesEndPoints.invoices) {
return Client.getInvoices(
this.props.company.id,
(invoices) => {
const hasDebt = _.find(invoices, {status: 2});
if (hasDebt) {
GlobalActions.showAlert({
type: 'error',
title: 'Cuenta con deuda',
body: 'Tiene una o más facturas impagas. Por favor corrija esta situación para prevenir un bloqueo de los servicios',
options: {
timeOut: 10000,
extendedTimeOut: 5000,
closeButton: true
}
});
}
this.setState({invoices});
},
(error) => {
this.setState({
error: {
message: error.message,
type: messageType.ERROR
Client.getInvoices(this.props.company.id).then((invoices) => {
const hasDebt = _.find(invoices, {status: 2});
if (hasDebt) {
GlobalActions.showAlert({
type: 'error',
title: 'Cuenta con deuda',
body: 'Tiene una o más facturas impagas. Por favor corrija esta situación para prevenir un bloqueo de los servicios',
options: {
timeOut: 10000,
extendedTimeOut: 5000,
closeButton: true
}
});
}
);
this.setState({invoices});
}).catch((error) => {
this.setState({
error: {
message: error.message,
type: messageType.ERROR
}
});
});
}
return this.setState({
......@@ -186,6 +184,6 @@ export default class CompanyInvoices extends React.Component {
}
CompanyInvoices.propTypes = {
company: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired
company: PropTypes.object.isRequired,
location: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import MessageBar from '../message_bar.jsx';
import Panel from '../panel.jsx';
......@@ -172,5 +173,5 @@ export default class CompanyMailboxPlans extends React.Component {
}
CompanyMailboxPlans.propTypes = {
company: React.PropTypes.object.isRequired
company: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import EventStore from '../../stores/event_store.jsx';
......@@ -509,6 +510,6 @@ export default class DistributionLists extends React.Component {
}
DistributionLists.propTypes = {
location: React.PropTypes.object,
params: React.PropTypes.object
location: PropTypes.object,
params: PropTypes.object
};
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import Button from '../button.jsx';
import MessageBar from '../message_bar.jsx';
import Panel from '../panel.jsx';
......@@ -255,6 +256,6 @@ export default class EditDistributionList extends React.Component {
}
EditDistributionList.propTypes = {
location: React.PropTypes.object,
params: React.PropTypes.any
location: PropTypes.object,
params: PropTypes.any
};
......@@ -15,6 +15,7 @@ import StatusLabel from '../status_label.jsx';
import {Modal} from 'react-bootstrap';
import React from 'react';
import PropTypes from 'prop-types';
export default class AddAdminModal extends React.Component {
constructor(props) {
......@@ -272,7 +273,7 @@ export default class AddAdminModal extends React.Component {
}
AddAdminModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
domain: React.PropTypes.object.isRequired
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired,
domain: PropTypes.object.isRequired
};
......@@ -10,6 +10,7 @@ import * as Utils from '../../utils/utils.jsx';
import {Modal} from 'react-bootstrap';
import React from 'react';
import PropTypes from 'prop-types';
export default class AddDistributionListModal extends React.Component {
constructor(props) {
......@@ -165,7 +166,7 @@ export default class AddDistributionListModal extends React.Component {
}
AddDistributionListModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
domain: React.PropTypes.object.isRequired
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired,
domain: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import Button from '../button.jsx';
import * as Client from '../../utils/client.jsx';
import * as Utils from '../../utils/utils.jsx';
......@@ -510,5 +511,5 @@ export default class AntiSpam extends React.Component {
}
AntiSpam.propTypes = {
data: React.PropTypes.object.isRequired
data: PropTypes.object.isRequired
};
//import * as Utils from '../../utils/utils.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import Panel from '../panel.jsx';
import CreateDomainForm from './multiform/create_domain_form.jsx';
import MailCleanerForm from './multiform/mailcleaner_form.jsx';
......@@ -174,6 +175,6 @@ export default class CreateDomain extends React.Component {
}
CreateDomain.propTypes = {
params: React.PropTypes.object.isRequired
params: PropTypes.object.isRequired
};
import React from 'react';
import PropTypes from 'prop-types';
import {FormGroup, Button, FormControl, InputGroup} from 'react-bootstrap';
import sweetAlert from 'sweetalert';
import * as Utils from '../../utils/utils.jsx';
......@@ -616,10 +617,10 @@ export default class DNSZoneForm extends React.Component {
}
DNSZoneForm.propTypes = {
domain: React.PropTypes.object,
zone: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.object
domain: PropTypes.object,
zone: PropTypes.oneOfType([
PropTypes.string,
PropTypes.object
]),
location: React.PropTypes.object
location: PropTypes.object
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import sweetAlert from 'sweetalert';
import DomainStore from '../../stores/domain_store.jsx';
......@@ -263,6 +264,6 @@ export default class DomainAdminList extends React.Component {
}
DomainAdminList.propTypes = {
domain: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired
domain: PropTypes.object.isRequired,
location: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
import Promise from 'bluebird';
......@@ -422,6 +423,6 @@ export default class DomainDetails extends React.Component {
}
DomainDetails.propTypes = {
location: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired,
params: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import sweetAlert from 'sweetalert';
import DomainStore from '../../stores/domain_store.jsx';
......@@ -309,6 +310,6 @@ export default class DomainDistributionList extends React.Component {
}
DomainDistributionList.propTypes = {
domain: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired
domain: PropTypes.object.isRequired,
location: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import Panel from '../panel.jsx';
......@@ -72,7 +73,13 @@ export default class DomainGeneralInfo extends React.Component {
}
}
renovationDate() {
const timestamp = moment(this.props.domain.attrs.zimbraCreateTimestamp);
const utc = Utils.getUTCTime(this.props.domain.attrs.zimbraCreateTimestamp);
if (!utc) {
return 'No disponible';
}
const timestamp = moment.utc(utc);
const now = moment();
timestamp.year(now.year());
if (timestamp.isBefore(now)) {
......@@ -188,7 +195,7 @@ export default class DomainGeneralInfo extends React.Component {
}
DomainGeneralInfo.propTypes = {
domain: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired
domain: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
params: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import MessageBar from '../message_bar.jsx';
import Panel from '../panel.jsx';
......@@ -226,7 +227,7 @@ export default class DomainMailboxPlans extends React.Component {
}
DomainMailboxPlans.propTypes = {
domain: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired
domain: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
params: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import MessageBar from '../message_bar.jsx';
......@@ -364,5 +365,5 @@ export default class Domains extends React.Component {
}
Domains.propTypes = {
location: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired
};
//import Textarea from 'react-textarea-autosize';
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
import MessageBar from '../message_bar.jsx';
......@@ -423,5 +424,5 @@ export default class EditDomain extends React.Component {
}
EditDomain.propTypes = {
params: React.PropTypes.object.isRequired
params: PropTypes.object.isRequired
};
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
import CompanyStore from '../../../stores/company_store.jsx';
......@@ -342,6 +343,6 @@ export default class CreateDomainForm extends React.Component {
}
CreateDomainForm.propTypes = {
params: React.PropTypes.object.isRequired,
state: React.PropTypes.object
params: PropTypes.object.isRequired,
state: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
import * as Utils from '../../../utils/utils.jsx';
import Constants from '../../../utils/constants.jsx';
......@@ -332,5 +333,5 @@ export default class DNSZoneForm extends React.Component {
}
DNSZoneForm.propTypes = {
state: React.PropTypes.object
state: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
import * as Utils from '../../../utils/utils.jsx';
import {browserHistory} from 'react-router';
......@@ -95,5 +96,5 @@ export default class MailCleanerForm extends React.Component {
}
MailCleanerForm.propTypes = {
state: React.PropTypes.object
state: PropTypes.object
};
......@@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import {Modal} from 'react-bootstrap';
import DateTimeField from 'react-bootstrap-datetimepicker';
import * as Client from '../../utils/client.jsx';
......@@ -406,7 +406,7 @@ export default class MultipleTaskModal extends React.Component {
}
MultipleTaskModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
data: React.PropTypes.object
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired,
data: PropTypes.object
};
......@@ -2,8 +2,8 @@
// See LICENSE.txt for license information.
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import {Link} from 'react-router';
export default class ErrorPage extends React.Component {
......@@ -37,8 +37,6 @@ export default class ErrorPage extends React.Component {
}
}
ErrorPage.defaultProps = {
};
ErrorPage.propTypes = {
location: React.PropTypes.object
location: PropTypes.object
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import {Modal} from 'react-bootstrap';
import * as GlobalActions from '../action_creators/global_actions.jsx';
import SelectCols from './select-col.jsx';
......@@ -537,6 +538,6 @@ export default class ImportMassiveModal extends React.Component {
}
ImportMassiveModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired
};
......@@ -8,6 +8,7 @@ import ToastAlert from './toast_alert.jsx';
import ProgressTask from './progress_task.jsx';
import React from 'react';
import PropTypes from 'prop-types';
export default class LoggedIn extends React.Component {
render() {
......@@ -26,13 +27,10 @@ export default class LoggedIn extends React.Component {
}
}
LoggedIn.defaultProps = {
};
LoggedIn.propTypes = {
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.element),
PropTypes.element
]),
location: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
import UserStore from '../../stores/user_store.jsx';
......@@ -152,8 +153,6 @@ export default class Login extends React.Component {
}
}
Login.defaultProps = {
};
Login.propTypes = {
location: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
export default class LoginEmail extends React.Component {
constructor(props) {
......@@ -74,10 +75,8 @@ export default class LoginEmail extends React.Component {
);
}
}
LoginEmail.defaultProps = {
};
LoginEmail.propTypes = {
submit: React.PropTypes.func.isRequired,
loginError: React.PropTypes.string
submit: PropTypes.func.isRequired,
loginError: PropTypes.string
};
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import {Modal} from 'react-bootstrap';
import UserStore from '../../stores/user_store.jsx';
import PasswordStrengthMeter from 'react-password-strength-meter';
......@@ -169,8 +170,8 @@ export default class ConfirmDeleteModal extends React.Component {
}
ConfirmDeleteModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
data: React.PropTypes.object,
location: React.PropTypes.object
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired,
data: PropTypes.object,
location: PropTypes.object
};
......@@ -10,6 +10,7 @@ import * as GlobalActions from '../../action_creators/global_actions.jsx';
import MailboxStore from '../../stores/mailbox_store.jsx';
import React from 'react';
import PropTypes from 'prop-types';
export default class ConfirmDeleteModal extends React.Component {
constructor(props) {
......@@ -161,8 +162,8 @@ export default class ConfirmDeleteModal extends React.Component {
}
ConfirmDeleteModal.propTypes = {
show: React.PropTypes.bool.isRequired,
onHide: React.PropTypes.func.isRequired,
data: React.PropTypes.object,
location: React.PropTypes.object
show: PropTypes.bool.isRequired,
onHide: PropTypes.func.isRequired,
data: PropTypes.object,
location: PropTypes.object
};
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import PasswordStrengthMeter from 'react-password-strength-meter';
import Panel from '../panel.jsx';
import Button from '../button.jsx';
......@@ -766,6 +767,6 @@ export default class CreateMailBox extends React.Component {
}
CreateMailBox.propTypes = {
location: React.PropTypes.object,
params: React.PropTypes.object
location: PropTypes.object,
params: PropTypes.object
};
......@@ -3,6 +3,7 @@
//import ToggleModalButton from '../toggle_modal_button.jsx';
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import sweetAlert from 'sweetalert';
import Button from '../button.jsx';
import MessageBar from '../message_bar.jsx';
......@@ -1124,6 +1125,6 @@ export default class EditMailBox extends React.Component {
}
EditMailBox.propTypes = {
location: React.PropTypes.object,
params: React.PropTypes.any
location: PropTypes.object,
params: PropTypes.any
};
import React from 'react';
import PropTypes from 'prop-types';
import Button from '../button.jsx';
import StatusLabel from '../status_label.jsx';
import * as Client from '../../utils/client.jsx';
......@@ -166,7 +167,7 @@ export default class BlockGeneralInfoMailbox extends React.Component {
}
BlockGeneralInfoMailbox.propTypes = {
data: React.PropTypes.object.isRequired,
webmail: React.PropTypes.string,
location: React.PropTypes.object.isRequired
data: PropTypes.object.isRequired,
webmail: PropTypes.string,
location: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import Promise from 'bluebird';
import EventStore from '../../stores/event_store.jsx';
import {browserHistory} from 'react-router';
......@@ -191,19 +192,23 @@ export default class Mailboxes extends React.Component {
);
}
getAccounts(domainName, maxResult) {
//const promises = [];
countAllLockoutAccounts(domainName) {
return new Promise((resolve, reject) => {
Client.countAllLockoutAccounts(domainName, (response) => {
resolve(response);
}, (error) => {
reject(error);
});
});
}
getAccountsFromAPI(domainName, maxResult) {
const attrneeded = Utils.getAttrsBySectionFromConfig('mailboxes');
const attrs = {
maxResults: maxResult
};
if (!this.state.loading) {
this.setState({
loading: true
});
}
if (attrneeded) {
attrs.attrs = attrneeded;
}
......@@ -213,57 +218,32 @@ export default class Mailboxes extends React.Component {
this.domainName = domainName;
}
new Promise((resolve, reject) => {
// if domain name exists, just search all mailbox from this domain
if (domainName) {
const hasMailboxForDomain = this.isStoreEnabled ? MailboxStore.getMailboxByDomainId(this.domainId) : null;
// if mailbox by domain exists return it
if (hasMailboxForDomain) {
return resolve(hasMailboxForDomain);
}
return new Promise((resolve, reject) => {
Client.getAllAccounts(attrs, resolve, reject);
});
}
// get all mailboxes from domain
return Client.getAllAccounts(attrs, (success) => {
if (success.total) {
const data = Utils.extractLockOuts(success);
if (this.isStoreEnabled) {
MailboxStore.setMailboxesByDomain(this.domainId, data);
} else {
this.setState({
accounts: data
});
}
}
getAccounts(domainName, maxResult) {
if (!this.state.loading) {
this.setState({ loading: true });
}
return resolve(success);
}, (error) => {
return reject(error);
});
}
const countLockoutAccounts = this.countAllLockoutAccounts(domainName);
const allAccounts = this.getAccountsFromAPI(domainName, maxResult);
// if all mailbox exists just return it
const hasMailboxes = this.isStoreEnabled ? MailboxStore.hasMailboxes() : null;
Promise.all([countLockoutAccounts, allAccounts]).then((results) => {
const lockout = results[0];
const accounts = results[1];
if (hasMailboxes) {
return resolve(MailboxStore.getMailboxes());
if (lockout.total > 0) {
GlobalActions.emitMessage({
error: `${lockout.total} casillas bloqueadas.`,
typeError: messageType.LOCKED
});
}
// if all mailboxes doesn't exist just search them.
return Client.getAllAccounts(attrs, (success) => {
const data = Utils.extractLockOuts(success);
if (this.isStoreEnabled) {
MailboxStore.setMailboxes(data);
}
return resolve(data);
}, (error) => {
return reject(error);
});
}).then((data) => {
if (data.account) {
this.mailboxes = data;
if (accounts.total > 0) {
this.mailboxes = accounts;
this.isRefreshing = false;
......@@ -281,7 +261,7 @@ export default class Mailboxes extends React.Component {
return this.setState({
data: tables,
loading: false,
ac: data.account
ac: accounts.account
});
}
......@@ -290,33 +270,19 @@ export default class Mailboxes extends React.Component {
domain: domainName,
loading: false
});
}).catch((error) => {
if (error.code === codes.TOO_MANY_SEARCH_RESULTS) {
this.isRefreshing = true;
const newMaxResult = (parseInt(maxResult, 10) + window.manager_config.autoincrementOnFailRequestZimbra);
window.manager_config.maxResultOnRequestZimbra = newMaxResult;
setTimeout(() => {
this.getAccounts(domainName, newMaxResult);
}, 250);
}
}).finally(() => {
if (!this.isRefreshing) {
return GlobalActions.emitEndLoading();
}
return GlobalActions.emitEndLoading();
});
}).catch(console.error.bind('error'));
}
getAllMailboxes(domainId) {
const MAX_RESULTS = 0; //window.manager_config.maxResultOnRequestZimbra;
if (domainId) {
return this.domainInfo(domainId).then((data) => {
const domain = this.isStoreEnabled ? DomainStore.getCurrent() : data;
this.getAccounts(domain.name, window.manager_config.maxResultOnRequestZimbra);
this.getAccounts(domain.name, MAX_RESULTS);
});
}
return this.getAccounts(null, window.manager_config.maxResultOnRequestZimbra);
return this.getAccounts(null, MAX_RESULTS);
}
refreshAllAccounts() {
......@@ -767,6 +733,6 @@ export default class Mailboxes extends React.Component {
}
Mailboxes.propTypes = {
location: React.PropTypes.object.isRequired,
params: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired,
params: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
import EventStore from '../../stores/event_store.jsx';
......@@ -432,6 +433,6 @@ export default class MailboxDetails extends React.Component {
}
MailboxDetails.propTypes = {
location: React.PropTypes.object,
params: React.PropTypes.object
location: PropTypes.object,
params: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
import * as Client from '../../utils/client.jsx';
import EventStore from '../../stores/event_store.jsx';
......@@ -159,5 +160,5 @@ export default class ResendForm extends React.Component {
}
ResendForm.propTypes = {
mailbox: React.PropTypes.object
mailbox: PropTypes.object
};
//import ZimbraStore from '../../stores/zimbra_store.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import * as Utils from '../../utils/utils.jsx';
import bytesConvertor from 'bytes';
import Constants from '../../utils/constants.jsx';
......@@ -118,5 +119,5 @@ export default class BlockGeneralInfoMailbox extends React.Component {
}
BlockGeneralInfoMailbox.propTypes = {
data: React.PropTypes.object.isRequired
data: PropTypes.object.isRequired
};
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
import {Link} from 'react-router';
import Constants from '../utils/constants.jsx';
......@@ -129,12 +130,12 @@ MessageBar.defaultProps = {
};
MessageBar.propTypes = {
message: React.PropTypes.string.isRequired,
type: React.PropTypes.oneOf(['SUCCESS', 'ERROR', 'WARNING', 'INFO', 'LOCKED']),
position: React.PropTypes.oneOf(['absolute', 'fixed', 'relative', 'static', 'inherit']),
canClose: React.PropTypes.bool,
autoclose: React.PropTypes.bool,
autocloseInSecs: React.PropTypes.number,
link: React.PropTypes.string,
linkText: React.PropTypes.string
message: PropTypes.string.isRequired,
type: PropTypes.oneOf(['SUCCESS', 'ERROR', 'WARNING', 'INFO', 'LOCKED']),
position: PropTypes.oneOf(['absolute', 'fixed', 'relative', 'static', 'inherit']),
canClose: PropTypes.bool,
autoclose: PropTypes.bool,
autocloseInSecs: PropTypes.number,
link: PropTypes.string,
linkText: PropTypes.string
};
......@@ -2,8 +2,8 @@
// See LICENSE.txt for license information.
import $ from 'jquery';
import React from 'react';
import PropTypes from 'prop-types';
export default class NotLoggedIn extends React.Component {
componentDidMount() {
......@@ -19,10 +19,7 @@ export default class NotLoggedIn extends React.Component {
}
}
NotLoggedIn.defaultProps = {
};
NotLoggedIn.propTypes = {
children: React.PropTypes.object,
location: React.PropTypes.object
children: PropTypes.object,
location: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
export default class PageInfo extends React.Component {
render() {
......@@ -18,8 +19,8 @@ export default class PageInfo extends React.Component {
}
PageInfo.propTypes = {
titlePage: React.PropTypes.any.isRequired,
descriptionPage: React.PropTypes.any
titlePage: PropTypes.any.isRequired,
descriptionPage: PropTypes.any
};
PageInfo.defaultProps = {
......
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
export default class Pagination extends React.Component {
......@@ -199,12 +200,12 @@ export default class Pagination extends React.Component {
}
Pagination.propTypes = {
url: React.PropTypes.string.isRequired,
currentPage: React.PropTypes.number.isRequired,
totalPages: React.PropTypes.number.isRequired,
range: React.PropTypes.number,
total: React.PropTypes.number,
name: React.PropTypes.string
url: PropTypes.string.isRequired,
currentPage: PropTypes.number.isRequired,
totalPages: PropTypes.number.isRequired,
range: PropTypes.number,
total: PropTypes.number,
name: PropTypes.string
};
Pagination.defaultProps = {
......
import React from 'react';
import PropTypes from 'prop-types';
import Button from './button.jsx';
export default class Panel extends React.Component {
......@@ -47,14 +48,14 @@ export default class Panel extends React.Component {
}
Panel.propTypes = {
hasHeader: React.PropTypes.bool,
btnsHeader: React.PropTypes.array,
title: React.PropTypes.string,
classHeader: React.PropTypes.string,
error: React.PropTypes.element,
children: React.PropTypes.any,
filter: React.PropTypes.element,
classCss: React.PropTypes.array
hasHeader: PropTypes.bool,
btnsHeader: PropTypes.array,
title: PropTypes.string,
classHeader: PropTypes.string,
error: PropTypes.element,
children: PropTypes.any,
filter: PropTypes.element,
classCss: PropTypes.array
};
Panel.defaultProps = {
......
//import Datalist from 'react-datalist';
import React from 'react';
import PropTypes from 'prop-types';
import Button from './button.jsx';
import PaginateArray from '../stores/paginate_array_store.jsx';
import DataList from 'react-datalist';
......@@ -638,22 +639,22 @@ export default class PanelActions extends React.Component {
}
PanelActions.propTypes = {
name: React.PropTypes.string.isRequired,
onApplyChanges: React.PropTypes.func.isRequired,
data: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.string
name: PropTypes.string.isRequired,
onApplyChanges: PropTypes.func.isRequired,
data: PropTypes.oneOfType([
PropTypes.array,
PropTypes.string
]),
options: React.PropTypes.array,
hasComboInput: React.PropTypes.bool,
onAdd: React.PropTypes.func,
onDelete: React.PropTypes.func,
onCancel: React.PropTypes.func,
hasExport: React.PropTypes.bool,
showNameOnButton: React.PropTypes.bool,
onExport: React.PropTypes.func,
isEmail: React.PropTypes.bool,
nameFunc: React.PropTypes.string.isRequired
options: PropTypes.array,
hasComboInput: PropTypes.bool,
onAdd: PropTypes.func,
onDelete: PropTypes.func,
onCancel: PropTypes.func,
hasExport: PropTypes.bool,
showNameOnButton: PropTypes.bool,
onExport: PropTypes.func,
isEmail: PropTypes.bool,
nameFunc: PropTypes.string.isRequired
};
PanelActions.defaultProps = {
......
//import Datalist from 'react-datalist';
import React from 'react';
import PropTypes from 'prop-types';
import Button from './button.jsx';
import PaginateArray from '../stores/paginate_array_store.jsx';
import DataList from 'react-datalist';
......@@ -639,22 +640,22 @@ export default class PanelActions extends React.Component {
}
PanelActions.propTypes = {
name: React.PropTypes.string.isRequired,
onApplyChanges: React.PropTypes.func.isRequired,
data: React.PropTypes.oneOfType([
React.PropTypes.array,
React.PropTypes.string
name: PropTypes.string.isRequired,
onApplyChanges: PropTypes.func.isRequired,
data: PropTypes.oneOfType([
PropTypes.array,
PropTypes.string
]),
options: React.PropTypes.array,
hasComboInput: React.PropTypes.bool,
onAdd: React.PropTypes.func,
onDelete: React.PropTypes.func,
onCancel: React.PropTypes.func,
hasExport: React.PropTypes.bool,
showNameOnButton: React.PropTypes.bool,
onExport: React.PropTypes.func,
isEmail: React.PropTypes.bool,
nameFunc: React.PropTypes.string.isRequired
options: PropTypes.array,
hasComboInput: PropTypes.bool,
onAdd: PropTypes.func,
onDelete: PropTypes.func,
onCancel: PropTypes.func,
hasExport: PropTypes.bool,
showNameOnButton: PropTypes.bool,
onExport: PropTypes.func,
isEmail: PropTypes.bool,
nameFunc: PropTypes.string.isRequired
};
PanelActions.defaultProps = {
......
import React from 'react';
import PropTypes from 'prop-types';
import * as Utils from '../utils/utils.jsx';
export default class Panel extends React.Component {
......@@ -75,8 +76,8 @@ export default class Panel extends React.Component {
}
Panel.propTypes = {
tabNames: React.PropTypes.arrayOf(React.PropTypes.string).isRequired,
tabs: React.PropTypes.object.isRequired,
location: React.PropTypes.object.isRequired,
onClick: React.PropTypes.func
tabNames: PropTypes.arrayOf(PropTypes.string).isRequired,
tabs: PropTypes.object.isRequired,
location: PropTypes.object.isRequired,
onClick: PropTypes.func
};
// Copyright (c) 2016 ZBox, Spa. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
import EventStore from '../stores/event_store.jsx';
export default class ProgressTask extends React.Component {
......@@ -128,12 +129,9 @@ export default class ProgressTask extends React.Component {
}
}
ProgressTask.defaultProps = {
};
ProgressTask.propTypes = {
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.element),
PropTypes.element
])
};
......@@ -4,6 +4,7 @@
import * as Client from '../utils/client.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory} from 'react-router';
......@@ -42,9 +43,7 @@ export default class Root extends React.Component {
return this.props.children;
}
}
Root.defaultProps = {
};
Root.propTypes = {
children: React.PropTypes.object
children: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
import PageInfo from '../page_info.jsx';
import Panel from '../panel.jsx';
import UserStore from '../../stores/user_store.jsx';
......@@ -245,5 +246,5 @@ export default class SalesForm extends React.Component {
}
SalesForm.propTypes = {
params: React.PropTypes.object
params: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
import PageInfo from '../page_info.jsx';
import * as GlobalActions from '../../action_creators/global_actions.jsx';
import * as Client from '../../utils/client.jsx';
......@@ -247,5 +248,5 @@ export default class SearchView extends React.Component {
}
SearchView.propTypes = {
params: React.PropTypes.object
params: PropTypes.object
};
import React from 'react';
import PropTypes from 'prop-types';
export default class SelectCol extends React.Component {
constructor(props) {
......@@ -92,15 +93,15 @@ export default class SelectCol extends React.Component {
}
SelectCol.propTypes = {
options: React.PropTypes.object.isRequired,
selectAttrs: React.PropTypes.object,
onSelected: React.PropTypes.func,
disabledOptions: React.PropTypes.object,
selected: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.bool
options: PropTypes.object.isRequired,
selectAttrs: PropTypes.object,
onSelected: PropTypes.func,
disabledOptions: PropTypes.object,
selected: PropTypes.oneOfType([
PropTypes.string,
PropTypes.bool
]),
id: React.PropTypes.any.isRequired
id: PropTypes.any.isRequired
};
SelectCol.defaultProps = {
......
......@@ -5,6 +5,7 @@ import UserStore from '../stores/user_store.jsx';
import SidebarMenu from './sidebar_menu.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import {Link} from 'react-router';
export default class Sidebar extends React.Component {
......@@ -58,5 +59,5 @@ export default class Sidebar extends React.Component {
}
Sidebar.propTypes = {
location: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired
};
......@@ -5,6 +5,7 @@ import * as GlobalActions from '../action_creators/global_actions.jsx';
import UserStore from '../stores/user_store.jsx';
import React from 'react';
import PropTypes from 'prop-types';
import {browserHistory, Link} from 'react-router';
export default class SidebarMenu extends React.Component {
......@@ -119,5 +120,5 @@ export default class SidebarMenu extends React.Component {
}
SidebarMenu.propTypes = {
location: React.PropTypes.object.isRequired
location: PropTypes.object.isRequired
};
import React from 'react';
import PropTypes from 'prop-types';
// Cambiar por algo que reciba el status y el tamaño y se cree el componente de una vez
export default class StatusLabel extends React.Component {
......@@ -12,8 +13,8 @@ export default class StatusLabel extends React.Component {
}
StatusLabel.propTypes = {
classes: React.PropTypes.string,
children: React.PropTypes.any
classes: PropTypes.string,
children: PropTypes.any
};
StatusLabel.defaultProps = {
......
......@@ -2,6 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import PropTypes from 'prop-types';
export default class ModalToggleButton extends React.Component {
constructor(props) {
......@@ -68,10 +69,10 @@ export default class ModalToggleButton extends React.Component {
}
ModalToggleButton.propTypes = {
children: React.PropTypes.node.isRequired,
dialogType: React.PropTypes.func.isRequired,
dialogProps: React.PropTypes.object,
onClick: React.PropTypes.func
children: PropTypes.node.isRequired,
dialogType: PropTypes.func.isRequired,
dialogProps: PropTypes.object,
onClick: PropTypes.func
};
ModalToggleButton.defaultProps = {
......
This diff is collapsed.
......@@ -46,27 +46,24 @@ const notFoundParams = {
};
function preRenderSetup(callwhendone) {
const d1 = Client.getClientConfig(
(data) => {
const config = data.result || data;
if (!config) {
return;
}
global.window.manager_config = config;
if (config.debug) {
global.window.Client = Client;
global.window.Utils = Utils;
}
},
(err) => {
console.error(err); //eslint-disable-line no-console
Client.getClientConfig().then((response) => {
const data = response.data;
const config = data.result || data;
if (!config) {
return;
}
);
$.when(d1).done(callwhendone);
global.window.manager_config = config;
if (config.debug) {
global.window.Client = Client;
global.window.Utils = Utils;
}
callwhendone();
}).catch((err) => {
console.error(err); //eslint-disable-line no-console
});
}
function onPreLoggedIn(nextState, replace, callback) {
......
.datepicker-days {
padding: 10px 10px 0px 10px;
.switch {
text-align: center;
}
.today {
color: #337ab7;
}
.day {
text-align: center;
&.disabled {
opacity: .5;
}
}
.active {
color: #FFF;
background-color: #337ab7;
}
}
......@@ -6,6 +6,7 @@
@import 'fonts';
@import 'grid';
@import 'icheck';
@import 'datepicker';
@import 'lists';
@import 'importer';
@import 'loader';
......
......@@ -3,6 +3,7 @@
import $ from 'jquery';
import Promise from 'bluebird';
import axios from 'axios';
import ZimbraAdminApi from 'zimbra-admin-api-js';
import Powerdns from 'js-powerdns';
......@@ -25,8 +26,6 @@ function handleError(methodName, err) {
return err;
}
console.error(methodName, err); //eslint-disable-line no-console
const error = {
type: Constants.MessageType.ERROR
};
......@@ -73,23 +72,30 @@ function initZimbra() {
});
}
export function getClientConfig(success, error) {
return $.ajax({
url: 'https://manager.zboxapp.com/ventas_api/parse/functions/getConfigManager',
//url: './config/config.json',
dataType: 'json',
method: 'POST',
//method: 'GET',
export function getClientConfig() {
const method = Utils.isDevMode() ? 'GET' : 'POST';
const url = Utils.getConfigName();
return axios({
url,
method,
headers: {
'X-Parse-Application-Id': 'salesZboxManagerApp'
},
data: {target: 'manager'},
success,
error: function onError(xhr, status, err) {
var e = handleError('getClientConfig', err);
error(e);
}
});
// return $.ajax({
// url,
// dataType: 'json',
// method,
// headers: {
// 'X-Parse-Application-Id': 'salesZboxManagerApp'
// },
// //data: {target: 'manager'},
// success,
// error: function onError(xhr, status, err) {
// var e = handleError('getClientConfig', err);
// error(e);
// }
// });
}
export function clearCacheZimbra(flushData, success, error) {
......@@ -222,37 +228,45 @@ export function getAllCompanies() {
export function getCompany(id) {
const url = global.window.manager_config.companiesEndPoints.detail.replace('{id}', id);
return new Promise((resolve, reject) => {
return $.ajax({
url,
beforeSend: function setApiToken(xhrObj) {
xhrObj.setRequestHeader('x-api-key', window.manager_config.user_token);
},
dataType: 'json',
success: function onSuccess(data) {
return resolve(data);
},
error: function onError(xhr) {
return reject(xhr.responseJSON);
}
});
return axios.get(url, {
headers: {
'x-api-key': window.manager_config.user_token
}
});
// return new Promise((resolve, reject) => {
// $.ajax({
// url,
// beforeSend: function setApiToken(xhrObj) {
// xhrObj.setRequestHeader('x-api-key', window.manager_config.user_token);
// },
// dataType: 'json',
// success: resolve,
// error: reject
// });
// });
}
export function getInvoices(id, success, error) {
export function getInvoices(id) {
const url = global.window.manager_config.companiesEndPoints.invoices.replace('{id}', id);
return $.ajax({
url,
beforeSend: function setApiToken(xhrObj) {
xhrObj.setRequestHeader('x-api-key', window.manager_config.user_token);
},
dataType: 'json',
success,
error: function onError(xhr, status, err) {
error(err);
return axios.get(url, {
headers: {
'x-api-key': window.manager_config.user_token
}
});
// return $.ajax({
// url,
// beforeSend: function setApiToken(xhrObj) {
// xhrObj.setRequestHeader('x-api-key', window.manager_config.user_token);
// },
// dataType: 'json',
// success,
// error: function onError(xhr, status, err) {
// error(err);
// }
// });
}
export function getAllDomains(opts, success, error) {
......@@ -598,6 +612,37 @@ export function addAccountAlias(alias, success, error) {
);
}
export function countAllLockoutAccounts(domainName, success, error) {
const searchObject = {
query: '(|(zimbraAccountStatus=*lockout*))',
types: 'accounts',
maxResults: 0,
attrs: '*'
};
if (domainName) {
searchObject.domain = domainName;
}
initZimbra().then((zimbra) => {
zimbra.directorySearch(
searchObject,
(err, data) => {
if (err) {
const e = handleError('getAllLockoutAccounts', err);
return error(e);
}
return success(data);
}
);
},
(err) => {
const e = handleError('getAllLockoutAccounts', err);
return error(e);
});
}
export function search(query, success, error) {
initZimbra().then(
(zimbra) => {
......
......@@ -6,6 +6,7 @@ import * as GlobalActions from '../action_creators/global_actions.jsx';
import Constants from './constants.jsx';
import ZimbraStore from '../stores/zimbra_store.jsx';
import sweetAlert from 'sweetalert';
import moment from 'moment';
const messageType = Constants.MessageType;
......@@ -600,6 +601,25 @@ export function getInitialDateFromTimestamp(timestamp) {
return timestampReseted;
}
export function timestampToUTCDate(timestamp) {
const timestampAsNumber = stringTSToNumber(timestamp);
const momentDate = moment(new Date(timestampAsNumber)).format('YYYY/MM/DD');
const UCTDate = momentDate.split('/').join('');
return `${UCTDate}000000Z`;
}
export function parseBooleanValue(boolean) {
if (typeof boolean === 'undefined') {
return false;
}
return boolean.toString().toLowerCase() === 'true';
}
export function stringTSToNumber(ts) {
return parseInt(ts, 10);
}
export function forceTimestampFromHumanDate(date) {
const arrDate = date.split('/').reverse();
const newDateArr = arrDate.map((pos, i) => {
......@@ -846,3 +866,49 @@ export function getDaysFromDate2Date(dateFrom, dateTo) {
export function randomRange(max, min) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
export function getHostname(nextPath) {
const { hostname, port, protocol } = window.location;
let host = `${protocol}//${hostname}`;
host = port && port.length > 0 ? `${host}:${port}` : host;
host += nextPath;
return host;
}
export function getConfigName() {
return isDevMode() ? '/config/config.development.json' : 'https://manager.zboxapp.com/ventas_api/parse/functions/getConfigManager';
}
export function isDevMode() {
return process.env.NODE_ENV === 'development';
}
export function getUTCTime(utc) {
if (!utc) {
return null;
}
const utcString = utc.slice(0, utc.length - 1);
const year = utcString.slice(0, 4);
const month = utcString.slice(4, 6);
const day = utcString.slice(6, 8);
const hours = utcString.slice(8, 10);
const minutes = utcString.slice(10, 12);
const seconds = utcString.slice(12, 14);
return [year, month, day, hours, minutes, seconds];
}
export function getTSFromUTC(utc) {
let time = utc;
const now = new Date();
if (!time) {
return now.getTime();
}
if (Object.prototype.toString.call(utc) === '[object Array]') {
time = new Date(...utc);
}
return time.getTime();
}
......@@ -111,10 +111,18 @@ var config = {
// Development mode configuration
if (DEV) {
config.plugins.push(
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('development')
}
})
);
if (FULLMAP) {
//config.devtool = 'source-map';
config.devtool = 'source-map';
} else {
//config.devtool = 'eval-cheap-module-source-map';
config.devtool = 'eval-cheap-module-source-map';
}
}
......@@ -125,7 +133,8 @@ if (!DEV) {
new webpack.optimize.UglifyJsPlugin({
'screw-ie8': true,
mangle: {
toplevel: false
toplevel: false,
keep_fnames: true
},
compress: {
warnings: false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment