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

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

export class PluginFrameComponent implements OnInit {

    @Input() plugin: Plugin;
    @Input() queryParams: Object;
    pluginUrl: string;
    private urlSearchParams: URLSearchParams;

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

    ngOnInit(): void {

        this.pluginUrl = this.plugin.pluginSourceUrl;

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

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