Skip to content

Commit 2aff349

Browse files
authored
πŸ₯–πŸ•οΈ ↝ [FCDB-3 CPW-2 SGV2-141]: Merge pull request #134 from Signal-K/CPW-2
πŸ¦”πŸ₯– ↝ [FCDB-3 CPW-2 SGV2-141]: Post cards & content from V1.0 into FCDB project/board
2 parents 0ba897f + 6b68267 commit 2aff349

39 files changed

+759
-167
lines changed

β€Ž.github/workflows/deta.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Push to Space
2+
on: push
3+
4+
jobs:
5+
push-to-space:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v3
9+
- name: Deta Space Deployment Github Action
10+
uses: neobrains/space-deployment-github-action@v0.5
11+
with:
12+
access_token: ${{ secrets.ACCESS_TOKEN }}
13+
project_id: ${{ secrets.PROJECT_ID }}
14+
space_push: true
15+
list_on_discovery: true

β€Ž.vscode/settings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"jira-plugin.workingProject": "",
33
"liveServer.settings.port": 5501,
4-
"solidity.defaultCompiler": "localFile",
5-
"solidity.compileUsingRemoteVersion": "v0.8.11+commit.d7f03943"
4+
"solidity.compileUsingRemoteVersion": "v0.8.11+commit.d7f03943",
5+
"solidity.defaultCompiler": "localFile"
66
}

β€ŽSpacefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Spacefile Docs: https://go.deta.dev/docs/spacefile/v0
2+
v: 0
3+
micros:
4+
- name: client
5+
src: ./
6+
engine: next
7+
primary: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import { PlanetGalleryIndexComp } from '../../../../pages/tests/planets';
3+
4+
interface Anomaly {
5+
id: string;
6+
name: string;
7+
icon: string;
8+
}
9+
10+
interface GardenProps {
11+
anomalies: Anomaly[];
12+
}
13+
14+
const Garden: React.FC<GardenProps> = ({ anomalies }) => {
15+
return (
16+
<div style={{ backgroundImage: `url('/garden.png')` }} className="bg-cover bg-center h-screen w-screen flex items-center justify-center relative">
17+
{/* <button className="p-2 bg-blue-500 text-white">Add Anomaly</button> */}
18+
<PlanetGalleryIndexComp />
19+
{anomalies.map((anomaly) => (
20+
<img key={anomaly.id} src={anomaly.icon} alt={anomaly.name} className="absolute top-0 left-0 w-16 h-16" />
21+
))}
22+
</div>
23+
);
24+
};
25+
26+
export default Garden;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
3+
interface HexagonProps {
4+
filled: boolean;
5+
fillType: string;
6+
fillIcon: string;
7+
colour: string;
8+
}
9+
10+
const Hexagon: React.FC<HexagonProps> = ({ filled, fillType, fillIcon, colour }) => {
11+
const hexagonClass = filled ? 'bg-opacity-50' : 'bg-opacity-20';
12+
const outlineColor = colour || '#BBBBBB';
13+
14+
return (
15+
<div className={`hexagon ${hexagonClass}`} style={{ borderColor: outlineColor }}>
16+
{fillIcon && !filled && (
17+
<img src={fillIcon} alt="" className="w-4/5 h-4/5 mx-auto my-auto" />
18+
)}
19+
</div>
20+
);
21+
};
22+
23+
export default Hexagon;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import Hexagon from './Hexagon';
3+
4+
interface HexagonProps {
5+
filled: boolean;
6+
fillType: string;
7+
fillIcon: string;
8+
colour: string;
9+
};
10+
11+
interface HoneycombProps {
12+
hexagons: Array<HexagonProps>;
13+
backgroundImage: string;
14+
}
15+
16+
const Honeycomb: React.FC<HoneycombProps> = ({ hexagons, backgroundImage }) => {
17+
const honeycombStyle = {
18+
backgroundImage: `url(${backgroundImage})`,
19+
};
20+
21+
return (
22+
<div className="honeycomb-container" style={honeycombStyle}>
23+
<div className="grid grid-cols-3 gap-4">
24+
{hexagons.map((hexagon, index) => (
25+
<Hexagon key={index} {...hexagon} />
26+
))}
27+
</div>
28+
</div>
29+
);
30+
};
31+
32+
export default Honeycomb;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { ReactNode } from "react";
2+
3+
interface BackgroundPageProps {
4+
backgroundImage: string;
5+
children: ReactNode;
6+
}
7+
8+
const BackgroundPage: React.FC<BackgroundPageProps> = ({
9+
backgroundImage,
10+
children,
11+
}) => {
12+
const backgroundStyle: React.CSSProperties = {
13+
backgroundImage: `url(${backgroundImage})`,
14+
backgroundSize: "cover",
15+
backgroundRepeat: "no-repeat",
16+
backgroundAttachment: "fixed",
17+
position: "fixed",
18+
top: 0,
19+
left: 0,
20+
width: "100%",
21+
height: "100%",
22+
zIndex: -1,
23+
};
24+
25+
const contentContainerStyle: React.CSSProperties = {
26+
position: "relative", // To allow children to be positioned relative to this container
27+
zIndex: 1, // Ensure content appears above the background
28+
};
29+
30+
return (
31+
<div style={backgroundStyle}>
32+
<div style={contentContainerStyle}>
33+
{children}
34+
</div>
35+
</div>
36+
);
37+
};
38+
39+
export default BackgroundPage;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React, { useEffect, useState } from "react";
2+
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
3+
4+
function CreateSectorComponent({ planetId }) {
5+
const supabase = useSupabaseClient();
6+
const session = useSession();
7+
const [isLoading, setIsLoading] = useState(false);
8+
9+
const createSector = async () => {
10+
if (!session?.user?.id) {
11+
return;
12+
}
13+
14+
if (!planetId) {
15+
// User is not on a planet
16+
return;
17+
}
18+
19+
// Generate random mineral deposits
20+
const depositCount = Math.floor(Math.random() * 5);
21+
const minerals = ['Gold', 'life', 'water', 'carbon', 'iron', 'hydrogen', 'energy', 'minerals'];
22+
const deposits = [];
23+
for (let i = 0; i < depositCount; i++) {
24+
const randomMineral = minerals[Math.floor(Math.random() * minerals.length)];
25+
deposits.push(randomMineral);
26+
}
27+
28+
// Calculate cost (1 silfur for the first sector, and 1 additional silfur for each additional sector)
29+
const cost = 1 // + (1 * /* Replace with the number of sectors on the planet */);
30+
31+
// Create the new sector
32+
setIsLoading(true);
33+
const { data, error } = await supabase.from('planetsssSECTORS').upsert([
34+
{
35+
ownerId: session.user.id,
36+
planetId: planetId,
37+
cost: cost,
38+
metadata: '',
39+
deposits: deposits,
40+
sectorImage: '', // Leave this blank for now
41+
images: {}, // Leave this blank for now
42+
},
43+
]);
44+
45+
setIsLoading(false);
46+
47+
if (error) {
48+
console.error('Error creating sector:', error);
49+
// Handle the error here
50+
} else {
51+
console.log('Sector created:', data);
52+
// Handle success, e.g., show a success message
53+
}
54+
};
55+
56+
return (
57+
<div>
58+
<button onClick={createSector} disabled={isLoading}>
59+
Create Sector
60+
</button>
61+
</div>
62+
);
63+
}
64+
65+
export default CreateSectorComponent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
3+
interface Sector {
4+
id: number;
5+
metadata: string;
6+
// Add more fields as needed
7+
}
8+
9+
interface PlanetSectorsProps {
10+
sectors: Sector[];
11+
}
12+
13+
const PlanetSectors: React.FC<PlanetSectorsProps> = ({ sectors }) => {
14+
return (
15+
<div className="sector-container">
16+
{sectors.map((sector, index) => (
17+
<div key={index} className="sector">
18+
<div className="sector-number">{index + 1}</div>
19+
<div className="sector-metadata">{sector.metadata}</div>
20+
{/* Add more sector information here */}
21+
</div>
22+
))}
23+
</div>
24+
);
25+
};
26+
27+
export default PlanetSectors;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { useState } from "react";
2+
3+
function GeneratePlot() {
4+
const [plotPath, setPlotPath] = useState("");
5+
6+
const generateSectorPlot = async (ticId) => {
7+
try {
8+
const response = await fetch("http://127.0.0.1:5000/generate_sector_plot", {
9+
method: "POST",
10+
headers: {
11+
"Content-Type": "application/json",
12+
},
13+
body: JSON.stringify({ ticId }),
14+
});
15+
const data = await response.json();
16+
setPlotPath(data.plot_path);
17+
} catch (error) {
18+
console.error(error);
19+
}
20+
};
21+
22+
return (
23+
<div>
24+
<button onClick={() => generateSectorPlot("55525572")}>Generate Sector Plot</button>
25+
{plotPath && <img src={plotPath} alt="Sector Plot" />}
26+
</div>
27+
);
28+
}
29+
30+
export default GeneratePlot;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import React, { useState } from 'react';
2+
import axios from 'axios';
3+
4+
const StarInfoComponent = () => {
5+
const [ticId, setTicId] = useState('');
6+
const [starInfo, setStarInfo] = useState<{ [key: string]: string }>({});
7+
const [error, setError] = useState('');
8+
9+
const handleTicIdChange = (e: React.ChangeEvent<HTMLInputElement>) => {
10+
setTicId(e.target.value);
11+
};
12+
13+
const getStarInfo = async () => {
14+
try {
15+
const response = await axios.post('http://127.0.0.1:5000/get_star_info', { ticId });
16+
setStarInfo(response.data);
17+
setError('');
18+
} catch (error) {
19+
setError('Error: Unable to fetch star information.');
20+
setStarInfo({});
21+
}
22+
};
23+
24+
return (
25+
<div className="max-w-sm mx-auto p-4 bg-white shadow-md rounded-md">
26+
<h1 className="text-2xl font-bold mb-4">Star Information</h1>
27+
<div className="mb-4">
28+
<input
29+
type="text"
30+
placeholder="Enter TIC ID"
31+
value={ticId}
32+
onChange={handleTicIdChange}
33+
className="w-full px-3 py-2 border rounded-md"
34+
/>
35+
</div>
36+
<button onClick={getStarInfo} className="w-full bg-blue-500 text-white py-2 rounded-md">
37+
Get Star Info
38+
</button>
39+
{error && <div className="text-red-500 mt-4">{error}</div>}
40+
{Object.keys(starInfo).length > 0 && (
41+
<div className="mt-4">
42+
<h2 className="text-lg font-semibold">Star Info:</h2>
43+
<ul>
44+
{Object.entries(starInfo).map(([key, value]) => (
45+
<li key={key} className="mt-2">
46+
<strong>{key}:</strong> {value}
47+
</li>
48+
))}
49+
</ul>
50+
</div>
51+
)}
52+
</div>
53+
);
54+
};
55+
56+
export default StarInfoComponent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, { useState } from 'react';
2+
3+
interface Sector {
4+
id: number;
5+
metadata: string;
6+
// Add more fields as needed
7+
}
8+
9+
interface SectorGridProps {
10+
sectors: Sector[];
11+
}
12+
13+
const SectorGrid: React.FC<SectorGridProps> = ({ sectors }) => {
14+
const [selectedSector, setSelectedSector] = useState<Sector | null>(null);
15+
16+
const handleHexagonClick = (sector: Sector) => {
17+
setSelectedSector(sector);
18+
};
19+
20+
return (
21+
<div className="sector-grid">
22+
{sectors.map((sector, index) => (
23+
<div key={index} className="hexagon" onClick={() => handleHexagonClick(sector)}>
24+
<div className="sector-number">{index + 1}</div>
25+
</div>
26+
))}
27+
{selectedSector && (
28+
<div className="sector-info">
29+
<h2>Sector Information</h2>
30+
<p>ID: {selectedSector.id}</p>
31+
<p>Metadata: {selectedSector.metadata}</p>
32+
{/* Add more sector information here */}
33+
</div>
34+
)}
35+
</div>
36+
);
37+
};
38+
39+
export default SectorGrid;

0 commit comments

Comments
Β (0)