@@ -14,7 +14,28 @@ module.exports = Mn.View.extend({
14
14
list_region : '.list-region' ,
15
15
add : '.add-item' ,
16
16
help : '.help' ,
17
- dimmer : '.dimmer'
17
+ dimmer : '.dimmer' ,
18
+ search : '.search-form' ,
19
+ query : 'input[name="source-query"]'
20
+ } ,
21
+
22
+ fetch : App . Api . Nginx . RedirectionHosts . getAll ,
23
+
24
+ showData : function ( response ) {
25
+ this . showChildView ( 'list_region' , new ListView ( {
26
+ collection : new RedirectionHostModel . Collection ( response )
27
+ } ) ) ;
28
+ } ,
29
+
30
+ showError : function ( err ) {
31
+ this . showChildView ( 'list_region' , new ErrorView ( {
32
+ code : err . code ,
33
+ message : err . message ,
34
+ retry : function ( ) {
35
+ App . Controller . showNginxRedirection ( ) ;
36
+ }
37
+ } ) ) ;
38
+ console . error ( err ) ;
18
39
} ,
19
40
20
41
regions : {
@@ -30,6 +51,17 @@ module.exports = Mn.View.extend({
30
51
'click @ui.help' : function ( e ) {
31
52
e . preventDefault ( ) ;
32
53
App . Controller . showHelp ( App . i18n ( 'redirection-hosts' , 'help-title' ) , App . i18n ( 'redirection-hosts' , 'help-content' ) ) ;
54
+ } ,
55
+
56
+ 'submit @ui.search' : function ( e ) {
57
+ e . preventDefault ( ) ;
58
+ let query = this . ui . query . val ( ) ;
59
+
60
+ this . fetch ( [ 'owner' , 'certificate' ] , query )
61
+ . then ( response => this . showData ( response ) )
62
+ . catch ( err => {
63
+ this . showError ( err ) ;
64
+ } ) ;
33
65
}
34
66
} ,
35
67
@@ -40,13 +72,11 @@ module.exports = Mn.View.extend({
40
72
onRender : function ( ) {
41
73
let view = this ;
42
74
43
- App . Api . Nginx . RedirectionHosts . getAll ( [ 'owner' , 'certificate' ] )
75
+ view . fetch ( [ 'owner' , 'certificate' ] )
44
76
. then ( response => {
45
77
if ( ! view . isDestroyed ( ) ) {
46
78
if ( response && response . length ) {
47
- view . showChildView ( 'list_region' , new ListView ( {
48
- collection : new RedirectionHostModel . Collection ( response )
49
- } ) ) ;
79
+ view . showData ( response ) ;
50
80
} else {
51
81
let manage = App . Cache . User . canManage ( 'redirection_hosts' ) ;
52
82
@@ -64,15 +94,7 @@ module.exports = Mn.View.extend({
64
94
}
65
95
} )
66
96
. catch ( err => {
67
- view . showChildView ( 'list_region' , new ErrorView ( {
68
- code : err . code ,
69
- message : err . message ,
70
- retry : function ( ) {
71
- App . Controller . showNginxRedirection ( ) ;
72
- }
73
- } ) ) ;
74
-
75
- console . error ( err ) ;
97
+ view . showError ( err ) ;
76
98
} )
77
99
. then ( ( ) => {
78
100
view . ui . dimmer . removeClass ( 'active' ) ;
0 commit comments