blob: 189356ff726cd795f201760a9b6318917e468ee8 [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2015-2018 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
import { Component, OnInit, ViewChild, Input, OnDestroy } from '@angular/core';
import { FormGroup, FormControl, FormBuilder, FormArray, Validators } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { DropdownModule } from 'primeng/dropdown';
import { TreeTableModule } from 'primeng/treetable';
import { TreeNode, MenuItem } from 'primeng/api';
import { ContextMenuModule } from 'primeng/contextmenu';
import { TreeTable, TreeTableToggler, DataTable } from 'primeng/primeng';
import { DialogModule } from 'primeng/dialog';
import { Observable, BehaviorSubject } from 'rxjs';
import { MDMNotificationService } from '../core/mdm-notification.service';
import { ExtSystemService } from './extsystem.service';
import { Node } from '../navigator/node';
import { NodeService } from '../navigator/node.service';
@Component( {
selector: 'mdm-extsystem',
templateUrl: './extsystem.component.html',
styleUrls: ['./extsystem.component.css']
})
export class ExtSystemComponent implements OnInit, OnDestroy {
// available external systems
extSystems: Node[];
bsExtSystems: BehaviorSubject<Node[]> = new BehaviorSubject<Node[]>(undefined);
selectedEnvironment: Node;
editorMode = false;
selectedExtSystem: string = undefined;
// dropdown selection
environments: Node[];
// unknown -> remove
scope: string;
constructor(private extSystemService: ExtSystemService,
private notificationService: MDMNotificationService,
private translateService: TranslateService,
private nodeService: NodeService) {
this.bsExtSystems.subscribe(value => {
this.extSystems = value;
});
}
ngOnInit() {
this.nodeService.getRootNodes().subscribe(
envs => this.environments = envs,
error => this.translateService.instant('basket.mdm-basket.err-cannot-load-sources')
.subscribe(msg => this.notificationService.notifyError(msg, error)
));
this.bsExtSystems.next(undefined);
}
ngOnDestroy() {
}
onEditModeChange(editMode: boolean) {
this.editorMode = editMode;
}
onChangeSelectedExtSystem(extSystem: string) {
this.selectedExtSystem = extSystem;
}
onChangeExtSystem(event: any) {
this.extSystems = undefined;
if (this.selectedEnvironment !== undefined) {
this.scope = this.selectedEnvironment.sourceName;
}
this.extSystemService.getExtSystemForScope(this.scope).subscribe(es => this.bsExtSystems.next(es));
}
onPageSwitchToEdit() {
this.onEditModeChange(true);
}
onPageBack() {
this.onEditModeChange(false);
}
}