Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #62 #69

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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