@@ -12,7 +12,7 @@ export class ConfigurationGateway {
1212 @SubscribeMessage ( 'panel.configurations.storefronts.get' )
1313 async getStorefrontConfigsForPanel ( ) {
1414 const configs = await this . configurationService . getAll ( PlatformTypes . Storefront ) ;
15- return { event : ` panel.configurations.storefronts` , data : configs } ;
15+ return { event : ' panel.configurations.storefronts' , data : configs } ;
1616 }
1717
1818 @SubscribeMessage ( 'panel.configurations.gateways.get' )
@@ -22,10 +22,51 @@ export class ConfigurationGateway {
2222 }
2323
2424 @SubscribeMessage ( 'panel.configurations.storefront.add' )
25- async addStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration [ ] , name : string } ) {
25+ async addStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
2626 if ( ! body . configurations ) return null ;
27- const configs = await this . configurationService . add ( PlatformTypes . Storefront , body . name , body . configurations ) ;
28- this . server . emit ( `panel.configurations.storefront.${ body . name } ` , configs ) ;
27+ await this . configurationService . add ( PlatformTypes . Storefront , body . name , body . configurations ) ;
28+ this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
29+ this . server . emit ( `configurations.storefront.update` , body . configurations ) ;
30+ }
31+
32+ @SubscribeMessage ( 'panel.configurations.gateway.add' )
33+ async addGatewayConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
34+ if ( ! body . configurations ) return null ;
35+ await this . configurationService . add ( PlatformTypes . Gateway , body . name , body . configurations ) ;
36+ this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
37+ this . server . emit ( `configurations.gateway.update` , body . configurations ) ;
38+ }
39+
40+ @SubscribeMessage ( 'panel.configurations.storefront.update' )
41+ async updateStorefrontConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
42+ if ( ! body . configurations ) return null ;
43+ await this . configurationService . update ( PlatformTypes . Storefront , body . name , body . configurations ) ;
44+ this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
45+ this . server . emit ( `configurations.storefront.update` , body . configurations ) ;
46+ }
47+
48+ @SubscribeMessage ( 'panel.configurations.gateway.update' )
49+ async updateGatewayConfigs ( @MessageBody ( ) body : { configurations : Configuration , name : string } ) {
50+ if ( ! body . configurations ) return null ;
51+ await this . configurationService . update ( PlatformTypes . Gateway , body . name , body . configurations ) ;
52+ this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
53+ this . server . emit ( `configurations.gateway.update` , body . configurations ) ;
54+ }
55+
56+ @SubscribeMessage ( 'panel.configurations.storefront.delete' )
57+ async deleteStorefrontConfigs ( @MessageBody ( ) body : { name : string } ) {
58+ if ( ! body . name ) return null ;
59+ await this . configurationService . delete ( PlatformTypes . Storefront , body . name ) ;
60+ this . server . emit ( 'panel.configurations.storefronts' , await this . configurationService . getAll ( PlatformTypes . Storefront ) ) ;
61+ this . server . emit ( `configurations.storefront.delete` , body . name ) ;
62+ }
63+
64+ @SubscribeMessage ( 'panel.configurations.gateway.delete' )
65+ async deleteGatewayConfigs ( @MessageBody ( ) body : { name : string } ) {
66+ if ( ! body . name ) return null ;
67+ await this . configurationService . delete ( PlatformTypes . Gateway , body . name ) ;
68+ this . server . emit ( 'panel.configurations.gateways' , await this . configurationService . getAll ( PlatformTypes . Gateway ) ) ;
69+ this . server . emit ( `configurations.gateway.delete` , body . name ) ;
2970 }
3071
3172 @SubscribeMessage ( 'configurations.storefront.get' )
0 commit comments