Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Павел Резуненко
/
MTAweb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c851fc8b
authored
Mar 27, 2013
by
Павел Резуненко
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Исправление файла сборки и коммит сопутствующих собранных
1 parent
847509aa
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
388 deletions
build.xml
public/app/view/view.js
public/css/default-theme.min.css
public/scripts/app-debug.js
public/scripts/app.js
build.xml
View file @
c851fc8
...
...
@@ -9,12 +9,13 @@
</target>
<target
name=
"copy"
>
<delete
dir=
"${source.dir}/${build.dir}"
quiet=
'true'
/>
<delete
dir=
"${source.dir}/${build.dir}"
quiet=
'true'
includeemptydirs=
"true"
/>
<mkdir
dir=
"${source.dir}/${build.dir}"
/>
<copy
todir=
"${source.dir}/${build.dir}"
>
<copy
todir=
"${source.dir}/${build.dir}"
overwrite=
"true"
>
<fileset
dir=
"${source.dir}"
>
<include
name=
"framework/**"
/>
<include
name=
"public/protected/**"
/>
<include
name=
"public/images/**"
/>
</fileset>
</copy>
</target>
...
...
@@ -51,8 +52,9 @@
<delete
includeemptydirs=
"true"
verbose=
"true"
failonerror=
"true"
>
<fileset
dir=
"public/"
>
<include
name=
"app/controller/controller.js"
/>
<include
name=
"app/view/view.js"
/>
<include
name=
"app/model/model.js"
/>
<include
name=
"app/model/model.js"
/>
<include
name=
"app/store/store.js"
/>
<include
name=
"app/view/view.js"
/>
<include
name=
"scripts/app.js"
/>
<include
name=
"scripts/app-debug.js"
/>
</fileset>
...
...
@@ -106,7 +108,7 @@
<filelist
dir=
"public/scripts"
files=
"app.js"
/>
</foreach>
<copy
todir=
"${build.dir}/public/scripts"
>
<copy
todir=
"${build.dir}/public/scripts"
overwrite=
"true"
>
<fileset
dir=
"public/scripts"
>
<include
name=
"**/app.js"
/>
<include
name=
"**/app-debug.js"
/>
...
...
public/app/view/view.js
View file @
c851fc8
...
...
@@ -514,11 +514,35 @@ Ext.define('MyMA.view.Authorize', {
monitorValid
:
true
,
frame
:
false
,
border
:
false
,
bodyStyle
:
{
border
:
0
,
background
:
'transparent'
},
defaults
:
{
anchor
:
'100%'
},
tbar
:
{
border
:
false
,
height
:
20
,
style
:
{
border
:
0
,
background
:
'transparent'
,
padding
:
0
},
items
:
{
xtype
:
'container'
,
itemId
:
'autherrormsg'
,
hidden
:
true
,
style
:
{
color
:
'red'
},
tpl
:
'{message}'
,
data
:
{
message
:
''
}
}
},
buttons
:
[{
text
:
'Login'
text
:
'Login'
,
itemId
:
'authorize'
}],
items
:
[{
fieldLabel
:
'Login'
,
...
...
public/css/default-theme.min.css
View file @
c851fc8
This diff could not be displayed because it is too large.
public/scripts/app-debug.js
View file @
c851fc8
...
...
@@ -765,11 +765,35 @@ Ext.define('MyMA.view.Authorize', {
monitorValid
:
true
,
frame
:
false
,
border
:
false
,
bodyStyle
:
{
border
:
0
,
background
:
'transparent'
},
defaults
:
{
anchor
:
'100%'
},
tbar
:
{
border
:
false
,
height
:
20
,
style
:
{
border
:
0
,
background
:
'transparent'
,
padding
:
0
},
items
:
{
xtype
:
'container'
,
itemId
:
'autherrormsg'
,
hidden
:
true
,
style
:
{
color
:
'red'
},
tpl
:
'{message}'
,
data
:
{
message
:
''
}
}
},
buttons
:
[{
text
:
'Login'
text
:
'Login'
,
itemId
:
'authorize'
}],
items
:
[{
fieldLabel
:
'Login'
,
...
...
@@ -988,384 +1012,6 @@ Ext.define('MyMA.store.Aliases', {
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Choice'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Brief'
,
model
:
'MyMA.model.Brief'
,
data
:
[{
id
:
0
,
name
:
'No'
},
{
id
:
1
,
name
:
'Yes'
}]
});
Ext
.
define
(
'MyMA.store.Programs'
,
{
extend
:
'Ext.data.ArrayStore'
,
fields
:
[
'id'
,
'name'
,
'state'
,
'item'
,
'title'
,
'control'
],
data
:
[],
/**
* Get item record from process storage
* @param object
*/
getProccess
:
function
(
data
)
{
var
data
=
data
||
{
property
:
'id'
,
value
:
null
},
idx
=
-
1
;
if
((
idx
=
this
.
find
(
data
.
property
,
data
.
value
,
0
,
false
,
true
,
true
))
>
-
1
)
{
return
this
.
getAt
(
idx
);
}
return
null
;
}
});
Ext
.
define
(
'MyMA.store.Transports'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Transports'
,
model
:
'MyMA.model.Transports'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Users'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Users'
,
model
:
'MyMA.model.Users'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Aliases'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Choice'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Brief'
,
model
:
'MyMA.model.Brief'
,
data
:
[{
id
:
0
,
name
:
'No'
},
{
id
:
1
,
name
:
'Yes'
}]
});
Ext
.
define
(
'MyMA.store.Programs'
,
{
extend
:
'Ext.data.ArrayStore'
,
fields
:
[
'id'
,
'name'
,
'state'
,
'item'
,
'title'
,
'control'
],
data
:
[],
/**
* Get item record from process storage
* @param object
*/
getProccess
:
function
(
data
)
{
var
data
=
data
||
{
property
:
'id'
,
value
:
null
},
idx
=
-
1
;
if
((
idx
=
this
.
find
(
data
.
property
,
data
.
value
,
0
,
false
,
true
,
true
))
>
-
1
)
{
return
this
.
getAt
(
idx
);
}
return
null
;
}
});
Ext
.
define
(
'MyMA.store.Transports'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Transports'
,
model
:
'MyMA.model.Transports'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Users'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Users'
,
model
:
'MyMA.model.Users'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Aliases'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Choice'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Brief'
,
model
:
'MyMA.model.Brief'
,
data
:
[{
id
:
0
,
name
:
'No'
},
{
id
:
1
,
name
:
'Yes'
}]
});
Ext
.
define
(
'MyMA.store.Programs'
,
{
extend
:
'Ext.data.ArrayStore'
,
fields
:
[
'id'
,
'name'
,
'state'
,
'item'
,
'title'
,
'control'
],
data
:
[],
/**
* Get item record from process storage
* @param object
*/
getProccess
:
function
(
data
)
{
var
data
=
data
||
{
property
:
'id'
,
value
:
null
},
idx
=
-
1
;
if
((
idx
=
this
.
find
(
data
.
property
,
data
.
value
,
0
,
false
,
true
,
true
))
>
-
1
)
{
return
this
.
getAt
(
idx
);
}
return
null
;
}
});
Ext
.
define
(
'MyMA.store.Transports'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Transports'
,
model
:
'MyMA.model.Transports'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Users'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Users'
,
model
:
'MyMA.model.Users'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Aliases'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Choice'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Brief'
,
model
:
'MyMA.model.Brief'
,
data
:
[{
id
:
0
,
name
:
'No'
},
{
id
:
1
,
name
:
'Yes'
}]
});
Ext
.
define
(
'MyMA.store.Programs'
,
{
extend
:
'Ext.data.ArrayStore'
,
fields
:
[
'id'
,
'name'
,
'state'
,
'item'
,
'title'
,
'control'
],
data
:
[],
/**
* Get item record from process storage
* @param object
*/
getProccess
:
function
(
data
)
{
var
data
=
data
||
{
property
:
'id'
,
value
:
null
},
idx
=
-
1
;
if
((
idx
=
this
.
find
(
data
.
property
,
data
.
value
,
0
,
false
,
true
,
true
))
>
-
1
)
{
return
this
.
getAt
(
idx
);
}
return
null
;
}
});
Ext
.
define
(
'MyMA.store.Transports'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Transports'
,
model
:
'MyMA.model.Transports'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Users'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Users'
,
model
:
'MyMA.model.Users'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Aliases'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Choice'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Brief'
,
model
:
'MyMA.model.Brief'
,
data
:
[{
id
:
0
,
name
:
'No'
},
{
id
:
1
,
name
:
'Yes'
}]
});
Ext
.
define
(
'MyMA.store.Programs'
,
{
extend
:
'Ext.data.ArrayStore'
,
fields
:
[
'id'
,
'name'
,
'state'
,
'item'
,
'title'
,
'control'
],
data
:
[],
/**
* Get item record from process storage
* @param object
*/
getProccess
:
function
(
data
)
{
var
data
=
data
||
{
property
:
'id'
,
value
:
null
},
idx
=
-
1
;
if
((
idx
=
this
.
find
(
data
.
property
,
data
.
value
,
0
,
false
,
true
,
true
))
>
-
1
)
{
return
this
.
getAt
(
idx
);
}
return
null
;
}
});
Ext
.
define
(
'MyMA.store.Transports'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Transports'
,
model
:
'MyMA.model.Transports'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Users'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Users'
,
model
:
'MyMA.model.Users'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Aliases'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
/**
* There is an undocumented incompatibility between a certain Store configuration and the Grouping Feature.
* Namely, you cannot have a Store with "remoteSort=true" while using the Grouping Feature.
* The problem is that the Store will be sorted as per the server reponse,
* while the Grouping Feature will cause the view to be sorted as per the groupings.
*/
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Choice'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Brief'
,
model
:
'MyMA.model.Brief'
,
data
:
[{
id
:
0
,
name
:
'No'
},
{
id
:
1
,
name
:
'Yes'
}]
});
Ext
.
define
(
'MyMA.store.Programs'
,
{
extend
:
'Ext.data.ArrayStore'
,
fields
:
[
'id'
,
'name'
,
'state'
,
'item'
,
'title'
,
'control'
],
data
:
[],
/**
* Get item record from process storage
* @param object
*/
getProccess
:
function
(
data
)
{
var
data
=
data
||
{
property
:
'id'
,
value
:
null
},
idx
=
-
1
;
if
((
idx
=
this
.
find
(
data
.
property
,
data
.
value
,
0
,
false
,
true
,
true
))
>
-
1
)
{
return
this
.
getAt
(
idx
);
}
return
null
;
}
});
Ext
.
define
(
'MyMA.store.Transports'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Transports'
,
model
:
'MyMA.model.Transports'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Users'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Users'
,
model
:
'MyMA.model.Users'
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
'MyMA.store.Aliases'
,
{
extend
:
'Ext.data.Store'
,
requires
:
'MyMA.model.Aliases'
,
model
:
'MyMA.model.Aliases'
,
groupField
:
'alias'
,
remoteSort
:
true
,
pageSize
:
100
});
...
...
@@ -2113,6 +1759,12 @@ Ext.define('MyMA.controller.Viewport', {
},
{
selector
:
'authorize > form'
,
ref
:
'authForm'
},
{
selector
:
'authorize > form #authorize'
,
ref
:
'authButton'
},
{
selector
:
'authorize > form #autherrormsg'
,
ref
:
'authErrorMsg'
}],
/**
...
...
@@ -2144,6 +1796,13 @@ Ext.define('MyMA.controller.Viewport', {
this
.
control
({
'authorize > form > toolbar > button'
:
{
click
:
this
.
Authorize
},
'authorize > form field'
:
{
specialkey
:
function
(
field
,
e
)
{
if
(
e
.
getKey
()
==
e
.
ENTER
)
{
this
.
Authorize
();
}
}
}
});
...
...
@@ -2160,12 +1819,14 @@ Ext.define('MyMA.controller.Viewport', {
if
(
this
.
getAuthPanel
())
{
var
form
=
this
.
getAuthPanel
().
down
(
'form'
).
getForm
();
if
(
form
.
isValid
())
{
this
.
getAuthButton
().
setIconCls
(
'x-ibtn-loading x-ibtn-def'
);
form
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
'api'
,
'login'
,
'authorize'
,
0
),
method
:
'PUT'
,
clientValidation
:
true
,
scope
:
this
,
success
:
this
.
successLogin
success
:
this
.
successLogin
,
failure
:
this
.
failLogin
})
}
}
...
...
@@ -2218,6 +1879,50 @@ Ext.define('MyMA.controller.Viewport', {
},
/**
* If login failed this function will show debug message if
* debug mode is on
*/
failLogin
:
function
(
form
,
action
)
{
try
{
this
.
getAuthButton
().
setIconCls
(
''
);
var
data
=
Ext
.
decode
(
action
.
response
.
responseText
);
if
(
data
.
error
.
trace
)
{
Ext
.
Msg
.
showError
({
msg
:
data
});
}
else
{
var
msg
=
this
.
getAuthErrorMsg
();
msg
.
tpl
.
overwrite
(
msg
.
getEl
(),
{
message
:
data
.
error
.
message
||
data
.
error
.
title
});
if
(
msg
&&
!
msg
.
isVisible
())
{
msg
.
show
();
}
msg
.
stopAnimation
();
msg
.
animate
({
duration
:
5
,
to
:
{
opacity
:
1
}
});
msg
.
animate
({
duration
:
5000
,
to
:
{
opacity
:
0
}
});
}
}
catch
(
e
)
{
}
},
/**
* Logout
* public
...
...
public/scripts/app.js
View file @
c851fc8
Ext
.
override
(
Ext
.
Msg
,{
onShow
:
function
(){
this
.
callParent
(
arguments
);
this
.
center
();
if
(
!
Ext
.
isEmpty
(
Ext
.
query
(
"div.x-msg-trace"
))
&&!
Ext
.
isEmpty
(
Ext
.
query
(
"div.x-msg-error"
))){
var
a
=
Ext
.
get
(
Ext
.
query
(
"div.x-msg-error"
)),
b
=
Ext
.
get
(
Ext
.
query
(
"div.x-msg-trace"
));
if
(
b
.
first
().
getHeight
()
+
a
.
first
().
getHeight
()
>
this
.
body
.
getHeight
()){
b
.
first
().
setHeight
(
this
.
body
.
getHeight
()
-
a
.
first
().
getHeight
());}}},
showInfo
:
function
(
a
){
Ext
.
Msg
.
show
(
Ext
.
apply
({
autoScroll
:
true
,
title
:
"Info"
,
msg
:
""
,
icon
:
Ext
.
Msg
.
INFO
,
buttons
:
Ext
.
Msg
.
OK
},
a
||
{}));},
showError
:
function
(
a
){
if
(
Ext
.
isObject
(
a
.
msg
)){
if
(
a
.
msg
.
tpl
){
if
(
Ext
.
isArray
(
a
.
msg
.
tpl
)
||
Ext
.
isString
(
a
.
msg
.
tpl
)){
a
.
msg
=
new
Ext
.
XTemplate
(
Ext
.
isArray
(
a
.
msg
.
tpl
)?
a
.
msg
.
tpl
.
join
(
""
):
a
.
msg
.
tpl
).
apply
(
a
.
msg
.
data
||
{});}
else
{
if
(
a
.
msg
.
tpl
.
isTemplate
){
a
.
msg
=
a
.
msg
.
tpl
.
apply
(
a
.
msg
.
data
||
{});}}}
else
{
if
(
a
.
msg
.
error
){
a
.
msg
=
new
Ext
.
XTemplate
(
'<div class="x-msg-error">'
,
'<tpl if="code">Error code: {code}<br/></tpl>'
,
'<tpl if="type">Error type: {type}<br/></tpl>'
,
'Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>'
,
'<tpl if="file">File: {file}<br/></tpl>'
,
'<tpl if="line">Line: {line}<br/></tpl>'
,
"</div>"
,
'<tpl if="traces">'
,
'<div class="x-msg-trace"><tpl for="traces">'
,
'({line}) {file}: <div class="x-msg-trace-detail">'
,
"<tpl if=\"type == '->'\">{class}->{function}()</tpl>"
,
'<tpl if="args && args.length > 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>'
,
"</div>"
,
"</tpl></div>"
,
"</tpl>"
).
apply
(
a
.
msg
.
error
);}}}
Ext
.
Msg
.
show
(
Ext
.
apply
({
autoScroll
:
true
,
title
:
"Error"
,
msg
:
""
,
icon
:
Ext
.
Msg
.
ERROR
,
buttons
:
Ext
.
Msg
.
OK
},
a
||
{}));}});
Ext
.
override
(
Ext
.
data
.
Connection
,{
url
:
"."
,
timeout
:
380000
,
setGuest
:
Ext
.
emptyFn
,
getGuest
:
Ext
.
emptyFn
,
getBaseUrl
:
function
(){
if
(
!
Ext
.
isDefined
(
this
.
baseUrl
)){
this
.
baseUrl
=
(
Ext
.
query
(
"meta[name=application-url]"
)[
0
]
||
{
content
:
"."
}).
content
;
this
.
baseUrl
.
replace
(
/
[\/\\]
+$/
,
""
);
this
.
url
=
this
.
baseUrl
;}
return
this
.
url
;},
getRestUrl
:
function
(){
var
a
=
[];
Ext
.
iterate
(
arguments
,
function
(
b
){
this
.
push
(
b
);},
a
);
a
=
a
.
join
(
"/"
);
a
.
replace
(
/^
[\/\\]
+/
,
""
);
return
[
this
.
getBaseUrl
(),
"/index.php/"
,
a
].
join
(
""
);},
onComplete
:
function
(
f
){
var
d
=
this
,
c
=
f
.
options
,
a
,
i
,
b
;
try
{
a
=
d
.
parseStatus
(
f
.
xhr
.
status
);}
catch
(
h
){
a
=
{
success
:
false
,
isException
:
false
};}
i
=
a
.
success
;
if
(
i
){
b
=
d
.
createResponse
(
f
);
d
.
fireEvent
(
"requestcomplete"
,
d
,
b
,
c
);
Ext
.
callback
(
c
.
success
,
c
.
scope
,[
b
,
c
]);}
else
{
if
(
a
.
isException
||
f
.
aborted
||
f
.
timedout
){
b
=
d
.
createException
(
f
);}
else
{
b
=
d
.
createResponse
(
f
);}
if
(
Ext
.
isEmpty
(
d
.
getGuest
())
&&
(
b
.
status
!=
404
||
b
.
status
!=
500
)){
d
.
setGuest
(
true
);}
else
{
if
(
c
.
proxy
&&
c
.
proxy
.
isProxy
){
var
g
=
b
.
responseText
?
Ext
.
decode
(
b
.
responseText
):{};
Ext
.
Msg
.
showError
({
title
:
g
.
error
.
title
||
"Error"
,
msg
:{
error
:
g
.
error
},
buttons
:
Ext
.
Msg
.
OK
});}
else
{
d
.
fireEvent
(
"requestexception"
,
d
,
b
,
c
);}
Ext
.
callback
(
c
.
failure
,
c
.
scope
,[
b
,
c
]);}}
if
(
!
Ext
.
isDefined
(
d
.
isGuest
)){
Ext
.
callback
(
c
.
callback
,
c
.
scope
,[
c
,
i
,
b
]);}
delete
d
.
requests
[
f
.
id
];
return
b
;}});
Ext
.
override
(
Ext
.
Toolbar
,{
getValues
:
function
(){
var
b
=
{},
a
=
this
.
query
(
"searchfield,textfield,numberfield,checkbox,radio,combo"
);
Ext
.
each
(
a
,
function
(
c
){
this
[
c
.
name
||
c
.
itemId
||
c
.
getId
()]
=
c
.
getValue
();},
b
);
return
b
;}});
Ext
.
define
(
"Ext.form.SearchField"
,{
extend
:
"Ext.form.field.Text"
,
alias
:
"widget.searchfield"
,
enableKeyEvents
:
true
,
handler
:
null
,
initComponent
:
function
(){
this
.
callParent
();
if
(
!
Ext
.
isEmpty
(
this
.
handler
)){
this
.
on
(
"specialkey"
,
this
.
checkEnterKey
,
this
);}},
checkEnterKey
:
function
(
d
,
c
){
var
b
=
this
.
getValue
();
if
(
c
.
getKey
()
===
c
.
ENTER
){
if
(
Ext
.
isFunction
(
this
.
handler
)){
this
.
handler
();}
else
{
if
(
Ext
.
isString
(
this
.
handler
)){
var
a
=
this
.
up
(
"toolbar"
).
query
(
"#"
+
this
.
handler
);
if
(
a
.
length
>
0
&&
a
[
0
].
getXType
()
==
"button"
){
a
[
0
].
fireEvent
(
"click"
,
a
[
0
]);}}}}}});
Ext
.
define
(
"MyMA.view.ProgramMenu"
,{
extend
:
"Ext.Button"
,
alias
:
"widget.programmenu"
,
text
:
"Menu"
,
height
:
30
,
ui
:
"program-menu"
,
menu
:[{
text
:
"Users"
,
widgetName
:
"users"
},{
text
:
"Aliases"
,
widgetName
:
"aliases"
},{
text
:
"Transports"
,
widgetName
:
"transports"
},
"-"
,{
text
:
"Logout"
,
itemId
:
"logout"
}]});
Ext
.
define
(
"MyMA.view.Taskpanel"
,{
extend
:
"Ext.Toolbar"
,
alias
:
"widget.taskpanel"
,
ui
:
"programbar"
,
height
:
28
,
style
:{
border
:
0
,
padding
:
0
},
autoScroll
:
true
,
items
:[]});
Ext
.
define
(
"MyMA.view.Aliases"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.aliases"
,
layout
:
"fit"
,
minimizable
:
true
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
width
:
900
,
listeners
:{
render
:
function
(
a
){
if
(
Ext
.
getBody
().
getHeight
()
>
500
){
a
.
setHeight
(
Ext
.
getBody
().
getHeight
()
-
150
);}}},
items
:[{
xtype
:
"grid"
,
border
:
false
,
viewConfig
:{
plugins
:{
ptype
:
"gridviewdragdrop"
},
listeners
:{
beforedrop
:
function
(
c
,
e
,
d
,
a
,
b
){
Ext
.
each
(
e
.
records
,
function
(
f
){
if
(
f
.
get
(
"alias"
)
!=
this
.
groupName
){
f
.
set
(
"alias"
,
this
.
groupName
);
f
.
save
({
action
:
"update"
,
scope
:
this
,
failure
:
function
(
g
){
g
.
store
.
reload
();}});}},{
data
:
e
,
groupName
:
this
.
getFeature
(
"alias-groups"
).
getGroupName
(
c
),
model
:
d
});}}},
tbar
:[{
xtype
:
"button"
,
itemId
:
"addrecord"
,
iconCls
:
"x-ibtn-add"
,
text
:
"New Item"
},{
xtype
:
"tbseparator"
,
width
:
5
},{
xtype
:
"searchfield"
,
handler
:
"search"
,
name
:
"query"
},{
xtype
:
"tbspacer"
,
width
:
5
},{
xtype
:
"button"
,
itemId
:
"search"
,
text
:
"Search"
}],
bbar
:{
xtype
:
"pagingtoolbar"
,
displayInfo
:
true
,
store
:
"Aliases"
},
features
:[{
ftype
:
"grouping"
,
id
:
"alias-groups"
,
groupHeaderTpl
:
"Group: {name} ({rows.length})"
,
startCollapsed
:
false
}],
selModel
:{
selType
:
"rowmodel"
},
columns
:[{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-edit x-ibtn-def"
;}}]},{
header
:
"ID"
,
dataIndex
:
"id"
,
width
:
40
},{
header
:
"Recipient"
,
dataIndex
:
"recipient"
,
flex
:
1
},{
header
:
"Alias"
,
hidden
:
true
,
dataIndex
:
"alias"
},{
header
:
"Comment"
,
dataIndex
:
"comment"
,
flex
:
1
},{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-delete x-ibtn-def"
;}}]}],
selType
:
"rowmodel"
,
multiSelect
:
true
,
store
:
"Aliases"
}]});
Ext
.
define
(
"MyMA.view.Alias"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.alias"
,
layout
:
"fit"
,
title
:
"Alias"
,
width
:
400
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
buttons
:[{
xtype
:
"button"
,
itemId
:
"savedata"
,
text
:
"Save"
,
scope
:
this
}],
items
:[{
xtype
:
"form"
,
frame
:
true
,
monitorValid
:
true
,
defaults
:{
xtype
:
"textfield"
,
anchor
:
"100%"
,
allowBlank
:
false
},
items
:[{
xtype
:
"hidden"
,
name
:
"id"
},{
fieldLabel
:
"Alias"
,
name
:
"alias"
,
vtype
:
"email"
},{
fieldLabel
:
"Recipient"
,
name
:
"recipient"
,
vtype
:
"email"
},{
fieldLabel
:
"Comment"
,
xtype
:
"textarea"
,
name
:
"comment"
}]}]});
Ext
.
define
(
"MyMA.view.Users"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.users"
,
layout
:
"fit"
,
minimizable
:
true
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
width
:
900
,
listeners
:{
render
:
function
(
a
){
if
(
Ext
.
getBody
().
getHeight
()
>
500
){
a
.
setHeight
(
Ext
.
getBody
().
getHeight
()
-
150
);}}},
items
:[{
xtype
:
"grid"
,
border
:
false
,
listeners
:{
edit
:
function
(
a
,
b
){
if
(
b
.
originalValue
==
b
.
value
){
return
;}
b
.
record
.
save
({
action
:
"update"
,
scope
:
b
,
success
:
function
(){
this
.
record
.
commit
();}});}},
tbar
:[{
xtype
:
"button"
,
iconCls
:
"x-ibtn-add"
,
itemId
:
"addrecord"
,
text
:
"New Item"
},{
xtype
:
"tbseparator"
,
width
:
5
},{
xtype
:
"searchfield"
,
handler
:
"search"
,
name
:
"query"
},{
xtype
:
"tbspacer"
,
width
:
5
},{
xtype
:
"button"
,
itemId
:
"search"
,
text
:
"Search"
}],
bbar
:{
xtype
:
"pagingtoolbar"
,
displayInfo
:
true
,
store
:
"Users"
},
plugins
:[
Ext
.
create
(
"Ext.grid.plugin.CellEditing"
,{
clicksToEdit
:
1
})],
selModel
:{
selType
:
"cellmodel"
},
columns
:[{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-edit x-ibtn-def"
;}}]},{
header
:
"ID"
,
dataIndex
:
"id"
,
width
:
40
},{
header
:
"Name"
,
dataIndex
:
"name"
,
editor
:{
xtype
:
"textfield"
},
flex
:
1
},{
header
:
"Login"
,
dataIndex
:
"login"
,
width
:
120
},{
header
:
"Password"
,
hidden
:
true
,
dataIndex
:
"passwd"
},{
header
:
"uid"
,
dataIndex
:
"uid"
,
width
:
40
},{
header
:
"gid"
,
dataIndex
:
"gid"
,
width
:
40
},{
header
:
"Mail directory"
,
dataIndex
:
"maildir"
},{
header
:
"SMTP"
,
dataIndex
:
"smtp"
,
editor
:{
xtype
:
"combo"
,
valueField
:
"id"
,
displayField
:
"name"
,
triggerAction
:
"all"
,
editable
:
false
,
store
:
"Choice"
},
renderer
:
function
(
a
){
if
(
a
==
1
){
return
"Yes"
;}
return
"No"
;}},{
header
:
"IMAP"
,
dataIndex
:
"imap"
,
editor
:{
xtype
:
"combo"
,
valueField
:
"id"
,
displayField
:
"name"
,
triggerAction
:
"all"
,
editable
:
false
,
store
:
"Choice"
},
renderer
:
function
(
a
){
if
(
a
==
1
){
return
"Yes"
;}
return
"No"
;}},{
header
:
"Quota"
,
dataIndex
:
"quota"
,
editor
:{
xtype
:
"numberfield"
,
allowDecimal
:
false
}},{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-delete x-ibtn-def"
;}}]}],
store
:
"Users"
}]});
Ext
.
define
(
"MyMA.view.User"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.user"
,
layout
:
"fit"
,
title
:
"User"
,
width
:
400
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
buttons
:[{
xtype
:
"button"
,
itemId
:
"savedata"
,
text
:
"Save"
,
scope
:
this
}],
items
:[{
xtype
:
"form"
,
frame
:
true
,
monitorValid
:
true
,
defaults
:{
xtype
:
"textfield"
,
anchor
:
"100%"
,
allowBlank
:
false
},
items
:[{
xtype
:
"hidden"
,
name
:
"id"
},{
xtype
:
"checkbox"
,
fieldLabel
:
"Manager"
,
name
:
"manager"
,
inputValue
:
1
},{
xtype
:
"checkbox"
,
fieldLabel
:
"SMTP"
,
name
:
"smtp"
,
inputValue
:
1
},{
xtype
:
"checkbox"
,
fieldLabel
:
"IMAP"
,
name
:
"imap"
,
inputValue
:
1
},{
fieldLabel
:
"Name"
,
name
:
"name"
},{
fieldLabel
:
"Login"
,
name
:
"login"
,
vtype
:
"email"
},{
fieldLabel
:
"Password"
,
name
:
"passwd"
},{
xtype
:
"numberfield"
,
allowDecimal
:
false
,
fieldLabel
:
"UID"
,
name
:
"uid"
,
anchor
:
"50%"
,
value
:
8
},{
xtype
:
"numberfield"
,
allowDecimal
:
false
,
fieldLabel
:
"GID"
,
name
:
"gid"
,
anchor
:
"50%"
,
value
:
12
},{
fieldLabel
:
"Mail directory"
,
name
:
"maildir"
},{
xtype
:
"numberfield"
,
name
:
"quota"
,
allowDecimal
:
false
,
fieldLabel
:
"Quota"
,
anchor
:
"60%"
,
value
:
100000000
}]}]});
Ext
.
define
(
"MyMA.view.Viewport"
,{
extend
:
"Ext.container.Viewport"
,
requires
:[
"MyMA.view.ProgramMenu"
,
"MyMA.view.Taskpanel"
,
"MyMA.view.Users"
,
"MyMA.view.Aliases"
],
layout
:
"fit"
,
statics
:{
ready
:
false
},
items
:{
xtype
:
"panel"
,
layout
:
"fit"
,
border
:
false
,
dockedItems
:[{
dock
:
"top"
,
xtype
:
"toolbar"
,
height
:
30
,
ui
:
"programbar-panel"
,
items
:[{
xtype
:
"programmenu"
,
width
:
100
},
"-"
,{
xtype
:
"taskpanel"
,
flex
:
1
}]}],
items
:[{
xtype
:
"panel"
,
border
:
false
,
ui
:
"desk-panel"
,
bodyCls
:
"x-desk-panel-bg"
,
layout
:{
type
:
"fit"
}}]}});
Ext
.
define
(
"MyMA.view.Authorize"
,{
extend
:
"Ext.Window"
,
alias
:
"widget.authorize"
,
layout
:
"fit"
,
autoShow
:
true
,
layout
:
"fit"
,
width
:
350
,
closable
:
false
,
constrain
:
true
,
draggable
:
false
,
resizable
:
false
,
modal
:
true
,
cls
:
"x-window-authbaner"
,
dockedItems
:[{
dock
:
"top"
,
xtype
:
"toolbar"
,
ui
:
"authform-baner"
,
height
:
43
,
html
:
"{LOGIN @ MAIL . PANEL }"
}],
items
:[{
xtype
:
"form"
,
url
:
"index.php"
,
monitorValid
:
true
,
frame
:
false
,
border
:
false
,
defaults
:{
anchor
:
"100%"
},
buttons
:[{
text
:
"Login"
}],
items
:[{
fieldLabel
:
"Login"
,
xtype
:
"textfield"
,
allowBlank
:
false
,
name
:
"login"
},{
fieldLabel
:
"Password"
,
xtype
:
"textfield"
,
name
:
"pass"
,
inputType
:
"password"
}]}]});
Ext
.
define
(
"MyMA.view.Transports"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.transports"
,
layout
:
"fit"
,
minimizable
:
true
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
width
:
900
,
listeners
:{
render
:
function
(
a
){
if
(
Ext
.
getBody
().
getHeight
()
>
500
){
a
.
setHeight
(
Ext
.
getBody
().
getHeight
()
-
150
);}}},
items
:[{
xtype
:
"grid"
,
border
:
false
,
tbar
:[{
xtype
:
"button"
,
itemId
:
"addrecord"
,
iconCls
:
"x-ibtn-add"
,
text
:
"New Item"
},{
xtype
:
"tbseparator"
,
width
:
5
},{
xtype
:
"searchfield"
,
handler
:
"search"
,
name
:
"query"
},{
xtype
:
"tbspacer"
,
width
:
5
},{
xtype
:
"button"
,
itemId
:
"search"
,
text
:
"Search"
}],
bbar
:{
xtype
:
"pagingtoolbar"
,
displayInfo
:
true
,
store
:
"Transports"
},
columns
:[{
header
:
"ID"
,
dataIndex
:
"id"
,
width
:
40
},{
header
:
"Domain"
,
dataIndex
:
"domain"
,
editor
:{
xtype
:
"textfield"
,
allowBlank
:
false
},
flex
:
1
},{
header
:
"Transport"
,
dataIndex
:
"transport"
},{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-delete x-ibtn-def"
;}}]}],
selType
:
"rowmodel"
,
plugins
:[
Ext
.
create
(
"Ext.grid.plugin.RowEditing"
,{
clicksToEdit
:
1
})],
store
:
"Transports"
}]});
Ext
.
define
(
"MyMA.model.Aliases"
,{
extend
:
"Ext.data.Model"
,
fields
:[{
name
:
"id"
,
type
:
"int"
},{
name
:
"alias"
,
type
:
"string"
},{
name
:
"recipient"
,
type
:
"string"
},{
name
:
"comment"
,
type
:
"string"
}],
proxy
:{
type
:
"rest"
,
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"alias"
),
reader
:{
type
:
"json"
,
root
:
"results"
,
totalProperty
:
"total"
},
writer
:{
type
:
"json"
,
allowSingle
:
true
}}});
Ext
.
define
(
"MyMA.model.Brief"
,{
extend
:
"Ext.data.Model"
,
fields
:[
"id"
,
"name"
],
proxy
:{
type
:
"memory"
,
reader
:{
type
:
"json"
,
root
:
"results"
}}});
Ext
.
define
(
"MyMA.model.Transports"
,{
extend
:
"Ext.data.Model"
,
fields
:[{
name
:
"id"
,
type
:
"int"
},{
name
:
"domain"
,
type
:
"string"
},{
name
:
"transport"
,
type
:
"string"
}],
proxy
:{
type
:
"rest"
,
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"transport"
),
reader
:{
type
:
"json"
,
root
:
"results"
,
totalProperty
:
"total"
},
writer
:{
type
:
"json"
,
allowSingle
:
true
}}});
Ext
.
define
(
"MyMA.model.Users"
,{
extend
:
"Ext.data.Model"
,
fields
:[{
name
:
"id"
,
type
:
"int"
},{
name
:
"name"
,
type
:
"string"
},{
name
:
"login"
,
type
:
"string"
},{
name
:
"passwd"
,
type
:
"string"
},{
name
:
"uid"
,
type
:
"int"
,
defaultValue
:
8
},{
name
:
"gid"
,
type
:
"int"
,
defaultValue
:
12
},{
name
:
"maildir"
,
type
:
"string"
},{
name
:
"smtp"
,
type
:
"int"
},{
name
:
"imap"
,
type
:
"int"
},{
name
:
"quota"
,
type
:
"int"
,
defaultValue
:
10000000
},{
name
:
"manager"
,
type
:
"int"
}],
validations
:[{
type
:
"format"
,
field
:
"maildir"
,
matcher
:
/^
\/[
a-z
]\.
ru
\/[
a-z_0-9
]\/
Maildir
\/
$/
}],
proxy
:{
type
:
"rest"
,
url
:
Ext
.
Ajax
.
getRestUrl
(
"api/user"
),
reader
:{
type
:
"json"
,
root
:
"results"
},
writer
:{
type
:
"json"
,
allowSingle
:
true
}}});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
false
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.controller.Alias"
,{
extend
:
"Ext.app.Controller"
,
views
:[
"Alias"
],
refs
:[{
selector
:
"alias"
,
ref
:
"aliasWindow"
}],
init
:
function
(){
this
.
control
({
"alias > toolbar > #savedata"
:{
click
:
this
.
saveData
}});},
saveData
:
function
(
a
){
var
b
=
this
.
getAliasWindow
().
down
(
"form"
).
getForm
(),
c
=
b
.
getValues
().
id
||
null
;
if
(
!
b
.
isValid
()){
return
false
;}
b
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"alias"
,
c
),
clientValidation
:
true
,
method
:
c
>
0
?
"PUT"
:
"POST"
,
scope
:{
controller
:
this
,
win
:
this
.
getAliasWindow
()},
success
:
this
.
onSuccessSubmit
,
failure
:
this
.
onFailSubmit
});},
onSuccessSubmit
:
function
(
a
,
b
){
this
.
win
.
close
();
this
.
controller
.
getController
(
"Aliases"
).
getStore
(
"Aliases"
).
reload
({
params
:{
start
:
0
}});
Ext
.
Msg
.
showInfo
({
msg
:
"Data saved"
});},
onFailSubmit
:
function
(
a
,
c
){
try
{
var
b
=
Ext
.
decode
(
c
.
response
.
responseText
);
throw
(
b
);}
catch
(
d
){
Ext
.
Msg
.
showError
({
msg
:
d
});}}});
Ext
.
define
(
"MyMA.controller.Aliases"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Aliases"
],
views
:[
"Aliases"
,
"Alias"
],
refs
:[{
selector
:
"aliases > grid"
,
ref
:
"aliasesList"
}],
init
:
function
(){
this
.
control
({
"aliases > grid > toolbar > #addrecord"
:{
click
:
this
.
showForm
},
"aliases > grid > toolbar > #search"
:{
click
:
this
.
onSearch
},
"aliases actioncolumn"
:{
click
:
this
.
onActionColumn
}});},
onActionColumn
:
function
(
g
,
a
,
h
,
i
,
f
,
j
,
b
){
if
(
f
.
getTarget
(
".x-ibtn-edit"
)){
var
d
=
j
.
store
.
getAt
(
h
);
var
c
=
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"alias"
});
c
.
setTitle
(
"Alias: "
+
d
.
get
(
"alias"
));
c
.
down
(
"form"
).
getForm
().
loadRecord
(
d
);}
if
(
f
.
getTarget
(
".x-ibtn-delete"
)){
var
d
=
j
.
store
.
getAt
(
h
);
Ext
.
Msg
.
confirm
(
"Info"
,
"Press Yes to confirm remove action"
,
function
(
e
){
if
(
e
===
"yes"
){
this
.
record
.
destroy
({
scope
:
this
,
success
:
function
(){
this
.
store
.
remove
(
this
.
record
);}});}},{
store
:
j
.
store
,
record
:
d
});}},
showForm
:
function
(
a
){
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"alias"
,
title
:
"New Alias"
});},
onSearch
:
function
(
a
){
this
.
getAliasesList
().
getStore
().
reload
({
params
:
a
.
up
(
"toolbar"
).
getValues
()});}});
Ext
.
define
(
"MyMA.controller.Program"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Programs"
],
refs
:[{
selector
:
"taskpanel"
,
ref
:
"taskPanel"
}],
init
:
function
(){
var
a
=
{};
Ext
.
each
(
this
.
refs
,
function
(
b
){
this
.
control
[
b
.
selector
]
=
{
beforeclose
:
this
.
me
.
programStop
,
hide
:
this
.
me
.
programState
,
show
:
this
.
me
.
programState
,
minimize
:
this
.
me
.
programMinimize
};},{
control
:
a
,
me
:
this
});
this
.
control
(
a
);},
registerControl
:
function
(
a
){
var
a
=
a
||
null
,
b
=
{};
if
(
!
a
){
return
;}
b
[
a
]
=
{
beforeclose
:
this
.
programStop
,
hide
:
this
.
programState
,
show
:
this
.
programState
,
minimize
:
this
.
programMinimize
};
this
.
control
(
b
);},
programMinimize
:
function
(
b
){
var
a
;
if
(
!
(
a
=
this
.
getStore
(
"Programs"
).
getProccess
({
property
:
"item"
,
value
:
b
.
getId
()}))){
return
false
;}
this
.
getTaskPanel
().
items
.
get
(
a
.
get
(
"control"
)).
toggle
(
false
);
b
.
hide
();
this
.
programState
(
b
);},
programState
:
function
(
c
,
b
){
var
a
;
if
(
!
(
a
=
this
.
getStore
(
"Programs"
).
getProccess
({
property
:
"item"
,
value
:
c
.
getId
()}))){
return
false
;}
a
.
set
(
"state"
,
c
.
isHidden
()?
"hide"
:
"show"
);},
programStop
:
function
(
b
,
a
){
var
a
=
a
||
Ext
.
undefined
;
if
(
!
a
.
data
){(
a
=
this
.
getStore
(
"Programs"
).
getProccess
({
property
:
"item"
,
value
:
b
.
getId
()}));}
if
(
b
.
animateTarget
){
b
.
animateTarget
=
null
;}
if
(
a
&&
a
.
data
){
this
.
getTaskPanel
().
items
.
get
(
a
.
get
(
"control"
)).
destroy
();
this
.
getStore
(
"Programs"
).
remove
(
a
);}}});
Ext
.
define
(
"MyMA.controller.ProgramMenu"
,{
extend
:
"Ext.app.Controller"
,
init
:
function
(){
this
.
control
({
"programmenu > menu"
:{
click
:
this
.
LaunchProgram
}});},
LaunchProgram
:
function
(
b
,
a
){
if
(
a
.
itemId
==
"logout"
){
this
.
getController
(
"Viewport"
).
Logout
();}
else
{
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
a
.
widgetName
,
title
:
a
.
text
});}}});
Ext
.
define
(
"MyMA.controller.Taskpanel"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Programs"
],
refs
:[{
selector
:
"taskpanel"
,
ref
:
"taskPanel"
}],
init
:
function
(){
this
.
control
({
"taskpanel > button"
:{
toggle
:
this
.
programState
}});},
addProgram
:
function
(
g
){
var
g
=
g
||
{
name
:
null
},
c
=
this
.
getStore
(
"Programs"
),
b
,
f
;
if
(
!
(
b
=
c
.
getProccess
({
property
:
"name"
,
value
:
g
.
name
}))){
try
{
var
f
=
Ext
.
widget
(
g
.
name
),
d
=
(
c
.
max
(
"id"
)
||
0
)
+
1
;}
catch
(
h
){
return
false
;}
var
a
=
this
.
getTaskPanel
().
add
({
xtype
:
"button"
,
ui
:
"program-button"
,
height
:
28
,
text
:
g
.
title
||
f
.
title
,
enableToggle
:
true
,
pressed
:
true
,
programId
:
d
});
b
=
c
.
add
({
id
:
d
,
title
:
g
.
title
||
f
.
title
,
name
:
g
.
name
,
state
:
"show"
,
item
:
f
.
getId
(),
control
:
a
.
getId
()})[
0
];
this
.
getController
(
"Program"
).
registerControl
(
g
.
name
);
f
.
animateTarget
=
a
.
getId
();
f
.
setTitle
(
g
.
title
);
f
.
show
();}
else
{
this
.
getTaskPanel
().
items
.
get
(
b
.
get
(
"control"
)).
toggle
(
true
);
if
((
f
=
Ext
.
getCmp
(
b
.
get
(
"item"
)))){
f
.
show
();}}
return
f
?
f
:
null
;},
callRef
:
function
(
a
){
var
d
=
this
;
try
{
for
(
var
b
=
0
,
c
=
this
.
refs
.
length
;
b
<
c
;
b
++
){
if
(
this
.
refs
[
b
][
"selector"
]
==
a
){
return
d
[
"get"
+
Ext
.
String
.
capitalize
(
this
.
refs
[
b
][
"ref"
])]();}}}
catch
(
f
){}
return
null
;},
programState
:
function
(
b
){
var
c
=
this
.
getStore
(
"Programs"
),
a
,
d
;
if
(
!
(
a
=
c
.
getProccess
({
property
:
"id"
,
value
:
b
.
programId
}))){
return
false
;}
if
((
d
=
Ext
.
getCmp
(
a
.
get
(
"item"
)))){
d
[
a
.
get
(
"state"
)
==
"show"
?
"hide"
:
"show"
]();}},
closeAll
:
function
(){
this
.
getStore
(
"Programs"
).
each
(
function
(
a
){
if
((
widget
=
Ext
.
getCmp
(
a
.
get
(
"item"
)))){
widget
.
hide
();
this
.
getTaskPanel
().
items
.
get
(
a
.
get
(
"control"
)).
destroy
();}},
this
);}});
Ext
.
define
(
"MyMA.controller.Transports"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Transports"
],
views
:[
"Transports"
],
refs
:[{
selector
:
"transports > grid"
,
ref
:
"transportsList"
}],
init
:
function
(){
this
.
control
({
"transports > grid > toolbar > #addrecord"
:{
click
:
this
.
addRecord
},
"transports > grid > toolbar > #search"
:{
click
:
this
.
onSearch
},
"transports actioncolumn"
:{
click
:
this
.
onActionColumn
},
"transports > grid"
:{
edit
:
this
.
onEditAction
}});},
onActionColumn
:
function
(
b
,
g
,
i
,
d
,
h
,
f
,
c
){
if
(
h
.
getTarget
(
".x-ibtn-delete"
)){
var
a
=
f
.
store
.
getAt
(
i
);
Ext
.
Msg
.
confirm
(
"Info"
,
"Press Yes to confirm remove action"
,
function
(
e
){
if
(
e
===
"yes"
){
if
(
!
this
.
record
.
get
(
"id"
)){
this
.
store
.
remove
(
this
.
record
);}
else
{
this
.
record
.
destroy
({
scope
:
this
,
success
:
function
(){
this
.
store
.
remove
(
this
.
record
);}});}}},{
store
:
f
.
store
,
record
:
a
});}},
addRecord
:
function
(
a
){
this
.
getTransportsList
().
getStore
().
insert
(
0
,
this
.
getTransportsList
().
getStore
().
model
.
create
({
id
:
0
,
domain
:
null
,
transport
:
"virtual"
}));},
onSearch
:
function
(
a
){
this
.
getTransportsList
().
getStore
().
reload
({
params
:
a
.
up
(
"toolbar"
).
getValues
()});},
onEditAction
:
function
(
a
,
b
){
b
.
record
.
save
({
scope
:
b
,
success
:
function
(
c
){
this
.
store
.
reload
();}});}});
Ext
.
define
(
"MyMA.controller.User"
,{
extend
:
"Ext.app.Controller"
,
views
:[
"User"
],
refs
:[{
selector
:
"user"
,
ref
:
"userWindow"
}],
init
:
function
(){
this
.
control
({
"user > toolbar > #savedata"
:{
click
:
this
.
saveData
}});},
saveData
:
function
(
a
){
var
b
=
this
.
getUserWindow
().
down
(
"form"
).
getForm
(),
c
=
b
.
getValues
().
id
||
null
;
if
(
!
b
.
isValid
()){
return
false
;}
b
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"user"
,
c
),
clientValidation
:
true
,
method
:
c
>
0
?
"PUT"
:
"POST"
,
params
:
Ext
.
applyIf
(
Ext
.
copyTo
({},
b
.
getValues
(),
"smtp,imap,manager"
),{
smtp
:
0
,
imap
:
0
,
manager
:
0
}),
scope
:{
controller
:
this
,
win
:
this
.
getUserWindow
()},
success
:
this
.
onSuccessSubmit
,
failure
:
this
.
onFailSubmit
});},
onSuccessSubmit
:
function
(
a
,
b
){
this
.
win
.
close
();
this
.
controller
.
getController
(
"Users"
).
getStore
(
"Users"
).
reload
({
params
:{
start
:
0
}});
Ext
.
Msg
.
showInfo
({
msg
:
"Data saved"
});},
onFailSubmit
:
function
(
a
,
c
){
try
{
var
b
=
Ext
.
decode
(
c
.
response
.
responseText
);
throw
(
b
);}
catch
(
d
){
Ext
.
Msg
.
showError
({
msg
:
d
});}}});
Ext
.
define
(
"MyMA.controller.Users"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Users"
,
"Choice"
],
views
:[
"Users"
,
"User"
],
refs
:[{
selector
:
"users > grid"
,
ref
:
"usersList"
},{
selector
:
"users"
,
ref
:
"usersWindow"
}],
init
:
function
(){
this
.
control
({
"users > grid > toolbar > #addrecord"
:{
click
:
this
.
showForm
},
"users > grid > toolbar > #search"
:{
click
:
this
.
onSearch
},
"users actioncolumn"
:{
click
:
this
.
onActionColumn
}});},
onActionColumn
:
function
(
g
,
a
,
h
,
i
,
f
,
j
,
b
){
if
(
f
.
getTarget
(
".x-ibtn-edit"
)){
var
d
=
j
.
store
.
getAt
(
h
);
var
c
=
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"user"
});
c
.
setTitle
(
"User: "
+
d
.
get
(
"name"
));
c
.
down
(
"form"
).
getForm
().
loadRecord
(
d
);}
if
(
f
.
getTarget
(
".x-ibtn-delete"
)){
var
d
=
j
.
store
.
getAt
(
h
);
Ext
.
Msg
.
confirm
(
"Info"
,
"Press Yes to conform remove action"
,
function
(
e
){
if
(
e
===
"yes"
){
this
.
record
.
destroy
({
scope
:
this
,
success
:
function
(){
this
.
store
.
remove
(
this
.
record
);}});}},{
store
:
j
.
store
,
record
:
d
});}},
showForm
:
function
(
a
){
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"user"
,
title
:
"New User"
});},
onSearch
:
function
(
a
){
this
.
getUsersList
().
getStore
().
reload
({
params
:
a
.
up
(
"toolbar"
).
getValues
()});}});
Ext
.
define
(
"MyMA.controller.Viewport"
,{
extend
:
"Ext.app.Controller"
,
views
:[
"Viewport"
,
"Authorize"
],
refs
:[{
selector
:
"viewport"
,
ref
:
"appView"
},{
selector
:
"authorize"
,
ref
:
"authPanel"
},{
selector
:
"authorize > form"
,
ref
:
"authForm"
}],
isGuest
:
Ext
.
undefined
,
init
:
function
(
a
){
Ext
.
override
(
Ext
.
data
.
Connection
,{
setGuest
:
Ext
.
Function
.
bind
(
this
.
setGuest
,
this
),
getGuest
:
Ext
.
Function
.
bind
(
this
.
getGuest
,
this
)});
this
.
control
({
"authorize > form > toolbar > button"
:{
click
:
this
.
Authorize
}});
this
.
Authorize
();},
Authorize
:
function
(){
if
(
this
.
getAuthPanel
()){
var
a
=
this
.
getAuthPanel
().
down
(
"form"
).
getForm
();
if
(
a
.
isValid
()){
a
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"login"
,
"authorize"
,
0
),
method
:
"PUT"
,
clientValidation
:
true
,
scope
:
this
,
success
:
this
.
successLogin
});}}
else
{
Ext
.
Ajax
.
request
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"login"
),
scope
:
this
,
callback
:
function
(){
if
(
!
this
.
isGuest
&&!
this
.
getAppView
()){
this
.
setGuest
(
false
);
this
.
getView
(
"Viewport"
).
create
();}}});}},
getGuest
:
function
(){
return
this
.
isGuest
;},
setGuest
:
function
(
a
){
this
.
isGuest
=
Ext
.
isBoolean
(
a
)?
a
:
true
;
if
(
this
.
isGuest
&&!
this
.
getAuthPanel
()){
this
.
getView
(
"Authorize"
).
create
();}},
successLogin
:
function
(
a
,
b
){
this
.
getAuthPanel
().
close
();
if
(
!
this
.
getAppView
()){
this
.
getView
(
"Viewport"
).
create
();}},
Logout
:
function
(){
Ext
.
Ajax
.
request
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"login"
,
"logout"
,
0
),
method
:
"PUT"
,
scope
:
this
,
callback
:
function
(){
if
(
this
.
getAppView
()){
this
.
getController
(
"Taskpanel"
).
closeAll
();
this
.
getAppView
().
destroy
();}
this
.
setGuest
(
this
,
true
);}});}});
Ext
.
application
({
name
:
"MyMA"
,
controllers
:[
"Viewport"
,
"ProgramMenu"
,
"Taskpanel"
,
"Program"
,
"Users"
,
"User"
,
"Aliases"
,
"Alias"
,
"Transports"
],
enableQuickTips
:
true
});
\ No newline at end of file
Ext
.
override
(
Ext
.
Msg
,{
onShow
:
function
(){
this
.
callParent
(
arguments
);
this
.
center
();
if
(
!
Ext
.
isEmpty
(
Ext
.
query
(
"div.x-msg-trace"
))
&&!
Ext
.
isEmpty
(
Ext
.
query
(
"div.x-msg-error"
))){
var
a
=
Ext
.
get
(
Ext
.
query
(
"div.x-msg-error"
)),
b
=
Ext
.
get
(
Ext
.
query
(
"div.x-msg-trace"
));
if
(
b
.
first
().
getHeight
()
+
a
.
first
().
getHeight
()
>
this
.
body
.
getHeight
()){
b
.
first
().
setHeight
(
this
.
body
.
getHeight
()
-
a
.
first
().
getHeight
());}}},
showInfo
:
function
(
a
){
Ext
.
Msg
.
show
(
Ext
.
apply
({
autoScroll
:
true
,
title
:
"Info"
,
msg
:
""
,
icon
:
Ext
.
Msg
.
INFO
,
buttons
:
Ext
.
Msg
.
OK
},
a
||
{}));},
showError
:
function
(
a
){
if
(
Ext
.
isObject
(
a
.
msg
)){
if
(
a
.
msg
.
tpl
){
if
(
Ext
.
isArray
(
a
.
msg
.
tpl
)
||
Ext
.
isString
(
a
.
msg
.
tpl
)){
a
.
msg
=
new
Ext
.
XTemplate
(
Ext
.
isArray
(
a
.
msg
.
tpl
)?
a
.
msg
.
tpl
.
join
(
""
):
a
.
msg
.
tpl
).
apply
(
a
.
msg
.
data
||
{});}
else
{
if
(
a
.
msg
.
tpl
.
isTemplate
){
a
.
msg
=
a
.
msg
.
tpl
.
apply
(
a
.
msg
.
data
||
{});}}}
else
{
if
(
a
.
msg
.
error
){
a
.
msg
=
new
Ext
.
XTemplate
(
'<div class="x-msg-error">'
,
'<tpl if="code">Error code: {code}<br/></tpl>'
,
'<tpl if="type">Error type: {type}<br/></tpl>'
,
'Message: <tpl if="message">{message}</tpl><tpl if="!values.message">Unknown error</tpl><br>'
,
'<tpl if="file">File: {file}<br/></tpl>'
,
'<tpl if="line">Line: {line}<br/></tpl>'
,
"</div>"
,
'<tpl if="traces">'
,
'<div class="x-msg-trace"><tpl for="traces">'
,
'({line}) {file}: <div class="x-msg-trace-detail">'
,
"<tpl if=\"type == '->'\">{class}->{function}()</tpl>"
,
'<tpl if="args && args.length > 0"><div><b>Arguments:</b> {[ Ext.encode(values.args) ]}</div></tpl>'
,
"</div>"
,
"</tpl></div>"
,
"</tpl>"
).
apply
(
a
.
msg
.
error
);}}}
Ext
.
Msg
.
show
(
Ext
.
apply
({
autoScroll
:
true
,
title
:
"Error"
,
msg
:
""
,
icon
:
Ext
.
Msg
.
ERROR
,
buttons
:
Ext
.
Msg
.
OK
},
a
||
{}));}});
Ext
.
override
(
Ext
.
data
.
Connection
,{
url
:
"."
,
timeout
:
380000
,
setGuest
:
Ext
.
emptyFn
,
getGuest
:
Ext
.
emptyFn
,
getBaseUrl
:
function
(){
if
(
!
Ext
.
isDefined
(
this
.
baseUrl
)){
this
.
baseUrl
=
(
Ext
.
query
(
"meta[name=application-url]"
)[
0
]
||
{
content
:
"."
}).
content
;
this
.
baseUrl
.
replace
(
/
[\/\\]
+$/
,
""
);
this
.
url
=
this
.
baseUrl
;}
return
this
.
url
;},
getRestUrl
:
function
(){
var
a
=
[];
Ext
.
iterate
(
arguments
,
function
(
b
){
this
.
push
(
b
);},
a
);
a
=
a
.
join
(
"/"
);
a
.
replace
(
/^
[\/\\]
+/
,
""
);
return
[
this
.
getBaseUrl
(),
"/index.php/"
,
a
].
join
(
""
);},
onComplete
:
function
(
f
){
var
d
=
this
,
c
=
f
.
options
,
a
,
i
,
b
;
try
{
a
=
d
.
parseStatus
(
f
.
xhr
.
status
);}
catch
(
h
){
a
=
{
success
:
false
,
isException
:
false
};}
i
=
a
.
success
;
if
(
i
){
b
=
d
.
createResponse
(
f
);
d
.
fireEvent
(
"requestcomplete"
,
d
,
b
,
c
);
Ext
.
callback
(
c
.
success
,
c
.
scope
,[
b
,
c
]);}
else
{
if
(
a
.
isException
||
f
.
aborted
||
f
.
timedout
){
b
=
d
.
createException
(
f
);}
else
{
b
=
d
.
createResponse
(
f
);}
if
(
Ext
.
isEmpty
(
d
.
getGuest
())
&&
(
b
.
status
!=
404
||
b
.
status
!=
500
)){
d
.
setGuest
(
true
);}
else
{
if
(
c
.
proxy
&&
c
.
proxy
.
isProxy
){
var
g
=
b
.
responseText
?
Ext
.
decode
(
b
.
responseText
):{};
Ext
.
Msg
.
showError
({
title
:
g
.
error
.
title
||
"Error"
,
msg
:{
error
:
g
.
error
},
buttons
:
Ext
.
Msg
.
OK
});}
else
{
d
.
fireEvent
(
"requestexception"
,
d
,
b
,
c
);}
Ext
.
callback
(
c
.
failure
,
c
.
scope
,[
b
,
c
]);}}
if
(
!
Ext
.
isDefined
(
d
.
isGuest
)){
Ext
.
callback
(
c
.
callback
,
c
.
scope
,[
c
,
i
,
b
]);}
delete
d
.
requests
[
f
.
id
];
return
b
;}});
Ext
.
override
(
Ext
.
Toolbar
,{
getValues
:
function
(){
var
b
=
{},
a
=
this
.
query
(
"searchfield,textfield,numberfield,checkbox,radio,combo"
);
Ext
.
each
(
a
,
function
(
c
){
this
[
c
.
name
||
c
.
itemId
||
c
.
getId
()]
=
c
.
getValue
();},
b
);
return
b
;}});
Ext
.
define
(
"Ext.form.SearchField"
,{
extend
:
"Ext.form.field.Text"
,
alias
:
"widget.searchfield"
,
enableKeyEvents
:
true
,
handler
:
null
,
initComponent
:
function
(){
this
.
callParent
();
if
(
!
Ext
.
isEmpty
(
this
.
handler
)){
this
.
on
(
"specialkey"
,
this
.
checkEnterKey
,
this
);}},
checkEnterKey
:
function
(
d
,
c
){
var
b
=
this
.
getValue
();
if
(
c
.
getKey
()
===
c
.
ENTER
){
if
(
Ext
.
isFunction
(
this
.
handler
)){
this
.
handler
();}
else
{
if
(
Ext
.
isString
(
this
.
handler
)){
var
a
=
this
.
up
(
"toolbar"
).
query
(
"#"
+
this
.
handler
);
if
(
a
.
length
>
0
&&
a
[
0
].
getXType
()
==
"button"
){
a
[
0
].
fireEvent
(
"click"
,
a
[
0
]);}}}}}});
Ext
.
define
(
"MyMA.view.ProgramMenu"
,{
extend
:
"Ext.Button"
,
alias
:
"widget.programmenu"
,
text
:
"Menu"
,
height
:
30
,
ui
:
"program-menu"
,
menu
:[{
text
:
"Users"
,
widgetName
:
"users"
},{
text
:
"Aliases"
,
widgetName
:
"aliases"
},{
text
:
"Transports"
,
widgetName
:
"transports"
},
"-"
,{
text
:
"Logout"
,
itemId
:
"logout"
}]});
Ext
.
define
(
"MyMA.view.Taskpanel"
,{
extend
:
"Ext.Toolbar"
,
alias
:
"widget.taskpanel"
,
ui
:
"programbar"
,
height
:
28
,
style
:{
border
:
0
,
padding
:
0
},
autoScroll
:
true
,
items
:[]});
Ext
.
define
(
"MyMA.view.Aliases"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.aliases"
,
layout
:
"fit"
,
minimizable
:
true
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
width
:
900
,
listeners
:{
render
:
function
(
a
){
if
(
Ext
.
getBody
().
getHeight
()
>
500
){
a
.
setHeight
(
Ext
.
getBody
().
getHeight
()
-
150
);}}},
items
:[{
xtype
:
"grid"
,
border
:
false
,
viewConfig
:{
plugins
:{
ptype
:
"gridviewdragdrop"
},
listeners
:{
beforedrop
:
function
(
c
,
e
,
d
,
a
,
b
){
Ext
.
each
(
e
.
records
,
function
(
f
){
if
(
f
.
get
(
"alias"
)
!=
this
.
groupName
){
f
.
set
(
"alias"
,
this
.
groupName
);
f
.
save
({
action
:
"update"
,
scope
:
this
,
failure
:
function
(
g
){
g
.
store
.
reload
();}});}},{
data
:
e
,
groupName
:
this
.
getFeature
(
"alias-groups"
).
getGroupName
(
c
),
model
:
d
});}}},
tbar
:[{
xtype
:
"button"
,
itemId
:
"addrecord"
,
iconCls
:
"x-ibtn-add"
,
text
:
"New Item"
},{
xtype
:
"tbseparator"
,
width
:
5
},{
xtype
:
"searchfield"
,
handler
:
"search"
,
name
:
"query"
},{
xtype
:
"tbspacer"
,
width
:
5
},{
xtype
:
"button"
,
itemId
:
"search"
,
text
:
"Search"
}],
bbar
:{
xtype
:
"pagingtoolbar"
,
displayInfo
:
true
,
store
:
"Aliases"
},
features
:[{
ftype
:
"grouping"
,
id
:
"alias-groups"
,
groupHeaderTpl
:
"Group: {name} ({rows.length})"
,
startCollapsed
:
false
}],
selModel
:{
selType
:
"rowmodel"
},
columns
:[{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-edit x-ibtn-def"
;}}]},{
header
:
"ID"
,
dataIndex
:
"id"
,
width
:
40
},{
header
:
"Recipient"
,
dataIndex
:
"recipient"
,
flex
:
1
},{
header
:
"Alias"
,
hidden
:
true
,
dataIndex
:
"alias"
},{
header
:
"Comment"
,
dataIndex
:
"comment"
,
flex
:
1
},{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-delete x-ibtn-def"
;}}]}],
selType
:
"rowmodel"
,
multiSelect
:
true
,
store
:
"Aliases"
}]});
Ext
.
define
(
"MyMA.view.Alias"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.alias"
,
layout
:
"fit"
,
title
:
"Alias"
,
width
:
400
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
buttons
:[{
xtype
:
"button"
,
itemId
:
"savedata"
,
text
:
"Save"
,
scope
:
this
}],
items
:[{
xtype
:
"form"
,
frame
:
true
,
monitorValid
:
true
,
defaults
:{
xtype
:
"textfield"
,
anchor
:
"100%"
,
allowBlank
:
false
},
items
:[{
xtype
:
"hidden"
,
name
:
"id"
},{
fieldLabel
:
"Alias"
,
name
:
"alias"
,
vtype
:
"email"
},{
fieldLabel
:
"Recipient"
,
name
:
"recipient"
,
vtype
:
"email"
},{
fieldLabel
:
"Comment"
,
xtype
:
"textarea"
,
name
:
"comment"
}]}]});
Ext
.
define
(
"MyMA.view.Users"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.users"
,
layout
:
"fit"
,
minimizable
:
true
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
width
:
900
,
listeners
:{
render
:
function
(
a
){
if
(
Ext
.
getBody
().
getHeight
()
>
500
){
a
.
setHeight
(
Ext
.
getBody
().
getHeight
()
-
150
);}}},
items
:[{
xtype
:
"grid"
,
border
:
false
,
listeners
:{
edit
:
function
(
a
,
b
){
if
(
b
.
originalValue
==
b
.
value
){
return
;}
b
.
record
.
save
({
action
:
"update"
,
scope
:
b
,
success
:
function
(){
this
.
record
.
commit
();}});}},
tbar
:[{
xtype
:
"button"
,
iconCls
:
"x-ibtn-add"
,
itemId
:
"addrecord"
,
text
:
"New Item"
},{
xtype
:
"tbseparator"
,
width
:
5
},{
xtype
:
"searchfield"
,
handler
:
"search"
,
name
:
"query"
},{
xtype
:
"tbspacer"
,
width
:
5
},{
xtype
:
"button"
,
itemId
:
"search"
,
text
:
"Search"
}],
bbar
:{
xtype
:
"pagingtoolbar"
,
displayInfo
:
true
,
store
:
"Users"
},
plugins
:[
Ext
.
create
(
"Ext.grid.plugin.CellEditing"
,{
clicksToEdit
:
1
})],
selModel
:{
selType
:
"cellmodel"
},
columns
:[{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-edit x-ibtn-def"
;}}]},{
header
:
"ID"
,
dataIndex
:
"id"
,
width
:
40
},{
header
:
"Name"
,
dataIndex
:
"name"
,
editor
:{
xtype
:
"textfield"
},
flex
:
1
},{
header
:
"Login"
,
dataIndex
:
"login"
,
width
:
120
},{
header
:
"Password"
,
hidden
:
true
,
dataIndex
:
"passwd"
},{
header
:
"uid"
,
dataIndex
:
"uid"
,
width
:
40
},{
header
:
"gid"
,
dataIndex
:
"gid"
,
width
:
40
},{
header
:
"Mail directory"
,
dataIndex
:
"maildir"
},{
header
:
"SMTP"
,
dataIndex
:
"smtp"
,
editor
:{
xtype
:
"combo"
,
valueField
:
"id"
,
displayField
:
"name"
,
triggerAction
:
"all"
,
editable
:
false
,
store
:
"Choice"
},
renderer
:
function
(
a
){
if
(
a
==
1
){
return
"Yes"
;}
return
"No"
;}},{
header
:
"IMAP"
,
dataIndex
:
"imap"
,
editor
:{
xtype
:
"combo"
,
valueField
:
"id"
,
displayField
:
"name"
,
triggerAction
:
"all"
,
editable
:
false
,
store
:
"Choice"
},
renderer
:
function
(
a
){
if
(
a
==
1
){
return
"Yes"
;}
return
"No"
;}},{
header
:
"Quota"
,
dataIndex
:
"quota"
,
editor
:{
xtype
:
"numberfield"
,
allowDecimal
:
false
}},{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-delete x-ibtn-def"
;}}]}],
store
:
"Users"
}]});
Ext
.
define
(
"MyMA.view.User"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.user"
,
layout
:
"fit"
,
title
:
"User"
,
width
:
400
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
buttons
:[{
xtype
:
"button"
,
itemId
:
"savedata"
,
text
:
"Save"
,
scope
:
this
}],
items
:[{
xtype
:
"form"
,
frame
:
true
,
monitorValid
:
true
,
defaults
:{
xtype
:
"textfield"
,
anchor
:
"100%"
,
allowBlank
:
false
},
items
:[{
xtype
:
"hidden"
,
name
:
"id"
},{
xtype
:
"checkbox"
,
fieldLabel
:
"Manager"
,
name
:
"manager"
,
inputValue
:
1
},{
xtype
:
"checkbox"
,
fieldLabel
:
"SMTP"
,
name
:
"smtp"
,
inputValue
:
1
},{
xtype
:
"checkbox"
,
fieldLabel
:
"IMAP"
,
name
:
"imap"
,
inputValue
:
1
},{
fieldLabel
:
"Name"
,
name
:
"name"
},{
fieldLabel
:
"Login"
,
name
:
"login"
,
vtype
:
"email"
},{
fieldLabel
:
"Password"
,
name
:
"passwd"
},{
xtype
:
"numberfield"
,
allowDecimal
:
false
,
fieldLabel
:
"UID"
,
name
:
"uid"
,
anchor
:
"50%"
,
value
:
8
},{
xtype
:
"numberfield"
,
allowDecimal
:
false
,
fieldLabel
:
"GID"
,
name
:
"gid"
,
anchor
:
"50%"
,
value
:
12
},{
fieldLabel
:
"Mail directory"
,
name
:
"maildir"
},{
xtype
:
"numberfield"
,
name
:
"quota"
,
allowDecimal
:
false
,
fieldLabel
:
"Quota"
,
anchor
:
"60%"
,
value
:
100000000
}]}]});
Ext
.
define
(
"MyMA.view.Viewport"
,{
extend
:
"Ext.container.Viewport"
,
requires
:[
"MyMA.view.ProgramMenu"
,
"MyMA.view.Taskpanel"
,
"MyMA.view.Users"
,
"MyMA.view.Aliases"
],
layout
:
"fit"
,
statics
:{
ready
:
false
},
items
:{
xtype
:
"panel"
,
layout
:
"fit"
,
border
:
false
,
dockedItems
:[{
dock
:
"top"
,
xtype
:
"toolbar"
,
height
:
30
,
ui
:
"programbar-panel"
,
items
:[{
xtype
:
"programmenu"
,
width
:
100
},
"-"
,{
xtype
:
"taskpanel"
,
flex
:
1
}]}],
items
:[{
xtype
:
"panel"
,
border
:
false
,
ui
:
"desk-panel"
,
bodyCls
:
"x-desk-panel-bg"
,
layout
:{
type
:
"fit"
}}]}});
Ext
.
define
(
"MyMA.view.Authorize"
,{
extend
:
"Ext.Window"
,
alias
:
"widget.authorize"
,
layout
:
"fit"
,
autoShow
:
true
,
layout
:
"fit"
,
width
:
350
,
closable
:
false
,
constrain
:
true
,
draggable
:
false
,
resizable
:
false
,
modal
:
true
,
cls
:
"x-window-authbaner"
,
dockedItems
:[{
dock
:
"top"
,
xtype
:
"toolbar"
,
ui
:
"authform-baner"
,
height
:
43
,
html
:
"{LOGIN @ MAIL . PANEL }"
}],
items
:[{
xtype
:
"form"
,
url
:
"index.php"
,
monitorValid
:
true
,
frame
:
false
,
border
:
false
,
bodyStyle
:{
border
:
0
,
background
:
"transparent"
},
defaults
:{
anchor
:
"100%"
},
tbar
:{
border
:
false
,
height
:
20
,
style
:{
border
:
0
,
background
:
"transparent"
,
padding
:
0
},
items
:{
xtype
:
"container"
,
itemId
:
"autherrormsg"
,
hidden
:
true
,
style
:{
color
:
"red"
},
tpl
:
"{message}"
,
data
:{
message
:
""
}}},
buttons
:[{
text
:
"Login"
,
itemId
:
"authorize"
}],
items
:[{
fieldLabel
:
"Login"
,
xtype
:
"textfield"
,
allowBlank
:
false
,
name
:
"login"
},{
fieldLabel
:
"Password"
,
xtype
:
"textfield"
,
name
:
"pass"
,
inputType
:
"password"
}]}]});
Ext
.
define
(
"MyMA.view.Transports"
,{
extend
:
"Ext.window.Window"
,
alias
:
"widget.transports"
,
layout
:
"fit"
,
minimizable
:
true
,
constrainHeader
:
true
,
closeAction
:
"destroy"
,
width
:
900
,
listeners
:{
render
:
function
(
a
){
if
(
Ext
.
getBody
().
getHeight
()
>
500
){
a
.
setHeight
(
Ext
.
getBody
().
getHeight
()
-
150
);}}},
items
:[{
xtype
:
"grid"
,
border
:
false
,
tbar
:[{
xtype
:
"button"
,
itemId
:
"addrecord"
,
iconCls
:
"x-ibtn-add"
,
text
:
"New Item"
},{
xtype
:
"tbseparator"
,
width
:
5
},{
xtype
:
"searchfield"
,
handler
:
"search"
,
name
:
"query"
},{
xtype
:
"tbspacer"
,
width
:
5
},{
xtype
:
"button"
,
itemId
:
"search"
,
text
:
"Search"
}],
bbar
:{
xtype
:
"pagingtoolbar"
,
displayInfo
:
true
,
store
:
"Transports"
},
columns
:[{
header
:
"ID"
,
dataIndex
:
"id"
,
width
:
40
},{
header
:
"Domain"
,
dataIndex
:
"domain"
,
editor
:{
xtype
:
"textfield"
,
allowBlank
:
false
},
flex
:
1
},{
header
:
"Transport"
,
dataIndex
:
"transport"
},{
xtype
:
"actioncolumn"
,
width
:
30
,
items
:[{
getClass
:
function
(){
return
"x-ibtn-delete x-ibtn-def"
;}}]}],
selType
:
"rowmodel"
,
plugins
:[
Ext
.
create
(
"Ext.grid.plugin.RowEditing"
,{
clicksToEdit
:
1
})],
store
:
"Transports"
}]});
Ext
.
define
(
"MyMA.model.Aliases"
,{
extend
:
"Ext.data.Model"
,
fields
:[{
name
:
"id"
,
type
:
"int"
},{
name
:
"alias"
,
type
:
"string"
},{
name
:
"recipient"
,
type
:
"string"
},{
name
:
"comment"
,
type
:
"string"
}],
proxy
:{
type
:
"rest"
,
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"alias"
),
reader
:{
type
:
"json"
,
root
:
"results"
,
totalProperty
:
"total"
},
writer
:{
type
:
"json"
,
allowSingle
:
true
}}});
Ext
.
define
(
"MyMA.model.Brief"
,{
extend
:
"Ext.data.Model"
,
fields
:[
"id"
,
"name"
],
proxy
:{
type
:
"memory"
,
reader
:{
type
:
"json"
,
root
:
"results"
}}});
Ext
.
define
(
"MyMA.model.Transports"
,{
extend
:
"Ext.data.Model"
,
fields
:[{
name
:
"id"
,
type
:
"int"
},{
name
:
"domain"
,
type
:
"string"
},{
name
:
"transport"
,
type
:
"string"
}],
proxy
:{
type
:
"rest"
,
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"transport"
),
reader
:{
type
:
"json"
,
root
:
"results"
,
totalProperty
:
"total"
},
writer
:{
type
:
"json"
,
allowSingle
:
true
}}});
Ext
.
define
(
"MyMA.model.Users"
,{
extend
:
"Ext.data.Model"
,
fields
:[{
name
:
"id"
,
type
:
"int"
},{
name
:
"name"
,
type
:
"string"
},{
name
:
"login"
,
type
:
"string"
},{
name
:
"passwd"
,
type
:
"string"
},{
name
:
"uid"
,
type
:
"int"
,
defaultValue
:
8
},{
name
:
"gid"
,
type
:
"int"
,
defaultValue
:
12
},{
name
:
"maildir"
,
type
:
"string"
},{
name
:
"smtp"
,
type
:
"int"
},{
name
:
"imap"
,
type
:
"int"
},{
name
:
"quota"
,
type
:
"int"
,
defaultValue
:
10000000
},{
name
:
"manager"
,
type
:
"int"
}],
validations
:[{
type
:
"format"
,
field
:
"maildir"
,
matcher
:
/^
\/[
a-z
]\.
ru
\/[
a-z_0-9
]\/
Maildir
\/
$/
}],
proxy
:{
type
:
"rest"
,
url
:
Ext
.
Ajax
.
getRestUrl
(
"api/user"
),
reader
:{
type
:
"json"
,
root
:
"results"
},
writer
:{
type
:
"json"
,
allowSingle
:
true
}}});
Ext
.
define
(
"MyMA.store.Aliases"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Aliases"
,
model
:
"MyMA.model.Aliases"
,
groupField
:
"alias"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Choice"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Brief"
,
model
:
"MyMA.model.Brief"
,
data
:[{
id
:
0
,
name
:
"No"
},{
id
:
1
,
name
:
"Yes"
}]});
Ext
.
define
(
"MyMA.store.Programs"
,{
extend
:
"Ext.data.ArrayStore"
,
fields
:[
"id"
,
"name"
,
"state"
,
"item"
,
"title"
,
"control"
],
data
:[],
getProccess
:
function
(
b
){
var
b
=
b
||
{
property
:
"id"
,
value
:
null
},
a
=-
1
;
if
((
a
=
this
.
find
(
b
.
property
,
b
.
value
,
0
,
false
,
true
,
true
))
>-
1
){
return
this
.
getAt
(
a
);}
return
null
;}});
Ext
.
define
(
"MyMA.store.Transports"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Transports"
,
model
:
"MyMA.model.Transports"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.store.Users"
,{
extend
:
"Ext.data.Store"
,
requires
:
"MyMA.model.Users"
,
model
:
"MyMA.model.Users"
,
remoteSort
:
true
,
pageSize
:
100
});
Ext
.
define
(
"MyMA.controller.Alias"
,{
extend
:
"Ext.app.Controller"
,
views
:[
"Alias"
],
refs
:[{
selector
:
"alias"
,
ref
:
"aliasWindow"
}],
init
:
function
(){
this
.
control
({
"alias > toolbar > #savedata"
:{
click
:
this
.
saveData
}});},
saveData
:
function
(
a
){
var
b
=
this
.
getAliasWindow
().
down
(
"form"
).
getForm
(),
c
=
b
.
getValues
().
id
||
null
;
if
(
!
b
.
isValid
()){
return
false
;}
b
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"alias"
,
c
),
clientValidation
:
true
,
method
:
c
>
0
?
"PUT"
:
"POST"
,
scope
:{
controller
:
this
,
win
:
this
.
getAliasWindow
()},
success
:
this
.
onSuccessSubmit
,
failure
:
this
.
onFailSubmit
});},
onSuccessSubmit
:
function
(
a
,
b
){
this
.
win
.
close
();
this
.
controller
.
getController
(
"Aliases"
).
getStore
(
"Aliases"
).
reload
({
params
:{
start
:
0
}});
Ext
.
Msg
.
showInfo
({
msg
:
"Data saved"
});},
onFailSubmit
:
function
(
a
,
c
){
try
{
var
b
=
Ext
.
decode
(
c
.
response
.
responseText
);
throw
(
b
);}
catch
(
d
){
Ext
.
Msg
.
showError
({
msg
:
d
});}}});
Ext
.
define
(
"MyMA.controller.Aliases"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Aliases"
],
views
:[
"Aliases"
,
"Alias"
],
refs
:[{
selector
:
"aliases > grid"
,
ref
:
"aliasesList"
}],
init
:
function
(){
this
.
control
({
"aliases > grid > toolbar > #addrecord"
:{
click
:
this
.
showForm
},
"aliases > grid > toolbar > #search"
:{
click
:
this
.
onSearch
},
"aliases actioncolumn"
:{
click
:
this
.
onActionColumn
}});},
onActionColumn
:
function
(
g
,
a
,
h
,
i
,
f
,
j
,
b
){
if
(
f
.
getTarget
(
".x-ibtn-edit"
)){
var
d
=
j
.
store
.
getAt
(
h
);
var
c
=
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"alias"
});
c
.
setTitle
(
"Alias: "
+
d
.
get
(
"alias"
));
c
.
down
(
"form"
).
getForm
().
loadRecord
(
d
);}
if
(
f
.
getTarget
(
".x-ibtn-delete"
)){
var
d
=
j
.
store
.
getAt
(
h
);
Ext
.
Msg
.
confirm
(
"Info"
,
"Press Yes to confirm remove action"
,
function
(
e
){
if
(
e
===
"yes"
){
this
.
record
.
destroy
({
scope
:
this
,
success
:
function
(){
this
.
store
.
remove
(
this
.
record
);}});}},{
store
:
j
.
store
,
record
:
d
});}},
showForm
:
function
(
a
){
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"alias"
,
title
:
"New Alias"
});},
onSearch
:
function
(
a
){
this
.
getAliasesList
().
getStore
().
reload
({
params
:
a
.
up
(
"toolbar"
).
getValues
()});}});
Ext
.
define
(
"MyMA.controller.Program"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Programs"
],
refs
:[{
selector
:
"taskpanel"
,
ref
:
"taskPanel"
}],
init
:
function
(){
var
a
=
{};
Ext
.
each
(
this
.
refs
,
function
(
b
){
this
.
control
[
b
.
selector
]
=
{
beforeclose
:
this
.
me
.
programStop
,
hide
:
this
.
me
.
programState
,
show
:
this
.
me
.
programState
,
minimize
:
this
.
me
.
programMinimize
};},{
control
:
a
,
me
:
this
});
this
.
control
(
a
);},
registerControl
:
function
(
a
){
var
a
=
a
||
null
,
b
=
{};
if
(
!
a
){
return
;}
b
[
a
]
=
{
beforeclose
:
this
.
programStop
,
hide
:
this
.
programState
,
show
:
this
.
programState
,
minimize
:
this
.
programMinimize
};
this
.
control
(
b
);},
programMinimize
:
function
(
b
){
var
a
;
if
(
!
(
a
=
this
.
getStore
(
"Programs"
).
getProccess
({
property
:
"item"
,
value
:
b
.
getId
()}))){
return
false
;}
this
.
getTaskPanel
().
items
.
get
(
a
.
get
(
"control"
)).
toggle
(
false
);
b
.
hide
();
this
.
programState
(
b
);},
programState
:
function
(
c
,
b
){
var
a
;
if
(
!
(
a
=
this
.
getStore
(
"Programs"
).
getProccess
({
property
:
"item"
,
value
:
c
.
getId
()}))){
return
false
;}
a
.
set
(
"state"
,
c
.
isHidden
()?
"hide"
:
"show"
);},
programStop
:
function
(
b
,
a
){
var
a
=
a
||
Ext
.
undefined
;
if
(
!
a
.
data
){(
a
=
this
.
getStore
(
"Programs"
).
getProccess
({
property
:
"item"
,
value
:
b
.
getId
()}));}
if
(
b
.
animateTarget
){
b
.
animateTarget
=
null
;}
if
(
a
&&
a
.
data
){
this
.
getTaskPanel
().
items
.
get
(
a
.
get
(
"control"
)).
destroy
();
this
.
getStore
(
"Programs"
).
remove
(
a
);}}});
Ext
.
define
(
"MyMA.controller.ProgramMenu"
,{
extend
:
"Ext.app.Controller"
,
init
:
function
(){
this
.
control
({
"programmenu > menu"
:{
click
:
this
.
LaunchProgram
}});},
LaunchProgram
:
function
(
b
,
a
){
if
(
a
.
itemId
==
"logout"
){
this
.
getController
(
"Viewport"
).
Logout
();}
else
{
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
a
.
widgetName
,
title
:
a
.
text
});}}});
Ext
.
define
(
"MyMA.controller.Taskpanel"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Programs"
],
refs
:[{
selector
:
"taskpanel"
,
ref
:
"taskPanel"
}],
init
:
function
(){
this
.
control
({
"taskpanel > button"
:{
toggle
:
this
.
programState
}});},
addProgram
:
function
(
g
){
var
g
=
g
||
{
name
:
null
},
c
=
this
.
getStore
(
"Programs"
),
b
,
f
;
if
(
!
(
b
=
c
.
getProccess
({
property
:
"name"
,
value
:
g
.
name
}))){
try
{
var
f
=
Ext
.
widget
(
g
.
name
),
d
=
(
c
.
max
(
"id"
)
||
0
)
+
1
;}
catch
(
h
){
return
false
;}
var
a
=
this
.
getTaskPanel
().
add
({
xtype
:
"button"
,
ui
:
"program-button"
,
height
:
28
,
text
:
g
.
title
||
f
.
title
,
enableToggle
:
true
,
pressed
:
true
,
programId
:
d
});
b
=
c
.
add
({
id
:
d
,
title
:
g
.
title
||
f
.
title
,
name
:
g
.
name
,
state
:
"show"
,
item
:
f
.
getId
(),
control
:
a
.
getId
()})[
0
];
this
.
getController
(
"Program"
).
registerControl
(
g
.
name
);
f
.
animateTarget
=
a
.
getId
();
f
.
setTitle
(
g
.
title
);
f
.
show
();}
else
{
this
.
getTaskPanel
().
items
.
get
(
b
.
get
(
"control"
)).
toggle
(
true
);
if
((
f
=
Ext
.
getCmp
(
b
.
get
(
"item"
)))){
f
.
show
();}}
return
f
?
f
:
null
;},
callRef
:
function
(
a
){
var
d
=
this
;
try
{
for
(
var
b
=
0
,
c
=
this
.
refs
.
length
;
b
<
c
;
b
++
){
if
(
this
.
refs
[
b
][
"selector"
]
==
a
){
return
d
[
"get"
+
Ext
.
String
.
capitalize
(
this
.
refs
[
b
][
"ref"
])]();}}}
catch
(
f
){}
return
null
;},
programState
:
function
(
b
){
var
c
=
this
.
getStore
(
"Programs"
),
a
,
d
;
if
(
!
(
a
=
c
.
getProccess
({
property
:
"id"
,
value
:
b
.
programId
}))){
return
false
;}
if
((
d
=
Ext
.
getCmp
(
a
.
get
(
"item"
)))){
d
[
a
.
get
(
"state"
)
==
"show"
?
"hide"
:
"show"
]();}},
closeAll
:
function
(){
this
.
getStore
(
"Programs"
).
each
(
function
(
a
){
if
((
widget
=
Ext
.
getCmp
(
a
.
get
(
"item"
)))){
widget
.
hide
();
this
.
getTaskPanel
().
items
.
get
(
a
.
get
(
"control"
)).
destroy
();}},
this
);}});
Ext
.
define
(
"MyMA.controller.Transports"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Transports"
],
views
:[
"Transports"
],
refs
:[{
selector
:
"transports > grid"
,
ref
:
"transportsList"
}],
init
:
function
(){
this
.
control
({
"transports > grid > toolbar > #addrecord"
:{
click
:
this
.
addRecord
},
"transports > grid > toolbar > #search"
:{
click
:
this
.
onSearch
},
"transports actioncolumn"
:{
click
:
this
.
onActionColumn
},
"transports > grid"
:{
edit
:
this
.
onEditAction
}});},
onActionColumn
:
function
(
b
,
g
,
i
,
d
,
h
,
f
,
c
){
if
(
h
.
getTarget
(
".x-ibtn-delete"
)){
var
a
=
f
.
store
.
getAt
(
i
);
Ext
.
Msg
.
confirm
(
"Info"
,
"Press Yes to confirm remove action"
,
function
(
e
){
if
(
e
===
"yes"
){
if
(
!
this
.
record
.
get
(
"id"
)){
this
.
store
.
remove
(
this
.
record
);}
else
{
this
.
record
.
destroy
({
scope
:
this
,
success
:
function
(){
this
.
store
.
remove
(
this
.
record
);}});}}},{
store
:
f
.
store
,
record
:
a
});}},
addRecord
:
function
(
a
){
this
.
getTransportsList
().
getStore
().
insert
(
0
,
this
.
getTransportsList
().
getStore
().
model
.
create
({
id
:
0
,
domain
:
null
,
transport
:
"virtual"
}));},
onSearch
:
function
(
a
){
this
.
getTransportsList
().
getStore
().
reload
({
params
:
a
.
up
(
"toolbar"
).
getValues
()});},
onEditAction
:
function
(
a
,
b
){
b
.
record
.
save
({
scope
:
b
,
success
:
function
(
c
){
this
.
store
.
reload
();}});}});
Ext
.
define
(
"MyMA.controller.User"
,{
extend
:
"Ext.app.Controller"
,
views
:[
"User"
],
refs
:[{
selector
:
"user"
,
ref
:
"userWindow"
}],
init
:
function
(){
this
.
control
({
"user > toolbar > #savedata"
:{
click
:
this
.
saveData
}});},
saveData
:
function
(
a
){
var
b
=
this
.
getUserWindow
().
down
(
"form"
).
getForm
(),
c
=
b
.
getValues
().
id
||
null
;
if
(
!
b
.
isValid
()){
return
false
;}
b
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"user"
,
c
),
clientValidation
:
true
,
method
:
c
>
0
?
"PUT"
:
"POST"
,
params
:
Ext
.
applyIf
(
Ext
.
copyTo
({},
b
.
getValues
(),
"smtp,imap,manager"
),{
smtp
:
0
,
imap
:
0
,
manager
:
0
}),
scope
:{
controller
:
this
,
win
:
this
.
getUserWindow
()},
success
:
this
.
onSuccessSubmit
,
failure
:
this
.
onFailSubmit
});},
onSuccessSubmit
:
function
(
a
,
b
){
this
.
win
.
close
();
this
.
controller
.
getController
(
"Users"
).
getStore
(
"Users"
).
reload
({
params
:{
start
:
0
}});
Ext
.
Msg
.
showInfo
({
msg
:
"Data saved"
});},
onFailSubmit
:
function
(
a
,
c
){
try
{
var
b
=
Ext
.
decode
(
c
.
response
.
responseText
);
throw
(
b
);}
catch
(
d
){
Ext
.
Msg
.
showError
({
msg
:
d
});}}});
Ext
.
define
(
"MyMA.controller.Users"
,{
extend
:
"Ext.app.Controller"
,
stores
:[
"Users"
,
"Choice"
],
views
:[
"Users"
,
"User"
],
refs
:[{
selector
:
"users > grid"
,
ref
:
"usersList"
},{
selector
:
"users"
,
ref
:
"usersWindow"
}],
init
:
function
(){
this
.
control
({
"users > grid > toolbar > #addrecord"
:{
click
:
this
.
showForm
},
"users > grid > toolbar > #search"
:{
click
:
this
.
onSearch
},
"users actioncolumn"
:{
click
:
this
.
onActionColumn
}});},
onActionColumn
:
function
(
g
,
a
,
h
,
i
,
f
,
j
,
b
){
if
(
f
.
getTarget
(
".x-ibtn-edit"
)){
var
d
=
j
.
store
.
getAt
(
h
);
var
c
=
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"user"
});
c
.
setTitle
(
"User: "
+
d
.
get
(
"name"
));
c
.
down
(
"form"
).
getForm
().
loadRecord
(
d
);}
if
(
f
.
getTarget
(
".x-ibtn-delete"
)){
var
d
=
j
.
store
.
getAt
(
h
);
Ext
.
Msg
.
confirm
(
"Info"
,
"Press Yes to conform remove action"
,
function
(
e
){
if
(
e
===
"yes"
){
this
.
record
.
destroy
({
scope
:
this
,
success
:
function
(){
this
.
store
.
remove
(
this
.
record
);}});}},{
store
:
j
.
store
,
record
:
d
});}},
showForm
:
function
(
a
){
this
.
getController
(
"Taskpanel"
).
addProgram
({
name
:
"user"
,
title
:
"New User"
});},
onSearch
:
function
(
a
){
this
.
getUsersList
().
getStore
().
reload
({
params
:
a
.
up
(
"toolbar"
).
getValues
()});}});
Ext
.
define
(
"MyMA.controller.Viewport"
,{
extend
:
"Ext.app.Controller"
,
views
:[
"Viewport"
,
"Authorize"
],
refs
:[{
selector
:
"viewport"
,
ref
:
"appView"
},{
selector
:
"authorize"
,
ref
:
"authPanel"
},{
selector
:
"authorize > form"
,
ref
:
"authForm"
},{
selector
:
"authorize > form #authorize"
,
ref
:
"authButton"
},{
selector
:
"authorize > form #autherrormsg"
,
ref
:
"authErrorMsg"
}],
isGuest
:
Ext
.
undefined
,
init
:
function
(
a
){
Ext
.
override
(
Ext
.
data
.
Connection
,{
setGuest
:
Ext
.
Function
.
bind
(
this
.
setGuest
,
this
),
getGuest
:
Ext
.
Function
.
bind
(
this
.
getGuest
,
this
)});
this
.
control
({
"authorize > form > toolbar > button"
:{
click
:
this
.
Authorize
},
"authorize > form field"
:{
specialkey
:
function
(
c
,
b
){
if
(
b
.
getKey
()
==
b
.
ENTER
){
this
.
Authorize
();}}}});
this
.
Authorize
();},
Authorize
:
function
(){
if
(
this
.
getAuthPanel
()){
var
a
=
this
.
getAuthPanel
().
down
(
"form"
).
getForm
();
if
(
a
.
isValid
()){
this
.
getAuthButton
().
setIconCls
(
"x-ibtn-loading x-ibtn-def"
);
a
.
submit
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"login"
,
"authorize"
,
0
),
method
:
"PUT"
,
clientValidation
:
true
,
scope
:
this
,
success
:
this
.
successLogin
,
failure
:
this
.
failLogin
});}}
else
{
Ext
.
Ajax
.
request
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"login"
),
scope
:
this
,
callback
:
function
(){
if
(
!
this
.
isGuest
&&!
this
.
getAppView
()){
this
.
setGuest
(
false
);
this
.
getView
(
"Viewport"
).
create
();}}});}},
getGuest
:
function
(){
return
this
.
isGuest
;},
setGuest
:
function
(
a
){
this
.
isGuest
=
Ext
.
isBoolean
(
a
)?
a
:
true
;
if
(
this
.
isGuest
&&!
this
.
getAuthPanel
()){
this
.
getView
(
"Authorize"
).
create
();}},
successLogin
:
function
(
a
,
b
){
this
.
getAuthPanel
().
close
();
if
(
!
this
.
getAppView
()){
this
.
getView
(
"Viewport"
).
create
();}},
failLogin
:
function
(
a
,
c
){
try
{
this
.
getAuthButton
().
setIconCls
(
""
);
var
b
=
Ext
.
decode
(
c
.
response
.
responseText
);
if
(
b
.
error
.
trace
){
Ext
.
Msg
.
showError
({
msg
:
b
});}
else
{
var
f
=
this
.
getAuthErrorMsg
();
f
.
tpl
.
overwrite
(
f
.
getEl
(),{
message
:
b
.
error
.
message
||
b
.
error
.
title
});
if
(
f
&&!
f
.
isVisible
()){
f
.
show
();}
f
.
stopAnimation
();
f
.
animate
({
duration
:
5
,
to
:{
opacity
:
1
}});
f
.
animate
({
duration
:
5000
,
to
:{
opacity
:
0
}});}}
catch
(
d
){}},
Logout
:
function
(){
Ext
.
Ajax
.
request
({
url
:
Ext
.
Ajax
.
getRestUrl
(
"api"
,
"login"
,
"logout"
,
0
),
method
:
"PUT"
,
scope
:
this
,
callback
:
function
(){
if
(
this
.
getAppView
()){
this
.
getController
(
"Taskpanel"
).
closeAll
();
this
.
getAppView
().
destroy
();}
this
.
setGuest
(
this
,
true
);}});}});
Ext
.
application
({
name
:
"MyMA"
,
controllers
:[
"Viewport"
,
"ProgramMenu"
,
"Taskpanel"
,
"Program"
,
"Users"
,
"User"
,
"Aliases"
,
"Alias"
,
"Transports"
],
enableQuickTips
:
true
});
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment