Skip to content

Commit 60716b8

Browse files
committed
2 parents 048c9c0 + ba86626 commit 60716b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+14779
-39
lines changed

.devcontainer/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM mcr.microsoft.com/vscode/devcontainers/universal:linux as builder
2+
USER root
3+
WORKDIR /app
4+
COPY . ./
5+
ENV TSFILE=tailscale_1.24.2_amd64.tgz
6+
RUN wget https://pkgs.tailscale.com/stable/${TSFILE} && \
7+
tar xzf ${TSFILE} --strip-components=1
8+
COPY . ./
9+
10+
FROM mcr.microsoft.com/vscode/devcontainers/universal:linux
11+
USER root
12+
13+
RUN apt-get update && apt-get install -y curl gpg dnsutils
14+
COPY tailscaled /etc/init.d/tailscaled
15+
COPY --from=builder /app/tailscaled /usr/sbin/tailscaled
16+
COPY --from=builder /app/tailscale /usr/bin/tailscale
17+
18+
RUN mkdir -p /var/run/tailscale /var/cache/tailscale /var/lib/tailscale

.devcontainer/devcontainer.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "Tailscale-enabled Codespace",
3+
"dockerFile": "Dockerfile",
4+
"context": "..",
5+
"runArgs": [
6+
"--cap-add=NET_ADMIN",
7+
"--cap-add=NET_RAW",
8+
"--device=/dev/net/tun"
9+
],
10+
"postStartCommand": "/etc/init.d/tailscaled start",
11+
}

diagram.svg

Lines changed: 1 addition & 1 deletion
Loading

firebase-storage-react/src/App.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717
width: 100%;
1818
}
1919

20+
.app__progress {
21+
width: 100%;
22+
height: 10px;
23+
background-color: #4caf50;
24+
position: relative;
25+
margin-top: 10px;
26+
}
27+
2028
.app {
2129
height: 100vh;
2230
display: flex;

firebase-storage-react/src/App.js

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,75 @@
1-
import { getDownloadURL, ref, uploadBytes } from 'firebase/storage';
2-
import './App.css';
3-
import { storage } from './firebase';
1+
import {
2+
getDownloadURL,
3+
ref,
4+
uploadBytes,
5+
uploadBytesResumable,
6+
} from "firebase/storage";
7+
import { useState } from "react";
48

9+
import "./App.css";
10+
import { storage } from "./firebase";
511

612
export default function App() {
7-
const handleSubmit = async (e) => {
8-
e.preventDefault();
9-
const file = e.target[0]?.files[0];
10-
if (!file) return null;
13+
const [progressPercent, setProgressPercent] = useState(0);
1114

12-
const storageRef = ref(storage, `files/${file.name}`);
13-
const snapshot = await uploadBytes(storageRef, file);
14-
// console.log(snapshot);
15-
if (snapshot) {
16-
e.target[0].value = null;
17-
const url = await getDownloadURL(storageRef)
18-
console.log(url);
19-
}
20-
}
15+
const handleSubmit = async (e) => {
16+
e.preventDefault();
17+
const file = e.target[0]?.files[0];
18+
console.log(`Handle Submit`, e.target[0].files);
19+
if (!file) return null;
2120

22-
return (
23-
<div className='App'>
24-
<div className="app" name="upload_file">
25-
<form className='app__form' onSubmit={handleSubmit}>
26-
<input type="file" />
27-
<button type="submit" className="button" onClick={e => e.preventDefault()}>Upload</button>
28-
</form>
29-
</div>
30-
</div >
31-
);
21+
const storageRef = ref(storage, `files/${file.name}`);
22+
// const snapshot = await uploadBytes(storageRef, file);
23+
24+
// console.log(snapshot);
25+
// if (snapshot) {
26+
// e.target[0].value = null;
27+
// const url = await getDownloadURL(storageRef);
28+
// console.log(url);
29+
// }
30+
31+
const uploadTask = uploadBytesResumable(storageRef, file);
32+
uploadTask.on(
33+
"state_changed",
34+
(snapshot) => {
35+
const progress = Math.round(
36+
(snapshot.bytesTransferred / snapshot.totalBytes) * 100
37+
);
38+
setProgressPercent(progress);
39+
},
40+
(error) => {
41+
switch (error.code) {
42+
case `storage/cancelled`:
43+
alert(`Upload cancelled`);
44+
break;
45+
default:
46+
alert(error);
47+
}
48+
},
49+
() => {
50+
e.target[0].value = "";
51+
getDownloadURL(storageRef).then((downloadURL) => {
52+
console.log(downloadURL);
53+
});
54+
}
55+
);
56+
};
57+
58+
return (
59+
<div className="App">
60+
<div className="app" name="upload_file">
61+
<form className="app__form" onSubmit={handleSubmit}>
62+
<input type="file" />
63+
<progress
64+
className="app__progress"
65+
value={progressPercent}
66+
max="100"
67+
/>
68+
<button type="submit" className="button">
69+
Upload
70+
</button>
71+
</form>
72+
</div>
73+
</div>
74+
);
3275
}

firebase-storage-react/src/firebase.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { getStorage } from "firebase/storage";
44

55
// Your web app's Firebase configuration
66
const firebaseConfig = {
7-
apiKey: "AIzaSyC5GB1ONo0cr4qAqZ9heNlaCLz6YWm2ZlM",
8-
authDomain: "firestore-react-tut.firebaseapp.com",
9-
projectId: "firestore-react-tut",
10-
storageBucket: "firestore-react-tut.appspot.com",
11-
messagingSenderId: "729522566387",
12-
appId: "1:729522566387:web:c5c73bcddefcaab175b386",
7+
apiKey: "AIzaSyB5DrC2FCtPhuFQ7kdxkt9TP0MBTq_Dwh0",
8+
authDomain: "fir-storage-react-6fc1b.firebaseapp.com",
9+
projectId: "fir-storage-react-6fc1b",
10+
storageBucket: "fir-storage-react-6fc1b.appspot.com",
11+
messagingSenderId: "348005102029",
12+
appId: "1:348005102029:web:7fa794cdf3ab020b801484"
1313
};
1414

1515
// Initialize Firebase

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"@mui/x-data-grid": "^5.12.0"
4+
}
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Use the draft/non-production database credentials here.
2+
PLANETSCALE_PRISMA_DATABASE_URL=mysql://draftbranch_username:[email protected]/test-database?sslaccept=strict
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Verify dependency licenses
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types:
9+
- opened
10+
- reopened
11+
- synchronize
12+
13+
jobs:
14+
licensing:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
with:
19+
fetch-depth: 0
20+
- run: sudo gem install license_finder
21+
- run: npm install
22+
- run: license_finder
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
netlify.toml
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env
29+
.env.local
30+
.env.development.local
31+
.env.test.local
32+
.env.production.local
33+
34+
# vercel
35+
.vercel

0 commit comments

Comments
 (0)