diff --git a/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformFormAddLabels.vue b/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformAddLabels.vue similarity index 58% rename from apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformFormAddLabels.vue rename to apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformAddLabels.vue index 44276d226b..fafe2b8b8b 100644 --- a/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformFormAddLabels.vue +++ b/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformAddLabels.vue @@ -1,5 +1,7 @@ - + - { inline /> - @@ -99,7 +132,7 @@ const handleRemoveLabel = (idx: number) => { /> @@ -118,11 +151,11 @@ const handleRemoveLabel = (idx: number) => { - + diff --git a/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformJoin.vue b/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformJoin.vue new file mode 100644 index 0000000000..db9aba07f8 --- /dev/null +++ b/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformJoin.vue @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + diff --git a/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformQuery.vue b/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformQuery.vue new file mode 100644 index 0000000000..fcc8bb94fa --- /dev/null +++ b/apps/web/src/common/modules/widgets/_components/WidgetFormDataTableCardTransformQuery.vue @@ -0,0 +1,171 @@ + + + + + + + + + {{ $t('COMMON.WIDGETS.DATA_TABLE.FORM.CONDITION') }} + + + + + + + + + + + + + + + + + + + + {{ $t('COMMON.WIDGETS.DATA_TABLE.FORM.ADD_CONDITION') }} + + + Pandas Query + + + + + + + + diff --git a/apps/web/src/common/modules/widgets/_constants/data-table-constant.ts b/apps/web/src/common/modules/widgets/_constants/data-table-constant.ts index e05c06c98c..97d026e0d3 100644 --- a/apps/web/src/common/modules/widgets/_constants/data-table-constant.ts +++ b/apps/web/src/common/modules/widgets/_constants/data-table-constant.ts @@ -1,5 +1,7 @@ - -import type { PivotOptions } from '@/common/modules/widgets/types/widget-model'; +import type { + AddLabelsOptions, + ConcatOptions, EvalOptions, JoinOptions, PivotOptions, QueryOptions, +} from '@/common/modules/widgets/types/widget-model'; import { GROUP_BY } from '@/services/cost-explorer/constants/cost-explorer-constant'; @@ -87,4 +89,30 @@ export const DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP = { desc: false, }, } as PivotOptions, + CONCAT: { + data_tables: [], + } as ConcatOptions, + JOIN: { + data_tables: [], + how: undefined, + } as JoinOptions, + EVAL: { + data_table_id: undefined, + expressions: [ + { + name: '', + field_type: DATA_TABLE_FIELD_TYPE.DATA, + expression: '', + }, + ], + } as EvalOptions, + QUERY: { + data_table_id: undefined, + conditions: [''], + // operator: 'AND', + } as QueryOptions, + ADD_LABELS: { + data_table_id: undefined, + labels: { '': '' }, + } as AddLabelsOptions, }; diff --git a/apps/web/src/common/modules/widgets/_store/widget-generate-store.ts b/apps/web/src/common/modules/widgets/_store/widget-generate-store.ts index bb130d5db0..b6f7d498ad 100644 --- a/apps/web/src/common/modules/widgets/_store/widget-generate-store.ts +++ b/apps/web/src/common/modules/widgets/_store/widget-generate-store.ts @@ -1,5 +1,6 @@ import { computed, reactive } from 'vue'; +import { cloneDeep } from 'lodash'; import { defineStore } from 'pinia'; import { SpaceConnector } from '@cloudforet/core-lib/space-connector'; @@ -24,7 +25,10 @@ import { showErrorMessage } from '@/lib/helper/notice-alert-helper'; import getRandomId from '@/lib/random-id-generator'; import ErrorHandler from '@/common/composables/error/errorHandler'; -import { DATA_TABLE_TYPE } from '@/common/modules/widgets/_constants/data-table-constant'; +import { + DATA_TABLE_TYPE, + DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP, +} from '@/common/modules/widgets/_constants/data-table-constant'; import { getWidgetConfig } from '@/common/modules/widgets/_helpers/widget-config-helper'; import { getDuplicatedDataTableName } from '@/common/modules/widgets/_helpers/widget-data-table-helper'; import { sanitizeWidgetOptions } from '@/common/modules/widgets/_helpers/widget-helper'; @@ -211,26 +215,13 @@ export const useWidgetGenerateStore = defineStore('widget-generate', () => { }, createUnsavedTransformDataTable: (operatorType: DataTableOperator) => { const options = { - JOIN: { - data_tables: [], - how: undefined, - }, - CONCAT: { - data_tables: [], - }, - AGGREGATE: { - data_table_id: undefined, - group_by: [], - }, - QUERY: { - data_table_id: undefined, - conditions: [], - }, - EVAL: { - data_table_id: undefined, - formulas: [], - }, - // TODO: PIVOT, ADD_LABELS, VALUE_MAPPING + JOIN: cloneDeep(DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP.JOIN), + CONCAT: cloneDeep(DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP.CONCAT), + QUERY: cloneDeep(DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP.QUERY), + EVAL: cloneDeep(DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP.EVAL), + PIVOT: cloneDeep(DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP.PIVOT), + ADD_LABELS: cloneDeep(DEFAULT_TRANSFORM_DATA_TABLE_VALUE_MAP.ADD_LABELS), + // TODO: VALUE_MAPPING }; const unsavedTransformData = { data_table_id: `UNSAVED-${getRandomId()}`, diff --git a/apps/web/src/common/modules/widgets/types/widget-model.ts b/apps/web/src/common/modules/widgets/types/widget-model.ts index 9dd1858180..081da256b9 100644 --- a/apps/web/src/common/modules/widgets/types/widget-model.ts +++ b/apps/web/src/common/modules/widgets/types/widget-model.ts @@ -63,12 +63,13 @@ export interface ConcatOptions { export interface JoinOptions { data_tables: string[]; - how: JoinType; + how?: JoinType; } export interface QueryOptions { - data_table_id: string; + data_table_id?: string; conditions: string[]; + // operator: 'AND'|'OR'; } export interface AggregateOptions { @@ -77,7 +78,7 @@ export interface AggregateOptions { } export interface EvalOptions { - data_table_id: string; + data_table_id?: string; expressions: EvaluateExpression[]; } @@ -85,6 +86,7 @@ export interface EvaluateExpression { name: string; field_type: DataTableFieldType; expression: string; + condition?: string; } export interface PivotOptions { @@ -106,7 +108,7 @@ export interface PivotFieldOptions { } export interface AddLabelsOptions { - data_table_id: string; + data_table_id?: string; labels: AdditionalLabels; } diff --git a/packages/language-pack/console-translation-2.8.babel b/packages/language-pack/console-translation-2.8.babel index 757cb1b60e..918dd5872d 100644 --- a/packages/language-pack/console-translation-2.8.babel +++ b/packages/language-pack/console-translation-2.8.babel @@ -22817,6 +22817,27 @@ + + PIVOT_DESC + false + + + + + + en-US + false + + + ja-JP + false + + + ko-KR + false + + + QUERY_DESC false diff --git a/packages/language-pack/en.json b/packages/language-pack/en.json index e913340c25..6438e8852f 100644 --- a/packages/language-pack/en.json +++ b/packages/language-pack/en.json @@ -1282,6 +1282,7 @@ "JOIN_DESC": "Merge rows from different tables based on a common column. ", "LEGACY_WARNING_DESC": "This ‘{operator}’ format is no longer supported. Please remove it and implement the new data transformation.", "LEGACY_WARNING_TITLE": "Unsupported ‘{operator}’ Format", + "PIVOT_DESC": "Summarize data by reorganizing key dimensions.", "QUERY_DESC": "Filter and extract data that meet specific conditions. ", "SELECT_DATA_SOURCE_SUCCESS": "Data successfully changed.", "SELECT_DATA_TABLE_WARNING": "Please save the data table first.", diff --git a/packages/language-pack/ja.json b/packages/language-pack/ja.json index bfb4b96d06..9ded0d4df4 100644 --- a/packages/language-pack/ja.json +++ b/packages/language-pack/ja.json @@ -1282,6 +1282,7 @@ "JOIN_DESC": "共通の列に基づいて、異なるテーブルの行を結合します。", "LEGACY_WARNING_DESC": "この「{operator}」形式はサポートされなくなりました。削除して、新しいデータ変換を実装してください。", "LEGACY_WARNING_TITLE": "サポートされていない「{operator}」形式", + "PIVOT_DESC": "", "QUERY_DESC": "特定の条件を満たすデータをフィルタリングして抽出します。", "SELECT_DATA_SOURCE_SUCCESS": "データが正常に変更されました。", "SELECT_DATA_TABLE_WARNING": "先にデータテーブルを保存してください。", diff --git a/packages/language-pack/ko.json b/packages/language-pack/ko.json index 24e0e31e5f..7119c6f58f 100644 --- a/packages/language-pack/ko.json +++ b/packages/language-pack/ko.json @@ -1282,6 +1282,7 @@ "JOIN_DESC": "공통 열을 기준으로 다른 테이블의 행을 병합합니다.", "LEGACY_WARNING_DESC": "이 ‘{operator}’ 형식은 더 이상 지원되지 않습니다. 이 형식을 삭제하고 새로운 데이터 변환을 추가해 주세요.", "LEGACY_WARNING_TITLE": "지원되지 않는 ‘{operator}’ 형식", + "PIVOT_DESC": "", "QUERY_DESC": "특정 조건을 충족하는 데이터를 필터링하고 추출합니다.", "SELECT_DATA_SOURCE_SUCCESS": "데이터 수정 완료", "SELECT_DATA_TABLE_WARNING": "데이터 테이블을 먼저 저장하세요.",