Skip to content
This repository was archived by the owner on Aug 17, 2024. It is now read-only.

Commit

Permalink
[master] Push
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan.genov committed Mar 18, 2020
1 parent a9f62ab commit d9bce38
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 29 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,4 @@ https://github.com/Michaelpalacce/Server/releases

#Future Improvements:
- A terminal emulator
- User section
- Ability to connect to a different server to serve as a connection between your devices and a private instance of the Server Emulator
4 changes: 4 additions & 0 deletions UPDATELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
8.11.2
- Updated the README
- Moved some controllers around

8.11.1
- Changed some text

Expand Down
6 changes: 4 additions & 2 deletions handlers/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

require( './main/security' );

require( './ip/controller/controller' );
require( './ip/controller/view' );
require( './file/controller/move' );
require( './file/controller/file_data' );
require( './file/controller/download' );
require( './file/controller/upload' );
require( './file/controller/delete' );
require( './file/controller/preview' );
require( './folder/controller/browse' );
require( './folder/controller/view' );
require( './folder/controller/list' );
require( './folder/controller/delete' );
require( './folder/controller/upload' );
require( './folder/controller/move' );
Expand All @@ -18,3 +19,4 @@ require( './user/controller/add' );
require( './user/controller/get' );
require( './user/controller/delete' );
require( './user/controller/update' );
require( './terminal/controller/view' );
28 changes: 28 additions & 0 deletions handlers/folder/controller/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

const { Server } = require( 'event_request' );
const app = Server();
const PathHelper = require( '../../main/path' );
const BrowseInput = require( '../input/browse_input' );

/**
* @brief Adds a '/browse/getFiles' route with method GET
*
* @details Required Parameters: NONE
* Optional Parameters: dir, position
*
* @return void
*/
app.get( '/browse/getFiles', ( event )=>{
const input = new BrowseInput( event );

if ( ! input.isValid() )
throw new Error( 'Invalid params' );

const dir = input.getDir();

PathHelper.getItems( event, dir, input.getPosition() ).then(( data ) => {
const { items, position, hasMore } = data;

event.send( { items, position, dir, hasMore } )
}).catch( event.next );
} );
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
const { Server } = require( 'event_request' );
const app = Server();

const PathHelper = require( '../../main/path' );
const BrowseInput = require( '../input/browse_input' );

/**
Expand Down Expand Up @@ -40,26 +39,3 @@ app.get( '/browse', async ( event )=>{

event.render( 'browse', { dir: encodeURIComponent( input.getDir() ) } );
} );

/**
* @brief Adds a '/browse/getFiles' route with method GET
*
* @details Required Parameters: NONE
* Optional Parameters: dir, position
*
* @return void
*/
app.get( '/browse/getFiles', ( event )=>{
const input = new BrowseInput( event );

if ( ! input.isValid() )
throw new Error( 'Invalid params' );

const dir = input.getDir();

PathHelper.getItems( event, dir, input.getPosition() ).then(( data ) => {
const { items, position, hasMore } = data;

event.send( { items, position, dir, hasMore } )
}).catch( event.next );
} );
File renamed without changes.
7 changes: 7 additions & 0 deletions handlers/terminal/controller/view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { Server } = require( 'event_request' );

const app = Server();

app.get( '/terminal', ( event )=>{
event.render( 'terminal', {} )
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "server-emulator",
"version": "8.11.1",
"version": "8.11.2",
"description": "Server emulator used to easily emulate the FS in a browser and allow streaming,downloading,deletion, etc.",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ app.apply( 'er_env' );
// Configure the plugins
require( './handlers/main/bootstrap_plugins' );

app.apply( app.er_static_resources, { paths : [process.env.STATIC_PATH, 'favicon.ico'] } );
app.apply( app.er_static_resources, { paths : [process.env.STATIC_PATH, 'favicon.ico', '/node_modules/xterm/'] } );
app.apply( app.er_body_parser_form );
app.apply( app.er_body_parser_json );
app.apply( app.er_body_parser_multipart, { tempDir : path.join( PROJECT_ROOT, process.env.UPLOADS_DIR ) } );
Expand Down
25 changes: 25 additions & 0 deletions templates/terminal.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<%- include("components/partial/stylesheets") %>
<link rel="stylesheet" href="/node_modules/xterm/css/xterm.css" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Server Emulator</title>
</head>
<body>
<%- include("components/modal", { active: "terminal" }) %>
<%- include("components/sidebar", { active: "terminal" }) %>

<div class="container pt-5" style="color: gray">

</div>
</body>
<%- include("components/partial/js-libs") %>
<script src="node_modules/xterm/lib/xterm.js"></script>
<script>
const term = new Terminal();
term.open( document.getElementById( 'terminal' ) );
term.write( 'Hello from \x1B[1;3;31mxterm.js\x1B[0m $ ' );
</script>
</html>

0 comments on commit d9bce38

Please sign in to comment.