Created
May 18, 2018 10:22
-
-
Save JohnBaek/26761ee1462551870af4fd1db407d569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; | |
import { LayoutModule } from '@progress/kendo-angular-layout'; | |
import { TranslateService } from '@ngx-translate/core'; | |
import { WindowService, WindowRef, WindowCloseResult, DialogService, DialogRef, DialogCloseResult } from '@progress/kendo-angular-dialog'; | |
// grid | |
import { GridDataResult, RowArgs } from '@progress/kendo-angular-grid'; | |
import { GridColumn } from '../../../../../shared/models/common/grid-column.model'; | |
import { EnumGridColumn } from '../../../../../shared/models/common/enum-grid-column.model'; | |
import { CommonKendoGridComponent } from '../../../../../shared/components/kendo-grid/kendo-grid.component'; | |
import { Grid } from '../../../../../shared/models/common/grid.model'; | |
import { GridModule } from '@progress/kendo-angular-grid'; | |
import { EnumApplicationStatus } from '../../../../../shared/models/enums/enum-application-status.model'; | |
// search | |
import { CommonSearch } from '../../../../../shared/models/common/common-search.model'; | |
import { ResponseList } from '../../../../../shared/models/response/response-list.model'; | |
import { ResponseEmpty } from '../../../../../shared/models/response/response-empty.model'; | |
// popup | |
import { PopupObjectServiceRegistComponent } from '../../../../../shared/components/popup/object/service/service-object-regist.component'; | |
import { PopupObjectServiceModifyComponent } from '../../../../../shared/components/popup/object/service/service-object-modify.component'; | |
import { PopupConfirmDeleteComponent } from '../../../../../shared/components/popup/confirm/delete.component'; | |
import { HttpService } from '../../../../../shared/services/http.service'; | |
import { HttpErrorResponse } from '@angular/common/http'; | |
import { MessageSeverity, AlertService } from '../../../../../shared/services/alert.service'; | |
import { EnumProtocolType } from '../../../../../shared/models/enums/enum-protocol-type.model'; | |
@Component({ | |
selector: 'management-firewall-paloalto-object-service', | |
templateUrl: 'service.component.html' | |
}) | |
export class ManagementFirewallPaloaltoObjectServiceComponent { | |
public readonly DEVICES_API_URL: string = 'api/v2/devices'; | |
public titleRegist: string = ""; // 서비스 등록 타이틀 | |
public titleModify: string = ""; // 서비스 수정 타이틀 | |
public titleDelete: string = ""; // 서비스 삭제 타이틀 | |
public selectedVirtualMachine: any; | |
/** Grid 생성 **/ | |
public grid: Grid = new Grid(); | |
public inCommunication: boolean = false; | |
public isLoading: boolean = false; | |
constructor(public windowService: WindowService, | |
public translate: TranslateService, | |
public dialogService: DialogService, | |
public httpService: HttpService, | |
public alertService: AlertService) { | |
this.setGridBase(); | |
this.setGridColums(); | |
} | |
public statusItems: Array<any>; | |
public selectedStatus: number; | |
// 서비스 등록 윈도우 입력 컨테이너 | |
@ViewChild("regist", { read: ViewContainerRef }) | |
public registContainer: ViewContainerRef; | |
// 서비스 수정 윈도우 입력 컨테이너 | |
@ViewChild("modify", { read: ViewContainerRef }) | |
public modifyContainer: ViewContainerRef; | |
// 서비스 삭제 다이얼로그 입력 컨테이너 | |
@ViewChild("delete", { read: ViewContainerRef }) | |
public deleteContainer: ViewContainerRef; | |
public registConst: WindowRef; | |
public modifyConst: WindowRef; | |
public deleteConst: DialogRef; | |
/** | |
* ngOnInit | |
*/ | |
ngOnInit() { | |
this.isLoading = true; | |
this.setTranslate(); | |
this.setGridBase(); | |
this.setGridColums(); | |
this.setSearchBar(); | |
//this.getServiceObject(); | |
} | |
/** | |
* 기본 번역을 초기화한다. | |
*/ | |
public setTranslate(): void { | |
// 서비스 등록 타이틀 번역 | |
this.translate.get("UL_COMMON__REGIST").subscribe(res => this.titleRegist = res); | |
// 서비스 수정 타이틀 번역 | |
this.translate.get("UL_COMMON__MODIFY").subscribe(res => this.titleModify = res); | |
// 서비스 삭제 타이틀 번역 | |
this.translate.get("UL_COMMON__DELETE").subscribe(res => this.titleDelete = res); | |
} | |
/** | |
* 가상머신 선택시에 오브젝트를 업데이트 한다 | |
* @param event | |
*/ | |
private selectVirtualMachine(deviceInfo): void { | |
if (typeof deviceInfo === "undefined") | |
return; | |
this.grid.baseApi = `${this.DEVICES_API_URL}/${deviceInfo.DeviceId}/${deviceInfo.VirtualDeviceId}/Objects/Services`; | |
this.grid.forceApiReload(); | |
} | |
/** | |
* | |
*/ | |
public setSearchBar(): void { | |
this.selectedStatus = EnumApplicationStatus.All; | |
this.statusItems = []; | |
this.statusItems.push({ value: EnumApplicationStatus.All, text: EnumApplicationStatus.toDisplayShortName(EnumApplicationStatus.All) }); | |
const items = EnumApplicationStatus.toTextValues((num => num !== EnumApplicationStatus.All)); | |
this.statusItems.push(...items); | |
}; | |
/** | |
* 그리드 기본정보를 세팅한다 | |
*/ | |
public setGridBase(): void { | |
this.grid.name = "Service"; | |
this.grid.pageSize = 20; | |
this.grid.skip = 0; | |
this.grid.gridView.data = []; | |
this.grid.gridView.total = 0; | |
this.grid.baseApi = `${this.DEVICES_API_URL}/c0d80b2b-50a8-4153-b304-bc422860051f/b2152e98-3ee3-41fe-9016-f7d5dbe3112c/Objects/Services`; | |
}; | |
///** 서비스 오브젝트 객체를 가져온다 */ | |
//private getServiceObject(): void { | |
// this.inCommunication = true; | |
// this.isLoading = true; | |
// let request = `${this.DEVICES_API_URL}/c0d80b2b-50a8-4153-b304-bc422860051f/b2152e98-3ee3-41fe-9016-f7d5dbe3112c/Objects/Services`; | |
// this.httpService.get<ResponseList<any>>(request).subscribe(response => { | |
// this.isLoading = false; | |
// this.inCommunication = false; | |
// console.log(response); | |
// this.grid.items = response.Data["Items"].slice(); | |
// this.grid.forceApiReload(); | |
// }, | |
// (err: HttpErrorResponse) => { | |
// console.log(err); | |
// this.inCommunication = false; | |
// this.alertService.showMessage(err.statusText, err.message, MessageSeverity.error); | |
// }) | |
//} | |
/** | |
* 그리드컬럼을 셋팅 한다 | |
*/ | |
public setGridColums(): void { | |
this.grid.isUseCheckboxSelect = true; | |
this.grid.selectableSettings = { | |
mode: "single", | |
} | |
this.grid.columns = [ | |
{ title: "UL_MANAGEMENT_OBJECT_SERVICE_NAME", field: "Name", width: "200", format: "", pipe: "", pipeEnumTranslateClass: "" }, | |
{ title: "UL_CONFIGS_COMMON_PROTOCOL", field: "Protocol", width: "200", format: "", pipe: "getEnumTranslate", pipeEnumTranslateClass: EnumProtocolType }, | |
{ title: "UL_MANAGEMENT_OBJECT_START_PORT", field: "DestinationPorts", width: "200", format: "", pipe: "toCommaWithValue", pipeEnumTranslateClass: "Name" }, | |
{ title: "UL_MANAGEMENT_OBJECT_DESTINATION_PORT", field: "SourcePorts", width: "200", format: "", pipe: "toCommaWithValue", pipeEnumTranslateClass: "Name" }, | |
{ title: "UL_MANAGEMENT_OBJECT_TAG", field: "Tags", width: "", format: "", pipe: "", pipeEnumTranslateClass: "" }, | |
{ title: "UL_COMMON__EXPLANATION", field: "Description", width: "", format: "", pipe: "", pipeEnumTranslateClass: "" }, | |
]; | |
} | |
/** 윈도우 종료 */ | |
public windowCloseEvent(): void { | |
if (this.registConst != null) { | |
this.registConst.close(); | |
this.registConst = null; | |
} | |
if (this.modifyConst != null) { | |
this.modifyConst.close(); | |
this.modifyConst = null; | |
} | |
if (this.deleteConst != null) { | |
this.deleteConst.close(); | |
this.deleteConst = null; | |
} | |
}; | |
/** 서비스 등록 윈도우 오픈 */ | |
public registWindowOpen() { | |
this.windowCloseEvent(); | |
this.registConst = this.windowService.open({ | |
appendTo: this.registContainer, | |
title: this.titleRegist, | |
content: PopupObjectServiceRegistComponent, | |
width: 800, | |
}); | |
this.registConst.result.subscribe((response) => { | |
let result = !(response instanceof WindowCloseResult); | |
if (result) { | |
this.grid.forceApiReload(); | |
} | |
}); | |
} | |
// 서비스 수정 윈도우 오픈 | |
public modifyWindowOpen() { | |
this.modifyConst = this.windowService.open({ | |
appendTo: this.modifyContainer, | |
title: this.titleModify, | |
content: PopupObjectServiceModifyComponent, | |
width: 800, | |
}); | |
} | |
// 서비스 수정 윈도우 오픈 | |
public deleteDialogOpen() { | |
this.deleteConst = this.dialogService.open({ | |
appendTo: this.deleteContainer, | |
title: this.titleDelete, | |
content: PopupConfirmDeleteComponent, | |
width: 400, | |
}); | |
} | |
/** | |
* 새로고침 | |
*/ | |
refresh() { | |
this.grid.rowsSelectedKeys.length = 0; | |
this.grid.selectedItems = []; | |
this.grid.forceApiReload(); | |
}; | |
/** | |
* 검색 | |
* @param param | |
*/ | |
search(param: CommonSearch): void { | |
this.grid.rowsSelectedKeys.length = 0; | |
this.grid.selectedItems = []; | |
this.grid.commonSearchOptions = param; | |
this.grid.forceApiReload(); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment