WIP for orbis

This commit is contained in:
willyb321
2018-07-27 11:44:14 +10:00
parent 90a3392b80
commit dbe836729f
3 changed files with 88 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ import { getBlueprint } from '../utils/BlueprintFunctions';
import * as ModuleUtils from '../shipyard/ModuleUtils';
// mapping from fd's ship model names to coriolis'
const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
export const SHIP_FD_NAME_TO_CORIOLIS_NAME = {
'Adder': 'adder',
'Anaconda': 'anaconda',
'Asp': 'asp',

View File

@@ -6,9 +6,9 @@ import request from 'superagent';
* @param {string} url The URL to shorten
* @param {function} success Success callback
* @param {function} error Failure/Error callback
*/
*/
export default function shorternUrl(url, success, error) {
shortenUrlOrbis(url, success, error);
orbisUpload(url, success, error);
}
const SHORTEN_API_GOOGLE = 'https://www.googleapis.com/urlshortener/v1/url?key=';
@@ -72,7 +72,7 @@ const SHORTEN_API_ORBIS = 'https://s.orbis.zone/a';
* @param {function} success Success callback
* @param {function} error Failure/Error callback
*/
function shortenUrlOrbis(url, success, error) {
function orbisUpload(url, success, error) {
if (window.navigator.onLine) {
try {
request.post(SHORTEN_API_ORBIS)
@@ -93,3 +93,31 @@ function shortenUrlOrbis(url, success, error) {
error('Not Online');
}
}
const API_ORBIS = 'http://localhost:3000/builds/add';
/**
* Upload to Orbis
* @param {object} ship The URL to shorten
* @param {function} success Success callback
* @param {function} error Failure/Error callback
*/
export function orbisUpload(ship, success, error) {
if (window.navigator.onLine) {
try {
request.post(API_ORBIS)
.send(ship)
.end(function(err, response) {
if (err) {
error('Bad Request');
} else {
success(response.body.link);
}
});
} catch (e) {
console.log(e);
error(e.message ? e.message : e);
}
} else {
error('Not Online');
}
}