Skip to content

Commit

Permalink
update table structure
Browse files Browse the repository at this point in the history
  • Loading branch information
BryonLewis committed Feb 13, 2025
1 parent 5b87c69 commit e1e873f
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 193 deletions.
7 changes: 2 additions & 5 deletions client/src/components/FeatureSelection/VectorFeatureChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ export default defineComponent({
let dataForGraph: { data: [number, number][], filterVal?: string } | undefined;
// Check for default data or apply filter if necessary
if (data.graphs.default) {
dataForGraph = data.graphs.default; // Use default data if no filter
} else if (props.graphInfo.filterValue && props.graphInfo.filterColumn) {
const filteredData = data.graphs as ParameterGraph;
dataForGraph = filteredData[props.graphInfo.filterValue]; // Apply filter by value
if (data.graphs[props.vectorFeatureId]) {
dataForGraph = data.graphs[props.vectorFeatureId]

Check failure on line 59 in client/src/components/FeatureSelection/VectorFeatureChart.vue

View workflow job for this annotation

GitHub Actions / lint-client

Missing semicolon
}
if (!dataForGraph) {
Expand Down
48 changes: 24 additions & 24 deletions client/src/components/TabularData/TableSummary.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import {
Ref, defineComponent, onMounted, ref,
Ref, defineComponent, onMounted, ref, computed,

Check failure on line 3 in client/src/components/TabularData/TableSummary.vue

View workflow job for this annotation

GitHub Actions / lint-client

Member 'computed' of the import declaration should be sorted alphabetically
} from 'vue';
import { TableSummary, VectorFeatureTableGraph } from '../../types';
import UVdatApi from '../../api/UVDATApi';
Expand All @@ -24,8 +24,7 @@ export default defineComponent({
const selectedTableType = ref<string | null>(null);
const selectedXColumn = ref<string | null>(null);
const selectedYColumn = ref<string | null>(null);
const selectedFilterColumn = ref<string>('');
const filterValue = ref<string>('');
const selectedIndexerColumn = ref<string>('');
const graphs = ref<VectorFeatureTableGraph[]>([]);
const getStyleVectorFeatureGraphs = () => {
Expand Down Expand Up @@ -59,8 +58,7 @@ export default defineComponent({
const resetGraphForm = () => {
selectedXColumn.value = null;
selectedYColumn.value = null;
selectedFilterColumn.value = '';
filterValue.value = '';
selectedIndexerColumn.value = '';
};
const addSaveGraph = () => {
Expand All @@ -70,8 +68,7 @@ export default defineComponent({
type: selectedTableType.value,
xAxis: selectedXColumn.value,
yAxis: selectedYColumn.value,
filterColumn: selectedFilterColumn.value ? selectedFilterColumn.value : undefined,
filterValue: filterValue.value ? filterValue.value : undefined,
indexer: selectedIndexerColumn.value ? selectedIndexerColumn.value : undefined,
};
if (editingGraphIndex.value !== null) {
Expand All @@ -89,15 +86,23 @@ export default defineComponent({
}
};
const availableColumns = computed(() => {
const baseColumns = selectedTableType ? summaryData?.tables[selectedTableType]?.columns : [];

Check failure on line 90 in client/src/components/TabularData/TableSummary.vue

View workflow job for this annotation

GitHub Actions / lint-client

Must use `.value` to read or write the value wrapped by `ref()`

Check failure on line 90 in client/src/components/TabularData/TableSummary.vue

View workflow job for this annotation

GitHub Actions / lint-client

Must use `.value` to read or write the value wrapped by `ref()`
if (baseColumns.length) {
const takenVals = [selectedXColumn.value, selectedYColumn.value, selectedIndexerColumn].filter((item) => item !== null);
return baseColumns.filter((item) => !takenVals.includes(item))

Check failure on line 93 in client/src/components/TabularData/TableSummary.vue

View workflow job for this annotation

GitHub Actions / lint-client

Missing semicolon
}
return baseColumns;
})

Check failure on line 96 in client/src/components/TabularData/TableSummary.vue

View workflow job for this annotation

GitHub Actions / lint-client

Missing semicolon
const editGraph = (index: number) => {
const graph = graphs.value[index];
// eslint-disable-next-line prefer-destructuring
selectedTableType.value = graph.type; // Assuming the table name is part of the graph name
selectedTableName.value = graph.name;
selectedXColumn.value = graph.xAxis;
selectedYColumn.value = graph.yAxis;
selectedFilterColumn.value = graph.filterColumn || '';
filterValue.value = graph.filterValue || ' ';
selectedIndexerColumn.value = graph.indexer || '';
editingGraphIndex.value = index;
};
Expand All @@ -116,13 +121,13 @@ export default defineComponent({
error,
tableChartDialog,
activeTab,
availableColumns,
selectedTableName,
selectedTableType,
selectedXColumn,
selectedYColumn,
selectedFilterColumn,
selectedIndexerColumn,
editingGraphIndex,
filterValue,
graphs,
addSaveGraph,
editGraph,
Expand Down Expand Up @@ -203,23 +208,18 @@ export default defineComponent({
/>
<v-select
v-model="selectedXColumn"
:items="selectedTableType ? summaryData?.tables[selectedTableType]?.columns : []"
:items="availableColumns"
label="Select X Axis"
/>
<v-select
v-model="selectedYColumn"
:items="selectedTableType ? summaryData?.tables[selectedTableType]?.columns : []"
:items="availableColumns"
label="Select Y Axis"
/>
<v-select
v-model="selectedFilterColumn"
:items="selectedTableType ? summaryData?.tables[selectedTableType]?.columns : []"
label="Select Filter Column"
/>
<v-text-field
v-model="filterValue"
label="Filter Value"
:disabled="!selectedFilterColumn"
v-model="selectedIndexerColumn"
:items="availableColumns"
label="Select Indexer Column"
/>
<v-btn :disabled="!selectedTableType || !selectedXColumn || !selectedYColumn" color="primary" @click="addSaveGraph">
{{ editingGraphIndex !== null ? 'Update' : 'Add' }} Graph
Expand All @@ -231,10 +231,10 @@ export default defineComponent({
<v-list-item-title>{{ graph.name }}</v-list-item-title>
<v-list-item-subtitle>
<div>{{ graph.type }}</div>
<div>{{ graph.xAxis }} vs {{ graph.yAxis }} {{ graph.filterValue ? `(Filter - ${graph.filterValue}` : '' }})</div>
<div>{{ graph.xAxis }} vs {{ graph.yAxis }} {{ graph.indexer ? `(Indexer - ${graph.indexer}` : '' }})</div>
</v-list-item-subtitle>
<v-list-item-subtitle v-if="graph.filterColumn">
Filter: {{ graph.filterColumn }} = {{ graph.filterValue }}
<v-list-item-subtitle v-if="graph.inexer">
Indexer: {{ graph.indexer }}
</v-list-item-subtitle>
<v-list-item-action>
<v-icon color="warning" @click="editGraph(index)">
Expand Down
27 changes: 6 additions & 21 deletions client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,53 +750,38 @@ interface TableInfo {
type ColumnSummary =
| NumberColumnSummary
| StringColumnSummary

Check failure on line 752 in client/src/types.ts

View workflow job for this annotation

GitHub Actions / lint-client

Missing semicolon
| ParameterColumnSummary;

interface NumberColumnSummary {
type: 'number';
min: number;
max: number;
value_count: number;
description?: string;
}

interface StringColumnSummary {
type: 'string';
values: string[];
value_count: number;
description?: string;
}

interface ParameterColumnSummary {
type: 'parameter_cd';
parameters: Record<string, ParameterStats>;
}

Check failure on line 769 in client/src/types.ts

View workflow job for this annotation

GitHub Actions / lint-client

More than 1 blank line not allowed
interface ParameterStats {
parameter_cd: string;
parameter_name: string;
min: number;
max: number;
mean: number;
}

export interface VectorFeatureTableGraph {
name: string;
type: string;
xAxis: string;
yAxis: string;
filterColumn?: string;
filterValue?: string;
indexer: string;
}

export interface FeatureGraphData {
table_name: string;
graphs:
Record<string, {
Record<number, {
data:[number, number][];
filterVal: string;
vectorFeatureId: number;
indexer: string | number;
}>
| {
default: {
data: [number, number][];
};
};
}
2 changes: 1 addition & 1 deletion scripts/nwis/getTVASites.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def fetch_tva_sites(param_codes, usgs_parameters, site_types):
print(f"ParamCodes: {param_codes}")
site_response = nwis.what_sites(
bBox=bbox,
parameterCd=list(param_codes),
parameterCd=",".join(param_codes),
siteType=query_site_types,
siteStatus='active',
startDt=start_dt,
Expand Down
Loading

0 comments on commit e1e873f

Please sign in to comment.