File indexing completed on 2025-05-04 05:31:00
0001 import React ,{useState,useEffect} from 'react' 0002 import TimeAgo from 'react-timeago' 0003 const Gitlab = (props) => { 0004 const [projects, setProjects] = useState([]); 0005 const [user, setUser] = useState({'username':''}); 0006 const [gitlabUrl, setGitlabUrl] = useState(window.config.gitlabUrl); 0007 0008 0009 useEffect(() => { 0010 loadData(); 0011 },[]); 0012 0013 const loadData = () => { 0014 0015 fetch(`/json/gitlab?username=${props.username}`, { 0016 mode: 'cors', 0017 credentials: 'include' 0018 }) 0019 .then(response => response.json()) 0020 .then(data => { 0021 let items = data; 0022 if (items && typeof(items.projects) != "undefined") 0023 { 0024 setProjects(items.projects); 0025 } 0026 0027 if (items && typeof(items.user) != "undefined") 0028 { 0029 setUser(items.user); 0030 } 0031 }); 0032 0033 } 0034 0035 return ( 0036 <div className="sub-system-container"> 0037 <div className="header">Opencode :<a href={gitlabUrl+'/'+user.username}> {user.username} </a> 0038 { 0039 user.avatar_url && 0040 <> 0041 <img src={user.avatar_url}></img> 0042 </> 0043 } 0044 0045 </div> 0046 0047 <div> 0048 <ul>{ 0049 0050 projects.slice(0, 5).map((p,index) => 0051 <li key={index}> 0052 <div className="title"> 0053 {p.avatar_url ? ( 0054 <img src={p.avatar_url} style={{width:'40px', height:'40px'}}></img> 0055 ) : ( 0056 <div style={{width:'40px',height:'40px',background:'#EEEEEE',fontSize:'16px' 0057 ,lineHeight:'38px', textAlign:'center',color:'#555555' 0058 ,display: 'block', float: 'left',marginRight: '10px' 0059 }}> 0060 {p.name.substr(0,1)}</div> 0061 )} 0062 0063 <a href={p.http_url_to_repo}> 0064 {p.name+' '+p.description} 0065 </a> 0066 <TimeAgo date={p.last_activity_at} /> 0067 </div> 0068 </li> 0069 ) 0070 0071 } 0072 </ul> 0073 </div> 0074 </div> 0075 ) 0076 } 0077 0078 export default Gitlab;