Skip to content

Commit feae45b

Browse files
committed
fix: update the schema file so that calls can be made properly to the new endpoints
1 parent b8ad1e4 commit feae45b

File tree

4 files changed

+250
-19
lines changed

4 files changed

+250
-19
lines changed

src/ListItems.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export const mainListItems = (
3131
</ListItemIcon>
3232
<ListItemText primary='Update Data' />
3333
</ListItemButton>
34-
<ListItemButton onClick={() => window.open('/admin/new-edit-site', '_self')}>
34+
<ListItemButton
35+
onClick={() => window.open('/admin/new-edit-site', '_self')}
36+
>
3537
<ListItemIcon>
3638
<EditIcon />
3739
</ListItemIcon>

src/admin/NewEditSite.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ const parseSitesFromJSON = (jsonString: string): Site[] => {
3030
address: site.address,
3131
cell_id: site.cell_id,
3232
color: site.color,
33-
boundary: site.boundary?.map((point: any) => ({
34-
lat: point.lat,
35-
lng: point.lng
36-
})) ?? [],
33+
boundary:
34+
site.boundary?.map((point: any) => ({
35+
lat: point.lat,
36+
lng: point.lng,
37+
})) ?? [],
3738
};
3839
});
3940

4041
return sites;
4142
} catch (error) {
42-
console.error("Failed to parse sites JSON:", error);
43+
console.error('Failed to parse sites JSON:', error);
4344
return [];
4445
}
4546
};
4647

47-
4848
export default function NewEditSite() {
4949
const [sites, setSites] = useState<Site[]>([]);
5050
const handleEdit = (siteName: string) => {
@@ -79,14 +79,14 @@ export default function NewEditSite() {
7979
});
8080

8181
return (
82-
<Container maxWidth="md" sx={{ mt: 4, mb: 4 }}>
82+
<Container maxWidth='md' sx={{ mt: 4, mb: 4 }}>
8383
<Paper elevation={3} sx={{ p: 3 }}>
84-
<Typography variant="h4" component="h1" gutterBottom>
84+
<Typography variant='h4' component='h1' gutterBottom>
8585
Site Management
8686
</Typography>
87-
87+
8888
<List>
89-
{sites.map((site) => (
89+
{sites.map(site => (
9090
<ListItem
9191
key={site.name}
9292
sx={{
@@ -98,16 +98,16 @@ export default function NewEditSite() {
9898
>
9999
<ListItemText
100100
primary={
101-
<Typography variant="h6" component="div">
101+
<Typography variant='h6' component='div'>
102102
{site.name}
103103
</Typography>
104104
}
105105
sx={{ flexGrow: 1 }}
106106
/>
107107
<Box sx={{ display: 'flex', gap: 1, ml: 2 }}>
108108
<Button
109-
variant="contained"
110-
color="warning"
109+
variant='contained'
110+
color='warning'
111111
onClick={() => handleEdit(site.name)}
112112
sx={{
113113
backgroundColor: '#d4af37',
@@ -120,8 +120,8 @@ export default function NewEditSite() {
120120
Edit
121121
</Button>
122122
<Button
123-
variant="contained"
124-
color="error"
123+
variant='contained'
124+
color='error'
125125
onClick={() => handleDelete(site.name)}
126126
sx={{
127127
backgroundColor: '#d32f2f',
@@ -140,8 +140,8 @@ export default function NewEditSite() {
140140

141141
{/* Floating Action Button */}
142142
<Fab
143-
color="primary"
144-
aria-label="add"
143+
color='primary'
144+
aria-label='add'
145145
onClick={handleAdd}
146146
sx={{
147147
position: 'fixed',

src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ type Measurement = {
7777
ping: number;
7878
site: string;
7979
device_id: number;
80-
};
80+
};

src/types/api.d.ts

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,57 @@ export interface paths {
435435
patch?: never;
436436
trace?: never;
437437
};
438+
'/api/public-sites': {
439+
parameters: {
440+
query?: never;
441+
header?: never;
442+
path?: never;
443+
cookie?: never;
444+
};
445+
/**
446+
* Get sites list
447+
* @description Returns a list of public sites
448+
*/
449+
get: {
450+
parameters: {
451+
query?: never;
452+
header?: never;
453+
path?: never;
454+
cookie?: never;
455+
};
456+
requestBody?: never;
457+
responses: {
458+
/** @description List of public sites */
459+
200: {
460+
headers: {
461+
[name: string]: unknown;
462+
};
463+
content: {
464+
'application/json': {
465+
/** @description List of sites */
466+
sites?: components['schemas']['Site'][];
467+
};
468+
};
469+
};
470+
/** @description Server error */
471+
500: {
472+
headers: {
473+
[name: string]: unknown;
474+
};
475+
content: {
476+
'text/plain': string;
477+
};
478+
};
479+
};
480+
};
481+
put?: never;
482+
post?: never;
483+
delete?: never;
484+
options?: never;
485+
head?: never;
486+
patch?: never;
487+
trace?: never;
488+
};
438489
'/secure/get_groups': {
439490
parameters: {
440491
query?: never;
@@ -1075,6 +1126,184 @@ export interface paths {
10751126
patch?: never;
10761127
trace?: never;
10771128
};
1129+
'/api/secure-site': {
1130+
parameters: {
1131+
query?: never;
1132+
header?: never;
1133+
path?: never;
1134+
cookie?: never;
1135+
};
1136+
get?: never;
1137+
/**
1138+
* Update an existing site
1139+
* @description Updates an existing site with the provided information
1140+
*/
1141+
put: {
1142+
parameters: {
1143+
query?: never;
1144+
header?: never;
1145+
path?: never;
1146+
cookie?: never;
1147+
};
1148+
requestBody: {
1149+
content: {
1150+
'application/json': components['schemas']['Site'];
1151+
};
1152+
};
1153+
responses: {
1154+
/** @description Site successfully updated */
1155+
200: {
1156+
headers: {
1157+
[name: string]: unknown;
1158+
};
1159+
content: {
1160+
'text/plain': string;
1161+
};
1162+
};
1163+
/** @description Bad request - invalid site data */
1164+
400: {
1165+
headers: {
1166+
[name: string]: unknown;
1167+
};
1168+
content: {
1169+
'text/plain': string;
1170+
};
1171+
};
1172+
/** @description Unauthorized - User not logged in */
1173+
401: {
1174+
headers: {
1175+
[name: string]: unknown;
1176+
};
1177+
content: {
1178+
'text/plain': string;
1179+
};
1180+
};
1181+
/** @description Server error while updating site */
1182+
500: {
1183+
headers: {
1184+
[name: string]: unknown;
1185+
};
1186+
content: {
1187+
'text/plain': string;
1188+
};
1189+
};
1190+
};
1191+
};
1192+
/**
1193+
* Add a new site
1194+
* @description Creates a new site with the provided information
1195+
*/
1196+
post: {
1197+
parameters: {
1198+
query?: never;
1199+
header?: never;
1200+
path?: never;
1201+
cookie?: never;
1202+
};
1203+
requestBody: {
1204+
content: {
1205+
'application/json': components['schemas']['Site'];
1206+
};
1207+
};
1208+
responses: {
1209+
/** @description Site successfully created */
1210+
201: {
1211+
headers: {
1212+
[name: string]: unknown;
1213+
};
1214+
content: {
1215+
'text/plain': string;
1216+
};
1217+
};
1218+
/** @description Bad request - invalid site data */
1219+
400: {
1220+
headers: {
1221+
[name: string]: unknown;
1222+
};
1223+
content: {
1224+
'text/plain': string;
1225+
};
1226+
};
1227+
/** @description Unauthorized - User not logged in */
1228+
401: {
1229+
headers: {
1230+
[name: string]: unknown;
1231+
};
1232+
content: {
1233+
'text/plain': string;
1234+
};
1235+
};
1236+
/** @description Server error while creating site */
1237+
500: {
1238+
headers: {
1239+
[name: string]: unknown;
1240+
};
1241+
content: {
1242+
'text/plain': string;
1243+
};
1244+
};
1245+
};
1246+
};
1247+
/**
1248+
* Delete a site
1249+
* @description Removes an existing site from the system
1250+
*/
1251+
delete: {
1252+
parameters: {
1253+
query?: never;
1254+
header?: never;
1255+
path?: never;
1256+
cookie?: never;
1257+
};
1258+
requestBody: {
1259+
content: {
1260+
'application/json': components['schemas']['Site'];
1261+
};
1262+
};
1263+
responses: {
1264+
/** @description Site successfully deleted */
1265+
200: {
1266+
headers: {
1267+
[name: string]: unknown;
1268+
};
1269+
content: {
1270+
'text/plain': string;
1271+
};
1272+
};
1273+
/** @description Bad request - invalid site data */
1274+
400: {
1275+
headers: {
1276+
[name: string]: unknown;
1277+
};
1278+
content: {
1279+
'text/plain': string;
1280+
};
1281+
};
1282+
/** @description Unauthorized - User not logged in */
1283+
401: {
1284+
headers: {
1285+
[name: string]: unknown;
1286+
};
1287+
content: {
1288+
'text/plain': string;
1289+
};
1290+
};
1291+
/** @description Server error while deleting site */
1292+
500: {
1293+
headers: {
1294+
[name: string]: unknown;
1295+
};
1296+
content: {
1297+
'text/plain': string;
1298+
};
1299+
};
1300+
};
1301+
};
1302+
options?: never;
1303+
head?: never;
1304+
patch?: never;
1305+
trace?: never;
1306+
};
10781307
}
10791308
export type webhooks = Record<string, never>;
10801309
export interface components {

0 commit comments

Comments
 (0)