diff --git a/webroot/static/html/item-add.html b/webroot/static/html/item-add.html new file mode 100644 index 0000000..f809a35 --- /dev/null +++ b/webroot/static/html/item-add.html @@ -0,0 +1,20 @@ +

{{product.title}}

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
diff --git a/webroot/static/js/global.js b/webroot/static/js/global.js new file mode 100644 index 0000000..23cc587 --- /dev/null +++ b/webroot/static/js/global.js @@ -0,0 +1,23 @@ +'use strict'; + +angular.module('microStock') + .controller('GlobalCtrl',['$scope',function($scope){ + $scope.loggedIn = false; + + function setCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + var expires = "expires="+d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; + } + + $scope.login = function(){ + if($scope.loggedIn){ + setCookie("session","logoff",1); + $scope.loggedIn = false; + }else { + setCookie("session","testsessionkey",1); + $scope.loggedIn = true; + } + }; + }]); diff --git a/webroot/static/js/item-add.controller.js b/webroot/static/js/item-add.controller.js new file mode 100644 index 0000000..bc005de --- /dev/null +++ b/webroot/static/js/item-add.controller.js @@ -0,0 +1,25 @@ +'use strict'; + +angular.module('microStock') + .controller('ItemAddCtrl',['$scope','$http','$stateParams',function($scope,$http,$stateParams){ + $scope.product = {}; + $scope.obj = {}; + $scope.count = 1; + + $http.get(config.microservice_dependencies.productById.replace("%d", $stateParams.productid)).then(function(res) { + $scope.product = res.data + }); + + $scope.submit = function(){ + function request(){ + return $http.post(config.store.goods.productById.replace("%d",$stateParams.productid),$scope.obj); + } + var last = request(); + for(var i=1;i < $scope.count;i++){ + last.then(request); + } + last.then(null,function(){ + console.log("did not work"); + }) + }; + }]);