Skip to content

Commit

Permalink
[WIP] Switching Javascript to Typescript
Browse files Browse the repository at this point in the history
* This commit includes js.map files and generated js files.
  - these files will be removed after the piplene which can
    compile *.ts file to .js files before web rendering are
    established in Django.

* And created doc directory

Related-Isues: #18
Related-Issue: #3
  • Loading branch information
travelist committed Apr 14, 2015
1 parent f5296ff commit 0022912
Show file tree
Hide file tree
Showing 23 changed files with 2,338 additions and 123 deletions.
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"indent": 4,
"white": false,

"globals": {
"jquery": false,
"d3": false,
Expand Down
360 changes: 248 additions & 112 deletions cognitive/MLApp/static/js/api/client_v1.js
Original file line number Diff line number Diff line change
@@ -1,116 +1,252 @@
var CognitiveAPIClientV1 = (function() {

function CognitiveAPIClientV1(options) {
this.prefix = '/api/v1';
}

function _send_request(api_url, method, json_data, node) {
$.ajax({
url: api_url,
type: method,
data: json_data,
success: function(result) {
console.log(result);
if (node != null){
node.setComponentId(result.id);
}
}
});
};

function createInputComponent(json_data, node) {
api_url = this.prefix + '/operations/input/';
_send_request(api_url, "POST", json_data, node);
};

function createOutputComponent(json_data, node) {
api_url = this.prefix + '/operations/output/';
_send_request(api_url, "POST", json_data, node);
};

function createAddRowComponent(json_data, node) {
api_url = this.prefix + '/operations/row/';
_send_request(api_url, "POST", json_data, node);
};

function createMathFormulaComponent(json_data, node) {
api_url = this.prefix + '/operations/math_formula/';
_send_request(api_url, "POST", json_data, node);
};

function createMetadataComponent(json_data, node) {
api_url = this.prefix + '/operations/metadata/';
_send_request(api_url, "POST", json_data, node);
};

function createMachineLeaningComponent(json_data, node) {
api_url = this.prefix + '/operations/machine_learning/';
_send_request(api_url, "POST", json_data, node);
};

function createNormalizationComponent(json_data, node) {
api_url = this.prefix + '/operations/normalization/';
_send_request(api_url, "POST", json_data, node);
};

function createRemoveDuplicatesComponent(json_data, node) {
api_url = this.prefix + '/operations/remove_duplicates/';
_send_request(api_url, "POST", json_data, node);
};

function createRemoveMissingValueComponent(json_data, node) {
api_url = this.prefix + '/operations/RemoveMissingValue';
_send_request(api_url, "POST", json_data, node);
};

function createFilterComponent(json_data, node) {
api_url = this.prefix + '/operations/filter';
_send_request(api_url, "POST", json_data, node);
};

function createRemoveMissingValuesComponent(json_data, node) {
api_url = this.prefix + '/operations/remove_missing/';
_send_request(api_url, "POST", json_data, node);
};

function run(json_data, node) {
api_url = this.prefix + '/operations/filter';
_send_request(api_url, "POST", json_data, node);
};

function createProjectionComponent(json_data, node) {
api_url = this.prefix + '/operations/projection/';
_send_request(api_url, "POST", json_data, node);
};

function executeAll(json_data) {
api_url = this.prefix + '/workflows/';
_send_request(api_url, "POST", json_data, null);
};

function getResult(component_id) {
api_url = this.prefix + '/results/?expetiment=1&component_id=' + component_id;
_send_request(api_url, "GET", null, null);
};


CognitiveAPIClientV1.prototype = {
constructor: CognitiveAPIClientV1,
createInputComponent: createInputComponent,
createOutputComponent: createOutputComponent,
createAddRowComponent: createAddRowComponent,
createMathFormulaComponent: createMathFormulaComponent,
createMetadataComponent: createMetadataComponent,
createMachineLeaningComponent: createMachineLeaningComponent,
createNormalizationComponent: createNormalizationComponent,
createRemoveDuplicatesComponent: createRemoveDuplicatesComponent,
createRemoveMissingValueComponent: createRemoveMissingValueComponent,
createFilterComponent: createFilterComponent,
createRemoveMissingValuesComponent: createRemoveMissingValuesComponent,
createProjectionComponent: createProjectionComponent,
executeAll: executeAll
};

return CognitiveAPIClientV1;
/*
* TODO: will separate cognitive specific function and others
* for ex: run function is kept here
* input/delete * component will be separated
* like plugin.
*/

function CognitiveAPIClientV1(options) {
this.prefix = '/api/v1';
}

function _send_request(api_url, method, json_data, node) {
$.ajax({
url: api_url,
type: method,
data: json_data,
success: function(result) {
console.log(result);
a = node;
if (node !== null){ node.set_backend_id(result.id);}
}
});
};

function createInputComponent(json_data, node) {
api_url = this.prefix + '/operations/input/';
_send_request(api_url, "POST", json_data, node);
};


function deleteInputComponent(id) {
api_url = this.prefix + '/operations/input/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createOutputComponent(json_data, node) {
api_url = this.prefix + '/operations/output/';
_send_request(api_url, "POST", json_data, node);
};

function deleteOutputComponent(id) {
api_url = this.prefix + '/operations/output/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createAddRowComponent(json_data, node) {
api_url = this.prefix + '/operations/row/';
_send_request(api_url, "POST", json_data, node);
};

function deleteAddRowComponent(id) {
api_url = this.prefix + '/operations/row/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createMathFormulaComponent(json_data, node) {
api_url = this.prefix + '/operations/math_formula/';
_send_request(api_url, "POST", json_data, node);
};

function deleteMathFormulaComponent(id) {
api_url = this.prefix + '/operations/math_formula/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createMetadataComponent(json_data, node) {
api_url = this.prefix + '/operations/metadata/';
_send_request(api_url, "POST", json_data, node);
};

function deleteMetadataComponent(id) {
api_url = this.prefix + '/operations/metadata/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createMachineLeaningComponent(json_data, node) {
api_url = this.prefix + '/operations/machine_learning/';
_send_request(api_url, "POST", json_data, node);
};

function deleteMachineLeaningComponent(id) {
api_url = this.prefix + '/operations/machine_learning/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createNormalizationComponent(json_data, node) {
api_url = this.prefix + '/operations/normalization/';
_send_request(api_url, "POST", json_data, node);
};

function deleteNormalizationComponent(id) {
api_url = this.prefix + '/operations/normalization/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createRemoveDuplicatesComponent(json_data, node) {
api_url = this.prefix + '/operations/remove_duplicates/';
_send_request(api_url, "POST", json_data, node);
};

function deleteRemoveDuplicatesComponent(id) {
api_url = this.prefix + '/operations/remove_duplicates/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createRemoveMissingValueComponent(json_data, node) {
api_url = this.prefix + '/operations/RemoveMissingValue';
_send_request(api_url, "POST", json_data, node);
};

function deleteRemoveMissingValueComponent(id) {
api_url = this.prefix + '/operations/RemoveMissingValue/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createFilterComponent(json_data, node) {
api_url = this.prefix + '/operations/filter';
_send_request(api_url, "POST", json_data, node);
};

function deleteFilterComponent(id) {
api_url = this.prefix + '/operations/filter/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createRemoveMissingValuesComponent(json_data, node) {
api_url = this.prefix + '/operations/remove_missing/';
_send_request(api_url, "POST", json_data, node);
};

function deleteRemoveMissingValuesComponent(id) {
api_url = this.prefix + '/operations/remove_missing/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function run(json_data, node) {
api_url = this.prefix + '/operations/filter';
_send_request(api_url, "POST", json_data, node);
};

function deleteOutputComponent(id) {
api_url = this.prefix + '/operations/filter/' + id;
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function createProjectionComponent(json_data, node) {
api_url = this.prefix + '/operations/projection/';
_send_request(api_url, "POST", json_data, node);
};

function deleteProjectionComponent(id) {
api_url = this.prefix + '/operations/projection/';
$.ajax({
url: api_url,
type: "DELETE",
success: function(result) { console.log(result); }
});
}

function executeAll(json_data) {
api_url = this.prefix + '/workflows/';
_send_request(api_url, "POST", json_data, null);
};

function getResult(component_id) {
api_url = this.prefix + '/results/?expetiment=1&component_id=' + component_id;
_send_request(api_url, "GET", null, null);
};


CognitiveAPIClientV1.prototype = {
constructor: CognitiveAPIClientV1,
createInputComponent: createInputComponent,
deleteInputComponent: deleteInputComponent,
createOutputComponent: createOutputComponent,
deleteOutputComponent: deleteOutputComponent,
createAddRowComponent: createAddRowComponent,
deleteAddRowComponent: deleteAddRowComponent,
createMathFormulaComponent: createMathFormulaComponent,
deleteMathFormulaComponent: deleteMathFormulaComponent,
createMetadataComponent: createMetadataComponent,
deleteMetadataComponent: deleteMetadataComponent,
createMachineLeaningComponent: createMachineLeaningComponent,
deleteMachineLeaningComponent: deleteMachineLeaningComponent,
createNormalizationComponent: createNormalizationComponent,
deleteNormalizationComponent: deleteNormalizationComponent,
createRemoveDuplicatesComponent: createRemoveDuplicatesComponent,
deleteRemoveDuplicatesComponent: deleteRemoveDuplicatesComponent,
createRemoveMissingValueComponent: createRemoveMissingValueComponent,
deleteRemoveMissingValueComponent: deleteRemoveMissingValueComponent,
createFilterComponent: createFilterComponent,
deleteFilterComponent: deleteFilterComponent,
createRemoveMissingValuesComponent: createRemoveMissingValuesComponent,
deleteRemoveMissingValuesComponent: deleteRemoveMissingValuesComponent,
createProjectionComponent: createProjectionComponent,
deleteProjectionComponent: deleteProjectionComponent,
executeAll: executeAll
};

return CognitiveAPIClientV1;

})();
Empty file.
11 changes: 6 additions & 5 deletions cognitive/MLApp/static/js/whiteboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,12 @@ $(function(){

} else if ($(this).hasClass('add_math_fomula')) {

node = new Node({
name:'Apply Formula',
input:1,
output:1
});
//node = new Node({
// name:'Apply Formula',
// input:1,
// output:1
//});
node = new MathFormula(Node);

var method = $('select#formula_method').val();
var column_num = $('select#formula_column').val();
Expand Down
Empty file.
1 change: 1 addition & 0 deletions cognitive/MLApp/static/ts/application.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Loading

0 comments on commit 0022912

Please sign in to comment.