-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Switching Javascript to Typescript
* 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
Showing
23 changed files
with
2,338 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
{ | ||
"indent": 4, | ||
"white": false, | ||
|
||
"globals": { | ||
"jquery": false, | ||
"d3": false, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Oops, something went wrong.