Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Angular_Full_Project_GULP/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ app.use(cors({
'http://localhost:3000', 'google.com'
]
}));
//var server = require('http').Server(app);
var id;
app.use(urlencodedParser);
app.use(bodyParser.json());

/*router.get('/user',function(req,res){
//console.log("Hi");
});*/

router.get('/user/:id',function(req,res){

id= req.params.id;
Expand All @@ -41,21 +35,27 @@ router.get('/user/:id',function(req,res){
);
});
router.post('/user/:id',function(req,res){
user2.findById(id,function(err,user) {
console.log(id);
if (err) {
res.send(err);
}
console.log("hi");
user.name=req.body.name;
user.email=req.body.email;
user.state=req.body.state;
user.city= req.body.city;
user.Gender=req.body.gender;
user.Dob=req.body.daterange;
user.IsDeleted=req.body.active;
user.save(function(err,user2){
user.save(function(err){
if(err)
{console.log(err);}
else{
console.log("no err");
}})
res.sendStatus(200);
})
}})})
res.sendStatus(200);}
)
router.get('/user',function(req,res){

user2.find({},function(err,users){
Expand All @@ -65,7 +65,7 @@ router.get('/user',function(req,res){
}
});
});
router.delete('',function(req,res){
router.delete('/user/:id',function(req,res){
id=req.params.id;
user2.findByIdAndRemove(req.params.id,function(err,tasks){console.log(tasks);});
});
Expand Down
2 changes: 1 addition & 1 deletion Angular_Full_Project_GULP/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

<!-- AngularJS -->
<script src="bower_components/angular/angular.min.js"></script>

<script src="bower_components/angular-bootstrap/ui-bootstrap.js"></script>
<!-- AngularJS plugins -->
<script src="bower_components/angular-animate/angular-animate.min.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.min.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions Angular_Full_Project_GULP/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ angular
'ncy-angular-breadcrumb',
'angular-loading-bar',
'ngSanitize',
'ngAnimate'//,
//'daterangepicker'
'ngAnimate',
'ui.bootstrap'
])

.config(function ($httpProvider) {
Expand Down
246 changes: 219 additions & 27 deletions Angular_Full_Project_GULP/js/controllers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,70 @@
// controller.js
angular
.module('app')
function userService($http){
this.getUser=function (){
return $http
.get('http://localhost:8001/api/user')
.then(function (d) {
console.log(d);
return d.data;
}, function (err) {
console.log(err);
}
);}
}
angular.module('app'/*,['ui.bootstrap']*/)
.controller('languageCtrl', languageCtrl)
.controller('addController', addController)
.service('userService',userService)
.service('modalService', ['$uibModal',
// NB: For Angular-bootstrap 0.14.0 or later, use $uibModal above instead of $modal
function ($uibModal) {

var modalDefaults = {
backdrop: true,
keyboard: true,
modalFade: true,
templateUrl: 'views/modal.html'
};

var modalOptions = {
closeButtonText: 'Close',
actionButtonText: 'OK',
headerText: 'Proceed?',
bodyText: 'Perform this action?'
};

this.showModal = function (customModalDefaults, customModalOptions) {
if (!customModalDefaults) customModalDefaults = {};
customModalDefaults.backdrop = 'static';
return this.show(customModalDefaults, customModalOptions);
};

this.show = function (customModalDefaults, customModalOptions) {
//Create temp objects to work with since we're in a singleton service
var tempModalDefaults = {};
var tempModalOptions = {};

//Map angular-ui modal custom defaults to modal defaults defined in service
angular.extend(tempModalDefaults, modalDefaults, customModalDefaults);

//Map modal.html $scope custom properties to defaults defined in service
angular.extend(tempModalOptions, modalOptions, customModalOptions);

if (!tempModalDefaults.controller) {
tempModalDefaults.controller = function ($scope, $modalInstance) {
$scope.modalOptions = tempModalOptions;
$scope.modalOptions.ok = function (result) {
$modalInstance.close(result);
};
$scope.modalOptions.close = function (result) {
$modalInstance.dismiss('cancel');
};
};
}

return $uibModal.open(tempModalDefaults).result;
};

}])
.service('fileUpload', ['$http', function ($http) {
this.uploadFileToUrl = function(file, uploadUrl){
var fd = new FormData();
Expand All @@ -20,8 +82,11 @@ angular
});
}
}])
.controller('addController', addController)


addController.$inject=['$http','$scope','fileUpload'];

addController.$inject=['$http','$scope','fileUpload','userService'];
languageCtrl.$inject = ['$translate', '$scope'];
function languageCtrl($translate, $scope) {
function checkLanguage(languages, langKey) {
Expand Down Expand Up @@ -61,31 +126,72 @@ function languageCtrl($translate, $scope) {
checkLanguage(languages, langKey)
};
}
function addController($http,$scope,fileUpload) {
/*function ModalDemoCtrl($rootScope, $scope, $log, $uibModal){
$scope.open = function(size, template) {
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: template || 'myModalContent.html',
controller: 'ModalInstanceCtrl',
size: size
});
}
$scope.toggleAnimation = function() {
$scope.animationsEnabled = !$scope.animationsEnabled;
};

}*/
/*
ModalInstanceCtrl.$inject=['$scope', '$uibModalInstance', 'modalFactory']
function ModalInstanceCtrl($scope, $uibModalInstance, modalFactory) {

//$scope.searchTerm = term;

$scope.ok = function() {
modalFactory.open('lg', 'result.html', {searchTerm: $scope.searchTerm});
//$uibModalInstance.close($scope.searchTerm);
};

$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
}
*/

function addController($http,$scope,fileUpload,userService) {
//var users=[]
$scope.displayForm = false;
this.array = ['Gujarat', 'Maharashtra', 'Uttarakhand'];
this.Myobject = {
Gujarat: ["Valsad", "Surat", "Baroda", "Rajkot", "Ahmedabad", "Gandhinagar"],
Maharashtra: ["Mumbai", "pune", "Aurangabad"],
Uttarakhand: ["Haridwar", "Hrishikesh", "Mussorie"]
};

this.getUser = function () {
$scope.users = [];
$http.get('http://localhost:8001/api/user').then(function (d) {
console.log(d);
for (i in d.data) {
$scope.users[i] = d.data[i];
}

}, function (err) {
console.log(err);
}
);
userService.getUser()
.then(function(d){
$scope.users= angular.copy[d];
$scope.users=d;
});

};

$scope.deleteItem = function (data) {


var modalOptions = {
closeButtonText: 'Cancel',
actionButtonText: 'Delete the user',
headerText: 'Delete ',
bodyText: 'Are you sure you want to delete'
};

modalService.showModal({}, modalOptions)
.then(function (result) {
//your-custom-logic
});
}
this.editItem = function (data) {
$scope.user = [];
$http.get('http://localhost:8001/api/user/' + data).then(function (d) {
Expand All @@ -99,6 +205,14 @@ function addController($http,$scope,fileUpload) {
// $scope.employee = data;
$scope.displayForm = true;
};

this.deleteitem=function(data){
$http
.delete("http://localhost:8001/api/user/"+data);
this.getUser()
};


this.addUser = function () {
$http({
url: 'http://localhost:8001/api/user',
Expand All @@ -124,7 +238,7 @@ function addController($http,$scope,fileUpload) {
fileUpload.uploadFileToUrl(file, uploadUrl);
}
}
}

/*.directive('fileModel', ['$parse', function ($parse) {
return {
restrict: 'A',
Expand All @@ -144,25 +258,103 @@ function addController($http,$scope,fileUpload) {



/*this.saveitem=function(data1){
console.log(data1);
this.saveitem=function(data){
console.log(data);
$http({
url: 'http://localhost:8001/api/user/'+data1,
url: 'http://localhost:8001/api/user/'+data,
method: 'POST',
data: {
'name': $scope.user.name,
'email': $scope.user.email,
'state': $scope.user.state,
'city': $scope.user.city,
'gender': $scope.user.gender,
'daterange': $scope.user.date,
'daterange': $scope.user.Dob,
'active': $scope.active
//'dob': $scope.newprofile.dob,
//'stateid': $scope.newprofile.stateid,
//'cityid': $scope.newprofile.cityid,
//'profileimg': $scope.newprofile.profileimg,
//'status': $scope.newprofile.status
}})
}});
$scope.users = [];
userService.getUser()
.then(function(d){
$scope.users=d;
});

}}

/*
angular.module('app1', ['ui.bootstrap'])*/



/*var modalController = function ($scope, $uibModalInstance) {
$scope.yes = function() {
$uibModalInstance.close();
};

$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
};

modalController.$inject = ['$scope', '$uibModalInstance'];*/
/*
function MyModalController($uibModalInstance, items) {
var vm = this;
vm.content = items;
vm.confirm = $uibModalInstance.close;
vm.cancel = $uibModalInstance.dismiss;
};

function modalTriggerDirective($myModal) {
function postLink(scope, iElement, iAttrs) {
function onClick() {
var size = scope.$eval(iAttrs.size) || 'lg'; // default to large size
var title = scope.$eval(iAttrs.title) || 'Default Title';
var message = scope.$eval(iAttrs.message) || 'Default Message';
$myModal.open(size, title, message);
}
iElement.on('click', onClick);
scope.$on('$destroy', function() {
iElement.off('click', onClick);
});
}

return {
link: postLink
};
}

function myModalFactory($uibModal) {
var open = function (size, title, message) {
return $uibModal.open({
controller: 'MyModalController',
controllerAs: 'vm',
templateUrl: 'templates/CustomModal.html',
size: size,
resolve: {
items: function () {
return {
title: title,
message: message
};
}
}
});
}};
var modalScope = $scope.$new();

/!*
var modalInstance = $uibModal.open({
templateUrl: 'foo-as-modal.html',
controller: 'fooController',
scope: modalScope
});
*!/

}*/
modalScope.modalInstance = modalInstance;
/!*var modalInstance = $uibModal.open({
animation: true,
templateUrl: '../Template/ConfirmForm.tpl.html',
controller: modalController,
});*!/

*/
Loading