diff --git a/.env.example b/.env.example
index 52995eea7..e10292e5c 100644
--- a/.env.example
+++ b/.env.example
@@ -15,3 +15,5 @@ REACT_APP_SNET_SIGNER_ADDRESS=
REACT_APP_EXECUTOR_WALLET_ADDRESS=
REACT_APP_SNET_SUPPORT_MAIL=
REACT_APP_SENTRY_DSN=
+REACT_APP_IS_ALL_SERVICES_AVAILIBLE=
+REACT_APP_TRAINING_ENABLE=
diff --git a/public/index.html b/public/index.html
index 887a0d140..cb5c7a8b8 100644
--- a/public/index.html
+++ b/public/index.html
@@ -8,6 +8,8 @@
+
+
-
SingularityNET Beta Dapp
+ SingularityNET AI Marketplace: The Decentralized Marketplace for Next-Gen AI Services
diff --git a/src/Redux/actionCreators/ServiceActions.js b/src/Redux/actionCreators/ServiceActions.js
index 4a646e7de..129215fa1 100644
--- a/src/Redux/actionCreators/ServiceActions.js
+++ b/src/Redux/actionCreators/ServiceActions.js
@@ -4,6 +4,7 @@ import { APIEndpoints, APIPaths } from "../../config/APIEndpoints";
import { loaderActions, userActions } from "./";
import { LoaderContent } from "../../utility/constants/LoaderContent";
import { initializeAPIOptions } from "../../utility/API";
+import { generateOrganizationsFilterObject } from "../../utility/constants/Pagination";
// import { cacheS3Url } from "../../utility/image";
export const UPDATE_SERVICE_LIST = "SET_SERVICE_LIST";
@@ -39,11 +40,33 @@ export const fetchServiceSuccess = (res) => (dispatch) => {
dispatch(loaderActions.stopAIServiceListLoader);
};
+export const fetchUserOrganizationsList = () => async (dispatch) => {
+ const apiName = APIEndpoints.REGISTRY.name;
+ const apiPath = APIPaths.GET_USER_ORGS;
+ const { token } = await dispatch(userActions.fetchAuthenticatedUser());
+ const apiOptions = initializeAPIOptions(token);
+ return API.get(apiName, apiPath, apiOptions);
+};
+
+const onlyUserOrgsFilter = () => async (dispatch) => {
+ const userOrganizations = await dispatch(fetchUserOrganizationsList());
+ const userOrganizationsId = userOrganizations.data.map((organization) => organization.org_id);
+ const filterObj = generateOrganizationsFilterObject([
+ ...userOrganizationsId,
+ process.env.REACT_APP_EXAMPLE_SERVICE_ORG_ID,
+ ]);
+ return filterObj;
+};
+
export const fetchService =
(pagination, filters = []) =>
- (dispatch) => {
+ async (dispatch) => {
+ if (process.env.REACT_APP_IS_ALL_SERVICES_AVAILIBLE !== "true") {
+ // env variable is string
+ filters = await dispatch(onlyUserOrgsFilter());
+ }
dispatch(loaderActions.startAIServiceListLoader);
- const url = new URL(`${APIEndpoints.CONTRACT.endpoint}/service`);
+ const url = new URL(APIEndpoints.CONTRACT.endpoint + APIPaths.GET_SERVICE_LIST);
return fetch(url, {
method: "POST",
body: JSON.stringify({ ...pagination, filters }),
diff --git a/src/components/AiMarketplace/MainSection/Filter/ToolBar/index.js b/src/components/AiMarketplace/MainSection/Filter/ToolBar/index.js
index d462c0d5e..80b9a05fa 100644
--- a/src/components/AiMarketplace/MainSection/Filter/ToolBar/index.js
+++ b/src/components/AiMarketplace/MainSection/Filter/ToolBar/index.js
@@ -8,7 +8,10 @@ import ServiceSortOptions from "./ServiceSortOptions";
import ViewToggler from "./ViewToggler";
import StyledDropdown from "../../../../common/StyledDropdown";
import { serviceActions } from "../../../../../Redux/actionCreators";
-import { defaultPaginationParameters } from "../../../../../utility/constants/Pagination";
+import {
+ defaultPaginationParameters,
+ generateOrganizationsFilterObject,
+} from "../../../../../utility/constants/Pagination";
const ToolBar = ({
listView,
@@ -46,19 +49,7 @@ const ToolBar = ({
}
let filterObj = [];
if (value !== "default") {
- filterObj = [
- {
- filter: [
- {
- filter_condition: {
- attr: "org_id",
- operator: "IN",
- value: [value],
- },
- },
- ],
- },
- ];
+ filterObj = generateOrganizationsFilterObject([value]);
}
setActiveOrgItem(value);
@@ -74,16 +65,18 @@ const ToolBar = ({
-
- Organization
-
-
+ {process.env.REACT_APP_IS_ALL_SERVICES_AVAILIBLE === "true" && (
+
+ Organization
+
+
+ )}
{total_count} services
diff --git a/src/config/APIEndpoints.js b/src/config/APIEndpoints.js
index d4304fc08..6dee79ccf 100644
--- a/src/config/APIEndpoints.js
+++ b/src/config/APIEndpoints.js
@@ -23,6 +23,10 @@ export const APIEndpoints = {
name: "Orchestrator",
endpoint: process.env.REACT_APP_ORCHESTRATOR_ENDPOINT,
},
+ REGISTRY: {
+ name: "Registry",
+ endpoint: process.env.REACT_APP_REGISTRY_ENDPOINT,
+ },
};
export const APIPaths = {
@@ -53,4 +57,5 @@ export const APIPaths = {
USD_RATE: "/currency/USD/token",
FREE_CALL_TOKEN: "/free-call/token",
GET_CAROUSEL: "/uicontent/marketplacecarousel",
+ GET_USER_ORGS: "/org",
};
diff --git a/src/utility/constants/Pagination.js b/src/utility/constants/Pagination.js
index 420d69e9e..14e6f2c45 100644
--- a/src/utility/constants/Pagination.js
+++ b/src/utility/constants/Pagination.js
@@ -20,6 +20,22 @@ export const filterTitles = {
org_id: "Organization",
};
+export const generateOrganizationsFilterObject = (value) => {
+ return [
+ {
+ filter: [
+ {
+ filter_condition: {
+ attr: "org_id",
+ operator: "IN",
+ value,
+ },
+ },
+ ],
+ },
+ ];
+};
+
export const generateFilterObject = (filterData) => {
const filterObject = [];
const filter = { filter: [] };