aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/ng2/components/ui/designer/designer-frame.component.ts
blob: b52696a2872eed6f8273132e12de5bd799bdd0da (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
import {Component, OnInit, Input} from "@angular/core";
import { URLSearchParams } from '@angular/http';
import {Designer} from "app/models";

@Component({
    selector: 'designer-frame',
    templateUrl: './designer-frame.component.html',
    styleUrls:['designer-frame.component.less']
})

export class DesignerFrameComponent implements OnInit {

    @Input() designer: Designer;
    @Input() queryParams: Object;
    designerUrl: string;
    private urlSearchParams: URLSearchParams;

    constructor() {
        this.urlSearchParams = new URLSearchParams();
    }

    ngOnInit(): void {

        this.designerUrl = this.designer.designerProtocol + "://" +
            this.designer.designerHost + ":" +
            this.designer.designerPort +
            this.designer.designerPath;

        if (this.queryParams && !_.isEmpty(this.queryParams)) {
            _.forOwn(this.queryParams, (value, key) => {
                this.urlSearchParams.set(key, value);
            });

            this.designerUrl += '?';
            this.designerUrl += this.urlSearchParams.toString();
        }
    }
}