Skip to content

Commit f34d9a9

Browse files
committed
added copy download url and makefile build changes
1 parent 1e0d81a commit f34d9a9

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ clean:
88
build: ui/build build/server
99
build/server:
1010
# cd server && go build -ldflags "-w -X main.VERSION=$(VERSION)" -o '../build/server'
11-
cd server && rice embed-go && CGO_ENABLED=1 gox \
11+
cd server && rice embed-go && CGO_ENABLED=0 gox \
1212
-osarch="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64" \
1313
-ldflags "-w -X main.VERSION=$(VERSION)" \
1414
-output="../build/{{.OS}}/{{.Arch}}/loadster" \

ui/src/pages/Home/Download.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ interface Asset {
1919
}
2020

2121
function ReleaseDropdown() {
22+
const [copy, setCopy] = useState<string>("");
2223
const [releases, setReleases] = useState<Release[]>([]);
2324
const [selectedRelease, setSelectedRelease] = useState<number | null>(null);
2425
const [selectedOS, setSelectedOS] = useState<string>("");
@@ -42,6 +43,11 @@ function ReleaseDropdown() {
4243
fetchReleases();
4344
}, []);
4445

46+
const onCopy = (text) => {
47+
navigator.clipboard.writeText(text);
48+
setCopy(() => text);
49+
};
50+
4551
useEffect(() => {
4652
// Fetch OS names for the selected release
4753
const fetchOSOptions = async () => {
@@ -122,10 +128,11 @@ function ReleaseDropdown() {
122128
};
123129

124130
const handleArchChange = (event: React.ChangeEvent<HTMLSelectElement>) => {
131+
setCopy("");
125132
setSelectedArch(event.target.value);
126133
};
127134

128-
const handleDownloadClick = () => {
135+
const handleDownloadClick = (isCopy?: boolean) => {
129136
if (selectedRelease && selectedOS && selectedArch) {
130137
const fileName = `${selectedOS}-${selectedArch}.tar.gz`;
131138
const selectedReleaseData = releases.find(
@@ -138,10 +145,14 @@ function ReleaseDropdown() {
138145
)?.browser_download_url;
139146
if (downloadUrl) {
140147
// Create a temporary link element and simulate click to trigger download
141-
const link = document.createElement("a");
142-
link.href = downloadUrl;
143-
link.download = fileName;
144-
link.click();
148+
if (isCopy) {
149+
onCopy(`wget ${downloadUrl}`);
150+
} else {
151+
const link = document.createElement("a");
152+
link.href = downloadUrl;
153+
link.download = fileName;
154+
link.click();
155+
}
145156
} else {
146157
console.error("Download URL not found for selected options.");
147158
}
@@ -193,11 +204,18 @@ function ReleaseDropdown() {
193204
</Box>
194205
<Button
195206
colorScheme="primary"
196-
onClick={handleDownloadClick}
207+
onClick={() => handleDownloadClick()}
197208
isDisabled={!selectedArch}
198209
>
199210
Download
200211
</Button>
212+
<Button
213+
onClick={() => {
214+
handleDownloadClick(true);
215+
}}
216+
>
217+
{copy ? "Copied!" : "Copy Url"}
218+
</Button>
201219
</HStack>
202220
);
203221
}

0 commit comments

Comments
 (0)