Skip to content

Commit

Permalink
ajustando página de revistas
Browse files Browse the repository at this point in the history
  • Loading branch information
jesielviana committed Jul 13, 2023
1 parent 7939a8a commit 48d4120
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
API_KEY=""
HOST_ELASTIC="http://172.16.16.90:9200"
ELASTIC_INDEXES="pesqdf-publication,pesqdf-person,pesqdf-orgunit,pesqdf-journals,pesqdf-program,pesqdf-patent,researchgroups"
ELASTIC_INDEXES="pesqdf-publication,pesqdf-person,pesqdf-orgunit,pesqdf-journals,pesqdf-program,pesqdf-patent,researchgroups,pesqdf-software"
VIVO_URL_ITEM_BASE="http://codich1.ibict.br:8081/vivo/individual?uri=https://brcris.ibict.br/individual"
VIVO_URL_BASE="http://codich1.ibict.br:8081/vivo"
LANGUAGES="en,pt-BR"
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@
"Additional information": "Additional information",
"Softwares by release year": "Softwares by release year",
"Softwares by knowledge area": "Softwares by knowledge area",
"Creator(s)": "Creator(s)"
"Creator(s)": "Creator(s)",
"Journals by qualis": "Journals by qualis"
}
3 changes: 2 additions & 1 deletion public/locales/pt-BR/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@
"Additional information": "Informações adicionais",
"Softwares by release year": "Softwares por ano de lançamento",
"Softwares by knowledge area": "Softwares por área de conhecimento",
"Creator(s)": "Criador(es)"
"Creator(s)": "Criador(es)",
"Journals by qualis": "Revistas por qualis"
}
18 changes: 12 additions & 6 deletions src/components/customResultView/CustomResultViewJournals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { ResultViewProps } from '@elastic/react-search-ui-views';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import { Author } from '../../types/Entities';
import AuthorLink from '../externalLinks/AuthorLink';

const VIVO_URL_ITEM_BASE = process.env.VIVO_URL_ITEM_BASE;

Expand Down Expand Up @@ -36,7 +38,11 @@ const CustomResultViewPeople = ({ result, onClickLink }: ResultViewProps) => {
</li>
<li>
<span className="sui-result__key">Issn</span>
<span className="sui-result__value">{result.issn?.raw}</span>
<span className="sui-result__value">
{result.issn?.raw.map((issn: any, index: any) => (
<span key={index}>{issn}</span>
))}
</span>
</li>
<li>
<span className="sui-result__key">Issnl</span>
Expand All @@ -52,11 +58,11 @@ const CustomResultViewPeople = ({ result, onClickLink }: ResultViewProps) => {
</li>
<li>
<span className="sui-result__key">{t('Publisher')}</span>
{result.publisher?.raw.map((publisher: any, index: any) => (
<span key={index} className="sui-result__value">
{publisher.name}
</span>
))}
<span className="sui-result__value">
{result.publisher?.raw.map((author: Author) => (
<AuthorLink key={author.id} id={author.id} name={author.name} idLattes={author.idLattes} />
))}
</span>
</li>
<li>
<span className="sui-result__key">{t('Keywords')} </span>
Expand Down
93 changes: 16 additions & 77 deletions src/components/indicators/JornalsIndicators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,15 @@ import {
Title,
Tooltip,
} from 'chart.js';
import { Bar, Pie } from 'react-chartjs-2';
import { Bar } from 'react-chartjs-2';
import { CHART_BACKGROUD_COLORS, CHART_BORDER_COLORS } from '../../../utils/Utils';
import ElasticSearchService from '../../services/ElasticSearchService';
import { IndicatorsProps } from '../../types/Propos';

ChartJS.register(CategoryScale, LinearScale, BarElement, Title, Tooltip, Legend, ArcElement);
const INDEX_NAME = 'pesqdf-journals';

export const optionsStatus = {
responsive: true,
plugins: {
legend: {
position: 'bottom',
display: true,
},
title: {
display: true,
text: 'Journals by status',
},
},
};

export const optPublishers: ChartOptions = {
export const optQualis: ChartOptions = {
parsing: {
xAxisKey: 'key',
yAxisKey: 'doc_count',
Expand All @@ -56,13 +42,13 @@ export const optPublishers: ChartOptions = {
},
title: {
display: true,
text: 'Journals by publishers',
text: 'Journals by qualis',
},
},
scales: {
x: {
ticks: {
display: false,
display: true,
},
},
},
Expand All @@ -73,13 +59,8 @@ type IndicatorType = {
doc_count: number;
};

const headersPublishers = [
{ label: 'Publisher', key: 'key' },
{ label: 'Quantity', key: 'doc_count' },
];

const headersStatus = [
{ label: 'Status', key: 'key' },
const headersQualis = [
{ label: 'Qualis', key: 'key' },
{ label: 'Quantity', key: 'doc_count' },
];

Expand Down Expand Up @@ -162,16 +143,10 @@ function JornalsIndicators({ filters, searchTerm, isLoading, indicatorsState }:
useEffect(() => {
// tradução
// @ts-ignore
optPublishers.plugins.title.text = t(optPublishers.plugins?.title?.text);
optionsStatus.plugins.title.text = t(optionsStatus.plugins?.title?.text);
optQualis.plugins.title.text = t(optQualis.plugins?.title?.text);
isLoading
? ElasticSearchService(
[
JSON.stringify(
getKeywordQuery(queryCommonBase, 'publisher.name', filters, searchTerm, indicatorsState.config)
),
JSON.stringify(getKeywordQuery(queryCommonBase, 'status', filters, searchTerm, indicatorsState.config)),
],
[JSON.stringify(getKeywordQuery(queryCommonBase, 'qualis', filters, searchTerm, indicatorsState.config))],
INDEX_NAME
).then((data) => {
setIndicators(data);
Expand All @@ -186,38 +161,32 @@ function JornalsIndicators({ filters, searchTerm, isLoading, indicatorsState }:
indicatorsState.config.searchQuery.operator,
]);

const publisherIndicators: IndicatorType[] = indicators ? indicators[0] : [];
const qualisIndicators: IndicatorType[] = indicators ? indicators[0] : [];

const publisherLabels = publisherIndicators != null ? publisherIndicators.map((d) => d.key) : [];

const statusIndicators: IndicatorType[] = indicators ? indicators[1] : [];

const statusLabels = statusIndicators != null ? statusIndicators.map((d) => d.key) : [];

const statusCount = statusIndicators != null ? statusIndicators.map((d) => d.doc_count) : [];
const qualisLabels = qualisIndicators != null ? qualisIndicators.map((d) => d.key) : [];

return (
<div className={styles.charts}>
<div className={styles.chart} hidden={publisherIndicators == null}>
<div className={styles.chart} hidden={qualisIndicators == null}>
<CSVLink
className={styles.download}
title="Export to csv"
data={publisherIndicators ? publisherIndicators : []}
data={qualisIndicators ? qualisIndicators : []}
filename={'arquivo.csv'}
headers={headersPublishers}
headers={headersQualis}
>
<IoCloudDownloadOutline />
</CSVLink>
<Bar
/**
// @ts-ignore */
options={optPublishers}
options={optQualis}
width="500"
data={{
labels: publisherLabels,
labels: qualisLabels,
datasets: [
{
data: publisherIndicators,
data: qualisIndicators,
label: 'Articles per Year',
backgroundColor: CHART_BACKGROUD_COLORS,
borderColor: CHART_BORDER_COLORS,
Expand All @@ -227,36 +196,6 @@ function JornalsIndicators({ filters, searchTerm, isLoading, indicatorsState }:
}}
/>
</div>

<div className={styles.chart} hidden={statusIndicators == null}>
<CSVLink
className={styles.download}
title={t('Export to csv') || ''}
data={statusIndicators ? statusIndicators : []}
filename={'arquivo.csv'}
headers={headersStatus}
>
<IoCloudDownloadOutline />
</CSVLink>
<Pie
/**
// @ts-ignore */
options={optionsStatus}
width="500"
data={{
labels: statusLabels.map((label) => label.split('#')[1] || label),
datasets: [
{
data: statusCount,
label: '# of Votes',
backgroundColor: CHART_BACKGROUD_COLORS,
borderColor: CHART_BORDER_COLORS,
borderWidth: 1,
},
],
}}
/>
</div>
</div>
);
}
Expand Down

0 comments on commit 48d4120

Please sign in to comment.