Skip to content

Commit

Permalink
adding new auth service with logout
Browse files Browse the repository at this point in the history
  • Loading branch information
vishivish18 committed Mar 12, 2016
1 parent 39f3a10 commit 81f548f
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 125 deletions.
24 changes: 24 additions & 0 deletions app/controllers/api/stockists.js
Expand Up @@ -67,4 +67,28 @@ router.get('/count', function(req, res, next) {

})



router.delete('/:_id', function(req, res, next) {

console.log(req.params._id)

Stockist.findById(req.params._id, function(err, stockist) {
if (err) {
// handle error
}

stockist.remove(function(err) {
if (err) {
res.send(err)
}
res.json({
message: 'Stockist Deleted'
})
}); //Removes the document
})


});

module.exports = router
6 changes: 3 additions & 3 deletions gulp/scripts.js
Expand Up @@ -4,11 +4,11 @@ var uglify = require('gulp-uglify')
var ngAnnotate = require('gulp-ng-annotate')
var sourcemaps = require('gulp-sourcemaps')

gulp.task('js', function() {
return gulp.src(['public/app/controllers/module.js', 'public/app/controllers/**/*.js'])
gulp.task('js', function() {
return gulp.src(['public/app/controllers/module.js', 'public/app/**/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('app.js'))
.pipe(ngAnnotate()) // ngAnnotate is causing trouble sunddenly , so skipping uglifying for a while
.pipe(ngAnnotate())
.pipe(uglify())
.pipe(sourcemaps.write())
.pipe(gulp.dest('public/assets'))
Expand Down
8 changes: 0 additions & 8 deletions public/app/controllers/error.ctrl.js

This file was deleted.

2 changes: 1 addition & 1 deletion public/app/controllers/homeCtrl.js
@@ -1,5 +1,5 @@
angular.module('app')
.controller('HomeCtrl', function($scope, $http) {
.controller('homeCtrl', function($scope, $http) {
$scope.model = "";


Expand Down
13 changes: 0 additions & 13 deletions public/app/controllers/login.ctrl.js

This file was deleted.

14 changes: 0 additions & 14 deletions public/app/controllers/register.ctrl.js

This file was deleted.

13 changes: 13 additions & 0 deletions public/app/controllers/resources/employeesCtrl.js
Expand Up @@ -16,6 +16,19 @@ angular.module('app')

$scope.setup();

$scope.deleteEmployee = function(employee_id) {
if (!confirm('Are you sure?')) return;
$http.delete('/api/employees/'+ employee_id)
.then(function(response) {
console.log(response)
$scope.setup();

}, function(response) {
console.log(response)
// if error occurs
});

}


})
Expand Down
12 changes: 12 additions & 0 deletions public/app/controllers/resources/stockistsCtrl.js
Expand Up @@ -16,7 +16,19 @@ angular.module('app')

$scope.setup();

$scope.deleteStockist = function(stockist_id) {
if (!confirm('Are you sure?')) return;
$http.delete('/api/stockists/'+ stockist_id)
.then(function(response) {
console.log(response)
$scope.setup();

}, function(response) {
console.log(response)
// if error occurs
});

}

})

53 changes: 34 additions & 19 deletions public/app/controllers/routes.js
Expand Up @@ -8,11 +8,12 @@ angular.module('app')
url: '/',
views: {
'header': {
templateUrl: '/nav.html'
templateUrl: '/nav.html',
controller: 'navCtrl'
},
'content': {
templateUrl: '/login.html',
controller: 'LoginCtrl'
controller: 'loginCtrl'
}
}
})
Expand All @@ -21,11 +22,12 @@ angular.module('app')
url: 'login',
views: {
'header': {
templateUrl: '/nav.html'
templateUrl: '/nav.html',
controller: 'navCtrl'
},
'content': {
templateUrl: '/login.html',
controller: 'LoginCtrl'
controller: 'loginCtrl'

}
}
Expand All @@ -36,7 +38,7 @@ angular.module('app')
views: {
'content@': {
templateUrl: 'register.html',
controller: 'RegisterCtrl'
controller: 'registerCtrl'
}
}

Expand All @@ -48,22 +50,12 @@ angular.module('app')
views: {
'content@': {
templateUrl: 'users/home.html',
controller: 'HomeCtrl'
}
}

})

.state('app.home.vehicles', {
url: '/vehicles/new',
views: {
'content@': {
templateUrl: 'vehicles/newVehicle.html',
controller: 'VehiclesNewInfoCtrl'
controller: 'homeCtrl'
}
}

})


.state('app.products', {
url: 'products',
Expand Down Expand Up @@ -160,6 +152,18 @@ angular.module('app')
}
}

})

.state('app.stockists.details', {
url: '/:id',

views: {
'content@': {
templateUrl: 'resources/editStockst.html',
controller: 'editStockistCtrl'
}
}

})


Expand Down Expand Up @@ -187,6 +191,18 @@ angular.module('app')

})

.state('app.employees.details', {
url: '/:id',

views: {
'content@': {
templateUrl: 'resources/editEmployees.html',
controller: 'editEmployeesCtrl'
}
}

})


// Sales Menu

Expand Down Expand Up @@ -280,8 +296,7 @@ angular.module('app')
url: 'about',
views: {
'content@': {
templateUrl: 'settings/about.html',
controller: 'HomeCtrl'
templateUrl: 'settings/about.html',
}
}

Expand Down
40 changes: 0 additions & 40 deletions public/app/controllers/user.svc.js

This file was deleted.

2 changes: 1 addition & 1 deletion public/app/views/nav.html
Expand Up @@ -65,7 +65,7 @@
<li><a ui-sref=".bug">Report A Bug</a></li>
<li><a ui-sref=".feedback">Feedback</a></li>
<li><a ui-sref=".about">About</a></li>
<li ui-sref-active="active"><a ui-sref=".login">Logout</a></li>
<li ><a href="#" ng-click="logout()">Logout</a></li>
</ul>
</li>

Expand Down
27 changes: 14 additions & 13 deletions public/app/views/resources/employees.html
@@ -1,33 +1,34 @@
<div class="container">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<a class="btn btn-primary btn-sm pull-left" ui-sref=".new">+ Add New Employee</a>
</div>
<br/><br/>
<br/>
<br/>
</div>
<table class="table table-hover table-striped table-bordered ">
<thead>
<tr>
<th>Code</th>
<th>Name</th>
<th>Area Code</th>
<th>Area Code</th>
<th>Opening Balance</th>
<th>BST Code</th>
<th>Date</th>
<th>Edit</th>
<th>BST Code</th>
<th>Date</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="employee in model | filter:searchProducts">
<td>{{employee.employee_code}}</td>
<td>{{employee.employee_name}}</td>
<td>{{employee.employee_areacode}}</td>
<td>{{employee.employee_openingbalance}}</td>
<td>{{employee.employee_bstcode}}</td>
<td>{{employee.employee_name}}</td>
<td>{{employee.employee_areacode}}</td>
<td>{{employee.employee_openingbalance}}</td>
<td>{{employee.employee_bstcode}}</td>
<td>{{employee.date}}</td>

<td><a class="btn btn-default" ui-sref=".details({id:employee._id})"><span class="glyphicon glyphicon-pencil"></span> Edit</a></td>
<td><a href="" ui-sref=".details({id:employee._id})"><span class="glyphicon glyphicon-pencil edit"></span></a></td>
<td><a href="" ng-click="deleteEmployee(employee._id)"><span class="glyphicon glyphicon-trash delete"></span></a></td>
</tbody>
</table>
</div>

27 changes: 14 additions & 13 deletions public/app/views/resources/stockists.html
@@ -1,33 +1,34 @@
<div class="container">
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12">
<a class="btn btn-primary btn-sm pull-left" ui-sref=".new">+ Add New Stockist</a>
</div>
<br/><br/>
<br/>
<br/>
</div>
<table class="table table-hover table-striped table-bordered ">
<thead>
<tr>
<th>Code</th>
<th>Name</th>
<th>Area Code</th>
<th>Area Code</th>
<th>Opening Balance</th>
<th>BST Code</th>
<th>Date</th>
<th>Edit</th>
<th>BST Code</th>
<th>Date</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="stockist in model | filter:searchProducts">
<td>{{stockist.stockist_code}}</td>
<td>{{stockist.stockist_name}}</td>
<td>{{stockist.stockist_areacode}}</td>
<td>{{stockist.stockist_openingbalance}}</td>
<td>{{stockist.stockist_bstcode}}</td>
<td>{{stockist.stockist_name}}</td>
<td>{{stockist.stockist_areacode}}</td>
<td>{{stockist.stockist_openingbalance}}</td>
<td>{{stockist.stockist_bstcode}}</td>
<td>{{stockist.date}}</td>

<td><a class="btn btn-default" ui-sref=".details({id:value.device_id})"><span class="glyphicon glyphicon-pencil"></span> Edit</a></td>
<td><a href="" ui-sref=".details({id:stockist._id})"><span class="glyphicon glyphicon-pencil edit"></span></a></td>
<td><a href="" ng-click="deleteStockist(stockist._id)"><span class="glyphicon glyphicon-trash delete"></span></a></td>
</tbody>
</table>
</div>

0 comments on commit 81f548f

Please sign in to comment.