Skip to content

Commit

Permalink
models in marketplace complete (TransformerOptimus#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
namansleeps authored Oct 10, 2023
1 parent b8ac6d2 commit 95df3b6
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 45 deletions.
3 changes: 3 additions & 0 deletions gui/pages/Content/Marketplace/Market.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export default function Market({env, getModels, sendModelData}) {
];

const renderTab = (tab) => {
if(tab.id === 'market_models' && !(window.location.href.toLowerCase().includes('marketplace')))
return

return (
<button
key={tab.id}
Expand Down
124 changes: 79 additions & 45 deletions gui/pages/Content/Models/MarketModels.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,93 @@ export default function MarketModels(){
const [loadingText, setLoadingText] = useState("Loading Models");
const [modelTemplates, setModelTemplates] = useState([]);

useEffect(() => {
loadingTextEffect('Loading Models', setLoadingText, 500);
// useEffect(() => {
// loadingTextEffect('Loading Models', setLoadingText, 500);
// setIsLoading(true)
// if (window.location.href.toLowerCase().includes('marketplace')) {
// axios.get('https://app.superagi.com/api/models_controller/get/models_details')
// .then((response) => {
// setModelTemplates(response.data)
// })
// }
// else {
// fetchMarketPlaceModel().then((response) => {
// setModelTemplates(response.data)
// })
// }
// },[])

if (window.location.href.toLowerCase().includes('marketplace')) {
axios.get('https://app.superagi.com/api/models_controller/get/models_details')
.then((response) => {
setModelTemplates(response.data)
})
}
else {
fetchMarketPlaceModel().then((response) => {
setModelTemplates(response.data)
})
}
},[])

useEffect(() => {
if(modelTemplates.length > 0)
setIsLoading(true)
else
setIsLoading(false)
}, [modelTemplates])
// useEffect(() => {
// if(modelTemplates.length > 0)
// setIsLoading(true)
// else
// setIsLoading(false)
// }, [modelTemplates])

function handleTemplateClick(item) {
const contentType = 'model_template';
EventBus.emit('openTemplateDetails', {item, contentType});
}

useEffect(() => {
loadingTextEffect('Loading Models', setLoadingText, 500);
setIsLoading(true)
const iframe = document.getElementById('marketplace_models');

const handleIframeLoad = () => {
setTimeout(() => {
setIsLoading(false)
}, 2000);
};

if (iframe) {
iframe.onload = handleIframeLoad;
}

return () => {
if (iframe) {
iframe.onload = null;
}
};
}, []);

return(
<div id="market_models" className={showMarketplace ? 'ml_8' : 'ml_3'}>
<div className="w_100 overflowY_auto mxh_78vh">
{isLoading ? <div>
{modelTemplates.length > 0 ? <div className="marketplaceGrid">{modelTemplates.map((item) => (
<div className="market_containers cursor_pointer" key={item.id} onClick={() => handleTemplateClick(item)}>
<div>{item.model_name && item.model_name.includes('/') ? item.model_name.split('/')[1] : item.model_name}</div>
<div className="horizontal_container color_gray">
<span>by { item.model_name && item.model_name.includes('/') ? item.model_name.split('/')[0] : item.provider }</span>
<Image className="mr_8 ml_4" width={14} height={14} src="/images/is_verified.svg" alt="is_verified" />·
<Image className="ml_8 mr_4" width={16} height={16} src={modelIcon(item.provider)} alt="source-icon" />
<span className="mr_8">{item.provider}</span>·
<Image className="ml_8 mr_4" width={15} height={15} src="/images/upload_icon.svg" alt="download-icon" />
<span>{item.installs}</span>
</div>
<div className="text_ellipsis mt_14 color_gray">{item.description}</div>
</div>
))}</div> : <div className="center_container mt_40">
<Image width={150} height={60} src="/images/no_permissions.svg" alt="no-permissions"/>
<span className="feed_title mt_8">No Models found!</span>
</div>}
</div> : <div className="horizontal_container_center h_75vh">
<div className="signInInfo text_16 ff_sourceCode">{loadingText}</div>
</div>}
</div>
<div className="h_calc_sub_60 w_99vw">
{isLoading ? <iframe
id="marketplace_models"
src="https://models.superagi.com/marketplace"
width="100%"
height="100%"
frameBorder="0"
allowFullScreen
></iframe>: <div className="horizontal_container_center h_75vh">
<div className="signInInfo text_16 ff_sourceCode">{loadingText}</div>
</div>}
</div>
// <div id="market_models" className={showMarketplace ? 'ml_8' : 'ml_3'}>
// <div className="w_100 overflowY_auto mxh_78vh">
// {isLoading ? <div>
// {modelTemplates.length > 0 ? <div className="marketplaceGrid">{modelTemplates.map((item) => (
// <div className="market_containers cursor_pointer" key={item.id} onClick={() => handleTemplateClick(item)}>
// <div>{item.model_name && item.model_name.includes('/') ? item.model_name.split('/')[1] : item.model_name}</div>
// <div className="horizontal_container color_gray">
// <span>by { item.model_name && item.model_name.includes('/') ? item.model_name.split('/')[0] : item.provider }</span>
// <Image className="mr_8 ml_4" width={14} height={14} src="/images/is_verified.svg" alt="is_verified" />·
// <Image className="ml_8 mr_4" width={16} height={16} src={modelIcon(item.provider)} alt="source-icon" />
// <span className="mr_8">{item.provider}</span>·
// <Image className="ml_8 mr_4" width={15} height={15} src="/images/upload_icon.svg" alt="download-icon" />
// <span>{item.installs}</span>
// </div>
// <div className="text_ellipsis mt_14 color_gray">{item.description}</div>
// </div>
// ))}</div> : <div className="center_container mt_40">
// <Image width={150} height={60} src="/images/no_permissions.svg" alt="no-permissions"/>
// <span className="feed_title mt_8">No Models found!</span>
// </div>}
// </div> : <div className="horizontal_container_center h_75vh">
// <div className="signInInfo text_16 ff_sourceCode">{loadingText}</div>
// </div>}
// </div>
// </div>
)
}
2 changes: 2 additions & 0 deletions gui/pages/_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ p {
.w_73{width: 73%}
.w_97{width: 97%}
.w_100{width: 100%}
.w_99vw{width: 99vw}
.w_inherit{width: inherit}
.w_fit_content{width:fit-content}
.w_inherit{width: inherit}
Expand All @@ -1124,6 +1125,7 @@ p {
.h_80vh{height: 80vh}
.h_calc92{height: calc(100vh - 92px)}
.h_calc_add40{height: calc(80vh + 40px)}
.h_calc_sub_60{height: calc(92.5vh - 60px)}

.mxh_78vh{max-height: 78vh}

Expand Down

0 comments on commit 95df3b6

Please sign in to comment.