Skip to content
Open
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
58 changes: 32 additions & 26 deletions app/assets/javascripts/controllers/check_in.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,31 @@ Application.Controllers.controller "CheckInController",["$rootScope", "$scope",

#when click on find user
$scope.login = () ->
user=$scope.user
Auth.login(user).then (user) ->
# Authentification succeeded ...
url= 'check_ins/'+user.id+'/is_checked'
$('.page-alert').alert 'close'
$.get url, (response)->
$scope.is_checked = response.message
if $scope.is_checked
$scope.messages = _t('you_have_checked_out_successfully')
is_auth = $scope.is_auth = true
$scope.lastcheck=response.lastCheck
$scope.lastcheck.check_in = new Date($scope.lastcheck.check_in).toLocaleString()
if $scope.lastcheck.check_out
$scope.lastcheck.check_out = new Date($scope.lastcheck.check_out).toLocaleString()
Auth.logout(user)
$scope.id = user.id
, (error) ->
# Authentication failed...
$('.page-alert').alert 'close'
createNoty _t('wrong_email_or_password'), 'danger'
$('#my-alert').fadeTo(50000, 500).slideUp 500, ->
$(this).alert 'close'
$('.page-alert .close').click (e) ->
e.preventDefault()
$(this).closest('.page-alert').slideUp()
user=$scope.user
Auth.login(user).then (user) ->
# Authentification succeeded ...
url= 'check_ins/'+user.id+'/is_checked'
$('.page-alert').alert 'close'
$.get url, (response)->
$scope.is_checked = response.message
if $scope.is_checked
$scope.messages = _t('you_have_checked_out_successfully')
is_auth = $scope.is_auth = true
$scope.lastcheck=response.lastCheck
$scope.lastcheck.check_in = new Date($scope.lastcheck.check_in).toLocaleString()
if $scope.lastcheck.check_out
$scope.lastcheck.check_out = new Date($scope.lastcheck.check_out).toLocaleString()
Auth.logout(user)
$scope.id = user.id
, (error) ->
# Authentication failed...
$('.page-alert').alert 'close'
createNoty _t('wrong_email_or_password'), 'danger'
$('#my-alert').fadeTo(50000, 500).slideUp 500, ->
$(this).alert 'close'
$('.page-alert .close').click (e) ->
e.preventDefault()
$(this).closest('.page-alert').slideUp()

#when click check in or checkout
$scope.check = () ->
Expand All @@ -110,6 +110,7 @@ Application.Controllers.controller "CheckInController",["$rootScope", "$scope",
e.preventDefault()
$(this).closest('.page-alert').slideUp()
initialize()

#when click cancel
$scope.cancel =()->
initialize()
Expand All @@ -127,9 +128,14 @@ Application.Controllers.controller "CheckInController",["$rootScope", "$scope",
is_auth = $scope.is_auth = false
is_checked = $scope.is_checked = false
messages = $scope.messages= _t('you_have_checked_in_successfully')

saveAdmin = ->
Admin = Auth._currentUser
if Admin.role == 'admin'
is_admin = $scope.is_admin = true
interval = setInterval(dateUpdate, 1000)
dateUpdate()
saveAdmin()
initialize()


]
2 changes: 1 addition & 1 deletion app/assets/templates/shared/checkin_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
</div>
</header>
<body>
<div ng-if="!is_auth">
<div ng-if="!is_auth && is_admin">
<div class="well m-b-n">

<form role="form" name="checkinForm" class="form-horizontal" novalidate autocomplete="off">
Expand Down
3 changes: 3 additions & 0 deletions app/assets/templates/shared/header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@

<!-- Top Nav -->
<ul class="nav navbar-nav navbar-right m-n hidden-xs nav-user user">
<li ng-if="isAuthenticated() && isAuthorized('admin')"><a href="/#!/checkin" class="font-sbold text-md" >CheckIn-Out</a></li>
<li class="notification-open" ng-if="isAuthenticated()">

<a ui-sref="app.logged.notifications"><i class="fa fa-bell fa-2x black"></i> <span class="badge" ng-class="{'bg-red': notifications.unread > 0}">{{notifications.unread}}</span></a>
</li>

<li class="dropdown user-profile-nav" ng-if="isAuthenticated()" uib-dropdown>
<a href="#" class="dropdown-toggle" uib-dropdown-toggle>
<span class="avatar text-center">
Expand Down