Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nodecloud web issues #40

Merged
merged 4 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions client/src/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { history } from "../_helpers/history.js";
import { alertActions } from "../_actions/alert.actions.js";
import { PrivateRoute } from "../_components/PrivateRoute.js";
import { HomePage } from "../HomePage/HomePage.js";
import { LoginPage } from "../LoginPage/LoginPage.js";
import { SignupPage } from "../SignupPage/SignupPage.js";
import { LoginPage, SignupPage } from "../Auth";
import { VirtualMachine } from "../CreateServices/VirtualMachine.js";
import { VirtualNetwork } from "../CreateServices/VirtualNetwork.js";
import { Database } from "../CreateServices/Database.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from "react";
import { Link } from "react-router-dom";
import { connect } from "react-redux";

import { userActions } from "../_actions/user.actions.js";
import "./LoginPage.css";
import { userActions } from "../../_actions/user.actions.js";

class LoginPage extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -62,7 +61,7 @@ class LoginPage extends React.Component {
<div className="innerBox">
<div className="logoHolder">
<img
src={require("../media/nodecloudlogo.png")}
src={require("../../media/nodecloudlogo.png")}
alt="Nodecloud Logo"
className="logo"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { Link } from "react-router-dom";
import { connect } from "react-redux";

import { userActions } from "../_actions/user.actions.js";
import { userActions } from "../../_actions/user.actions.js";

class SignupPage extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -47,7 +47,6 @@ class SignupPage extends React.Component {
dispatch(userActions.register(user));
}
}

handleValidation() {
const { user } = this.state;
let isFormValid = true;
Expand Down Expand Up @@ -127,7 +126,7 @@ class SignupPage extends React.Component {
<div className="innerBox">
<div className="logoHolder">
<img
src={require("../media/nodecloudlogo.png")}
src={require("../../media/nodecloudlogo.png")}
alt="Nodecloud Logo"
className="logo"
/>
Expand Down
5 changes: 5 additions & 0 deletions client/src/Auth/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { LoginPage } from "./LoginPage/LoginPage";
import { SignupPage } from "./SignupPage/SignupPage";
import "./style.css";

export { LoginPage, SignupPage };
48 changes: 42 additions & 6 deletions client/src/LoginPage/LoginPage.css → client/src/Auth/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,22 @@
display: flex;
}
.innerBox {
width: 65%;
height: 60%;
background-color: aqua;
position: absolute;
max-width: 900px;
margin: 0 auto;
width: 100%;
border-radius: 22px;
flex-direction: row;
display: flex;
flex-wrap: wrap;
}
@media screen and (max-width: 840px) {
.innerBox {
margin: 0 20px;
}
}
.logoHolder {
width: 40%;
height: 100%;
min-height: 450px;
border-top-left-radius: 22px;
border-bottom-left-radius: 22px;
background-image: linear-gradient(#009cff, #0080d4);
Expand All @@ -28,7 +33,6 @@
}
.formHolder {
width: 60%;
height: 100%;
border-top-right-radius: 22px;
border-bottom-right-radius: 22px;
background-color: white;
Expand All @@ -39,23 +43,55 @@
align-items: center;
display: flex;
}
@media screen and (max-width: 640px) {
.logoHolder,
.formHolder {
width: 100%;
}
.logoHolder {
border-radius: 0px;
min-height: 200px;
border-top-right-radius: 22px;
border-top-left-radius: 22px;
}
.formHolder {
border: 1px solid #d2d2d2;
border-radius: 0px;
padding: 30px 3px;
border-bottom-left-radius: 22px;
border-bottom-right-radius: 22px;
}
}

.logo {
width: 100px;
height: 100px;
background-color: #fcfcfc;
border-radius: 50px;
margin-top: 30%;
}
@media screen and (max-width: 640px) {
.logo {
margin-top: 10%;
}
}

.title {
font-family: Courier;
letter-spacing: 1;
color: white;
margin-top: 20%;
font-size: 24px;
}
@media screen and (max-width: 640px) {
.title {
margin-top: 10%;
}
}
.subtitle {
font-size: 14px;
color: #c4daff;
padding-bottom: 20px;
}
.label {
align-self: left;
Expand Down
114 changes: 0 additions & 114 deletions client/src/SignupPage/SignupPage.css

This file was deleted.

1 change: 0 additions & 1 deletion client/src/_helpers/PageNotFound.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import { Link } from "react-router-dom";
import { Icon } from "semantic-ui-react";
import "../LoginPage/LoginPage.css";

class PageNotFound extends React.Component {
constructor(props) {
Expand Down
9 changes: 8 additions & 1 deletion client/src/_services/user.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ function register(user) {

return fetch(Urls.BASE_URL + Urls.SUB_URL_SIGNUP, requestOptions).then(
handleResponse
);
).then(res => {
if (res.success) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem("user", JSON.stringify(res.data));
localStorage.setItem("access_token", res.token);
}
return res;
});
}

function createVirtualMachine(params) {
Expand Down
8 changes: 4 additions & 4 deletions server/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const options = {
useNullAsDefault: true
};

const createTableUser = () => {
const createTableUser = async () => {

const knex = require("knex")(options);
if(knex.schema.hasTable("users")) return;
if(await knex.schema.hasTable("users")) return;

knex.schema
.createTable("users", function(t) {
Expand All @@ -37,10 +37,10 @@ const createTableUser = () => {
// db.run("CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT UNIQUE, username TEXT, password TEXT)");
};

const createTableService = () => {
const createTableService = async () => {

const knex = require("knex")(options);
if(knex.schema.hasTable("services")) return;
if(await knex.schema.hasTable("services")) return;

knex.schema
.createTable("services", function(t) {
Expand Down
Binary file modified server/db.sqlite3
Binary file not shown.
2 changes: 1 addition & 1 deletion server/knexfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = {
client: "sqlite3",
connection: {
filename: "./user.sqlite3"
filename: "./db.sqlite3"
},
useNullAsDefault: true

Expand Down