Commit 507fa3fc authored by Elias Nahum's avatar Elias Nahum Committed by Juorder Antonio

fixed hide menu, not show plans not assigned, link to company from domain...

fixed hide menu, not show plans not assigned, link to company from domain view, now can export on mailbox and dl
parent 53092b3f
1464204428
\ No newline at end of file
1464270876
\ No newline at end of file
......@@ -22,7 +22,7 @@ Vagrant.configure(2) do |config|
config.vm.network 'forwarded_port', guest: 8081, host: 8081
config.vm.network 'forwarded_port', guest: 9081, host: 9081
config.vm.network 'forwarded_port', guest: 9082, host: 9082
config.vm.network 'forwarded_port', guest: 443, host: 7443
config.vm.network 'forwarded_port', guest: 8443, host: 7443
config.vm.network 'forwarded_port', guest: 80, host: 7080
config.vm.network 'forwarded_port', guest: 389, host: 7389
......
module.exports = {"main":{"js":"/070120bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/220281bundle.js"}}
\ No newline at end of file
......@@ -34,6 +34,8 @@ export default class DistributionLists extends React.Component {
this.onSubmitMembers = this.onSubmitMembers.bind(this);
this.onCancelMember = this.onCancelMember.bind(this);
this.onCancelOwner = this.onCancelOwner.bind(this);
this.onExportMembers = this.onExportMembers.bind(this);
this.onExportAllowers = this.onExportAllowers.bind(this);
this.domain = null;
this.state = {};
......@@ -48,6 +50,16 @@ export default class DistributionLists extends React.Component {
});
}
onExportMembers(data) {
const title = `Miembros de la lista de distribución '${this.state.distributionsList.name}' de ${this.state.domain.name}`;
Utils.exportAsCSV(data, 'members', title, true);
}
onExportAllowers(data) {
const title = `Permitidos de la lista de distribución '${this.state.distributionsList.name}' de ${this.state.domain.name}`;
Utils.exportAsCSV(data, 'allowers', title, true);
}
getDistributionLists() {
const id = this.props.params.id;
const response = {};
......@@ -451,6 +463,9 @@ export default class DistributionLists extends React.Component {
onCancel={(response) => {
this.onCancelMember(response);
}}
onExport={(members) => {
this.onExportMembers(members);
}}
/>
);
......@@ -469,6 +484,9 @@ export default class DistributionLists extends React.Component {
onCancel={(response) => {
this.onCancelOwner(response);
}}
onExport={(allowers) => {
this.onExportAllowers(allowers);
}}
/>
);
}
......
......@@ -95,7 +95,7 @@ export default class DomainGeneralInfo extends React.Component {
<p>
<a
className='account-name'
onClick={(e) => Utils.handleLink(e, `/accounts/${domain.id_empresa}`, this.props.location)}
onClick={(e) => Utils.handleLink(e, `/companies/${domain.attrs.businessCategory}`, this.props.location)}
>
{this.state.company}
</a>
......
......@@ -64,6 +64,7 @@ export default class DomainMailboxPlans extends React.Component {
];
const mailboxPlans = [];
let panelBody = null;
const cos = Utils.getEnabledPlansByCosId(ZimbraStore.getAllCos());
const planKeys = Object.keys(cos).map((c) => {
return cos[c];
......@@ -95,7 +96,7 @@ export default class DomainMailboxPlans extends React.Component {
}
for (const key in plans) {
if (plans.hasOwnProperty(key)) {
if (plans.hasOwnProperty(key) && plans[key].used !== 0 && plans[key].limit !== 0) {
const plan = plans[key];
totalUsed += (parseInt(plan.used, 10)) ? parseInt(plan.used, 10) : 0;
if (plan.limit === 0) {
......@@ -138,48 +139,56 @@ export default class DomainMailboxPlans extends React.Component {
}
}
mailboxPlans.push(
<tr key='totalizacion-planes'>
<td className='mbx-plan'
style={{borderTop: 0}}
>
<strong>{'Total'}</strong>
</td>
<td
className='text-center'
style={{borderTop: 0}}
>
<strong>{totalLimit}</strong>
</td>
<td
className='text-center'
style={{borderTop: 0}}
>
<strong>{totalUsed}</strong>
</td>
</tr>
);
const panelBody = (
<table
id='domain-mbxs'
cellPadding='1'
cellSpacing='1'
className='table'
style={{marginBottom: '0px'}}
>
<thead>
<tr>
<th style={{width: '50%'}}></th>
<th className='text-center'>{'Límite'}</th>
<th className='text-center'>{'Usadas'}</th>
if (mailboxPlans.length > 0) {
mailboxPlans.push(
<tr key='totalizacion-planes'>
<td className='mbx-plan'
style={{borderTop: 0}}
>
<strong>{'Total'}</strong>
</td>
<td
className='text-center'
style={{borderTop: 0}}
>
<strong>{totalLimit}</strong>
</td>
<td
className='text-center'
style={{borderTop: 0}}
>
<strong>{totalUsed}</strong>
</td>
</tr>
</thead>
<tbody>
{mailboxPlans}
</tbody>
</table>
);
);
panelBody = (
<table
id='domain-mbxs'
cellPadding='1'
cellSpacing='1'
className='table'
style={{marginBottom: '0px'}}
>
<thead>
<tr>
<th style={{width: '50%'}}></th>
<th className='text-center'>{'Límite'}</th>
<th className='text-center'>{'Usadas'}</th>
</tr>
</thead>
<tbody>
{mailboxPlans}
</tbody>
</table>
);
} else {
panelBody = (
<div className='text-center'>
<h4 className='text-danger'>{'No posee casillas asignadas a su dominio.'}</h4>
</div>
);
}
return (
<Panel
......
......@@ -24,12 +24,11 @@ import ToggleModalButton from '../toggle_modal_button.jsx';
import ImportMassiveModal from '../import_massive_modal.jsx';
import DomainStore from '../../stores/domain_store.jsx';
import ZimbraStore from '../../stores/zimbra_store.jsx';
const QueryOptions = Constants.QueryOptions;
const messageType = Constants.MessageType;
import ZimbraStore from '../../stores/zimbra_store.jsx';
export default class Mailboxes extends React.Component {
constructor(props) {
super(props);
......@@ -57,6 +56,7 @@ export default class Mailboxes extends React.Component {
};
this.optionPlans = window.manager_config.plans;
this.domainId = null;
this.domainName = null;
this.state = {
page,
......@@ -122,10 +122,10 @@ export default class Mailboxes extends React.Component {
handleExportAsCSV(e) {
e.preventDefault();
const accounts = MailboxStore.getMailboxes();
if (accounts && accounts.account && accounts.account.length > 0) {
return Utils.exportAsCSV(accounts.account, 'all_accounts', true);
if (MailboxStore.getMailboxByDomainId(this.domainId)) {
const accounts = MailboxStore.getMailboxByDomainId(this.domainId);
const title = `Casillas de ${accounts.account[0].domain}`;
return Utils.exportAsCSV(accounts.account, 'domain', title, true);
}
return false;
......@@ -134,6 +134,7 @@ export default class Mailboxes extends React.Component {
componentWillReceiveProps(newProps) {
const condition = this.props.location.query.page !== newProps.location.query.page;
let domainId = null;
this.domainName = null;
if (condition) {
const page = parseInt(newProps.location.query.page, 10) || 1;
......@@ -198,18 +199,19 @@ export default class Mailboxes extends React.Component {
if (domainName) {
attrs.domain = domainName;
this.domainName = domainName;
}
new Promise((resolve, reject) => {
if (domainName) {
const hasMailboxForDomain = MailboxStore.getMailboxByDomainId(domainName);
const hasMailboxForDomain = MailboxStore.getMailboxByDomainId(this.domainId);
if (hasMailboxForDomain) {
return resolve(hasMailboxForDomain);
}
return Client.getAllAccounts(attrs, (success) => {
MailboxStore.setMailboxesByDomain(domainName, success);
MailboxStore.setMailboxesByDomain(this.domainId, success);
return resolve(success);
}, (error) => {
return reject(error);
......@@ -265,8 +267,10 @@ export default class Mailboxes extends React.Component {
}
}).finally(() => {
if (!this.isRefreshing) {
GlobalActions.emitEndLoading();
return GlobalActions.emitEndLoading();
}
return GlobalActions.emitEndLoading();
});
}
......@@ -310,6 +314,7 @@ export default class Mailboxes extends React.Component {
EventStore.removeMessageListener(this.showMessage);
MailboxStore.removeListenerAddMassive(this.showMessage);
$('#sidebar-mailboxes').removeClass('active');
this.domainName = null;
}
buildRow(row, classes, status) {
......@@ -464,6 +469,8 @@ export default class Mailboxes extends React.Component {
limit = partialAccounts.length;
}
const response = {};
for (let i = 0; i < limit; i++) {
const account = partialAccounts[i].attrs;
switch (account.zimbraAccountStatus) {
......@@ -476,14 +483,12 @@ export default class Mailboxes extends React.Component {
case 'locked':
activeAccounts.push(this.buildRow(partialAccounts[i], 'label label-warning m-r', 'Inactiva'));
break;
case 'lockedout':
case 'lockout':
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;
}
}
const response = {};
const all = `${arrayTabNames.shift()} (${totalAccounts})`;
const locked = `${arrayTabNames.shift()} (${lockedAccounts.length})`;
......@@ -622,6 +627,8 @@ export default class Mailboxes extends React.Component {
render() {
let message = null;
let content = null;
let panelInfo = null;
const data = this.state.data;
if (this.state.loading) {
content = (
......@@ -643,7 +650,7 @@ export default class Mailboxes extends React.Component {
}
if (this.state.notMatches) {
const domain = (this.state.domain) ? `para el dominio: ${this.state.domain}` : '';
const domain = (this.domainName) ? `para el dominio: ${this.domainName}` : '';
content = (
<div className='text-center'>
<h4>
......@@ -653,16 +660,24 @@ export default class Mailboxes extends React.Component {
);
}
const pagelInfo = (
panelInfo = (
<PageInfo
titlePage='Casillas'
descriptionPage='Usuarios de correo electrónico'
/>
);
if (this.state.data) {
const data = this.state.data;
if (this.domainId && data && this.domainName) {
const domainName = this.domainName;
panelInfo = (
<PageInfo
titlePage='Casillas'
descriptionPage={`Usuarios de correo electrónico de ${domainName}`}
/>
);
}
if (data) {
content = (
<PanelTab
tabNames={data.tabNames}
......@@ -675,7 +690,7 @@ export default class Mailboxes extends React.Component {
return (
<div>
{pagelInfo}
{panelInfo}
<div className='content animate-panel'>
{message}
<div className='row'>
......
......@@ -3,7 +3,7 @@
"zimbraUrl": "http://zimbra.zboxapp.dev:9081/zimbra_proxy/service/admin/soap",
"zimbraProxy": "https://192.168.1.8:7071",
"dnsApiUrl": "http://zimbra.zboxapp.dev:3000",
"webMailUrl": "https://zimbra.zboxapp.dev",
"webMailUrl": "https://192.168.1.8:8443",
"dns": {
"url": "http://zimbra.zboxapp.dev:9081//powerdns_proxy/",
"token": "otto"
......@@ -56,5 +56,21 @@
"zimbraLastLogonTimestamp": true
}
}
},
"export" : {
"domain": {
"name": "Email",
"giverName": "Nombre",
"sn": "Apellido",
"cn": "Usuario",
"zimbraCOSId": "Plan",
"zimbraAccountStatus": "Status"
},
"members": {
"name": "Miembros"
},
"allowers": {
"name": "Permitidos"
}
}
}
......@@ -516,8 +516,10 @@ body {
margin-left: -$menu-width;
}
#wrapper {
margin-left: 0;
#root {
#wrapper {
margin-left: 0;
}
}
}
......
......@@ -4,6 +4,7 @@
import {browserHistory} from 'react-router';
import * as GlobalActions from '../action_creators/global_actions.jsx';
import Constants from './constants.jsx';
import ZimbraStore from '../stores/zimbra_store.jsx';
const messageType = Constants.MessageType;
......@@ -345,34 +346,55 @@ export function getDomainFromString(string, otherwise) {
return domain;
}
export function exportAsCSV(data, title, hasLabel) {
const info = (typeof data === 'object') ? data : JSON.parse(data);
export function exportAsCSV(data, target, title, hasLabel) {
let info = (typeof data === 'object') ? data : JSON.parse(data);
const cos = getEnabledPlansByCosId(ZimbraStore.getAllCos());
const headers = window.manager_config.export[target];
const keys = Object.keys(headers);
const colNames = Object.values(headers);
const status = {
active: 'Activa',
closed: 'Cerrada',
locked: 'Inactiva',
lockout: 'Bloqueada'
};
let row = '';
let CSV = '';
CSV += title + '\r\n\n';
if (hasLabel) {
let row = '';
for (const index in info[0]) {
if (info[0].hasOwnProperty(index)) {
row += index + ',';
}
}
row = row.slice(0, row.length - 1);
row = colNames.join(',');
CSV += row + '\r\n';
}
for (var i = 0; i < info.length; i++) {
let row = '';
row = '';
const item = info[i];
for (var j = 0; j < keys.length; j++) {
let col = null;
for (var index in info[i]) {
if (info[i].hasOwnProperty(index)) {
row += '\'' + info[i][index] + '\',';
if (typeof item === 'object') {
col = status[item.attrs[keys[j]]] || item.attrs[keys[j]];
}
if (keys[j] === 'name') {
if (typeof item === 'string') {
col = item;
} else {
col = item[keys[j]] || item;
}
}
if (keys[j] === 'zimbraCOSId') {
col = cos[item.attrs[keys[j]]] || 'Sin plan';
col = titleCase(col);
}
col = col || 'No definido';
row += col + ',';
}
row = row.slice(0, -1);
......
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