diff --git a/login/app.js b/login/app.js
index 9d56fd2..ae20f6c 100644
--- a/login/app.js
+++ b/login/app.js
@@ -3,29 +3,79 @@ var express=require('express');
var bodyParser=require('body-parser');
mongoose.connect('mongodb://localhost:27017/test');
var urlencodedParser=bodyParser.urlencoded({extended:true});
+var cors = require('express-cors');
var Employee=require('./js/employee.js');
-var app=express();
-var router=express.Router();
+var app = express();
+app.use(urlencodedParser);
+var router = express.Router();
var multer=require('multer');
-router.get("/employee",function(){
+var id;
+app.use('/uploads',express.static(__dirname+"/upload"));
+var upload=multer({dest:"./uploads/"}).array('name',1);
+app.use(cors({
+ allowedOrigins: [
+ 'http://localhost:63342', 'google.com'
+ ]
+}));
+router.get("/employee",function(req,res){
Employee.find({},function(err,employee){
if(!err){
console.log(employee);
- res.json(employee)
+ res.json(employee);
}
});
+ /*Employee.find({},"-_id Name",function(err,employees){
+ res.json(employees)
+ });*/
});
-router.get("/employee/name",function(){
- Employee.find({},"-_id Name",function(err,employee){
- res.json(employee)
+router.get("/employeename",function(req,res){
+ Employee.find({},"-_id Name",function(err,employees){
+ res.json(employees)
})
})
-router.post();
-router.put();
-router.delete();
+var storage = multer.diskStorage({
+ destination: function (req, file, callback) {
+ callback(null,'./uploads');
+ },
+ filename: function (req, file, callback) {
+ console.log(file);
+ var filename = file.originalname;
+ req.body.file = filename;
+ callback(null, file.originalname)
+ }
+ });
+var upload = multer({ //multer settings
+ storage: storage
+}).single('file');
+router.post("/employee", upload,function(req,res) {
+ console.log("it is here");
+ var emp3 = new Employee();
+ emp3.Name = req.body.name;
+ Employee.findOne({Name:req.body.employee},"_id",function(err,id1){
+ id=id1;
+})
+ emp3.EmployeeId = id;
+ emp3.File = req.body.file;
+ emp3.save(function (err, emp3) {
+ if (err) {
+ console.log(err);
+ }
+ console.log(emp3);
+ })
+})
+
+
+/*
+router.put();*/
+
+router.delete("/employee/:id",function(req,res){
+ Employee.findByIdAndRemove(req.params.id,function(err,emp){console.log(emp);});
+});
+
+
-app.use(urlencodedParser);
app.use('/api',router);
+app.listen(8001);
\ No newline at end of file
diff --git a/login/index.html b/login/index.html
index 76dfa6d..92f489b 100644
--- a/login/index.html
+++ b/login/index.html
@@ -6,17 +6,15 @@
Title
-
+
-
+
-
-
diff --git a/login/js/app.js b/login/js/app.js
index b22599c..e12ca36 100644
--- a/login/js/app.js
+++ b/login/js/app.js
@@ -19,41 +19,50 @@ angular.module('myapp',['ngRoute','ui.bootstrap','angularModalService','ngAnimat
}
})
.controller('listController',function($scope,$http){
- $scope.items=['hdhsjhfshf','dshgsjhchb'];
- $scope.status={
- isopen:false
- };
- $scope.toggled=function(open){
- console.log("open");
- };
- $scope.toggleDropDown=function($event){
- $event.preventDefault();
- $event.stopPropagation();
- $scope.status.isopen = !$scope.status.isopen;
- };
- $scope.appendToEl = angular.element(document.querySelector('#dropdown-long-content'));
$scope.emp = [];
- function getUser(){
+ $scope.getEmp=function (){
$http
- .get('http://localhost:8000/api/user')
+ .get('http://localhost:8001/api/employee')
.then(function (d) {
$scope.emp= d.data;
+ console.log(d.data);
//$scope.emp=d;
})}})
.controller('ComplexController', [
- '$scope', '$element', 'title', 'close',
- function($scope, $element, title, close) {
+ '$scope', '$element', 'title','emp', 'close','Upload',
+ function($scope, $element, title,emp,close,Upload) {
$scope.name = null;
$scope.employee = null;
$scope.title = title;
-
+ $scope.emp2=emp;
// This close function doesn't need to use jQuery or bootstrap, because
// the button has the 'data-dismiss' attribute.
$scope.close = function() {
+ var add=function(){
+ Upload.upload({
+ url: 'http://localhost:8001/api/employee',
+ method: 'POST',
+ data: {
+ 'name': $scope.name,
+ 'employee':$scope.employee,
+ 'file':$scope.file
+ }
+ })
+ .success(function(data){
+ //$scope.newprofile = {};
+ $scope.emp2 = data;
+
+ })
+ .error(function(data){
+ console.log(data);
+ })
+ }
+ add();
close({
name: $scope.name,
- age: $scope.employee,
+ employee: $scope.employee,
+ file:$scope.file
}, 500); // close, but give 500ms for bootstrap to animate
};
@@ -65,36 +74,37 @@ angular.module('myapp',['ngRoute','ui.bootstrap','angularModalService','ngAnimat
$element.modal('hide');
// Now call close, returning control to the caller.
- close({
+ close(
+ {
name: $scope.name,
- age: $scope.age
+ employee: $scope.employee,
+ file:$scope.file
}, 500); // close, but give 500ms for bootstrap to animate
};
- function add(){
- Upload.upload({
- url: 'http://localhost:8001/api/user',
- method: 'POST',
- data: {
- 'name': $scope.name,
- 'customer':$scope.employee
- }
- })
- }}]
+ }]
)
-.controller('SampleController', ['$scope', 'ModalService', function($scope, ModalService){
+.controller('SampleController', ['$scope', 'ModalService','$http', function($scope, ModalService,$http){
+ $scope.getUser1= function() {
+ $scope.emp2=[];
+ $http
+ .get('http://localhost:8001/api/employeename')
+ .then(function (d) {
+ $scope.emp2 = d.data;
+ console.log($scope.emp2)
+ })
+ }
$scope.showComplex = function() {
-
+ $scope.getUser1();
ModalService.showModal({
templateUrl: "views/modal.html",
controller: "ComplexController",
inputs: {
- title: "A More Complex Example"
+ title: "A More Complex Example",
+ emp: $scope.emp2
}
}).then(function(modal) {
- // modal.element.modal();
modal.close.then(function(result) {
- $scope.complexResult = "Name: " + result.name + ", EmployeeName: " + result.employee;
});
});
diff --git a/login/views/list.html b/login/views/list.html
index 1397e12..4caf26b 100644
--- a/login/views/list.html
+++ b/login/views/list.html
@@ -1,24 +1,22 @@
-
-
Show Complex
-
{{complexResult}}
+
+
+
+
+ {{e.Name}}
+
+
+
+
+
+ {{e.EmployeeId}}
+
+
+
+
+
-
-
-
- {{emp.Name}}
-
-
- {{emp.File}}
-
-
- {{emp.}}
-
-
-
-
\ No newline at end of file
+
diff --git a/login/views/login.html b/login/views/login.html
index 18ec67f..fc85007 100644
--- a/login/views/login.html
+++ b/login/views/login.html
@@ -2,7 +2,6 @@
-