IGNITE-10525 Web Console: "Import models" dialog should be a singleton.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ea872cc5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ea872cc5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ea872cc5

Branch: refs/heads/ignite-10044
Commit: ea872cc51c6fef019ac368bfe17e9db035c6256e
Parents: b94a3c2
Author: Vasiliy Sisko <[email protected]>
Authored: Tue Dec 4 22:33:45 2018 +0700
Committer: Alexey Kuznetsov <[email protected]>
Committed: Tue Dec 4 22:33:45 2018 +0700

----------------------------------------------------------------------
 .../components/modal-import-models/service.js   | 32 ++++++++++++++++----
 1 file changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ea872cc5/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js
 
b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js
index e17721db..c45abaa 100644
--- 
a/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js
+++ 
b/modules/web-console/frontend/app/components/page-configure/components/modal-import-models/service.js
@@ -16,15 +16,23 @@
  */
 
 export default class ModalImportModels {
-    static $inject = ['$modal', '$uiRouter', 'AgentManager'];
+    static $inject = ['$modal', '$q', '$uiRouter', 'AgentManager'];
 
-    constructor($modal, $uiRouter, AgentManager) {
+    deferred;
+
+    constructor($modal, $q, $uiRouter, AgentManager) {
         this.$modal = $modal;
+        this.$q = $q;
         this.$uiRouter = $uiRouter;
         this.AgentManager = AgentManager;
     }
 
     _goToDynamicState() {
+        if (this.deferred)
+            return this.deferred.promise;
+
+        this.deferred = this.$q.defer();
+
         if (this._state)
             this.$uiRouter.stateRegistry.deregister(this._state);
 
@@ -36,7 +44,6 @@ export default class ModalImportModels {
             },
             onExit: () => {
                 this.AgentManager.stopWatch();
-
                 this._modal && this._modal.hide();
             }
         });
@@ -45,21 +52,34 @@ export default class ModalImportModels {
     }
 
     _open() {
+        const self = this;
+
         this._modal = this.$modal({
             template: `
                 <modal-import-models
-                    on-hide='$ctrl.$state.go("^")'
+                    on-hide='$ctrl.onHide()'
                     cluster-id='$ctrl.$state.params.clusterID'
                 ></modal-import-models>
             `,
-            controller: ['$state', function($state) {this.$state = $state;}],
+            controller: ['$state', function($state) {
+                this.$state = $state;
+
+                this.onHide = () => {
+                    self.deferred.resolve(true);
+
+                    this.$state.go('^');
+                };
+            }],
             controllerAs: '$ctrl',
+            backdrop: 'static',
             show: false
         });
 
         return this.AgentManager.startAgentWatch('Back', 
this.$uiRouter.globals.current.name)
             .then(() => this._modal.$promise)
-            .then(() => this._modal.show());
+            .then(() => this._modal.show())
+            .then(() => this.deferred.promise)
+            .finally(() => this.deferred = null);
     }
 
     open() {

Reply via email to