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

Django Channels + React along with API translation #46

Merged
merged 39 commits into from Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2cce9f9
Django Channels + React along with API translation
AvaisP Jun 26, 2017
f6a6f8f
Allow modifying demos
AvaisP Jun 27, 2017
c95a91b
Bug fix: Modify demos
AvaisP Jun 27, 2017
d4b90d6
Bug fix: Save number of components in a demo
AvaisP Jun 29, 2017
d9adbb6
Render demo component
AvaisP Jun 29, 2017
808df62
Allow communication between demo and lib
AvaisP Jun 30, 2017
df3ee94
Removed unnecessary logging
AvaisP Jun 30, 2017
744e335
Removed unnecassary print statements
AvaisP Jun 30, 2017
9537b03
Support to add root user
AvaisP Jun 30, 2017
594ec03
Removed unwanted files
AvaisP Jun 30, 2017
4501fb3
Tests for demo and components
AvaisP Jul 1, 2017
d786796
Tests for permalink
AvaisP Jul 1, 2017
88a9684
Fix PEP8 errors
AvaisP Jul 1, 2017
c60c2a1
Formatted using prettier
AvaisP Jul 1, 2017
7be6f5b
Add socialapp with rootsettings
AvaisP Jul 1, 2017
7d28744
Remoeved print statements
AvaisP Jul 1, 2017
acb3198
Modified update instructions
AvaisP Jul 1, 2017
9183f1d
Configured travis
AvaisP Jul 2, 2017
020141b
Fixed import for python 3
AvaisP Jul 2, 2017
da48d5a
Fixed python3 errors
AvaisP Jul 2, 2017
02c20a2
Linked to docs
AvaisP Jul 2, 2017
257e750
Update README.md
tocttou Jul 3, 2017
f62bf13
Modified gitignore
AvaisP Jul 3, 2017
d85c5bb
Modified Readme
AvaisP Jul 3, 2017
84c7b1d
Added csrf token
AvaisP Jul 3, 2017
835cb57
Merge branch 'socket-translate-api' of https://github.com/Cloud-CV/Or…
AvaisP Jul 3, 2017
19e2b3b
Modified travis
AvaisP Jul 3, 2017
28e4d47
Replace camelCase with underscores
AvaisP Jul 3, 2017
5e5c1b2
Replace Json/HttpResponse with DRF Response and status code
AvaisP Jul 3, 2017
ff772be
Modified readme
AvaisP Jul 3, 2017
b67dee8
camelCase socket events
AvaisP Jul 3, 2017
1e2f23b
Don't delete modify user on login
AvaisP Jul 3, 2017
31e25ec
Uses permalink serializer
AvaisP Jul 3, 2017
7593b03
Use component serializers
AvaisP Jul 4, 2017
71c9cae
Always modify rootsettings
AvaisP Jul 4, 2017
78227a3
Drop field 'id' from components
AvaisP Jul 4, 2017
07a11bc
Send Json not found instead of empty dict
AvaisP Jul 4, 2017
b6636ec
Import only required classes
AvaisP Jul 4, 2017
fd1974b
Added new line
AvaisP Jul 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.