Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorth committed Feb 21, 2024
1 parent 64937e1 commit 6a30925
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 25 deletions.
12 changes: 10 additions & 2 deletions backend/src/explorer/search/search.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ export class SearchController {

@HttpCode(200)
@Post('/scroll/:scroll')
async searchScroll(@Body() query: SearchRequest, @Param('scroll') scroll: string) {
async searchScroll(
@Body() query: SearchRequest,
@Param('scroll') scroll: string,
) {
query['track_total_hits'] = true;
const body = await this.elasticSearvice.get(null, 'DEFAULT_DASHBOARD', query, scroll);
const body = await this.elasticSearvice.get(
null,
'DEFAULT_DASHBOARD',
query,
scroll,
);
return body;
}
}
7 changes: 6 additions & 1 deletion backend/src/export/export.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@ export class ExportController {
const searchQuery: any = { ...query, size: 2000 };
this.exportService.downloadFile(
res,
await this.elasticService.get(index_name, dashboard, searchQuery, scrollId),
await this.elasticService.get(
index_name,
dashboard,
searchQuery,
scrollId,
),
type,
part,
fileName,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/harvesters/DSpace7/dspace7.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ export class DSpace7Service {
);
if (mappedValue !== '' && mappedValue != null) {
finalValues[schemaName] = this.formatService.setValue(
finalValues[schemaName],
mappedValue,
finalValues[schemaName],
mappedValue,
);
}
} else {
Expand Down
29 changes: 22 additions & 7 deletions backend/src/shared/services/elastic/elastic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,12 @@ export class ElasticService {
}
}

async get(index_name: string, dashboardName = 'DEFAULT_DASHBOARD', query: SearchRequest, scrollId?: string) {
async get(
index_name: string,
dashboardName = 'DEFAULT_DASHBOARD',
query: SearchRequest,
scrollId?: string,
) {
try {
let scrollSearch: SearchResponse;
if (scrollId) {
Expand All @@ -256,21 +261,31 @@ export class ElasticService {
}

async addPreDefinedFiltersQuery(query: SearchRequest, dashboardName: string) {
const predefinedFilters = await this.jsonFilesService.getPredefinedFiltersFromDashboard(dashboardName);
if (!predefinedFilters || !Array.isArray(predefinedFilters) || predefinedFilters.length === 0) {
const predefinedFilters =
await this.jsonFilesService.getPredefinedFiltersFromDashboard(
dashboardName,
);
if (
!predefinedFilters ||
!Array.isArray(predefinedFilters) ||
predefinedFilters.length === 0
) {
return query;
}
const predefinedQuery: QueryDslQueryContainer = {
bool: {
filter: {
bool: {
must: predefinedFilters,
}
}
}
},
},
},
};
if (query?.query) {
((predefinedQuery.bool.filter as QueryDslQueryContainer).bool.must as QueryDslQueryContainer[]).push(query?.query);
(
(predefinedQuery.bool.filter as QueryDslQueryContainer).bool
.must as QueryDslQueryContainer[]
).push(query?.query);
}
query.query = predefinedQuery;

Expand Down
26 changes: 14 additions & 12 deletions frontend/src/app/admin/design/design.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class DesignComponent implements OnInit {
dashboard_name: string;
exportLink: string;
predefinedFilters: any = null;
predefinedFiltersExample = JSON.stringify([{"terms": {"FIELD_NAME": ["VALUE"]}}]);
predefinedFiltersExample = JSON.stringify([
{ terms: { FIELD_NAME: ['VALUE'] } },
]);
footer: any = null;
welcome: any;
welcome_text = '';
Expand Down Expand Up @@ -80,14 +82,8 @@ export class DesignComponent implements OnInit {
await this.spinner.show();
const dashboard_name = (this.dashboard_name =
this.activeRoute.snapshot.paramMap.get('dashboard_name'));
const {
counters,
filters,
dashboard,
footer,
predefinedFilters,
welcome
} = await this.settingsService.readExplorerSettings(dashboard_name);
const { counters, filters, dashboard, footer, predefinedFilters, welcome } =
await this.settingsService.readExplorerSettings(dashboard_name);
if (welcome.componentConfigs && welcome.componentConfigs.text)
this.welcome_text = welcome.componentConfigs.text;
if (!this.welcome)
Expand Down Expand Up @@ -123,7 +119,8 @@ export class DesignComponent implements OnInit {
}

populateForm(settings) {
const { counters, filters, dashboard, footer, predefinedFilters, welcome } = settings;
const { counters, filters, dashboard, footer, predefinedFilters, welcome } =
settings;
if (welcome.componentConfigs && welcome.componentConfigs.text)
this.welcome_text = welcome.componentConfigs.text;
if (!this.welcome)
Expand Down Expand Up @@ -258,15 +255,20 @@ export class DesignComponent implements OnInit {
.length == 0
) {
let predefinedFilters = null;
if (this.predefinedFilters && this.predefinedFilters.trim(this.predefinedFilters) !== '') {
if (
this.predefinedFilters &&
this.predefinedFilters.trim(this.predefinedFilters) !== ''
) {
try {
predefinedFilters = JSON.parse(this.predefinedFilters);
} catch (e) {
predefinedFilters = null;
}
if (predefinedFilters == null || !Array.isArray(predefinedFilters)) {
await this.spinner.hide();
this.toastr.error('Please add a valid JSON array in the Predefined filters field');
this.toastr.error(
'Please add a valid JSON array in the Predefined filters field',
);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export class PieComponent extends ParentChart implements OnInit {
commonProperties.legend.labelFormatter = function () {
const label = `${this.name} (${(this as any).y})`;
return label.replace(
new RegExp(`(?![^\\n]{1,${30}}$)([^\\n]{1,${30}})\\s`, 'g'), '$1<br>'
new RegExp(`(?![^\\n]{1,${30}}$)([^\\n]{1,${30}})\\s`, 'g'),
'$1<br>',
);
};
commonProperties.legend.useHTML = true;
Expand Down

0 comments on commit 6a30925

Please sign in to comment.