Skip to content

Commit

Permalink
#352: replaced static publications count data on homepage with API res
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxue1123 committed Nov 15, 2024
1 parent 201381c commit 619de5c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
15 changes: 10 additions & 5 deletions src/components/Home/DynamicMetrics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import AnimatedNumber from "react-animated-number";
import FABRICLogo from "../../imgs/logos/fabric-logo-without-text.png";
import { getCoreApiMetrics, getOrchestratorMetrics } from "../../services/metricsService";
import { getPublications } from "../../services/publicationService.js";
import { toast } from "react-toastify";
import { Link } from "react-router-dom";

Expand All @@ -27,7 +28,7 @@ class DynamicMetrics extends React.Component {
},
{
name: "Publications Using FABRIC",
count: 33,
count: 0,
link: "/community/fabric-user-publications"
}
]
Expand All @@ -37,15 +38,19 @@ class DynamicMetrics extends React.Component {
try {
const { data: resCoreMetrics } = await getCoreApiMetrics();
const { data: resOrchestratorMetrics } = await getOrchestratorMetrics();
const { data: resPublications } = await getPublications();
this.setState({
metricsItems: this.generateMetricsItems(resCoreMetrics.results[0], resOrchestratorMetrics.results[0])
});
metricsItems: this.generateMetricsItems(
resCoreMetrics.results[0],
resOrchestratorMetrics.results[0],
resPublications.results
)});
} catch (err) {
toast.error("Failed to load FABRIC metrics data.")
}
}

generateMetricsItems = (coreMetrics, sliceMetrics) => {
generateMetricsItems = (coreMetrics, sliceMetrics, publicationMetrics) => {
const metricsItems = [];
// total slices' count and active slices' count
metricsItems.push({
Expand All @@ -69,7 +74,7 @@ class DynamicMetrics extends React.Component {
});
metricsItems.push({
name: "FABRIC User Publications",
count: 33,
count: publicationMetrics.length,
link: "/community/fabric-user-publications"
});

Expand Down
48 changes: 26 additions & 22 deletions src/components/common/Form/InputTag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ class InputTag extends React.Component {
<label htmlFor={name}>{label}</label>
<div className="input-tag form-control">
<ul className="input-tag__tags">
{tags.map((tag, i) => (
<li key={tag}>
{tag}
<i
className="fa fa-times ms-2"
onClick={() => {
this.raiseRemoveTag(i);
}}
></i>
</li>
))}
{
tags.length > 0 && tags.map((tag, i) => (
<li key={tag}>
{tag}
<i
className="fa fa-times ms-2"
onClick={() => {
this.raiseRemoveTag(i);
}}
></i>
</li>
))
}
<li className="input-tag__tags__input">
<input
type="text"
Expand All @@ -63,17 +65,19 @@ class InputTag extends React.Component {
</div>
</div> :
<ul className="input-tag__tags">
{tags.map((tag, i) => (
<li key={tag}>
{tag}
<i
className="fa fa-times ms-2"
onClick={() => {
this.raiseRemoveTag(i);
}}
></i>
</li>
))}
{
tags.length > 0 && tags.map((tag, i) => (
<li key={tag}>
{tag}
<i
className="fa fa-times ms-2"
onClick={() => {
this.raiseRemoveTag(i);
}}
></i>
</li>
))
}
</ul>
);
}
Expand Down

0 comments on commit 619de5c

Please sign in to comment.