genofire/hs_monolith
genofire
/
hs_monolith
Archived
1
0
Fork 0

[TASK] add on webadmin adding goods

This commit is contained in:
Martin Geno 2017-05-12 10:58:43 +02:00
parent 2ea9033ba1
commit 9d33f6deda
No known key found for this signature in database
GPG Key ID: F0D39A37E925E941
3 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,20 @@
<h1>{{product.title}}</h1>
<form class="ui form" ng-submit="submit()">
<div class="field">
<label>Fouled at</label>
<input type="date" name="fouled_at" placeholder="Fouled at date" ng-model="obj.fouled_at">
</div>
<div class="field">
<label>Position</label>
<input type="text" name="position" placeholder="Location in Store", ng-model="obj.position">
</div>
<div class="field">
<label>Comment</label>
<input type="text" name="comment" placeholder="Comment to this good", ng-model="obj.comment">
</div>
<div class="field">
<label>Count</label>
<input type="number" name="count" ng-model="count" min="1">
</div>
<button class="ui button" type="submit">Submit</button>
</form>

View File

@ -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;
}
};
}]);

View File

@ -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");
})
};
}]);