Skip to content

Commit 2570b4e

Browse files
committed
Base code for settings and schedules
1 parent 9b80546 commit 2570b4e

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

app/Transformers/Api/Client/ServerTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function transform(Server $server): array
3535
'uuid' => $server->uuid,
3636
'name' => $server->name,
3737
'node' => $server->node->name,
38+
'sftp_details' => [
39+
'ip' => $server->node->fqdn,
40+
'port' => $server->node->daemonSFTP,
41+
],
3842
'description' => $server->description,
3943
'allocation' => [
4044
'ip' => $server->allocation->alias,

resources/scripts/api/server/getServer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ export interface Server {
1212
uuid: string;
1313
name: string;
1414
node: string;
15+
sftpDetails: {
16+
ip: string;
17+
port: number;
18+
};
1519
description: string;
1620
allocations: Allocation[];
1721
limits: {
@@ -32,6 +36,10 @@ export const rawDataToServerObject = (data: any): Server => ({
3236
uuid: data.uuid,
3337
name: data.name,
3438
node: data.node,
39+
sftpDetails: {
40+
ip: data.sftp_details.ip,
41+
port: data.sftp_details.port,
42+
},
3543
description: data.description ? ((data.description.length > 0) ? data.description : null) : null,
3644
allocations: [{
3745
ip: data.allocation.ip,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import React from 'react';
2+
3+
export default () => null;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import TitledGreyBox from '@/components/elements/TitledGreyBox';
3+
import { ServerContext } from '@/state/server';
4+
import { useStoreState } from 'easy-peasy';
5+
import { ApplicationStore } from '@/state';
6+
import { UserData } from '@/state/user';
7+
8+
export default () => {
9+
const user = useStoreState<ApplicationStore, UserData>(state => state.user.data!);
10+
const server = ServerContext.useStoreState(state => state.server.data!);
11+
12+
return (
13+
<div className={'my-10 mb-6 flex'}>
14+
<TitledGreyBox title={'SFTP Details'} className={'w-full md:w-1/2'}>
15+
<div>
16+
<label className={'input-dark-label'}>Server Address</label>
17+
<input
18+
type={'text'}
19+
className={'input-dark'}
20+
value={`sftp://${server.sftpDetails.ip}:${server.sftpDetails.port}`}
21+
readOnly={true}
22+
/>
23+
</div>
24+
<div className={'mt-6'}>
25+
<label className={'input-dark-label'}>Username</label>
26+
<input
27+
type={'text'}
28+
className={'input-dark'}
29+
value={`${user.username}.${server.id}`}
30+
readOnly={true}
31+
/>
32+
</div>
33+
<div className={'mt-6'}>
34+
<div className={'border-l-4 border-cyan-500 p-3'}>
35+
<p className={'text-xs text-neutral-200'}>
36+
Your SFTP password is the same as the password you use to access this panel.
37+
</p>
38+
</div>
39+
</div>
40+
</TitledGreyBox>
41+
</div>
42+
);
43+
};

resources/scripts/routers/ServerRouter.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { CSSTransition } from 'react-transition-group';
1313
import SuspenseSpinner from '@/components/elements/SuspenseSpinner';
1414
import FileEditContainer from '@/components/server/files/FileEditContainer';
1515
import UsersContainer from '@/components/server/users/UsersContainer';
16+
import ScheduleContainer from '@/components/server/schedules/ScheduleContainer';
17+
import SettingsContainer from '@/components/server/settings/SettingsContainer';
1618

1719
const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>) => {
1820
const server = ServerContext.useStoreState(state => state.server.data);
@@ -36,6 +38,8 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
3638
<NavLink to={`${match.url}/files`}>File Manager</NavLink>
3739
<NavLink to={`${match.url}/databases`}>Databases</NavLink>
3840
<NavLink to={`${match.url}/users`}>User Management</NavLink>
41+
<NavLink to={`${match.url}/schedules`}>Schedules</NavLink>
42+
<NavLink to={`${match.url}/settings`}>Settings</NavLink>
3943
</div>
4044
</div>
4145
</div>
@@ -64,6 +68,8 @@ const ServerRouter = ({ match, location }: RouteComponentProps<{ id: string }>)
6468
/>
6569
<Route path={`${match.path}/databases`} component={DatabasesContainer} exact/>
6670
<Route path={`${match.path}/users`} component={UsersContainer} exact/>
71+
<Route path={`${match.path}/schedules`} component={ScheduleContainer} exact/>
72+
<Route path={`${match.path}/settings`} component={SettingsContainer} exact/>
6773
</Switch>
6874
</React.Fragment>
6975
}

0 commit comments

Comments
 (0)