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
4505d6e4
Commit
4505d6e4
authored
Apr 18, 2016
by
enahum
Committed by
Juorder Gonzalez
Apr 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pagination modified, TODO: next, prev buttons (#18)
parent
18a4ce67
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
98 deletions
+119
-98
domains.jsx
src/components/domain/domains.jsx
+48
-23
pagination.jsx
src/components/pagination.jsx
+57
-27
client.jsx
src/utils/client.jsx
+7
-17
constants.jsx
src/utils/constants.jsx
+7
-31
No files found.
src/components/domain/domains.jsx
View file @
4505d6e4
...
@@ -7,11 +7,15 @@ import {browserHistory} from 'react-router';
...
@@ -7,11 +7,15 @@ import {browserHistory} from 'react-router';
import
MessageBar
from
'../message_bar.jsx'
;
import
MessageBar
from
'../message_bar.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
PageInfo
from
'../page_info.jsx'
;
import
Pagination
from
'../pagination.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
Panel
from
'../panel.jsx'
;
import
StatusLabel
from
'../status_label.jsx'
;
import
StatusLabel
from
'../status_label.jsx'
;
import
*
as
Client
from
'../../utils/client.jsx'
;
import
*
as
Client
from
'../../utils/client.jsx'
;
import
*
as
GlobalActions
from
'../../action_creators/global_actions.jsx'
;
import
*
as
GlobalActions
from
'../../action_creators/global_actions.jsx'
;
import
Constants
from
'../../utils/constants.jsx'
;
const
QueryOptions
=
Constants
.
QueryOptions
;
export
default
class
Domains
extends
React
.
Component
{
export
default
class
Domains
extends
React
.
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
...
@@ -20,8 +24,11 @@ export default class Domains extends React.Component {
...
@@ -20,8 +24,11 @@ export default class Domains extends React.Component {
this
.
handleLink
=
this
.
handleLink
.
bind
(
this
);
this
.
handleLink
=
this
.
handleLink
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
this
.
getDomains
=
this
.
getDomains
.
bind
(
this
);
const
page
=
parseInt
(
this
.
props
.
location
.
query
.
page
,
10
)
||
1
;
this
.
state
=
{
this
.
state
=
{
data
:
null
page
,
offset
:
((
page
-
1
)
*
QueryOptions
.
DEFAULT_LIMIT
)
};
};
}
}
handleLink
(
e
,
path
)
{
handleLink
(
e
,
path
)
{
...
@@ -33,6 +40,10 @@ export default class Domains extends React.Component {
...
@@ -33,6 +40,10 @@ export default class Domains extends React.Component {
}
}
getDomains
()
{
getDomains
()
{
Client
.
getAllDomains
(
Client
.
getAllDomains
(
{
limit
:
QueryOptions
.
DEFAULT_LIMIT
,
offset
:
this
.
state
.
offset
},
(
data
)
=>
{
(
data
)
=>
{
this
.
setState
({
this
.
setState
({
data
data
...
@@ -47,6 +58,20 @@ export default class Domains extends React.Component {
...
@@ -47,6 +58,20 @@ export default class Domains extends React.Component {
}
}
);
);
}
}
componentWillReceiveProps
(
newProps
)
{
if
(
this
.
props
.
location
.
query
.
page
!==
newProps
.
location
.
query
.
page
)
{
const
page
=
parseInt
(
newProps
.
location
.
query
.
page
,
10
)
||
1
;
GlobalActions
.
emitStartLoading
();
this
.
state
=
{
page
,
offset
:
((
page
-
1
)
*
QueryOptions
.
DEFAULT_LIMIT
)
};
this
.
getDomains
();
}
}
componentDidMount
()
{
componentDidMount
()
{
$
(
'#sidebar-domains'
).
addClass
(
'active'
);
$
(
'#sidebar-domains'
).
addClass
(
'active'
);
this
.
getDomains
();
this
.
getDomains
();
...
@@ -149,7 +174,7 @@ export default class Domains extends React.Component {
...
@@ -149,7 +174,7 @@ export default class Domains extends React.Component {
}
}
const
panelBody
=
(
const
panelBody
=
(
<
div
>
<
div
key=
'panelBody'
>
<
div
<
div
id=
'index-domains-table'
id=
'index-domains-table'
className=
'table-responsive'
className=
'table-responsive'
...
@@ -177,32 +202,33 @@ export default class Domains extends React.Component {
...
@@ -177,32 +202,33 @@ export default class Domains extends React.Component {
</
div
>
</
div
>
);
);
const
pageInfo
=
(
let
pagination
;
<
PageInfo
if
(
this
.
state
.
offset
>
0
||
(
this
.
state
.
data
&&
this
.
state
.
data
.
more
))
{
titlePage=
'Dominios'
const
totalPages
=
this
.
state
.
data
?
Math
.
ceil
(
this
.
state
.
data
.
total
/
QueryOptions
.
DEFAULT_LIMIT
)
:
0
;
descriptionPage=
'Dominios de correos creados'
pagination
=
(
<
Pagination
key=
'panelPagination'
url=
'domains'
currentPage=
{
this
.
state
.
page
}
totalPages=
{
totalPages
}
/>
/>
);
);
}
const
hasPageInfo
=
(
this
.
props
.
children
)
?
''
:
{
pageInfo
};
const
viewIndex
=
(
<
Panel
btnsHeader=
{
addDomainButton
}
children=
{
panelBody
}
/>
);
const
view
=
(
this
.
props
.
children
||
viewIndex
);
return
(
return
(
<
div
>
<
div
>
{
hasPageInfo
}
<
PageInfo
titlePage=
'Dominios'
descriptionPage=
'Dominios de correos creados'
/>
{
message
}
{
message
}
<
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'
>
{
view
}
<
Panel
btnsHeader=
{
addDomainButton
}
children=
{
[
panelBody
,
pagination
]
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -212,6 +238,5 @@ export default class Domains extends React.Component {
...
@@ -212,6 +238,5 @@ export default class Domains extends React.Component {
}
}
Domains
.
propTypes
=
{
Domains
.
propTypes
=
{
location
:
React
.
PropTypes
.
object
.
isRequired
,
location
:
React
.
PropTypes
.
object
.
isRequired
children
:
React
.
PropTypes
.
any
};
};
src/components/pagination.jsx
View file @
4505d6e4
import
React
from
'react'
;
import
React
from
'react'
;
import
Anchor
from
'./anchor.jsx
'
;
import
{
browserHistory
}
from
'react-router
'
;
export
default
class
Pagination
extends
React
.
Component
{
export
default
class
Pagination
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
handleChange
=
this
.
handleChange
.
bind
(
this
);
}
handleChange
(
e
)
{
e
.
preventDefault
();
const
page
=
parseInt
(
e
.
currentTarget
.
innerText
,
10
);
let
pageUrl
=
''
;
if
(
page
>
1
)
{
pageUrl
=
`?page=
${
page
}
`
;
}
browserHistory
.
push
(
`/
${
this
.
props
.
url
}${
pageUrl
}
`
);
}
render
()
{
render
()
{
return
(
const
total
=
this
.
props
.
totalPages
;
<
div
const
current
=
this
.
props
.
currentPage
;
className=
{
this
.
props
.
classes
}
const
pages
=
[];
id=
{
this
.
props
.
id
}
// let first;
// let prev;
// let next;
// let last;
let
i
=
1
;
// if (current > 1 && current < total) {
//
// }
for
(;
i
<=
total
;
i
++
)
{
if
(
current
===
i
)
{
pages
.
push
(
<
li
key=
{
`page-${i}`
}
className=
'active'
>
>
<
ul
className=
{
this
.
props
.
ulClasses
}
>
<
a
remote=
'false'
>
{
i
.
toString
()
}
</
a
>
{
this
.
props
.
linksArray
.
map
((
link
,
i
)
=>
{
</
li
>
return
(
);
<
Anchor
}
else
{
key=
{
i
}
pages
.
push
(
url=
{
link
.
url
}
<
li
key=
{
`page-${i}`
}
>
label=
{
link
.
label
}
<
a
attrs=
{
link
.
props
}
onClick=
{
this
.
handleChange
}
/>
>
{
i
.
toString
()
}
</
a
>
</
li
>
);
);
})
}
}
}
return
(
<
div
className=
'pagination'
>
<
ul
className=
'pagination'
>
{
pages
}
</
ul
>
</
ul
>
</
div
>
</
div
>
);
);
...
@@ -26,15 +64,7 @@ export default class Pagination extends React.Component {
...
@@ -26,15 +64,7 @@ export default class Pagination extends React.Component {
}
}
Pagination
.
propTypes
=
{
Pagination
.
propTypes
=
{
classes
:
React
.
PropTypes
.
string
,
url
:
React
.
PropTypes
.
string
.
isRequired
,
id
:
React
.
PropTypes
.
string
,
currentPage
:
React
.
PropTypes
.
number
.
isRequired
,
ulClasses
:
React
.
PropTypes
.
string
,
totalPages
:
React
.
PropTypes
.
number
.
isRequired
linksArray
:
React
.
PropTypes
.
array
};
Pagination
.
defaultProps
=
{
classes
:
''
,
id
:
'pagination'
,
ulClasses
:
'pagination'
,
linksArray
:
[]
};
};
src/utils/client.jsx
View file @
4505d6e4
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
// See LICENSE.txt for license information.
// See LICENSE.txt for license information.
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
{
browserHistory
}
from
'react-router'
;
import
ZimbraAdminApi
from
'zimbra-admin-api-js'
;
import
ZimbraAdminApi
from
'zimbra-admin-api-js'
;
import
ZimbraStore
from
'../stores/zimbra_store.jsx'
;
import
ZimbraStore
from
'../stores/zimbra_store.jsx'
;
...
@@ -15,29 +14,20 @@ import Constants from './constants.jsx';
...
@@ -15,29 +14,20 @@ import Constants from './constants.jsx';
// función que maneja el error como corresponde
// función que maneja el error como corresponde
function
handleError
(
methodName
,
err
)
{
function
handleError
(
methodName
,
err
)
{
if
(
err
.
type
&&
err
.
type
===
Constants
.
ActionTyp
es
.
NOT_LOGGED_IN
)
{
if
(
err
.
extra
&&
err
.
extra
.
code
===
Constants
.
ZimbraCod
es
.
NOT_LOGGED_IN
)
{
browserHistory
.
push
(
'/login'
);
Utils
.
setCookie
(
'token'
,
''
,
-
1
);
return
err
;
return
err
;
}
}
let
e
=
null
;
console
.
error
(
methodName
,
err
);
//eslint-disable-line no-console
try
{
e
=
JSON
.
parse
(
err
.
responseText
);
}
catch
(
parseError
)
{
e
=
null
;
}
console
.
error
(
methodName
,
e
);
//eslint-disable-line no-console
const
error
=
{};
const
error
=
{};
if
(
e
)
{
if
(
e
rr
)
{
error
.
message
=
e
.
Body
.
Fault
.
Reason
.
Text
;
error
.
message
=
e
rr
.
extra
.
reason
;
}
else
{
}
else
{
error
.
message
=
'Ocurrio un error general'
;
error
.
message
=
'Ocurrio un error general'
;
}
}
// Aqui deberiamos revisar si falta hacer login nuevamente
return
error
;
return
error
;
}
}
...
@@ -146,7 +136,7 @@ export function isLoggedIn(callback) {
...
@@ -146,7 +136,7 @@ export function isLoggedIn(callback) {
return
callback
(
data
);
return
callback
(
data
);
}
}
export
function
getAllDomains
(
success
,
error
)
{
export
function
getAllDomains
(
opts
,
success
,
error
)
{
initZimbra
().
then
(
initZimbra
().
then
(
(
zimbra
)
=>
{
(
zimbra
)
=>
{
zimbra
.
getAllDomains
((
err
,
data
)
=>
{
zimbra
.
getAllDomains
((
err
,
data
)
=>
{
...
@@ -156,7 +146,7 @@ export function getAllDomains(success, error) {
...
@@ -156,7 +146,7 @@ export function getAllDomains(success, error) {
}
}
return
success
(
data
);
return
success
(
data
);
});
}
,
opts
);
},
},
(
err
)
=>
{
(
err
)
=>
{
let
e
=
handleError
(
'getAllDomains'
,
err
);
let
e
=
handleError
(
'getAllDomains'
,
err
);
...
...
src/utils/constants.jsx
View file @
4505d6e4
...
@@ -8,8 +8,7 @@ export default {
...
@@ -8,8 +8,7 @@ export default {
START_LOADING
:
null
,
START_LOADING
:
null
,
END_LOADING
:
null
,
END_LOADING
:
null
,
USER_CHANGED
:
null
,
USER_CHANGED
:
null
,
RECEIVED_ERROR
:
null
,
RECEIVED_ERROR
:
null
NOT_LOGGED_IN
:
null
}),
}),
PayloadSources
:
keyMirror
({
PayloadSources
:
keyMirror
({
...
@@ -17,39 +16,16 @@ export default {
...
@@ -17,39 +16,16 @@ export default {
VIEW_ACTION
:
null
VIEW_ACTION
:
null
}),
}),
RESERVED_TEAM_NAMES
:
[
ZimbraCodes
:
{
'www'
,
NOT_LOGGED_IN
:
'service.AUTH_EXPIRED'
'web'
,
},
'admin'
,
'support'
,
'notify'
,
'test'
,
'demo'
,
'mail'
,
'team'
,
'channel'
,
'internal'
,
'localhost'
,
'dockerhost'
,
'stag'
,
'post'
,
'cluster'
,
'api'
],
RESERVED_USERNAMES
:
[
RESERVED_USERNAMES
:
[
'admin'
,
'admin'
,
'root'
'root'
],
],
MONTHS
:
[
'Enero'
,
'Febrero'
,
'Marzo'
,
'Abril'
,
'Mayo'
,
'Junio'
,
'Juio'
,
'Agosto'
,
'Septiembre'
,
'Octubre'
,
'Noviembre'
,
'Diciembre'
],
MONTHS
:
[
'Enero'
,
'Febrero'
,
'Marzo'
,
'Abril'
,
'Mayo'
,
'Junio'
,
'Juio'
,
'Agosto'
,
'Septiembre'
,
'Octubre'
,
'Noviembre'
,
'Diciembre'
],
KeyCodes
:
{
QueryOptions
:
{
UP
:
38
,
DEFAULT_LIMIT
:
10
DOWN
:
40
,
LEFT
:
37
,
RIGHT
:
39
,
BACKSPACE
:
8
,
ENTER
:
13
,
ESCAPE
:
27
,
SPACE
:
32
,
TAB
:
9
}
}
};
};
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