Skip to content

Commit

Permalink
Merge pull request #2 from stappjno/feature/teddycloud-web
Browse files Browse the repository at this point in the history
Feature/teddycloud web
  • Loading branch information
SciLor authored Jul 28, 2023
2 parents 375385c + d47beb8 commit 8cac1be
Show file tree
Hide file tree
Showing 51 changed files with 35,124 additions and 1 deletion.
49 changes: 49 additions & 0 deletions contrib/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,10 @@ <h2>Client certificate upload</h2>
path: '/',
files: [],
selectedFiles: [],
<<<<<<< HEAD
tonies: [],
=======
>>>>>>> bcbad4f (fix web interface, uploading etc)
};
this.fetchFileIndex = this.fetchFileIndex.bind(this);
this.uploadFiles = this.uploadFiles.bind(this);
Expand All @@ -728,7 +731,10 @@ <h2>Client certificate upload</h2>
this.deleteSelectedFiles = this.deleteSelectedFiles.bind(this);
this.toggleFileSelection = this.toggleFileSelection.bind(this);
this.selectAllFiles = this.selectAllFiles.bind(this);
<<<<<<< HEAD
this.oggPlayerRef = React.createRef();
=======
>>>>>>> bcbad4f (fix web interface, uploading etc)
}

componentDidMount() {
Expand Down Expand Up @@ -840,7 +846,11 @@ <h2>Client certificate upload</h2>
const response = await fetch(api, {
method: 'POST',
headers: { 'Content-Type': 'text/plain' },
<<<<<<< HEAD
body: this.state.path + '/' + file.name,
=======
body: this.state.path + file.name,
>>>>>>> bcbad4f (fix web interface, uploading etc)
});

if (response.ok && await response.text() === 'OK') {
Expand All @@ -854,9 +864,13 @@ <h2>Client certificate upload</h2>
}
}

<<<<<<< HEAD
if (failedCount > 0) {
alert(`Deleted: ${deletedCount}, Failed: ${failedCount} `);
}
=======
alert(`Deleted: ${deletedCount}, Failed: ${failedCount} `);
>>>>>>> bcbad4f (fix web interface, uploading etc)
this.setState({ selectedFiles: [] });
this.fetchFileIndex(this.state.path); // Refresh files after delete
}
Expand Down Expand Up @@ -922,6 +936,7 @@ <h2>File Viewer</h2>
</pre>
)}

<<<<<<< HEAD
{this.state.files.map((file, index) => {
let maxLen = 24;
let filename = file.name.substring(0, maxLen);
Expand Down Expand Up @@ -1008,13 +1023,47 @@ <h2>File Viewer</h2>
})
}

=======
{this.state.files.map((file, index) => (
<pre key={index} style={{ fontFamily: 'monospace' }}>
<input
type="checkbox"
checked={this.state.selectedFiles.includes(file)}
onChange={() => this.toggleFileSelection(file)}
/>
{file.isDirectory ? (
<React.Fragment>
<a href="#" onClick={(e) => { e.preventDefault(); this.fetchFileIndex(`${this.state.path}${file.name}/`); }}>
{file.name}
</a >
<span>{' '.repeat(32 - file.name.length)}</span>
<span>{file.date}</span>
<span>{'-'.padStart(10)}</span>
</React.Fragment >
) : (
<React.Fragment>
<a href={`/content${this.state.path}${file.name}`} target="_blank" rel="noopener noreferrer">
{file.name}
</a >
<span>{' '.repeat(32 - file.name.length)}</span>
<span>{file.date.padEnd(10)}</span>
<span>{file.size.padStart(10)}</span>
</React.Fragment>
)
}
</pre >
))}
>>>>>>> bcbad4f (fix web interface, uploading etc)
</div >
);
}
}


<<<<<<< HEAD

=======
>>>>>>> bcbad4f (fix web interface, uploading etc)
class App extends React.Component {
constructor(props) {
super(props);
Expand Down
10 changes: 10 additions & 0 deletions include/handler_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ error_t handleApiGet(HttpConnection *connection, const char_t *uri, const char_t
error_t handleApiSet(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleApiTrigger(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleApiFileIndex(HttpConnection *connection, const char_t *uri, const char_t *queryString);
<<<<<<< HEAD
<<<<<<< HEAD
=======
>>>>>>> bcbad4f (fix web interface, uploading etc)
error_t handleApiFileUpload(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleApiDirectoryCreate(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleApiFileDelete(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleApiDirectoryDelete(HttpConnection *connection, const char_t *uri, const char_t *queryString);
<<<<<<< HEAD
=======
error_t handleApiFileUpload(HttpConnection *connection, const char_t *uri, const char_t *queryString);
>>>>>>> e6efbc1 (passthrough queryString)
=======
>>>>>>> bcbad4f (fix web interface, uploading etc)
6 changes: 5 additions & 1 deletion include/handler_cloud.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ error_t handleCloudClaim(HttpConnection *connection, const char_t *uri, const ch
error_t handleCloudContent(HttpConnection *connection, const char_t *uri, const char_t *queryString, bool_t noPassword);
error_t handleCloudContentV1(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleCloudContentV2(HttpConnection *connection, const char_t *uri, const char_t *queryString);
<<<<<<< HEAD
error_t handleCloudFreshnessCheck(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleCloudReset(HttpConnection *connection, const char_t *uri, const char_t *queryString);
error_t handleCloudReset(HttpConnection *connection, const char_t *uri, const char_t *queryString);
=======
error_t handleCloudFreshnessCheck(HttpConnection *connection, const char_t *uri, const char_t *queryString);
>>>>>>> e6efbc1 (passthrough queryString)
3 changes: 3 additions & 0 deletions run-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker-compose -f docker/docker-compose.yaml up
6 changes: 6 additions & 0 deletions src/handler_cloud.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ error_t handleCloudClaim(HttpConnection *connection, const char_t *uri, const ch
}
freeTonieInfo(&tonieInfo);

<<<<<<< HEAD
=======
cbr_ctx_t ctx;
req_cbr_t cbr = getCloudCbr(connection, uri, queryString, V1_CLAIM, &ctx);
cloud_request_get(NULL, 0, uri, queryString, token, &cbr);
>>>>>>> e6efbc1 (passthrough queryString)
return NO_ERROR;
}

Expand Down
1 change: 1 addition & 0 deletions teddycloud-web/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TEDDYCLOUD_API_URL=http://localhost/api
23 changes: 23 additions & 0 deletions teddycloud-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
46 changes: 46 additions & 0 deletions teddycloud-web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Getting Started with Create React App

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

## Available Scripts

In the project directory, you can run:

### `npm start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `npm test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `npm run build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
Loading

0 comments on commit 8cac1be

Please sign in to comment.