Skip to content

Commit

Permalink
Django Channels + React along with API translation (#46)
Browse files Browse the repository at this point in the history
* Django Channels + React along with API translation

* Allow modifying demos

* Bug fix: Modify demos

* Bug fix: Save number of components in a demo

* Render demo component

* Allow communication between demo and lib

* Removed unnecessary logging

* Removed unnecassary print statements

* Support to add root user

* Removed unwanted files

* Tests for demo and components

* Tests for permalink

* Fix PEP8 errors

* Formatted using prettier

* Add socialapp with rootsettings

* Remoeved print statements

* Modified update instructions

* Configured travis

* Fixed import for python 3

* Fixed python3 errors

* Linked to docs

* Update README.md

* Modified gitignore

* Modified Readme

* Added csrf token

* Modified travis

* Replace camelCase with underscores

* Replace Json/HttpResponse with DRF Response and status code

* Modified readme

* camelCase socket events

* Don't delete modify user on login

* Uses permalink serializer

* Use component serializers

* Always modify rootsettings

* Drop field 'id' from components

* Send Json not found instead of empty dict

* Import only required classes

* Added new line
  • Loading branch information
AvaisP committed Jul 6, 2017
1 parent 62b8ff8 commit df98e89
Show file tree
Hide file tree
Showing 71 changed files with 1,357 additions and 683 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -32,6 +32,8 @@ _templates

# SQLite
db.sqlite3
api/migrations/*
!api/migrations/__init__.py

# Bundle
django_server/static/bundles/local/*.js
Expand Down
30 changes: 30 additions & 0 deletions .travis.yml
@@ -0,0 +1,30 @@
sudo: required
language: python

python:
- "2.7"
- "3.4"

before_cache:
- rm -f $HOME/.cache/pip/log/debug.log


before_install:
- pip install -U pip
- nvm install 6.0.0
- nvm use 6.0.0
- npm install -g yarn@0.23.4

install:
- pip install -r requirements.txt
- yarn install

script:
- python manage.py makemigrations
- python manage.py migrate
- python manage.py test

cache:
directories:
- node_modules
- $HOME/.cache/pip
4 changes: 2 additions & 2 deletions Origami/outCalls/config.js
@@ -1,6 +1,6 @@
const appConfig = {
CLIENT_IP: "0.0.0.0",
CLIENT_PORT: 5001,
CLIENT_IP: "localhost",
CLIENT_PORT: 8000,
DROPBOX_API_KEY: "API_KEY"
};

Expand Down
63 changes: 0 additions & 63 deletions Origami/src/actions/githubDemoModelActions.js

This file was deleted.

12 changes: 6 additions & 6 deletions Origami/src/actions/inputComponentDemoModelActions.js
Expand Up @@ -20,12 +20,12 @@ export function updateInputComponentModel(newModelData) {
return function(dispatch) {
return new Promise((resolve, reject) => {
getComponentDeployed(
newModelData.userid,
newModelData.user_id,
newModelData.id,
"input"
).then(data => {
if (JSON.parse(data).length > 0) {
modifyComponentDeployed(newModelData.userid, newModelData, "input")
if (JSON.parse(data).text !== "Not Found") {
modifyComponentDeployed(newModelData.user_id, newModelData, "input")
.then(() => {
dispatch(updateInputComponentModelSuccess(newModelData));
resolve("dispatched input component model update call");
Expand All @@ -34,7 +34,7 @@ export function updateInputComponentModel(newModelData) {
reject("cannot dispatch input component model update call");
});
} else {
addComponentDeployed(newModelData.userid, newModelData, "input")
addComponentDeployed(newModelData.user_id, newModelData, "input")
.then(() => {
dispatch(updateInputComponentModelSuccess(newModelData));
resolve("dispatched input component model update call");
Expand All @@ -48,10 +48,10 @@ export function updateInputComponentModel(newModelData) {
};
}

export function killInputComponentModel(userid, repoId) {
export function killInputComponentModel(user_id, repoId) {
return function(dispatch) {
return new Promise((reject, resolve) => {
deleteComponentDeployed(userid, repoId, "input").then(() => {
deleteComponentDeployed(user_id, repoId, "input").then(() => {
dispatch(killInputComponentModelSuccess());
});
});
Expand Down
12 changes: 6 additions & 6 deletions Origami/src/actions/nonghDemoModelActions.js
Expand Up @@ -15,17 +15,17 @@ export function killNonGHDemoModelSuccess() {
export function addToDBNonGHDemoModel(newModelData) {
return function(dispatch) {
return new Promise((resolve, reject) => {
getDeployed(newModelData.userid, newModelData.id).then(data => {
if (JSON.parse(data).length > 0) {
modifyDeployed(newModelData.userid, newModelData)
getDeployed(newModelData.user_id, newModelData.id).then(data => {
if (JSON.parse(data).text !== "Not Found") {
modifyDeployed(newModelData.user_id, newModelData)
.then(data => {
resolve("dispatched nongh model update call");
})
.catch(err => {
reject("cannot dispatch nongh model update call, DB failed");
});
} else {
addDeployed(newModelData.userid, newModelData)
addDeployed(newModelData.user_id, newModelData)
.then(data => {
resolve("dispatched nongh model update call");
})
Expand All @@ -47,10 +47,10 @@ export function updateNonGHDemoModel(newModelData) {
};
}

export function killNonGHDemoModel(userid, repoId) {
export function killNonGHDemoModel(user_id, repoId) {
return function(dispatch) {
return new Promise((resolve, reject) => {
deleteDeployed(userid, repoId)
deleteDeployed(user_id, repoId)
.then(() => {
dispatch(killNonGHDemoModelSuccess());
resolve("dispatched nongh demo kill call");
Expand Down
12 changes: 6 additions & 6 deletions Origami/src/actions/outputComponentDemoModelActions.js
Expand Up @@ -20,12 +20,12 @@ export function updateOutputComponentModel(newModelData) {
return function(dispatch) {
return new Promise((resolve, reject) => {
getComponentDeployed(
newModelData.userid,
newModelData.user_id,
newModelData.id,
"output"
).then(data => {
if (JSON.parse(data).length > 0) {
modifyComponentDeployed(newModelData.userid, newModelData, "output")
if (JSON.parse(data).text !== "Not Found") {
modifyComponentDeployed(newModelData.user_id, newModelData, "output")
.then(() => {
dispatch(updateOutputComponentModelSuccess(newModelData));
resolve("dispatched output component model update call");
Expand All @@ -34,7 +34,7 @@ export function updateOutputComponentModel(newModelData) {
reject("cannot dispatch output component model update call");
});
} else {
addComponentDeployed(newModelData.userid, newModelData, "output")
addComponentDeployed(newModelData.user_id, newModelData, "output")
.then(() => {
dispatch(updateOutputComponentModelSuccess(newModelData));
resolve("dispatched output component model update call");
Expand All @@ -48,10 +48,10 @@ export function updateOutputComponentModel(newModelData) {
};
}

export function killOutputComponentModel(userid, repoId) {
export function killOutputComponentModel(user_id, repoId) {
return function(dispatch) {
return new Promise((reject, resolve) => {
deleteComponentDeployed(userid, repoId, "output").then(() => {
deleteComponentDeployed(user_id, repoId, "output").then(() => {
dispatch(killOutputComponentModelSuccess());
});
});
Expand Down
8 changes: 6 additions & 2 deletions Origami/src/api/CommonLocal/addComponentDeployed.js
@@ -1,15 +1,19 @@
import request from "superagent";
const appConfig = require("../../../outCalls/config");
import { baseURL } from "./baseURL";
import Cookies from "universal-cookie";

export function addComponentDeployed(userid, componentData, type) {
let URL = `${baseURL}/api/${type}model/${userid}`;
const cookies = new Cookies();

export function addComponentDeployed(user_id, componentData, type) {
let URL = `${baseURL}/api/${type}component/${user_id}`;
return new Promise((resolve, reject) => {
request
.post(URL)
.send(componentData)
.set("Content-Type", "application/json")
.set("Accept", "application/json")
.set("X-CSRFToken", cookies.get("csrftoken"))
.end((err, res) => {
if (err) {
reject(err);
Expand Down
25 changes: 16 additions & 9 deletions Origami/src/api/CommonLocal/deleteComponentDeployed.js
@@ -1,16 +1,23 @@
import request from "superagent";
const appConfig = require("../../../outCalls/config");
import { baseURL } from "./baseURL";
import Cookies from "universal-cookie";

export function deleteComponentDeployed(userid, repoId, type) {
let URL = `${baseURL}/api/${type}model/${userid}/${repoId}`;
const cookies = new Cookies();

export function deleteComponentDeployed(user_id, repoId, type) {
let URL = `${baseURL}/api/${type}component/${user_id}/${repoId}`;
return new Promise((resolve, reject) => {
request.delete(URL).set("Accept", "application/json").end((err, res) => {
if (err) {
reject(err);
} else {
resolve(res.text);
}
});
request
.delete(URL)
.set("Accept", "application/json")
.set("X-CSRFToken", cookies.get("csrftoken"))
.end((err, res) => {
if (err) {
reject(err);
} else {
resolve(res.text);
}
});
});
}
4 changes: 2 additions & 2 deletions Origami/src/api/CommonLocal/getComponentDeployed.js
Expand Up @@ -2,8 +2,8 @@ import request from "superagent";
const appConfig = require("../../../outCalls/config");
import { baseURL } from "./baseURL";

export function getComponentDeployed(userid, repoId, type) {
let URL = `${baseURL}/api/${type}model/${userid}`;
export function getComponentDeployed(user_id, repoId, type) {
let URL = `${baseURL}/api/${type}component/${user_id}`;
if (repoId) {
URL += `/${repoId}`;
}
Expand Down
8 changes: 6 additions & 2 deletions Origami/src/api/CommonLocal/modifyComponentDeployed.js
@@ -1,15 +1,19 @@
import request from "superagent";
const appConfig = require("../../../outCalls/config");
import { baseURL } from "./baseURL";
import Cookies from "universal-cookie";

export function modifyComponentDeployed(userid, componentData, type) {
let URL = `${baseURL}/api/${type}model/${userid}/${componentData.id}`;
const cookies = new Cookies();

export function modifyComponentDeployed(user_id, componentData, type) {
let URL = `${baseURL}/api/${type}component/${user_id}/${componentData.id}`;
return new Promise((resolve, reject) => {
request
.put(URL)
.send(componentData)
.set("Content-Type", "application/json")
.set("Accept", "application/json")
.set("X-CSRFToken", cookies.get("csrftoken"))
.end((err, res) => {
if (err) {
reject(err);
Expand Down
4 changes: 4 additions & 0 deletions Origami/src/api/CommonLocal/rootSettingsApi.js
@@ -1,6 +1,9 @@
import request from "superagent";
const appConfig = require("../../../outCalls/config");
import { baseURL } from "./baseURL";
import Cookies from "universal-cookie";

const cookies = new Cookies();

export function checkRootSettings() {
let URL = `${baseURL}/api/rootsettings`;
Expand All @@ -23,6 +26,7 @@ export function addRootSettings(settingsData) {
.send(settingsData)
.set("Content-Type", "application/json")
.set("Accept", "application/json")
.set("X-CSRFToken", cookies.get("csrftoken"))
.end((err, res) => {
if (err) {
reject(err);
Expand Down
8 changes: 4 additions & 4 deletions Origami/src/api/Generic/getCloudCVDemos.js
Expand Up @@ -2,8 +2,8 @@ import request from "superagent";
const appConfig = require("../../../outCalls/config");
import { baseURL } from "../CommonLocal/baseURL";

export function isCloudCV() {
let URL = `${baseURL}/api/isCloudCV`;
export function is_cloudcv() {
let URL = `${baseURL}/api/is_cloudcv`;
return new Promise((resolve, reject) => {
request.get(URL).set("Accept", "application/json").end((err, res) => {
if (err) {
Expand All @@ -15,8 +15,8 @@ export function isCloudCV() {
});
}

export function getAllDemosByCloudCV(userid) {
let URL = `${baseURL}/api/nonghdemomodel/${userid}`;
export function getAllDemosByCloudCV(user_id) {
let URL = `${baseURL}/api/demo/user/${user_id}`;
return new Promise((resolve, reject) => {
request.get(URL).set("Accept", "application/json").end((err, res) => {
if (err) {
Expand Down
21 changes: 0 additions & 21 deletions Origami/src/api/GithubLocal/addDeployed.js

This file was deleted.

16 changes: 0 additions & 16 deletions Origami/src/api/GithubLocal/deleteDeployed.js

This file was deleted.

0 comments on commit df98e89

Please sign in to comment.