Skip to content

Commit

Permalink
Merge pull request #69 from lukashornych/dev
Browse files Browse the repository at this point in the history
Release #62
  • Loading branch information
lukashornych authored Nov 7, 2023
2 parents 062acbb + 9b5426b commit 9db56f9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ async function executeQuery(): Promise<void> {
loading.value = true
try {
resultCode.value = await evitaQLConsoleService.executeEvitaQLQuery(props.params.dataPointer, queryCode.value, JSON.parse(variablesCode.value))
loading.value = false
enteredQueryCode.value = queryCode.value
} catch (error: any) {
toaster.error(error)
loading.value = false
}
loading.value = false
}
emit('ready')
Expand Down Expand Up @@ -140,6 +141,7 @@ if (props.params.executeOnOpen) {
>
<VWindowItem :value="ResultTabType.Raw">
<CodemirrorFull
v-if="resultTab === ResultTabType.Raw"
v-model="resultCode"
placeholder="Results will be displayed here..."
read-only
Expand All @@ -149,6 +151,7 @@ if (props.params.executeOnOpen) {

<VWindowItem :value="ResultTabType.Visualiser">
<LabEditorResultVisualiser
v-if="resultTab === ResultTabType.Visualiser"
:catalog-pointer="params.dataPointer"
:visualiser-service="visualiserService"
:input-query="enteredQueryCode || ''"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ async function executeQuery(): Promise<void> {
loading.value = true
try {
resultCode.value = await graphQLConsoleService.executeGraphQLQuery(props.params.instancePointer, queryCode.value, JSON.parse(variablesCode.value))
loading.value = false
enteredQueryCode.value = queryCode.value
} catch (error: any) {
loading.value = false
toaster.error(error)
}
loading.value = false
}
function initializeSchemaEditor(): void {
Expand Down Expand Up @@ -212,6 +213,7 @@ function initializeSchemaEditor(): void {
>
<VWindowItem :value="ResultTabType.Raw">
<CodemirrorFull
v-if="resultTab === ResultTabType.Raw"
v-model="resultCode"
placeholder="Results will be displayed here..."
read-only
Expand All @@ -221,6 +223,7 @@ function initializeSchemaEditor(): void {

<VWindowItem v-if="supportsVisualisation" :value="ResultTabType.Visualiser">
<LabEditorResultVisualiser
v-if="resultTab === ResultTabType.Visualiser"
:catalog-pointer="params.instancePointer"
:visualiser-service="visualiserService"
:input-query="enteredQueryCode || ''"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,11 @@ export class EvitaQLResultVisualiserService extends JsonResultVisualiserService
return undefined
}

const actualRepresentativeAttributes: (string | undefined)[] = []
const possibleAttributes: [any, boolean][] = []

const globalAttributes: Result = entityResult['attributes']?.['global'] || {}
for (const attributeName in globalAttributes) {
if (!representativeAttributes.includes(attributeName)) {
continue;
}
actualRepresentativeAttributes.push(this.toPrintableAttributeValue(globalAttributes[attributeName]))
possibleAttributes.push([globalAttributes[attributeName], representativeAttributes.includes(attributeName)])
}

const localizedAttributes: Result = entityResult['attributes']?.['localized'] || {}
Expand All @@ -78,17 +75,21 @@ export class EvitaQLResultVisualiserService extends JsonResultVisualiserService
const locale: string = localizedAttributesLocales[0]
const attributesInLocale: Result = localizedAttributes[locale]
for (const attributeName in attributesInLocale) {
if (!representativeAttributes.includes(attributeName)) {
continue;
}
actualRepresentativeAttributes.push(this.toPrintableAttributeValue(attributesInLocale[attributeName]))
possibleAttributes.push([attributesInLocale[attributeName], representativeAttributes.includes(attributeName)])
}
}

if (actualRepresentativeAttributes.length === 0) {
if (possibleAttributes.length === 0) {
return undefined
} else if (possibleAttributes.length <= 3) {
return possibleAttributes.map(it => this.toPrintableAttributeValue(it[0])).join(', ')
} else {
// if there are too many attributes, we only print the representative ones
return possibleAttributes
.filter(it => it[1])
.map(it => this.toPrintableAttributeValue(it[0]))
.join(', ')
}
return actualRepresentativeAttributes.filter(it => it != undefined).join(', ')
}

getFacetSummaryService(): FacetSummaryVisualiserService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,23 @@ export class GraphQLResultVisualiserService extends JsonResultVisualiserService
return undefined
}

const actualRepresentativeAttributes: (string | undefined)[] = []
const possibleAttributes: [any, boolean][] = []
const attributes = entityResult['attributes'] || {}
for (const attributeName in attributes) {
if (!representativeAttributes.includes(attributeName) && attributeName !== 'title') {
continue;
}
actualRepresentativeAttributes.push(this.toPrintableAttributeValue(attributes[attributeName]))
possibleAttributes.push([attributes[attributeName], representativeAttributes.includes(attributeName)])
}

if (actualRepresentativeAttributes.length === 0) {
if (possibleAttributes.length === 0) {
return undefined
} else if (possibleAttributes.length <= 3) {
return possibleAttributes.map(it => this.toPrintableAttributeValue(it[0])).join(', ')
} else {
// if there are too many attributes, we only print the representative ones
return possibleAttributes
.filter(it => it[1])
.map(it => this.toPrintableAttributeValue(it[0]))
.join(', ')
}
return actualRepresentativeAttributes.filter(it => it != undefined).join(', ')
}

getFacetSummaryService(): FacetSummaryVisualiserService {
Expand Down

0 comments on commit 9db56f9

Please sign in to comment.