[helix-front] Allow new cluster activation

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

Branch: refs/heads/master
Commit: 8bbe0575459c27dfe608c5456bf76bcc052b3e45
Parents: 83e10db
Author: Vivo Xu <v...@linkedin.com>
Authored: Tue Sep 19 14:36:50 2017 -0700
Committer: Junkai Xue <j...@linkedin.com>
Committed: Mon Nov 6 17:08:13 2017 -0800

----------------------------------------------------------------------
 .../cluster-detail.component.html               |  4 +++
 .../cluster-detail/cluster-detail.component.ts  | 36 ++++++++++++++++++++
 .../app/cluster/shared/cluster.service.ts       |  5 +++
 3 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/8bbe0575/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
----------------------------------------------------------------------
diff --git 
a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html 
b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
index e321703..f6ee7d1 100644
--- 
a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
+++ 
b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.html
@@ -15,6 +15,10 @@
           <md-icon>menu</md-icon>
         </button>
         <md-menu #menu="mdMenu">
+          <button md-menu-item *ngIf="cluster.controller == 'No Lead 
Controller!'" (click)="activateCluster()">
+            <md-icon>settings_input_antenna</md-icon>
+            <span>Activate this Cluster</span>
+          </button>
           <button md-menu-item *ngIf="cluster.enabled" 
(click)="disableCluster()">
             <md-icon>not_interested</md-icon>
             <span>Disable this Cluster</span>

http://git-wip-us.apache.org/repos/asf/helix/blob/8bbe0575/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
----------------------------------------------------------------------
diff --git 
a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts 
b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
index 2f7b37f..e0db1b5 100644
--- a/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
+++ b/helix-front/client/app/cluster/cluster-detail/cluster-detail.component.ts
@@ -6,6 +6,7 @@ import { Cluster } from '../shared/cluster.model';
 import { HelperService } from '../../shared/helper.service';
 import { ClusterService } from '../shared/cluster.service';
 import { InstanceService } from '../../instance/shared/instance.service';
+import { AlertDialogComponent } from 
'../../shared/dialog/alert-dialog/alert-dialog.component';
 import { InputDialogComponent } from 
'../../shared/dialog/input-dialog/input-dialog.component';
 
 @Component({
@@ -119,6 +120,41 @@ export class ClusterDetailComponent implements OnInit {
       );
   }
 
+  activateCluster() {
+    this.dialog
+      .open(InputDialogComponent, {
+        data: {
+          title: 'Activate this Cluster',
+          message: 'To link this cluster to a Helix super cluster 
(controller), please enter the super cluster name:',
+          values: {
+            name: {
+              label: 'super cluster name'
+            }
+          }
+        }
+      })
+      .afterClosed()
+      .subscribe(result => {
+        if (result && result.name.value) {
+          this.clusterService
+            .activate(this.clusterName, result.name.value)
+            .subscribe(
+              () => {
+                // since this action may delay a little bit, to prevent 
re-activation,
+                // use an alert dialog to reload the data later
+                this.dialog.open(AlertDialogComponent, { data: {
+                  title: 'Cluster Activated',
+                  message: `Cluster '${ this.clusterName }' is linked to super 
cluster '${ result.name.value }'.`
+                }}).afterClosed().subscribe(() => {
+                  this.loadCluster();
+                });
+              },
+              error => this.helperService.showError(error)
+            );
+        }
+      });
+  }
+
   deleteCluster() {
     // disable delete function right now since it's too dangerous
     /*

http://git-wip-us.apache.org/repos/asf/helix/blob/8bbe0575/helix-front/client/app/cluster/shared/cluster.service.ts
----------------------------------------------------------------------
diff --git a/helix-front/client/app/cluster/shared/cluster.service.ts 
b/helix-front/client/app/cluster/shared/cluster.service.ts
index 2244729..43b1c8f 100644
--- a/helix-front/client/app/cluster/shared/cluster.service.ts
+++ b/helix-front/client/app/cluster/shared/cluster.service.ts
@@ -44,4 +44,9 @@ export class ClusterService extends HelixService {
     return this
       .post(`/clusters/${ name }?command=disable`, null);
   }
+
+  public activate(name: string, superCluster: string) {
+    return this
+      .post(`/clusters/${ name }?command=activate&superCluster=${ superCluster 
}`, null);
+  }
 }

Reply via email to