@@ -14,7 +14,28 @@ module.exports = Mn.View.extend({
1414 list_region : '.list-region' ,
1515 add : '.add-item' ,
1616 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 ) ;
1839 } ,
1940
2041 regions : {
@@ -30,6 +51,17 @@ module.exports = Mn.View.extend({
3051 'click @ui.help' : function ( e ) {
3152 e . preventDefault ( ) ;
3253 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+ } ) ;
3365 }
3466 } ,
3567
@@ -40,13 +72,11 @@ module.exports = Mn.View.extend({
4072 onRender : function ( ) {
4173 let view = this ;
4274
43- App . Api . Nginx . RedirectionHosts . getAll ( [ 'owner' , 'certificate' ] )
75+ view . fetch ( [ 'owner' , 'certificate' ] )
4476 . then ( response => {
4577 if ( ! view . isDestroyed ( ) ) {
4678 if ( response && response . length ) {
47- view . showChildView ( 'list_region' , new ListView ( {
48- collection : new RedirectionHostModel . Collection ( response )
49- } ) ) ;
79+ view . showData ( response ) ;
5080 } else {
5181 let manage = App . Cache . User . canManage ( 'redirection_hosts' ) ;
5282
@@ -64,15 +94,7 @@ module.exports = Mn.View.extend({
6494 }
6595 } )
6696 . 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 ) ;
7698 } )
7799 . then ( ( ) => {
78100 view . ui . dimmer . removeClass ( 'active' ) ;
0 commit comments