Change designer to plugin in code
[sdc.git] / catalog-ui / src / app / ng2 / components / ui / plugin / plugin-frame.component.ts
1 import {Component, OnInit, Input} from "@angular/core";
2 import { URLSearchParams } from '@angular/http';
3 import {Plugin} from "app/models";
4
5 @Component({
6     selector: 'plugin-frame',
7     templateUrl: './plugin-frame.component.html',
8     styleUrls:['plugin-frame.component.less']
9 })
10
11 export class PluginFrameComponent implements OnInit {
12
13     @Input() plugin: Plugin;
14     @Input() queryParams: Object;
15     pluginUrl: string;
16     private urlSearchParams: URLSearchParams;
17
18     constructor() {
19         this.urlSearchParams = new URLSearchParams();
20     }
21
22     ngOnInit(): void {
23
24         this.pluginUrl = this.plugin.pluginProtocol + "://" +
25             this.plugin.pluginHost + ":" +
26             this.plugin.pluginPort +
27             this.plugin.pluginPath;
28
29         if (this.queryParams && !_.isEmpty(this.queryParams)) {
30             _.forOwn(this.queryParams, (value, key) => {
31                 this.urlSearchParams.set(key, value);
32             });
33
34             this.pluginUrl += '?';
35             this.pluginUrl += this.urlSearchParams.toString();
36         }
37     }
38 }