-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddStockDetail.js
65 lines (57 loc) · 2.79 KB
/
addStockDetail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var app = angular.module("addStock", ['ui.router'])
.controller("AddStockController", function($scope,$q,$http,pizzaServices) {
this.stockID1 = '';
this.price = '';
this.companyDes = '';
this.companyName = '';
$scope.status = '';
this.login = function(stockid){
var url = "https://api.iextrading.com/1.0/stock/"+ this.stockID1 + "/price";
$http.get(url).then(
function(response) {
if(response.data !== undefined){
var id = document.getElementById("stockID").value;
addStock(response.data,id);
}
},
function(response) {
console.log('Erroer getSpecificStockDetailFromAPI_Current');
//walkthroughFactory.setSpecificStockDetailFromAPI({});
//defered.reject('error');
return [];
});
}
function addStock(actualPrice,stockIDTemp){
var url = "https://api.iextrading.com/1.0/stock/"+ stockIDTemp + "/company";
$http.get(url).then(
function(response) {
if(response.data !== undefined){
var companyName = response.data['companyName'];
var companydes = response.data['description'];
var comments = document.getElementById("comments").value;
console.log(comments);
var targetPrice = document.getElementById("price").value;
var url = "add_update_Stock.php?stockid="+ stockIDTemp + "&companyname=" +companyName + "&companydes="+companydes+"&targetprice="+targetPrice + "&actualPrice=" + actualPrice + "&comments=" +comments;
var defered = $q.defer();
$http.get(url).
then(
function(response) {
$scope.status = response.data;
pizzaServices.getCurrentPrice(stockIDTemp,'quote');
pizzaServices.getdividends3M(stockIDTemp);
pizzaServices.getSpecificStockDetailFromAPI_Current(stockIDTemp,['TIME_SERIES_DAILY','TIME_SERIES_WEEKLY']);
pizzaServices.updateEPS(stockIDTemp)
},
function(response) {
$scope.status = "Error in Add record";
});
}
},
function(response) {
console.log('Erroer getSpecificStockDetailFromAPI_Current');
//walkthroughFactory.setSpecificStockDetailFromAPI({});
//defered.reject('error');
return [];
});
}
});