summaryrefslogtreecommitdiffstats
path: root/components/datalake-handler/admin/src/app/database/database-list/database-list.component.ts
blob: 5fb941b95a90e5b75881e612b4fedd785e9ae87d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { Component, OnInit, ViewChild, ElementRef } from "@angular/core";
import { Db } from "../../core/models/DB/db.model";
import { NgbModal, ModalDismissReasons } from "@ng-bootstrap/ng-bootstrap";
import { DatabaseAddModalComponent } from "./database-add-modal/database-add-modal.component";

// DB modal components
import { CouchbaseComponent } from "./dbs-modal/couchbase/couchbase.component";
import { DruidComponent } from "./dbs-modal/druid/druid.component";
import { ElasticsearchComponent } from "./dbs-modal/elasticsearch/elasticsearch.component";
import { MongodbComponent } from "./dbs-modal/mongodb/mongodb.component";

@Component({
  selector: "app-database-list",
  templateUrl: "./database-list.component.html",
  styleUrls: ["./database-list.component.css"]
})
export class DatabaseListComponent implements OnInit {
  constructor(private modalService: NgbModal) {}

  @ViewChild("addDbModal") private addDBModal: ElementRef;

  dbs: Db[] = [];

  dbSupports: any[];

  ngOnInit() {
    // TODO: rest api
    this.dbs.push(
      {
        name: "Couchbase",
        host: "host1",
        login: "login1",
        pass: "pass1",
        port: 111,
        ssl: true
      },
      {
        name: "Druid",
        host: "host2",
        login: "login2",
        pass: "pass2",
        port: 222,
        ssl: true
      },
      {
        name: "Elasticsearch",
        host: "host3",
        login: "login3",
        pass: "pass3",
        port: 333,
        ssl: false
      },
      {
        name: "MongoDB",
        host: "host4",
        login: "login4",
        pass: "pass4",
        port: 444,
        ssl: false
      }
    );
  }

  openDbAddModal() {
    this.modalService.open(DatabaseAddModalComponent, {
      size: "lg",
      centered: true
    });
  }

  openDbDetailModal(db: Db) {
    console.log("db name: " + db.name);

    switch (db.name) {
      case "Couchbase": {
        const modalRef = this.modalService.open(CouchbaseComponent, {
          size: "lg",
          centered: true
        });
        modalRef.componentInstance.dbname = "Couchbase";
        modalRef.componentInstance.name = db.name;
        modalRef.componentInstance.host = db.host;
        modalRef.componentInstance.port = db.port;
        modalRef.componentInstance.login = db.login;
        modalRef.componentInstance.pass = db.pass;
        modalRef.componentInstance.ssl = db.ssl;
        break;
      }
      case "Druid": {
        const modalRef = this.modalService.open(DruidComponent, {
          size: "lg",
          centered: true
        });
        modalRef.componentInstance.name = "World";
        break;
      }
      case "Elasticsearch": {
        const modalRef = this.modalService.open(ElasticsearchComponent, {
          size: "lg",
          centered: true
        });
        modalRef.componentInstance.name = "World";
        break;
      }
      case "MongoDB": {
        const modalRef = this.modalService.open(MongodbComponent, {
          size: "lg",
          centered: true
        });
        modalRef.componentInstance.name = "World";
        break;
      }
      default: {
        break;
      }
    }
  }
}