Fix formatting - mainly spacing
This commit is contained in:
parent
c0b5500f00
commit
918a04076f
6
app/.prettierrc
Normal file
6
app/.prettierrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"semi": true,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"trailingComma": "es5"
|
||||||
|
}
|
@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
|
Before Width: | Height: | Size: 1.5 KiB |
@ -1,7 +1,7 @@
|
|||||||
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
|
||||||
import Login from './components/Login'
|
import Login from './components/Login';
|
||||||
import Signup from './components/Signup'
|
import Signup from './components/Signup';
|
||||||
import Dashboard from './components/Dashboard'
|
import Dashboard from './components/Dashboard';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@ -12,7 +12,7 @@ function App() {
|
|||||||
<Route path="/dashboard" element={<Dashboard />} />
|
<Route path="/dashboard" element={<Dashboard />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</Router>
|
</Router>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App
|
export default App;
|
||||||
|
@ -6,7 +6,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|||||||
import { faTrash } from '@fortawesome/free-solid-svg-icons';
|
import { faTrash } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
function Dashboard() {
|
function Dashboard() {
|
||||||
document.title = 'LinkLogger | Dashboard'
|
document.title = 'LinkLogger | Dashboard';
|
||||||
|
|
||||||
interface Log {
|
interface Log {
|
||||||
id: number;
|
id: number;
|
||||||
@ -34,31 +34,34 @@ function Dashboard() {
|
|||||||
|
|
||||||
// Fetch links from API
|
// Fetch links from API
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Axios.get('/api/links').then((res) => {
|
Axios.get('/api/links')
|
||||||
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLinks(res.data);
|
setLinks(res.data);
|
||||||
} else {
|
} else {
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
})
|
||||||
|
.catch(() => {
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
// Fetch logs from API
|
// Fetch logs from API
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Axios.get('/api/logs').then((res) => {
|
Axios.get('/api/logs')
|
||||||
|
.then((res) => {
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
setLogs(res.data);
|
setLogs(res.data);
|
||||||
} else {
|
} else {
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
})
|
||||||
|
.catch(() => {
|
||||||
navigate('/login');
|
navigate('/login');
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
const toggleLogRow = (link: string) => {
|
const toggleLogRow = (link: string) => {
|
||||||
setVisibleLog(visibleLog === link ? null : link);
|
setVisibleLog(visibleLog === link ? null : link);
|
||||||
};
|
};
|
||||||
@ -79,9 +82,16 @@ function Dashboard() {
|
|||||||
<React.Fragment key={link.link}>
|
<React.Fragment key={link.link}>
|
||||||
<tr className={styles.linkTableRow}>
|
<tr className={styles.linkTableRow}>
|
||||||
<td>
|
<td>
|
||||||
<button onClick={() => toggleLogRow(link.link)} className={styles.linkButton}>{link.link}</button>
|
<button
|
||||||
|
onClick={() => toggleLogRow(link.link)}
|
||||||
|
className={styles.linkButton}
|
||||||
|
>
|
||||||
|
{link.link}
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{logs.filter((log) => log.link === link.link).length || 0}
|
||||||
</td>
|
</td>
|
||||||
<td>{logs.filter((log) => log.link === link.link).length || 0}</td>
|
|
||||||
<td>{link.redirect_link}</td>
|
<td>{link.redirect_link}</td>
|
||||||
<td>{link.expire_date}</td>
|
<td>{link.expire_date}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -111,7 +121,12 @@ function Dashboard() {
|
|||||||
<td>{log.ip}</td>
|
<td>{log.ip}</td>
|
||||||
<td>{log.location}</td>
|
<td>{log.location}</td>
|
||||||
<td>{log.isp}</td>
|
<td>{log.isp}</td>
|
||||||
<td><FontAwesomeIcon icon={faTrash} className={styles.trashBin}/></td>
|
<td>
|
||||||
|
<FontAwesomeIcon
|
||||||
|
icon={faTrash}
|
||||||
|
className={styles.trashBin}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -123,7 +138,7 @@ function Dashboard() {
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Dashboard;
|
export default Dashboard;
|
@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
function Login() {
|
function Login() {
|
||||||
document.title = 'LinkLogger | Login'
|
document.title = 'LinkLogger | Login';
|
||||||
|
|
||||||
const [username, setUsername] = useState('');
|
const [username, setUsername] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
@ -76,7 +76,12 @@ function Login() {
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<hr></hr>
|
<hr></hr>
|
||||||
<p id={styles.bottomText}>Don't have an account? <Link to="/signup" className={styles.link}>Create one now</Link></p>
|
<p id={styles.bottomText}>
|
||||||
|
Don't have an account?{' '}
|
||||||
|
<Link to="/signup" className={styles.link}>
|
||||||
|
Create one now
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom';
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
function Signup() {
|
function Signup() {
|
||||||
document.title = 'LinkLogger | Signup'
|
document.title = 'LinkLogger | Signup';
|
||||||
|
|
||||||
const [username, setUsername] = useState('');
|
const [username, setUsername] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
@ -98,7 +98,12 @@ function Signup() {
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
<hr></hr>
|
<hr></hr>
|
||||||
<p id={styles.bottomText}>Already have an account? <Link to="/login" className={styles.link}>Log in here.</Link></p>
|
<p id={styles.bottomText}>
|
||||||
|
Already have an account?{' '}
|
||||||
|
<Link to="/login" className={styles.link}>
|
||||||
|
Log in here.
|
||||||
|
</Link>
|
||||||
|
</p>
|
||||||
</header>
|
</header>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* Accept an API endpoint, method, and body to send to the API.
|
|
||||||
* - If successful, return the response
|
|
||||||
* - If not, return false
|
|
||||||
* @param {*} endpoint API endpoint
|
|
||||||
* @param {*} method String (GET, POST, PUT, DELETE)
|
|
||||||
* @param {*} body Data to send to the API
|
|
||||||
* @returns response.json or false
|
|
||||||
*/
|
|
||||||
async function accessAPI(endpoint, method, body) {
|
|
||||||
let response = await fetch(`http://127.0.0.1:5252/api${endpoint}`, {
|
|
||||||
method: method,
|
|
||||||
credentials: 'include',
|
|
||||||
body: body,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.ok) {
|
|
||||||
let data = await response.json();
|
|
||||||
data = await data;
|
|
||||||
return data;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { accessAPI };
|
|
@ -1,9 +1,9 @@
|
|||||||
import { StrictMode } from 'react'
|
import { StrictMode } from 'react';
|
||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client';
|
||||||
import App from './App.tsx'
|
import App from './App.tsx';
|
||||||
|
|
||||||
createRoot(document.getElementById('root')!).render(
|
createRoot(document.getElementById('root')!).render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</StrictMode>,
|
</StrictMode>
|
||||||
)
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user