Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
c68b517c
Commit
c68b517c
authored
Apr 29, 2016
by
Elias Nahum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Calculo de tipos de cuenta utilizando getAllCos y maxAccountsByCos
parent
b1bd98c2
Changes
16
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
775 additions
and
396 deletions
+775
-396
list.json
companies/list.json
+4
-0
companies.jsx
src/components/companies/companies.jsx
+50
-41
company_admins.jsx
src/components/companies/company_admins.jsx
+147
-78
company_details.jsx
src/components/companies/company_details.jsx
+1
-26
company_domains.jsx
src/components/companies/company_domains.jsx
+22
-6
company_mailbox_plans.jsx
src/components/companies/company_mailbox_plans.jsx
+56
-5
create_domain.jsx
src/components/domain/create_domain.jsx
+267
-199
domain_mailbox_plans.jsx
src/components/domain/domain_mailbox_plans.jsx
+50
-5
domains.jsx
src/components/domain/domains.jsx
+39
-28
login.jsx
src/components/login/login.jsx
+8
-1
message_bar.jsx
src/components/message_bar.jsx
+1
-1
index.jsx
src/index.jsx
+15
-1
company_store.jsx
src/stores/company_store.jsx
+60
-0
zimbra_store.jsx
src/stores/zimbra_store.jsx
+9
-0
client.jsx
src/utils/client.jsx
+27
-2
utils.jsx
src/utils/utils.jsx
+19
-3
No files found.
companies/list.json
View file @
c68b517c
...
@@ -14,5 +14,9 @@
...
@@ -14,5 +14,9 @@
{
{
"id"
:
"76424135-5"
,
"id"
:
"76424135-5"
,
"name"
:
"Test Company"
"name"
:
"Test Company"
},
{
"id"
:
"1233667482"
,
"name"
:
"Parnasa"
}
}
]
]
src/components/companies/companies.jsx
View file @
c68b517c
...
@@ -5,10 +5,12 @@ import $ from 'jquery';
...
@@ -5,10 +5,12 @@ import $ from 'jquery';
import
React
from
'react'
;
import
React
from
'react'
;
import
Promise
from
'bluebird'
;
import
Promise
from
'bluebird'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
CompaniesStore
from
'../../stores/company_store.jsx'
;
import
CompaniesStore
from
'../../stores/company_store.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
import
*
as
Client
from
'../../utils/client.jsx'
;
import
*
as
Client
from
'../../utils/client.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
...
@@ -27,7 +29,6 @@ export default class Companies extends React.Component {
...
@@ -27,7 +29,6 @@ export default class Companies extends React.Component {
this
.
getCompanies
=
this
.
getCompanies
.
bind
(
this
);
this
.
getCompanies
=
this
.
getCompanies
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getPlans
=
this
.
getPlans
.
bind
(
this
);
this
.
getPlans
=
this
.
getPlans
.
bind
(
this
);
this
.
getAdmins
=
this
.
getAdmins
.
bind
(
this
);
this
.
gotoCompany
=
this
.
gotoCompany
.
bind
(
this
);
this
.
gotoCompany
=
this
.
gotoCompany
.
bind
(
this
);
}
}
...
@@ -47,8 +48,8 @@ export default class Companies extends React.Component {
...
@@ -47,8 +48,8 @@ export default class Companies extends React.Component {
}
}
return
Client
.
getAllCompanies
().
then
((
data
)
=>
{
return
Client
.
getAllCompanies
().
then
((
data
)
=>
{
const
domains
=
data
.
map
((
d
)
=>
{
const
domains
=
data
.
map
((
company
)
=>
{
return
self
.
getDomains
(
d
);
return
self
.
getDomains
(
company
);
});
});
return
Promise
.
all
(
domains
).
then
((
comps
)
=>
{
return
Promise
.
all
(
domains
).
then
((
comps
)
=>
{
...
@@ -80,13 +81,17 @@ export default class Companies extends React.Component {
...
@@ -80,13 +81,17 @@ export default class Companies extends React.Component {
},
},
(
data
)
=>
{
(
data
)
=>
{
const
domains
=
data
.
domain
;
const
domains
=
data
.
domain
;
Promise
.
all
([
self
.
getPlans
(
domains
),
self
.
getAdmins
(
domains
)]).
if
(
domains
)
{
then
(()
=>
{
self
.
getPlans
(
domains
).
then
(()
=>
{
company
.
domains
=
domains
;
company
.
domains
=
domains
;
resolve
(
company
);
resolve
(
company
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
reject
(
error
);
reject
(
error
);
});
});
}
else
{
company
.
domains
=
[];
resolve
(
company
);
}
},
},
(
error
)
=>
{
(
error
)
=>
{
reject
(
error
);
reject
(
error
);
...
@@ -94,31 +99,6 @@ export default class Companies extends React.Component {
...
@@ -94,31 +99,6 @@ export default class Companies extends React.Component {
});
});
}
}
getAdmins
(
domains
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
promises
=
domains
.
map
((
d
)
=>
{
return
new
Promise
((
solve
,
rej
)
=>
{
return
d
.
getAdmins
((
err
,
admins
)
=>
{
if
(
err
)
{
return
rej
(
err
);
}
d
.
admins
=
admins
.
account
;
return
solve
(
d
);
});
});
});
Promise
.
all
(
promises
).
then
((
doms
)
=>
{
resolve
(
doms
);
}).
catch
((
error
)
=>
{
reject
(
error
);
});
});
}
getPlans
(
domains
)
{
getPlans
(
domains
)
{
const
names
=
domains
.
map
((
d
)
=>
{
const
names
=
domains
.
map
((
d
)
=>
{
return
d
.
name
;
return
d
.
name
;
...
@@ -155,6 +135,7 @@ export default class Companies extends React.Component {
...
@@ -155,6 +135,7 @@ export default class Companies extends React.Component {
}
}
let
panelBody
;
let
panelBody
;
let
noLimitError
;
if
(
this
.
state
.
companies
.
length
===
0
)
{
if
(
this
.
state
.
companies
.
length
===
0
)
{
panelBody
=
(
panelBody
=
(
<
div
className=
'center-block text-center'
>
<
div
className=
'center-block text-center'
>
...
@@ -168,17 +149,43 @@ export default class Companies extends React.Component {
...
@@ -168,17 +149,43 @@ export default class Companies extends React.Component {
);
);
}
else
{
}
else
{
const
rows
=
this
.
state
.
companies
.
map
((
c
)
=>
{
const
rows
=
this
.
state
.
companies
.
map
((
c
)
=>
{
const
plans
=
Utils
.
getPlansFromDomains
(
c
.
domains
);
const
cos
=
Utils
.
getEnabledPlansByCosId
(
ZimbraStore
.
getAllCos
()
);
const
plansString
=
[];
const
plansString
=
[];
const
totalBought
=
Object
.
keys
(
plans
).
reduce
((
prev
,
current
)
=>
{
const
domains
=
c
.
domains
;
const
limit
=
plans
[
current
].
limit
;
const
planKeys
=
Object
.
keys
(
cos
).
map
((
cosKey
)
=>
{
return
cos
[
cosKey
];
});
const
plans
=
{};
plansString
.
push
(
`
${
limit
}
${
Utils
.
titleCase
(
current
.
slice
(
0
,
3
))}
`
);
//eslint-disable-line no-undefined
planKeys
.
forEach
((
key
)
=>
{
plans
[
key
]
=
0
;
});
if
(
plans
[
prev
])
{
domains
.
forEach
((
d
)
=>
{
return
plans
[
prev
].
limit
+
limit
;
const
domainCos
=
d
.
maxAccountsByCos
();
if
(
domainCos
)
{
Object
.
keys
(
domainCos
).
forEach
((
id
)
=>
{
const
limit
=
domainCos
[
id
];
plans
[
cos
[
id
]]
+=
limit
;
});
}
else
if
(
!
noLimitError
)
{
noLimitError
=
(
<
MessageBar
message=
'Existen dominios sin límites asignados'
type=
'WARNING'
autoclose=
{
true
}
/>
);
}
}
return
limit
;
});
let
totalBought
=
0
;
planKeys
.
forEach
((
key
)
=>
{
const
limit
=
plans
[
key
];
plansString
.
push
(
`
${
limit
}
${
Utils
.
titleCase
(
key
.
slice
(
0
,
3
))}
`
);
//eslint-disable-line no-undefined
totalBought
+=
limit
;
});
});
return
(
return
(
<
tr
key=
{
c
.
id
}
>
<
tr
key=
{
c
.
id
}
>
...
@@ -203,6 +210,7 @@ export default class Companies extends React.Component {
...
@@ -203,6 +210,7 @@ export default class Companies extends React.Component {
</
tr
>
</
tr
>
);
);
});
});
panelBody
=
(
panelBody
=
(
<
div
className=
'table-responsive'
>
<
div
className=
'table-responsive'
>
<
div
className=
'table-responsive'
>
<
div
className=
'table-responsive'
>
...
@@ -232,6 +240,7 @@ export default class Companies extends React.Component {
...
@@ -232,6 +240,7 @@ export default class Companies extends React.Component {
titlePage=
'Empresas'
titlePage=
'Empresas'
descriptionPage=
'Las empresas son los que pagan el servicio'
descriptionPage=
'Las empresas son los que pagan el servicio'
/>
/>
{
noLimitError
}
<
div
className=
'content animate-panel'
>
<
div
className=
'content animate-panel'
>
<
div
className=
'row'
>
<
div
className=
'row'
>
<
div
className=
'col-md-12 central-content'
>
<
div
className=
'col-md-12 central-content'
>
...
...
src/components/companies/company_admins.jsx
View file @
c68b517c
...
@@ -3,10 +3,13 @@
...
@@ -3,10 +3,13 @@
import
React
from
'react'
;
import
React
from
'react'
;
import
_
from
'lodash'
;
import
_
from
'lodash'
;
import
Promise
from
'bluebird'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
StatusLabel
from
'../status_label.jsx'
;
import
StatusLabel
from
'../status_label.jsx'
;
import
CompanyStore
from
'../../stores/company_store.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
export
default
class
CompanyAdmins
extends
React
.
Component
{
export
default
class
CompanyAdmins
extends
React
.
Component
{
...
@@ -14,30 +17,93 @@ export default class CompanyAdmins extends React.Component {
...
@@ -14,30 +17,93 @@ export default class CompanyAdmins extends React.Component {
super
(
props
);
super
(
props
);
this
.
getCompanyAdmins
=
this
.
getCompanyAdmins
.
bind
(
this
);
this
.
getCompanyAdmins
=
this
.
getCompanyAdmins
.
bind
(
this
);
this
.
getAdmins
=
this
.
getAdmins
.
bind
(
this
);
this
.
state
=
{};
}
this
.
state
=
this
.
getCompanyAdmins
();
getAdmins
(
domains
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
promises
=
domains
.
map
((
d
)
=>
{
return
new
Promise
((
solve
,
rej
)
=>
{
return
d
.
getAdmins
((
err
,
admins
)
=>
{
if
(
err
)
{
return
rej
(
err
);
}
}
d
.
admins
=
admins
.
account
;
return
solve
(
d
);
});
});
});
return
Promise
.
all
(
promises
).
then
((
doms
)
=>
{
return
resolve
(
doms
);
}).
catch
((
error
)
=>
{
return
reject
(
error
);
});
});
}
getCompanyAdmins
()
{
getCompanyAdmins
()
{
const
domains
=
this
.
props
.
company
.
domains
;
const
company
=
this
.
props
.
company
;
const
domains
=
company
.
domains
;
const
admins
=
[];
const
admins
=
[];
const
domainsArray
=
[];
if
(
domains
)
{
if
(
domains
)
{
domains
.
forEach
((
d
)
=>
{
domains
.
forEach
((
d
)
=>
{
if
(
d
.
admins
)
{
if
(
d
.
admins
)
{
Reflect
.
apply
(
Array
.
prototype
.
push
,
admins
,
d
.
admins
);
Reflect
.
apply
(
Array
.
prototype
.
push
,
admins
,
d
.
admins
);
}
else
{
domainsArray
.
push
(
d
);
}
});
}
if
(
domainsArray
.
length
>
0
)
{
return
this
.
getAdmins
(
domainsArray
).
then
((
doms
)
=>
{
doms
.
forEach
((
d
)
=>
{
if
(
!
d
.
admins
)
{
d
.
admins
=
[];
}
CompanyStore
.
addDomainAdmins
(
company
.
id
,
d
);
Reflect
.
apply
(
Array
.
prototype
.
push
,
admins
,
d
.
admins
);
});
return
this
.
setState
({
admins
:
_
.
uniqBy
(
admins
,
'id'
)
});
}).
catch
(()
=>
{
return
this
.
setState
({
error
:
{
message
:
'No pudimos obtener los admins de los dominios'
,
type
:
'ERROR'
}
}
});
});
});
}
}
return
{
return
this
.
setState
(
{
admins
:
_
.
uniqBy
(
admins
,
'id'
)
admins
:
_
.
uniqBy
(
admins
,
'id'
)
};
});
}
componentDidMount
()
{
this
.
getCompanyAdmins
();
}
}
render
()
{
render
()
{
const
admins
=
this
.
state
.
admins
;
const
admins
=
this
.
state
.
admins
;
const
error
=
this
.
state
.
error
;
if
(
admins
||
error
)
{
let
panelBody
;
let
panelBody
;
if
(
admins
.
length
>
0
)
{
if
(
!
error
&&
admins
.
length
>
0
)
{
const
rows
=
admins
.
map
((
a
)
=>
{
const
rows
=
admins
.
map
((
a
)
=>
{
let
globalAdmin
=
a
.
attrs
.
zimbraIsAdminAccount
===
'TRUE'
;
let
globalAdmin
=
a
.
attrs
.
zimbraIsAdminAccount
===
'TRUE'
;
let
adminClass
=
''
;
let
adminClass
=
''
;
...
@@ -116,6 +182,9 @@ export default class CompanyAdmins extends React.Component {
...
@@ -116,6 +182,9 @@ export default class CompanyAdmins extends React.Component {
/>
/>
);
);
}
}
return
<
div
/>;
}
}
}
CompanyAdmins
.
propTypes
=
{
CompanyAdmins
.
propTypes
=
{
...
...
src/components/companies/company_details.jsx
View file @
c68b517c
...
@@ -32,7 +32,6 @@ export default class CompaniesDetails extends React.Component {
...
@@ -32,7 +32,6 @@ export default class CompaniesDetails extends React.Component {
this
.
getCompany
=
this
.
getCompany
.
bind
(
this
);
this
.
getCompany
=
this
.
getCompany
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getAdmins
=
this
.
getAdmins
.
bind
(
this
);
this
.
getPlans
=
this
.
getPlans
.
bind
(
this
);
this
.
getPlans
=
this
.
getPlans
.
bind
(
this
);
}
}
...
@@ -76,7 +75,7 @@ export default class CompaniesDetails extends React.Component {
...
@@ -76,7 +75,7 @@ export default class CompaniesDetails extends React.Component {
},
},
(
data
)
=>
{
(
data
)
=>
{
const
domains
=
data
.
domain
;
const
domains
=
data
.
domain
;
Promise
.
all
([
self
.
getPlans
(
domains
),
self
.
getAdmins
(
domains
)]
).
self
.
getPlans
(
domains
).
then
(()
=>
{
then
(()
=>
{
company
.
domains
=
domains
;
company
.
domains
=
domains
;
resolve
(
company
);
resolve
(
company
);
...
@@ -90,30 +89,6 @@ export default class CompaniesDetails extends React.Component {
...
@@ -90,30 +89,6 @@ export default class CompaniesDetails extends React.Component {
});
});
}
}
getAdmins
(
domains
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
const
promises
=
domains
.
map
((
d
)
=>
{
return
new
Promise
((
solve
,
rej
)
=>
{
return
d
.
getAdmins
((
err
,
admins
)
=>
{
if
(
err
)
{
return
rej
(
err
);
}
d
.
admins
=
admins
.
account
;
return
solve
(
d
);
});
});
});
Promise
.
all
(
promises
).
then
((
doms
)
=>
{
resolve
(
doms
);
}).
catch
((
error
)
=>
{
reject
(
error
);
});
});
}
getPlans
(
domains
)
{
getPlans
(
domains
)
{
const
names
=
domains
.
map
((
d
)
=>
{
const
names
=
domains
.
map
((
d
)
=>
{
return
d
.
name
;
return
d
.
name
;
...
...
src/components/companies/company_domains.jsx
View file @
c68b517c
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
import
React
from
'react'
;
import
React
from
'react'
;
import
UserStore
from
'../../stores/user_store.jsx'
;
import
UserStore
from
'../../stores/user_store.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
StatusLabel
from
'../status_label.jsx'
;
import
StatusLabel
from
'../status_label.jsx'
;
...
@@ -21,7 +22,7 @@ export default class CompanyDomains extends React.Component {
...
@@ -21,7 +22,7 @@ export default class CompanyDomains extends React.Component {
label
:
'Agregar Dominio'
,
label
:
'Agregar Dominio'
,
props
:
{
props
:
{
className
:
'btn btn-default btn-xs'
,
className
:
'btn btn-default btn-xs'
,
onClick
:
(
e
)
=>
Utils
.
handleLink
(
e
,
'/domains/new'
,
this
.
props
.
location
)
onClick
:
(
e
)
=>
Utils
.
handleLink
(
e
,
`/companies/
${
this
.
props
.
company
.
id
}
/domains/new`
,
this
.
props
.
location
)
}
}
}];
}];
}
}
...
@@ -47,15 +48,30 @@ export default class CompanyDomains extends React.Component {
...
@@ -47,15 +48,30 @@ export default class CompanyDomains extends React.Component {
}
}
let
totalAccounts
=
0
;
let
totalAccounts
=
0
;
const
plans
=
Utils
.
getPlansFromDomain
(
d
);
const
cos
=
Utils
.
getEnabledPlansByCosId
(
ZimbraStore
.
getAllCos
());
const
planKeys
=
Object
.
keys
(
cos
).
map
((
cosKey
)
=>
{
return
cos
[
cosKey
];
});
const
plans
=
{};
planKeys
.
forEach
((
key
)
=>
{
plans
[
key
]
=
0
;
});
const
domainCos
=
d
.
maxAccountsByCos
();
if
(
domainCos
)
{
Object
.
keys
(
domainCos
).
forEach
((
id
)
=>
{
const
limit
=
domainCos
[
id
];
plans
[
cos
[
id
]]
+=
limit
;
});
}
const
plansArray
=
Object
.
keys
(
plans
).
map
((
p
)
=>
{
const
plansArray
=
planKeys
.
map
((
key
)
=>
{
const
limit
=
plans
[
p
].
limit
;
const
limit
=
plans
[
key
]
;
totalAccounts
+=
limit
;
totalAccounts
+=
limit
;
return
(
return
(
<
li
key=
{
`domain-${d.id}-${
p
}`
}
>
<
li
key=
{
`domain-${d.id}-${
key
}`
}
>
{
limit
}
{
Utils
.
titleCase
(
p
.
slice
(
0
,
3
))
}
{
limit
}
{
Utils
.
titleCase
(
key
.
slice
(
0
,
3
))
}
</
li
>
</
li
>
);
);
});
});
...
...
src/components/companies/company_mailbox_plans.jsx
View file @
c68b517c
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
import
React
from
'react'
;
import
React
from
'react'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
export
default
class
CompanyMailboxPlans
extends
React
.
Component
{
export
default
class
CompanyMailboxPlans
extends
React
.
Component
{
...
@@ -29,8 +32,55 @@ export default class CompanyMailboxPlans extends React.Component {
...
@@ -29,8 +32,55 @@ export default class CompanyMailboxPlans extends React.Component {
];
];
const
mailboxPlans
=
[];
const
mailboxPlans
=
[];
const
cos
=
Utils
.
getEnabledPlansByCosId
(
ZimbraStore
.
getAllCos
());
const
planKeys
=
Object
.
keys
(
cos
).
map
((
c
)
=>
{
return
cos
[
c
];
});
const
domains
=
company
.
domains
;
const
domains
=
company
.
domains
;
const
plans
=
Utils
.
getPlansFromDomains
(
domains
);
const
plans
=
{};
let
noLimitError
;
planKeys
.
forEach
((
key
)
=>
{
plans
[
key
]
=
{
limit
:
0
,
used
:
0
,
free
:
0
,
noLimit
:
false
};
});
domains
.
forEach
((
d
)
=>
{
const
domainCos
=
d
.
maxAccountsByCos
();
const
domainPlans
=
Utils
.
getPlansFromDomain
(
d
);
let
used
=
0
;
if
(
domainCos
)
{
Object
.
keys
(
domainCos
).
forEach
((
id
)
=>
{
const
limit
=
domainCos
[
id
];
used
=
domainPlans
[
cos
[
id
]].
used
;
plans
[
cos
[
id
]].
limit
+=
limit
;
plans
[
cos
[
id
]].
used
+=
used
;
plans
[
cos
[
id
]].
free
+=
(
limit
-
used
);
});
}
else
{
if
(
!
noLimitError
)
{
noLimitError
=
(
<
MessageBar
message=
'Existen dominios sin límites asignados'
type=
'WARNING'
autoclose=
{
true
}
/>
);
}
Object
.
keys
(
domainPlans
).
forEach
((
id
)
=>
{
used
=
domainPlans
[
id
].
used
;
plans
[
id
].
noLimit
=
true
;
plans
[
id
].
used
+=
used
;
});
}
});
for
(
const
key
in
plans
)
{
for
(
const
key
in
plans
)
{
if
(
plans
.
hasOwnProperty
(
key
))
{
if
(
plans
.
hasOwnProperty
(
key
))
{
...
@@ -42,12 +92,12 @@ export default class CompanyMailboxPlans extends React.Component {
...
@@ -42,12 +92,12 @@ export default class CompanyMailboxPlans extends React.Component {
const
plan
=
plans
[
key
];
const
plan
=
plans
[
key
];
limit
=
plan
.
limit
;
limit
=
plan
.
limit
;
used
=
plan
.
used
;
used
=
plan
.
used
;
if
(
limit
)
{
if
(
plan
.
noLimit
)
{
free
=
limit
-
used
;
percent
=
Math
.
round
((
used
*
100
)
/
limit
);
}
else
{
limit
=
free
=
'
\
u221e'
;
limit
=
free
=
'
\
u221e'
;
percent
=
100
;
percent
=
100
;
}
else
{
free
=
limit
-
used
;
percent
=
Math
.
round
((
used
*
100
)
/
limit
);
}
}
if
(
percent
<=
10
)
{
if
(
percent
<=
10
)
{
...
@@ -112,6 +162,7 @@ export default class CompanyMailboxPlans extends React.Component {
...
@@ -112,6 +162,7 @@ export default class CompanyMailboxPlans extends React.Component {
<
Panel
<
Panel
title=
'Casillas'
title=
'Casillas'
btnsHeader=
{
headerButtons
}
btnsHeader=
{
headerButtons
}
error=
{
noLimitError
}
children=
{
panelBody
}
children=
{
panelBody
}
/>
/>
);
);
...
...
src/components/domain/create_domain.jsx
View file @
c68b517c
This diff is collapsed.
Click to expand it.
src/components/domain/domain_mailbox_plans.jsx
View file @
c68b517c
...
@@ -3,8 +3,11 @@
...
@@ -3,8 +3,11 @@
import
React
from
'react'
;
import
React
from
'react'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
import
*
as
Utils
from
'../../utils/utils.jsx'
;
export
default
class
DomainMailboxPlans
extends
React
.
Component
{
export
default
class
DomainMailboxPlans
extends
React
.
Component
{
...
@@ -61,15 +64,56 @@ export default class DomainMailboxPlans extends React.Component {
...
@@ -61,15 +64,56 @@ export default class DomainMailboxPlans extends React.Component {
];
];
const
mailboxPlans
=
[];
const
mailboxPlans
=
[];
const
plans
=
this
.
state
.
plans
;
const
cos
=
Utils
.
getEnabledPlansByCosId
(
ZimbraStore
.
getAllCos
());
const
configPlans
=
global
.
window
.
manager_config
.
plans
;
const
planKeys
=
Object
.
keys
(
cos
).
map
((
c
)
=>
{
return
cos
[
c
];
});
const
domain
=
this
.
props
.
domain
;
const
domainCos
=
domain
.
maxAccountsByCos
();
const
domainPlans
=
Utils
.
getPlansFromDomain
(
domain
);
const
plans
=
{};
let
noLimitError
;
let
totalUsed
=
0
;
let
totalUsed
=
0
;
let
totalLimit
=
0
;
let
totalLimit
=
0
;
planKeys
.
forEach
((
key
)
=>
{
plans
[
key
]
=
{
limit
:
0
,
used
:
0
};
});
let
used
=
0
;
if
(
domainCos
)
{
Object
.
keys
(
domainCos
).
forEach
((
id
)
=>
{
const
limit
=
domainCos
[
id
];
used
=
domainPlans
[
cos
[
id
]].
used
;
plans
[
cos
[
id
]].
limit
+=
limit
;
plans
[
cos
[
id
]].
used
+=
used
;
});
}
for
(
const
key
in
plans
)
{
for
(
const
key
in
plans
)
{
if
(
plans
.
hasOwnProperty
(
key
)
&&
configPlans
[
key
]
)
{
if
(
plans
.
hasOwnProperty
(
key
))
{
const
plan
=
plans
[
key
];
const
plan
=
plans
[
key
];
totalUsed
+=
plan
.
used
;
totalUsed
+=
plan
.
used
;
totalLimit
+=
plan
.
limit
||
0
;
if
(
plan
.
limit
===
0
)
{
totalLimit
=
'
\
u221e'
;
if
(
!
noLimitError
)
{
noLimitError
=
(
<
MessageBar
message=
'Existen dominios sin límites asignados'
type=
'WARNING'
autoclose=
{
true
}
/>
);
}
}
else
{
totalLimit
+=
plan
.
limit
;
}
mailboxPlans
.
push
(
mailboxPlans
.
push
(
<
tr
key=
{
`plan-${key}`
}
>
<
tr
key=
{
`plan-${key}`
}
>
<
td
className=
'mbx-plan'
<
td
className=
'mbx-plan'
...
@@ -105,7 +149,7 @@ export default class DomainMailboxPlans extends React.Component {
...
@@ -105,7 +149,7 @@ export default class DomainMailboxPlans extends React.Component {
className=
'text-center'
className=
'text-center'
style=
{
{
borderTop
:
0
}
}
style=
{
{
borderTop
:
0
}
}
>
>
<
strong
>
{
totalLimit
||
'
\
u221e'
}
</
strong
>
<
strong
>
{
totalLimit
}
</
strong
>
</
td
>
</
td
>
<
td
<
td
className=
'text-center'
className=
'text-center'
...
@@ -141,6 +185,7 @@ export default class DomainMailboxPlans extends React.Component {
...
@@ -141,6 +185,7 @@ export default class DomainMailboxPlans extends React.Component {
<
Panel
<
Panel
title=
'Casillas'
title=
'Casillas'
btnsHeader=
{
headerButtons
}
btnsHeader=
{
headerButtons
}
error=
{
noLimitError
}
children=
{
panelBody
}
children=
{
panelBody
}
/>
/>
);
);
...
...
src/components/domain/domains.jsx
View file @
c68b517c
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
React
from
'react'
;
import
React
from
'react'
;
import
Promise
from
'bluebird'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
...
@@ -42,42 +43,51 @@ export default class Domains extends React.Component {
...
@@ -42,42 +43,51 @@ export default class Domains extends React.Component {
},
},
(
data
)
=>
{
(
data
)
=>
{
const
domains
=
data
.
domain
;
const
domains
=
data
.
domain
;
const
plans
=
domains
.
map
((
d
)
=>
{
this
.
getPlans
(
domains
).
return
self
.
getPlans
(
d
);
then
(()
=>
{
});
Promise
.
all
(
plans
).
then
(
()
=>
{
self
.
setState
({
self
.
setState
({
data
data
});
});
GlobalActions
.
emitEndLoading
();
}).
},
catch
(()
=>
{
()
=>
{
this
.
setState
({
this
.
setState
({
error
:
'No se obtuvieron los planes de las cuentas'
error
:
{
message
:
'No se obtuvieron los planes de las cuentas'
,
type
:
messageType
.
ERROR
}
});
});
}).
finally
(()
=>
{
GlobalActions
.
emitEndLoading
();
GlobalActions
.
emitEndLoading
();
}
});
);
},
},
(
error
)
=>
{
(
error
)
=>
{
this
.
setState
({
this
.
setState
({
error
:
error
.
message
error
:
{
message
:
error
.
message
,
type
:
messageType
.
ERROR
}
});
});
GlobalActions
.
emitEndLoading
();
GlobalActions
.
emitEndLoading
();
}
}
);
);
}
}
getPlans
(
domain
)
{
getPlans
(
domains
)
{
const
names
=
domains
.
map
((
d
)
=>
{
return
d
.
name
;
});
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
Client
.
countAccounts
(
domain
.
name
,
return
Client
.
batchCountAccount
(
(
info
)
=>
{
names
,
domain
.
plans
=
info
;
(
data
)
=>
{
resolve
();
domains
.
forEach
((
d
,
i
)
=>
{
d
.
plans
=
data
[
i
];
});
resolve
(
domains
);
},
},
()
=>
{
(
error
)
=>
{
reject
();
reject
(
error
);
}
}
);
);
});
});
...
@@ -105,12 +115,13 @@ export default class Domains extends React.Component {
...
@@ -105,12 +115,13 @@ export default class Domains extends React.Component {
}
}
render
()
{
render
()
{
const
error
=
this
.
state
.
error
;
let
message
;
let
message
;
if
(
this
.
state
.
error
)
{
if
(
error
)
{
message
=
(
message
=
(
<
MessageBar
<
MessageBar
message=
{
this
.
state
.
error
}
message=
{
error
.
message
}
type=
{
messageType
.
WARNING
}
type=
{
error
.
type
}
autoclose=
{
true
}
autoclose=
{
true
}
/>
/>
);
);
...
...
src/components/login/login.jsx
View file @
c68b517c
...
@@ -6,6 +6,8 @@ import React from 'react';
...
@@ -6,6 +6,8 @@ import React from 'react';
import
{
browserHistory
}
from
'react-router'
;
import
{
browserHistory
}
from
'react-router'
;
import
UserStore
from
'../../stores/user_store.jsx'
;
import
UserStore
from
'../../stores/user_store.jsx'
;
import
ZimbraStore
from
'../../stores/zimbra_store.jsx'
;
import
Constants
from
'../../utils/constants.jsx'
;
import
Constants
from
'../../utils/constants.jsx'
;
import
*
as
Client
from
'../../utils/client.jsx'
;
import
*
as
Client
from
'../../utils/client.jsx'
;
...
@@ -66,7 +68,12 @@ export default class Login extends React.Component {
...
@@ -66,7 +68,12 @@ export default class Login extends React.Component {
Client
.
login
(
email
,
password
,
Client
.
login
(
email
,
password
,
()
=>
{
()
=>
{
return
Client
.
getAllCos
(
(
cosData
)
=>
{
ZimbraStore
.
setAllCos
(
cosData
);
browserHistory
.
push
(
'/companies'
);
browserHistory
.
push
(
'/companies'
);
}
);
},
},
(
err
)
=>
{
(
err
)
=>
{
this
.
setState
({
loginError
:
err
.
message
});
this
.
setState
({
loginError
:
err
.
message
});
...
...
src/components/message_bar.jsx
View file @
c68b517c
...
@@ -103,7 +103,7 @@ export default class MessageBar extends React.Component {
...
@@ -103,7 +103,7 @@ export default class MessageBar extends React.Component {
MessageBar
.
defaultProps
=
{
MessageBar
.
defaultProps
=
{
message
:
null
,
message
:
null
,
type
:
'
error
'
,
type
:
'
ERROR
'
,
position
:
'relative'
,
position
:
'relative'
,
canClose
:
true
,
canClose
:
true
,
autoclose
:
false
,
autoclose
:
false
,
...
...
src/index.jsx
View file @
c68b517c
...
@@ -77,7 +77,17 @@ function onPreLoggedIn(nextState, replace, callback) {
...
@@ -77,7 +77,17 @@ function onPreLoggedIn(nextState, replace, callback) {
global
.
window
.
Zimbra
=
ZimbraStore
.
getCurrent
();
global
.
window
.
Zimbra
=
ZimbraStore
.
getCurrent
();
}
}
const
cos
=
ZimbraStore
.
getAllCos
();
if
(
cos
)
{
return
callback
();
return
callback
();
}
return
Client
.
getAllCos
(
(
cosData
)
=>
{
ZimbraStore
.
setAllCos
(
cosData
);
return
callback
();
}
);
},
},
(
err
)
=>
{
(
err
)
=>
{
let
query
;
let
query
;
...
@@ -145,6 +155,10 @@ function renderRootComponent() {
...
@@ -145,6 +155,10 @@ function renderRootComponent() {
path=
'companies/:id'
path=
'companies/:id'
component=
{
Company
}
component=
{
Company
}
/>
/>
<
Route
path=
'companies/:id/domains/new'
component=
{
CreateDomains
}
/>
<
Route
<
Route
path=
'mailboxes'
path=
'mailboxes'
...
...
src/stores/company_store.jsx
View file @
c68b517c
...
@@ -51,6 +51,66 @@ class CompanyStoreClass {
...
@@ -51,6 +51,66 @@ class CompanyStoreClass {
setCurrent
(
company
)
{
setCurrent
(
company
)
{
this
.
current
=
company
;
this
.
current
=
company
;
}
}
addDomain
(
companyId
,
domain
)
{
const
currentCompany
=
this
.
getCurrent
();
const
company
=
this
.
getCompanyById
(
companyId
);
if
(
currentCompany
&&
currentCompany
.
id
===
companyId
)
{
currentCompany
.
domains
.
push
(
domain
);
if
(
company
)
{
this
.
companies
[
companyId
]
=
currentCompany
;
}
}
else
if
(
company
)
{
company
.
domains
.
push
(
domain
);
}
}
addDomainAdmins
(
companyId
,
domain
)
{
function
findDomain
(
company
)
{
const
domains
=
company
.
domains
;
let
index
=
-
1
;
if
(
domains
)
{
domains
.
forEach
((
d
,
i
)
=>
{
if
(
d
.
id
===
domain
.
id
)
{
index
=
i
;
return
false
;
}
return
true
;
});
}
return
index
;
}
function
replaceDomain
(
company
,
index
)
{
if
(
index
>=
0
)
{
company
.
domains
[
index
]
=
domain
;
}
else
{
company
.
domains
.
push
(
domain
);
}
}
const
currentCompany
=
this
.
getCurrent
();
const
company
=
this
.
getCompanyById
(
companyId
);
let
index
=
-
1
;
if
(
currentCompany
&&
currentCompany
.
id
===
companyId
)
{
index
=
findDomain
(
currentCompany
);
replaceDomain
(
currentCompany
,
index
);
if
(
company
)
{
this
.
companies
[
companyId
]
=
currentCompany
;
}
}
else
if
(
company
)
{
index
=
findDomain
(
company
);
replaceDomain
(
company
,
index
);
}
}
}
}
const
CompanyStore
=
new
CompanyStoreClass
();
const
CompanyStore
=
new
CompanyStoreClass
();
...
...
src/stores/zimbra_store.jsx
View file @
c68b517c
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
class
ZimbraStoreClass
{
class
ZimbraStoreClass
{
constructor
()
{
constructor
()
{
this
.
zimbra
=
null
;
this
.
zimbra
=
null
;
this
.
cos
=
null
;
}
}
getCurrent
()
{
getCurrent
()
{
...
@@ -13,6 +14,14 @@ class ZimbraStoreClass {
...
@@ -13,6 +14,14 @@ class ZimbraStoreClass {
setCurrent
(
zimbra
)
{
setCurrent
(
zimbra
)
{
this
.
zimbra
=
zimbra
;
this
.
zimbra
=
zimbra
;
}
}
setAllCos
(
cos
)
{
this
.
cos
=
cos
;
}
getAllCos
()
{
return
this
.
cos
;
}
}
}
var
ZimbraStore
=
new
ZimbraStoreClass
();
var
ZimbraStore
=
new
ZimbraStoreClass
();
...
...
src/utils/client.jsx
View file @
c68b517c
...
@@ -228,6 +228,25 @@ export function getDomain(id, success, error) {
...
@@ -228,6 +228,25 @@ export function getDomain(id, success, error) {
);
);
}
}
export
function
createDomain
(
domain
,
success
,
error
)
{
initZimbra
().
then
(
(
zimbra
)
=>
{
zimbra
.
createDomain
(
domain
.
name
,
domain
.
attrs
,
(
err
,
data
)
=>
{
if
(
err
)
{
const
e
=
handleError
(
'createDomain'
,
err
);
return
error
(
e
);
}
return
success
(
data
);
});
},
(
err
)
=>
{
const
e
=
handleError
(
'createDomain'
,
err
);
return
error
(
e
);
}
);
}
export
function
addDistributionList
(
name
,
attrs
,
success
,
error
)
{
export
function
addDistributionList
(
name
,
attrs
,
success
,
error
)
{
initZimbra
().
then
(
initZimbra
().
then
(
(
zimbra
)
=>
{
(
zimbra
)
=>
{
...
@@ -500,15 +519,21 @@ export function getAllCos(success, error) {
...
@@ -500,15 +519,21 @@ export function getAllCos(success, error) {
zimbra
.
getAllCos
((
err
,
data
)
=>
{
zimbra
.
getAllCos
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
const
e
=
handleError
(
'getAllCos'
,
err
);
const
e
=
handleError
(
'getAllCos'
,
err
);
if
(
error
)
{
return
error
(
e
);
return
error
(
e
);
}
}
}
return
success
(
data
);
return
success
(
data
);
});
});
},
},
(
err
)
=>
{
(
err
)
=>
{
const
e
=
handleError
(
'getAllCos'
,
err
);
const
e
=
handleError
(
'getAllCos'
,
err
);
if
(
error
)
{
return
error
(
e
);
return
error
(
e
);
}
}
return
null
;
}
);
);
}
}
src/utils/utils.jsx
View file @
c68b517c
...
@@ -3,7 +3,9 @@
...
@@ -3,7 +3,9 @@
import
{
browserHistory
}
from
'react-router'
;
import
{
browserHistory
}
from
'react-router'
;
import
*
as
GlobalActions
from
'../action_creators/global_actions.jsx'
;
import
*
as
GlobalActions
from
'../action_creators/global_actions.jsx'
;
import
CONSTANTS
from
'./constants.jsx'
;
import
Constants
from
'./constants.jsx'
;
const
messageType
=
Constants
.
MessageType
;
export
function
setCookie
(
cname
,
cvalue
)
{
export
function
setCookie
(
cname
,
cvalue
)
{
localStorage
.
setItem
(
cname
,
cvalue
);
localStorage
.
setItem
(
cname
,
cvalue
);
...
@@ -178,7 +180,7 @@ export function validateInputRequired(refs) {
...
@@ -178,7 +180,7 @@ export function validateInputRequired(refs) {
}
}
const
Error
=
{
const
Error
=
{
message
,
message
,
typeError
:
'warning'
,
typeError
:
messageType
.
ERROR
,
node
:
refs
[
ref
]
node
:
refs
[
ref
]
};
};
...
@@ -210,7 +212,7 @@ export function dateFormatted(dateString, isShortDate, separator) {
...
@@ -210,7 +212,7 @@ export function dateFormatted(dateString, isShortDate, separator) {
const
year
=
date
.
substr
(
0
,
4
);
const
year
=
date
.
substr
(
0
,
4
);
const
month
=
(
isShortDate
)
?
date
.
substr
(
4
,
2
)
:
parseInt
(
date
.
substr
(
4
,
2
),
10
);
const
month
=
(
isShortDate
)
?
date
.
substr
(
4
,
2
)
:
parseInt
(
date
.
substr
(
4
,
2
),
10
);
const
day
=
date
.
substr
(
6
,
2
);
const
day
=
date
.
substr
(
6
,
2
);
let
dateFormattedString
=
`
${
day
}
de
${
C
ONSTANTS
.
MONTHS
[
month
-
1
]}
de
${
year
}
`
;
let
dateFormattedString
=
`
${
day
}
de
${
C
onstants
.
MONTHS
[
month
-
1
]}
de
${
year
}
`
;
if
(
isShortDate
)
{
if
(
isShortDate
)
{
dateFormattedString
=
`
${
day
}${
separator
}${
month
}${
separator
}${
year
}
`
;
dateFormattedString
=
`
${
day
}${
separator
}${
month
}${
separator
}${
year
}
`
;
...
@@ -295,3 +297,17 @@ export function getEnabledPlansByCos(cosArray) {
...
@@ -295,3 +297,17 @@ export function getEnabledPlansByCos(cosArray) {
return
plans
;
return
plans
;
}
}
export
function
getEnabledPlansByCosId
(
cosArray
)
{
const
configPlans
=
global
.
window
.
manager_config
.
plans
;
const
plans
=
{};
cosArray
.
forEach
((
cos
)
=>
{
const
key
=
cos
.
name
;
if
(
configPlans
.
hasOwnProperty
(
key
)
&&
configPlans
[
key
])
{
plans
[
cos
.
id
]
=
key
;
}
});
return
plans
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment