diff --git a/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx b/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx index 8636927cf..f958cae77 100644 --- a/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx +++ b/src/Explorer/Tabs/QueryTablesTab/QueryTableEntityClause.tsx @@ -21,8 +21,8 @@ export interface IQueryTableEntityClauseProps { entityValuePlaceHolder?: string; selectedOperator: string; selectedOperation: string; - opertorOptions: IOption[]; - opertationOptions: IOption[]; + operatorOptions: IOption[]; + operationOptions: IOption[]; isQueryTableEntityChecked: boolean; selectedField: string; fieldOptions: IOption[]; @@ -42,14 +42,14 @@ export const QueryTableEntityClause: FunctionComponent, selectedOption: IDropdownOption) => onDropdownChange(selectedOption, "selectedOperation") } - options={opertationOptions} + options={operationOptions} id="operatorOptionId" styles={dropdownStyles} /> @@ -120,7 +120,7 @@ export const QueryTableEntityClause: FunctionComponent, selectedOption: IDropdownOption) => onDropdownChange(selectedOption, "selectedOperator") } - options={opertorOptions} + options={operatorOptions} id="operatorOptionId" styles={dropdownStyles} /> diff --git a/src/Explorer/Tabs/QueryTablesTab/QueryTableTabUtils.tsx b/src/Explorer/Tabs/QueryTablesTab/QueryTableTabUtils.tsx index acbb6e42b..af59909f7 100644 --- a/src/Explorer/Tabs/QueryTablesTab/QueryTableTabUtils.tsx +++ b/src/Explorer/Tabs/QueryTablesTab/QueryTableTabUtils.tsx @@ -70,50 +70,15 @@ export interface IQueryTableRowsType { selectedOperation: string; selectedTimestamp: string; fieldOptions: IOption[]; - opertorOptions: IOption[]; + operatorOptions: IOption[]; entityTypeOptions: IOption[]; - opertionOptions: IOption[]; + operationOptions: IOption[]; timestampOptions: IOption[]; id: string; } -export const opertionOptions = [ - { key: "And", text: "And" }, - { key: "Or", text: "Or" }, -]; -export const opertorOptions = [ - { key: "=", text: "=" }, - { key: ">", text: ">" }, - { key: ">=", text: ">=" }, - { key: "<", text: "<" }, - { key: "<=", text: "<=" }, - { key: "<>", text: "<>" }, -]; - -export const fieldOptions = [ - { key: "PartitionKey", text: "PartitionKey" }, - { key: "RowKey", text: "RowKey" }, - { key: "Timestamp", text: "Timestamp" }, - { key: "t3PN", text: "t3PN" }, -]; - -export const entityTypeOptions = [ - { key: "String", text: "String" }, - { key: "Boolean", text: "Boolean" }, - { key: "Binary", text: "Binary" }, - { key: "DateTime", text: "DateTime" }, - { key: "Double", text: "Double" }, - { key: "Guid", text: "Guid" }, - { key: "Int32", text: "Int32" }, - { key: "Int64", text: "Int64" }, -]; - -export const timestampOptions = [ - { key: "Last hour", text: "Last hour" }, - { key: "Last 24 hours", text: "Last 24 hours" }, - { key: "Last 7 days", text: "Last 7 days" }, - { key: "Last 31 days", text: "Last 31 days" }, - { key: "Last 365 days", text: "Last 365 days" }, - { key: "Current month", text: "Current month" }, - { key: "Current year", text: "Current year" }, -]; +export const getformattedOptions = (options: Array): IOption[] => { + return options.map((option) => { + return { key: option, text: option }; + }); +}; diff --git a/src/Explorer/Tabs/QueryTablesTab/QueryTablesTabComponent.tsx b/src/Explorer/Tabs/QueryTablesTab/QueryTablesTabComponent.tsx index c8ad050d5..97a6a707c 100644 --- a/src/Explorer/Tabs/QueryTablesTab/QueryTablesTabComponent.tsx +++ b/src/Explorer/Tabs/QueryTablesTab/QueryTablesTabComponent.tsx @@ -39,21 +39,18 @@ import { CassandraAPIDataClient, TableDataClient } from "../../Tables/TableDataC // import NewQueryTablesTab from "./QueryTablesTab"; import { QueryTableEntityClause } from "./QueryTableEntityClause"; import { - entityTypeOptions, - fieldOptions, + getformattedOptions, IDocument, IQueryTableRowsType, IQueryTablesTabComponentProps, IQueryTablesTabComponentStates, - opertionOptions, - opertorOptions, - timestampOptions, } from "./QueryTableTabUtils"; export interface Button { visible: boolean; enabled: boolean; isSelected?: boolean; } + // export interface IDocument { // partitionKey: string; // rowKey: string; @@ -164,9 +161,28 @@ class QueryTablesTabComponent extends Component { + // if (this.tableEntityListViewModel2().items().length > 0 && userContext.apiType === "Tables") { + // // this.queryViewModel().queryBuilderViewModel().setExample(); + // console.log( + // "🚀 ~ file: QueryTablesTab.tsx ~ line 55 ~ QueryTablesTab ~ sampleQuerySubscription ~ this.queryViewModel().queryBuilderViewModel().setExample()" + // // this.queryViewModel().queryBuilderViewModel().setExample() + // ); + // } + // sampleQuerySubscription.dispose(); + // }); + + const tableEntityListViewModel = new TableEntityListViewModel(this.tableCommands, props.queryTablesTab); + // this._queryViewModel = new QueryViewModel(this.props.queryTablesTab); + const queryBuilderViewModel = new QueryViewModel(this.props.queryTablesTab).queryBuilderViewModel(); + + const entityTypeOptions = queryBuilderViewModel.edmTypes(); + const timestampOptions = queryBuilderViewModel.timeOptions(); + const operatorsOptions = queryBuilderViewModel.operators(); + const operationOptions = queryBuilderViewModel.clauseRules(); + this.state = { - tableEntityListViewModel: new TableEntityListViewModel(this.tableCommands, props.queryTablesTab), + tableEntityListViewModel, queryViewModel: new QueryViewModel(this.props.queryTablesTab), queryText: "PartitionKey eq 'partionKey1'", selectedQueryText: "", @@ -216,21 +232,22 @@ class QueryTablesTabComponent extends Component { // console.log("items > ", this.state.tableEntityListViewModel.cache.data); // console.log("items > ", this.state.tableEntityListViewModel.items()); // console.log("items1 > ", this.state.tableEntityListViewModel.headers); this.columns = []; - this.state.tableEntityListViewModel.headers.map((header) => { + tableEntityListViewModel.headers.map((header) => { this.columns.push({ key: header, name: header, @@ -302,11 +320,16 @@ class QueryTablesTabComponent extends Component { // console.log( // "🚀 ~ file: QueryTablesTabComponent.tsx ~ line 248 ~ QueryTablesTabComponent ~ setTimeout ~ columns", @@ -320,17 +343,17 @@ class QueryTablesTabComponent extends Component { @@ -639,12 +661,15 @@ class QueryTablesTabComponent extends Component this.onDeleteClause(index)}