Skip to content

Commit

Permalink
#684 fix enhanced search datasource (#1025)
Browse files Browse the repository at this point in the history
* #684 fix criterion filter list position, change message bundle

* #684 response raw Enum value

* #684 add filter name translate logic

* #684 add filter name translate logic in criterion box component

* #684 handle current time

* #684 remove Status(BAD), SourceType(NONE)
  • Loading branch information
brandon-wonjune authored and alchan-lee committed Dec 7, 2018
1 parent 2a03b05 commit 15c911e
Show file tree
Hide file tree
Showing 15 changed files with 307 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<label class="ddp-label-checkbox">
<input type="checkbox" [checked]="isCheckedItem(item)">
<i class="ddp-icon-checkbox"></i>
<span class="ddp-txt-checkbox">{{isRequireTranslate(item.filterName) ? (item.filterName | translate) : item.filterName}}</span>
<span class="ddp-txt-checkbox">{{getTranslateFilterName(item)}}</span>
</label>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { Component, ElementRef, EventEmitter, Injector, Input, Output } from '@a
import { StringUtil } from '../../../common/util/string.util';
import * as _ from 'lodash';
import { CriterionKey, ListCriterion } from '../../../domain/datasource/listCriterion';
import { ListFilter } from '../../../domain/datasource/listFilter';
import { ConnectionType, DataSourceType, SourceType, Status } from '../../../domain/datasource/datasource';

@Component({
selector: 'criterion-checkbox-component',
Expand Down Expand Up @@ -101,6 +103,26 @@ export class CriterionCheckboxComponent extends AbstractComponent {
return -1 !== label.indexOf('msg.');
}

/**
* Get translated filter name
* @param {ListFilter} filter
* @returns {string}
*/
public getTranslateFilterName(filter: ListFilter): string {
switch (filter.criterionKey) {
case CriterionKey.STATUS:
return this._getDatasourceStatusTranslate(filter.filterName);
case CriterionKey.DATASOURCE_TYPE:
return this._getDataSourceTypeTranslate(filter.filterName);
case CriterionKey.SOURCE_TYPE:
return this._getSourceTypeTranslate(filter.filterName);
case CriterionKey.CONNECTION_TYPE:
return this._getConnectionTypeTranslate(filter.filterName);
default:
return this.isRequireTranslate(filter.filterName) ? this.translateService.instant(filter.filterName): filter.filterName;
}
}

/**
* Item check event
* @param item
Expand Down Expand Up @@ -160,4 +182,90 @@ export class CriterionCheckboxComponent extends AbstractComponent {
list.filters = list.filters.filter(item => -1 !== (this.isRequireTranslate(item.filterName) ? this.translateService.instant(item.filterName) : item.filterName).toUpperCase().indexOf(this.searchKeyword.trim().toUpperCase()));
});
}

/**
* Get datasource type translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getDataSourceTypeTranslate(filterName: string): string {
switch (filterName) {
case DataSourceType.JOIN.toString():
return this.translateService.instant('msg.storage.ui.source.type.join');
case DataSourceType.MASTER.toString():
return this.translateService.instant('msg.storage.ui.source.type.master');
case DataSourceType.VOLATILITY.toString():
return this.translateService.instant('msg.storage.ui.source.type.volatility');
default:
return this.isRequireTranslate(filterName) ? this.translateService.instant(filterName): filterName;
}
}

/**
* Get connection type translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getConnectionTypeTranslate(filterName: string): string {
switch (filterName) {
case ConnectionType.ENGINE.toString():
return this.translateService.instant('msg.storage.ui.list.ingested.data');
case ConnectionType.LINK.toString():
return this.translateService.instant('msg.storage.ui.list.linked.data');
default:
return this.isRequireTranslate(filterName) ? this.translateService.instant(filterName): filterName;
}
}

/**
* Get datasource status translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getDatasourceStatusTranslate(filterName: string): string {
switch (filterName) {
case Status.ENABLED.toString():
return 'Enabled';
case Status.PREPARING.toString():
return 'Preparing';
case Status.DISABLED.toString():
return 'Disabled';
case Status.FAILED.toString():
return 'Failed';
case Status.BAD.toString():
return 'Bad';
default:
return 'Disabled';
}
}

/**
* Get source type translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getSourceTypeTranslate(filterName: string): string {
switch (filterName) {
case SourceType.IMPORT.toString():
return this.translateService.instant('msg.storage.li.druid');
case SourceType.FILE.toString():
return this.translateService.instant('msg.storage.li.file');
case SourceType.JDBC.toString():
return this.translateService.instant('msg.storage.li.db');
case SourceType.HIVE.toString():
return this.translateService.instant('msg.storage.li.hive');
case SourceType.REALTIME.toString():
return this.translateService.instant('msg.storage.li.stream');
case SourceType.SNAPSHOT.toString():
return this.translateService.instant('msg.storage.li.ss');
case SourceType.HDFS.toString():
return filterName;
default:
return this.isRequireTranslate(filterName) ? this.translateService.instant(filterName): filterName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,27 @@
<div [class.ddp-filter-more]="criterionKey.toString() === 'MORE'"
[class.ddp-form-filtering]="criterionKey.toString() !== 'MORE'">
<a href="javascript:" class="ddp-btn-filter-more" *ngIf="criterionKey.toString() === 'MORE'" (click)="isShowList = !isShowList"></a>
<div class="ddp-result-filtering" (click)="onClickShowList($event)">
<div class="ddp-result-filtering" [class.ddp-selected]="isShowList" (click)="onClickShowList($event)">
<span class="ddp-txt-label" *ngIf="isEnableFilterTitle()">{{filterTitle}}:</span>
<div class="ddp-ui-result">
<!-- 클릭시 ddp-selected 추가-->
<div class="ddp-box-result" [class.ddp-selected]="isShowList">
<span class="ddp-txt-result" *ngIf="criterionKey.toString() !== 'MORE'"
title="{{selectedItemsLabel}}">{{selectedItemsLabel}}</span>
<!-- popup -->
<criterion-checkbox-component *ngIf="criterionData && criterionType.toString() === 'CHECKBOX'"
[criterion]="criterionData"
[defaultSelectedItemList]="defaultSelectedItemList"
[searchPlaceHolder]="searchPlaceHolder"
[enableAllOption]="isEnableAllOption"
(changedSelectItem)="onChangedSelectItem($event)">
</criterion-checkbox-component>
<criterion-time-radio-component *ngIf="criterionData && criterionType.toString().indexOf('DATETIME') !== -1"
[criterion]="criterionData"
[enableFromToOption]="criterionType.toString() === 'RANGE_DATETIME'"
[enableAllOption]="true"
(changedSelectItem)="onChangedSelectItem($event)">
</criterion-time-radio-component>
<!-- //popup -->
</div>
<a href="javascript:" class="ddp-btn-del" *ngIf="isEnableRemoveButton" (click)="onClickRemoveCriterionFilter()"></a>
<div class="ddp-box-result">
<span class="ddp-txt-result" *ngIf="criterionKey.toString() !== 'MORE'" title="{{selectedItemsLabel}}">{{selectedItemsLabel}}</span>
</div>
<!-- popup -->
<criterion-checkbox-component *ngIf="criterionData && criterionType.toString() === 'CHECKBOX'"
[criterion]="criterionData"
[defaultSelectedItemList]="defaultSelectedItemList"
[searchPlaceHolder]="searchPlaceHolder"
[enableAllOption]="isEnableAllOption"
(changedSelectItem)="onChangedSelectItem($event)">
</criterion-checkbox-component>
<criterion-time-radio-component *ngIf="criterionData && criterionType.toString().indexOf('DATETIME') !== -1"
[criterion]="criterionData"
[enableFromToOption]="criterionType.toString() === 'RANGE_DATETIME'"
[enableAllOption]="true"
(changedSelectItem)="onChangedSelectItem($event)">
</criterion-time-radio-component>
<!-- //popup -->
<a href="javascript:" class="ddp-btn-del" *ngIf="isEnableRemoveButton" (click)="onClickRemoveCriterionFilter()"></a>
</div>
</div>

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { AbstractComponent } from '../../../common/component/abstract.component'
import { StringUtil } from '../../../common/util/string.util';
import { CriterionKey, CriterionType, ListCriterion } from '../../../domain/datasource/listCriterion';
import { ListFilter } from '../../../domain/datasource/listFilter';
import { ConnectionType, DataSourceType, SourceType, Status } from '../../../domain/datasource/datasource';

@Component({
selector: 'criterion-filter-box',
Expand Down Expand Up @@ -240,9 +241,9 @@ export class CriterionFilterBoxComponent extends AbstractComponent {
Object.keys(selectedItemList).forEach(key =>
selectedItemList[key].forEach((item) => {
if (StringUtil.isEmpty(temp)) {
temp += this._isRequireTranslate(item.filterName) ? this.translateService.instant(item.filterName) : item.filterName;
temp += this._getTranslateFilterName(item);
} else {
temp += `, ${this._isRequireTranslate(item.filterName) ? this.translateService.instant(item.filterName) : item.filterName}`;
temp += `, ${this._getTranslateFilterName(item)}`;
}
}));
}
Expand Down Expand Up @@ -317,4 +318,111 @@ export class CriterionFilterBoxComponent extends AbstractComponent {
// if start with msg.*, translate label
return -1 !== label.indexOf('msg.');
}

/**
* Get translated filter name
* @param {ListFilter} filter
* @returns {string}
* @private
*/
private _getTranslateFilterName(filter: ListFilter): string {
switch (filter.criterionKey) {
case CriterionKey.STATUS:
return this._getDatasourceStatusTranslate(filter.filterName);
case CriterionKey.DATASOURCE_TYPE:
return this._getDataSourceTypeTranslate(filter.filterName);
case CriterionKey.SOURCE_TYPE:
return this._getSourceTypeTranslate(filter.filterName);
case CriterionKey.CONNECTION_TYPE:
return this._getConnectionTypeTranslate(filter.filterName);
default:
return this._isRequireTranslate(filter.filterName) ? this.translateService.instant(filter.filterName): filter.filterName;
}
}

/**
* Get datasource type translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getDataSourceTypeTranslate(filterName: string): string {
switch (filterName) {
case DataSourceType.JOIN.toString():
return this.translateService.instant('msg.storage.ui.source.type.join');
case DataSourceType.MASTER.toString():
return this.translateService.instant('msg.storage.ui.source.type.master');
case DataSourceType.VOLATILITY.toString():
return this.translateService.instant('msg.storage.ui.source.type.volatility');
default:
return this._isRequireTranslate(filterName) ? this.translateService.instant(filterName): filterName;
}
}

/**
* Get connection type translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getConnectionTypeTranslate(filterName: string): string {
switch (filterName) {
case ConnectionType.ENGINE.toString():
return this.translateService.instant('msg.storage.ui.list.ingested.data');
case ConnectionType.LINK.toString():
return this.translateService.instant('msg.storage.ui.list.linked.data');
default:
return this._isRequireTranslate(filterName) ? this.translateService.instant(filterName): filterName;
}
}

/**
* Get datasource status translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getDatasourceStatusTranslate(filterName: string): string {
switch (filterName) {
case Status.ENABLED.toString():
return 'Enabled';
case Status.PREPARING.toString():
return 'Preparing';
case Status.DISABLED.toString():
return 'Disabled';
case Status.FAILED.toString():
return 'Failed';
case Status.BAD.toString():
return 'Bad';
default:
return 'Disabled';
}
}

/**
* Get source type translated label
* @param {string} filterName
* @returns {string}
* @private
*/
private _getSourceTypeTranslate(filterName: string): string {
switch (filterName) {
case SourceType.IMPORT.toString():
return this.translateService.instant('msg.storage.li.druid');
case SourceType.FILE.toString():
return this.translateService.instant('msg.storage.li.file');
case SourceType.JDBC.toString():
return this.translateService.instant('msg.storage.li.db');
case SourceType.HIVE.toString():
return this.translateService.instant('msg.storage.li.hive');
case SourceType.REALTIME.toString():
return this.translateService.instant('msg.storage.li.stream');
case SourceType.SNAPSHOT.toString():
return this.translateService.instant('msg.storage.li.ss');
case SourceType.HDFS.toString():
return filterName;
default:
return this._isRequireTranslate(filterName) ? this.translateService.instant(filterName): filterName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,21 +199,6 @@
<div class="ddp-ui-option-sub" *ngIf="createType === 'STAGING' && partitionKeyList.length !== 0">
<label class="ddp-ui-label-name">
{{'msg.storage.ui.dsource.create.partition.keys' | translate}}
</label>
<div class="ddp-ui-edit-option">
<!-- not strict mode, show partition radio button -->
<ng-container *ngIf="!isStrictMode">
<label class="ddp-label-radio" (change)="onChangePartitionType(partitionTypeList[0])">
<input type="radio" [checked]="selectedPartitionType.value === partitionTypeList[0].value">
<i class="ddp-icon-radio"></i>
<span class="ddp-txt-radio">{{partitionTypeList[0].label}}</span>
</label>
<label class="ddp-label-radio ddp-mgr0" (change)="onChangePartitionType(partitionTypeList[1])">
<input type="radio" [checked]="selectedPartitionType.value === partitionTypeList[1].value">
<i class="ddp-icon-radio"></i>
<span class="ddp-txt-radio">{{partitionTypeList[1].label}}</span>
</label>
</ng-container>
<!-- info -->
<div class="ddp-wrap-hover-info ddp-type">
<em class="ddp-icon-info3"></em>
Expand Down Expand Up @@ -359,6 +344,21 @@
</div>
</div>
<!-- //info -->
</label>
<div class="ddp-ui-edit-option">
<!-- not strict mode, show partition radio button -->
<ng-container *ngIf="!isStrictMode">
<label class="ddp-label-radio" (change)="onChangePartitionType(partitionTypeList[0])">
<input type="radio" [checked]="selectedPartitionType.value === partitionTypeList[0].value">
<i class="ddp-icon-radio"></i>
<span class="ddp-txt-radio">{{partitionTypeList[0].label}}</span>
</label>
<label class="ddp-label-radio ddp-mgr0" (change)="onChangePartitionType(partitionTypeList[1])">
<input type="radio" [checked]="selectedPartitionType.value === partitionTypeList[1].value">
<i class="ddp-icon-radio"></i>
<span class="ddp-txt-radio">{{partitionTypeList[1].label}}</span>
</label>
</ng-container>
<!-- partition -->
<div class="ddp-wrap-partition" *ngIf="partitionKeyList.length !== 0 && selectedPartitionType.value === 'ENABLE'">
<div class="ddp-ui-partition">
Expand Down
3 changes: 2 additions & 1 deletion discovery-frontend/src/app/domain/datasource/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ export enum IngestionStatus {

export enum DataSourceType {
MASTER = <any>'MASTER',
JOIN = <any>'JOIN'
JOIN = <any>'JOIN',
VOLATILITY = <any>'VOLATILITY'
}

export enum ConnectionType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
.ddp-wrap-top-filtering .ddp-form-filtering .ddp-result-filtering .ddp-box-result .ddp-txt-result {display:block;white-space:nowrap; text-overflow:ellipsis; overflow:Hidden;}
.ddp-wrap-top-filtering .ddp-form-filtering .ddp-result-filtering .ddp-box-result:before {display:inline-block; position:absolute; top:50%; right:0; width:8px; height:4px; margin-top:-2px; background:url(../../../images/icon_select.png) no-repeat; background-position:-16px top; content:'';}
.ddp-wrap-top-filtering .ddp-form-filtering .ddp-wrap-popup2 {display:none; position:absolute; top:24px; left:0; min-width:180px; max-width:250px; max-height:250px; overflow:auto;}
.ddp-wrap-top-filtering .ddp-form-filtering .ddp-box-result.ddp-selected .ddp-wrap-popup2 {display:block;}
.ddp-wrap-top-filtering .ddp-result-filtering.ddp-selected .ddp-wrap-popup2 {display:block; top:31px;}
.ddp-wrap-top-filtering .ddp-form-filtering .ddp-result-filtering.ddp-selected .ddp-wrap-popup2 {display:block; left:20px;}

.ddp-wrap-top-filtering .ddp-form-filtering .ddp-wrap-popup2.ddp-date .ddp-ui-dateinfo .ddp-box-dateinfo input.ddp-input-calen {width:74px; padding-right:2px;}
.ddp-wrap-top-filtering .ddp-form-filtering .ddp-wrap-popup2.ddp-date .ddp-ui-dateinfo .ddp-box-dateinfo input.ddp-input-time {width:36px; padding-left:2px; padding-right:2px;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
.ddp-wrap-edit2 .ddp-wrap-hover-info .ddp-box-layout4.ddp-config,
.ddp-wrap-edit3 .ddp-wrap-hover-info .ddp-box-layout4.ddp-config{margin:0; padding:0; height:auto;}
.ddp-wrap-edit2 .ddp-ui-option-sub .ddp-ui-label-name {display:block; padding-bottom:10px; color:#4c515a; font-size:13px;}
.ddp-wrap-edit2 .ddp-ui-option-sub .ddp-ui-label-name .ddp-wrap-hover-info {position:relative; top:2px; vertical-align:middle;}

.ddp-wrap-edit2 .ddp-ui-option-sub .ddp-radio-set {float:left;}
.ddp-wrap-edit2 .ddp-ui-option-sub .ddp-radio-hidden {overflow:hidden;}
Expand Down
Loading

0 comments on commit 15c911e

Please sign in to comment.