Commit 3061904d authored by Elias Nahum's avatar Elias Nahum Committed by Juorder Antonio

fixed filter mailboxes, fixed sum to domain, fixed mx, fixed mailbox limits

parent d36467ce
1464106868
\ No newline at end of file
1464204428
\ No newline at end of file
module.exports = {"main":{"js":"/699779bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/896467bundle.js"}}
\ No newline at end of file
......@@ -35,7 +35,8 @@ export default class Companies extends React.Component {
this.state = {
page,
offset: ((page - 1) * Constants.QueryOptions.DEFAULT_LIMIT)
offset: ((page - 1) * Constants.QueryOptions.DEFAULT_LIMIT),
loading: true
};
this.isGlobalAdmin = UserStore.isGlobalAdmin();
......@@ -68,13 +69,15 @@ export default class Companies extends React.Component {
CompaniesStore.setCompanies(comps);
self.setState({
companies: comps
companies: comps,
loading: false
});
}).
catch((error) => {
self.setState({error: {
message: error,
type: messageTypes.ERROR
type: messageTypes.ERROR,
loading: false
}});
});
}).catch((error) => {
......@@ -91,7 +94,8 @@ export default class Companies extends React.Component {
}, (error) => {
self.setState({error: {
message: error,
type: messageTypes.ERROR
type: messageTypes.ERROR,
loading: false
}});
});
} else {
......@@ -103,13 +107,15 @@ export default class Companies extends React.Component {
}, (error) => {
self.setState({error: {
message: error,
type: messageTypes.ERROR
type: messageTypes.ERROR,
loading: false
}});
});
}, (error) => {
self.setState({
error,
type: messageTypes.ERROR
type: messageTypes.ERROR,
loading: false
});
});
}
......@@ -194,6 +200,16 @@ export default class Companies extends React.Component {
let panelBody;
let noLimitError;
let pagination = null;
const textLoading = this.isGlobalAdmin ? 'Cargando Empresas...' : 'Cargando Mi Empresa...';
if (this.state.loading) {
panelBody = (
<div className='text-center'>
<i className='fa fa-spinner fa-spin fa-4x fa-fw'></i>
<p>{textLoading}</p>
</div>
);
}
if (this.state.companies.length === 0) {
panelBody = (
......@@ -213,7 +229,7 @@ export default class Companies extends React.Component {
const totalPages = Math.ceil(data.length / Constants.QueryOptions.DEFAULT_LIMIT);
pagination = (
<Pagination
key='panelPaginationCompanies'
key='paginationCompany'
url='companies'
currentPage={this.state.page}
totalPages={totalPages}
......
......@@ -29,25 +29,23 @@ export default class DomainGeneralInfo extends React.Component {
}
componentWillMount() {
const domain = this.props.domain;
this.getMXRecord(domain.name);
this.getMXRecord(domain);
this.getCompany(domain.attrs.businessCategory);
}
getMXRecord(name) {
getMXRecord(domain) {
const self = this;
Client.getDnsInfo(
name,
(data) => {
self.setState({
mx: data.mx
});
},
(err) => {
self.setState({
domain.checkMxRecord((err, data) => {
if (err) {
return self.setState({
mx: err
});
}
);
return self.setState({
mx: data.entry
});
});
}
getCompany(id) {
const company = CompanyStore.getCompanyById(id);
......
......@@ -30,13 +30,13 @@ export default class DomainMailboxPlans extends React.Component {
plans
});
}
return this.props.domain.countAccounts(
(err, data) => {
if (err) {
return this.setState({plans: {}});
}
this.props.domain.plans = data;
return this.setState({plans: data});
}
);
......@@ -94,12 +94,12 @@ export default class DomainMailboxPlans extends React.Component {
});
}
for (const key in plans) {
for (const key in this.state.plans) {
if (plans.hasOwnProperty(key)) {
const plan = plans[key];
totalUsed += plan.used;
totalUsed += (parseInt(plan.used, 10)) ? parseInt(plan.used, 10) : 0;
if (plan.limit === 0) {
totalLimit = '\u221e';
//totalLimit = '\u221e';
if (!noLimitError) {
noLimitError = (
......@@ -111,7 +111,6 @@ export default class DomainMailboxPlans extends React.Component {
);
}
} else {
console.log(totalLimit); //eslint-disable-line no-console
totalLimit += plan.limit;
}
......
......@@ -36,14 +36,25 @@ export default class Mailboxes extends React.Component {
this.showMessage = this.showMessage.bind(this);
this.refreshAllAccounts = this.refreshAllAccounts.bind(this);
this.handleFilterMailbox = this.handleFilterMailbox.bind(this);
this.handleChangeFilter = this.handleChangeFilter.bind(this);
this.makeFilter = this.makeFilter.bind(this);
const page = parseInt(this.props.location.query.page, 10) || 1;
this.mailboxes = null;
this.status = '';
this.mailboxesFiltered = null;
this.filtering = false;
this.selectedStatusFilter = '';
this.selectedPlanFilter = '';
this.cos = Utils.getEnabledPlansByCos(ZimbraStore.getAllCos());
this.cosById = Utils.getEnabledPlansByCosId(ZimbraStore.getAllCos());
this.isRefreshing = true;
this.optionStatus = {
active: 'Active',
locked: 'Inactiva',
lockedout: 'Bloqueada',
closed: 'Cerrada'
};
this.optionPlans = window.manager_config.plans;
this.state = {
page,
......@@ -54,65 +65,49 @@ export default class Mailboxes extends React.Component {
handleChangeFilter(e) {
const selected = e.target.value;
const cos = Utils.getEnabledPlansByCos(ZimbraStore.getAllCos());
if (e.target.className.indexOf('plans') > -1) {
this.cos = cos[selected];
this.selectedPlanFilter = '';
if (this.cos[selected]) {
this.selectedPlanFilter = this.cos[selected];
}
}
if (e.target.className.indexOf('status') > -1) {
this.status = selected;
this.selectedStatusFilter = selected.length > 0 ? selected : null;
}
const data = Object.assign({}, this.mailboxes);
const domainId = this.props.params.domain_id;
const arrayFiltered = data.account.filter((strArray) => {
const status = this.status === '' ? strArray.attrs.zimbraAccountStatus : this.status;
const plan = this.cos ? this.cos : strArray.attrs.zimbraCOSId;
this.getAllMailboxes(domainId, window.manager_config.maxResultOnRequestZimbra);
}
if (strArray.attrs.zimbraAccountStatus === status && strArray.attrs.zimbraCOSId === plan) {
return strArray;
}
makeFilter() {
const mailboxes = Object.assign({}, this.mailboxes);
let cos = this.selectedPlanFilter;
let status = this.selectedStatusFilter;
if (cos === '' && status === '') {
return false;
});
data.account = arrayFiltered;
data.total = arrayFiltered.length;
const tables = this.buildTableFromData(data, ['Todas', 'Bloqueadas']);
return this.setState({
data: tables
});
}
handleFilterMailbox(e, info) {
const search = e.target.value;
const data = Object.assign({}, info);
}
const arrayFiltered = data.account.filter((strArray) => {
if (this.status === '') {
if (strArray.name.match(search)) {
return strArray;
}
}
const arrayFiltered = mailboxes.account.filter((strArray) => {
const CurrentStatus = status || strArray.attrs.zimbraAccountStatus;
const plan = cos || strArray.attrs.zimbraCOSId;
if (strArray.name.match(search) && strArray.attrs.zimbraAccountStatus === this.status) {
if (strArray.attrs.zimbraAccountStatus === CurrentStatus && strArray.attrs.zimbraCOSId === plan) {
return strArray;
}
return false;
});
data.account = arrayFiltered;
data.total = arrayFiltered.length;
mailboxes.account = arrayFiltered;
mailboxes.total = arrayFiltered.length;
const tables = this.buildTableFromData(data, ['Todas', 'Bloqueadas']);
this.mailboxesFiltered = mailboxes;
return this.setState({
data: tables
});
return this.mailboxesFiltered;
}
showMessage(attrs) {
......@@ -224,7 +219,9 @@ export default class Mailboxes extends React.Component {
this.isRefreshing = false;
const tables = this.buildTableFromData(data, ['Todas', 'Bloqueadas']);
const items = this.makeFilter() || this.mailboxes;
const tables = this.buildTableFromData(items, ['Todas', 'Bloqueadas']);
if (tables.lockedAlert) {
GlobalActions.emitMessage({
......@@ -441,26 +438,33 @@ export default class Mailboxes extends React.Component {
if (data.account) {
const accounts = data.account;
const totalAccounts = data.total;
const limit = data.account.length;
let limit = data.account.length;
const hasPage = totalAccounts > Constants.QueryOptions.DEFAULT_LIMIT;
let activeAccounts = [];
let lockedAccounts = [];
const tabs = {};
let partialAccounts = accounts;
if (hasPage) {
partialAccounts = accounts.slice(this.state.offset, (this.state.page * Constants.QueryOptions.DEFAULT_LIMIT));
limit = partialAccounts.length;
}
for (let i = 0; i < limit; i++) {
const account = accounts[i].attrs;
const account = partialAccounts[i].attrs;
switch (account.zimbraAccountStatus) {
case 'active':
activeAccounts.push(this.buildRow(accounts[i], 'label label-success m-r', 'Activa'));
activeAccounts.push(this.buildRow(partialAccounts[i], 'label label-success m-r', 'Activa'));
break;
case 'closed':
activeAccounts.push(this.buildRow(accounts[i], 'label label-default m-r', 'Cerrada'));
activeAccounts.push(this.buildRow(partialAccounts[i], 'label label-default m-r', 'Cerrada'));
break;
case 'locked':
activeAccounts.push(this.buildRow(accounts[i], 'label label-warning m-r', 'Inactiva'));
activeAccounts.push(this.buildRow(partialAccounts[i], 'label label-warning m-r', 'Inactiva'));
break;
case 'lockedout':
lockedAccounts.push(this.buildRow(accounts[i], 'label label-locked m-r', 'Bloqueada'));
activeAccounts.push(this.buildRow(accounts[i], 'label label-locked m-r', 'Bloqueada'));
lockedAccounts.push(this.buildRow(partialAccounts[i], 'label label-locked m-r', 'Bloqueada'));
activeAccounts.push(this.buildRow(partialAccounts[i], 'label label-locked m-r', 'Bloqueada'));
break;
}
}
......@@ -513,24 +517,40 @@ export default class Mailboxes extends React.Component {
}
];
const totalPage = Math.ceil(totalAccounts / QueryOptions.DEFAULT_LIMIT);
let activePagination = {
total: totalPage
};
if (activeAccounts.length > QueryOptions.DEFAULT_LIMIT) {
activeAccounts = activeAccounts.slice(this.state.offset, (this.state.page * QueryOptions.DEFAULT_LIMIT));
let activePagination = null;
let lockedPagination = null;
if (hasPage) {
const totalPage = Math.ceil(totalAccounts / QueryOptions.DEFAULT_LIMIT);
activePagination = {
total: totalPage
};
}
let lockedPagination = null;
if (lockedAccounts.length > QueryOptions.DEFAULT_LIMIT) {
lockedAccounts = lockedAccounts.slice(this.state.offset, (this.state.page * QueryOptions.DEFAULT_LIMIT));
lockedPagination = {
total: totalPage
};
}
const status = Object.keys(this.optionStatus).map((item, i) => {
return (
<option
key={`status-${i}`}
value={`${item}`}
>
{Utils.titleCase(this.optionStatus[item])}
</option>
);
});
const plans = Object.keys(this.optionPlans).map((item, i) => {
if (item.toLowerCase() === 'default') {
return false;
}
return (
<option
key={`plan-${i}`}
value={`${item}`}
>
{Utils.titleCase(this.optionPlans[item].label)}
</option>
);
});
const filter = (
<div>
......@@ -538,12 +558,10 @@ export default class Mailboxes extends React.Component {
<select
className='form-control status'
onChange={this.handleChangeFilter}
value={this.selectedStatusFilter}
>
<option value=''>Todas</option>
<option value='active'>Activa</option>
<option value='locked'>Inactiva</option>
<option value='lockedout'>Bloqueada</option>
<option value='closed'>Cerradas</option>
{status}
</select>
</div>
......@@ -551,11 +569,10 @@ export default class Mailboxes extends React.Component {
<select
className='form-control plans'
onChange={this.handleChangeFilter}
value={this.selectedPlanFilter}
>
<option value=''>Todos los planes</option>
<option value='basic'>Básico</option>
<option value='professional'>Profesional</option>
<option value='premium'>Premium</option>
{plans}
</select>
</div>
</div>
......
......@@ -107,7 +107,7 @@ export default class BlockGeneralInfoMailbox extends React.Component {
<div className='col-xs-6'>
{sizeEnaled && (
<p>
<span className='center-block'>Espacio Disponible</span>
<span className='center-block'>Espacio Total</span>
<strong>{sizeEnaled}</strong>
</p>
)}
......
......@@ -12,13 +12,16 @@
"autoincrementOnFailRequestZimbra": 500,
"plans": {
"basic": {
"statusCos": "btn-success"
"statusCos": "btn-success",
"label": "Básica"
},
"premium": {
"statusCos": "btn-primary2"
"statusCos": "btn-primary2",
"label": "Premium"
},
"professional": {
"statusCos": "btn-primary"
"statusCos": "btn-primary",
"label": "Profesional"
},
"default": 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