[go: nahoru, domu]

Skip to content

Commit

Permalink
upcoming, new time picker, auth user api call
Browse files Browse the repository at this point in the history
  • Loading branch information
notRealLi committed Jul 4, 2019
1 parent 1daa0f8 commit 683da34
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/Controllers/Http/HomeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,9 @@ class HomeController {
.where('status', 'Approved')
.whereRaw("bookings.'from' >= ?", moment().format('YYYY-MM-DDTHH:mm')) // eslint-disable-line
.select('*')
.orderBy('from', 'asc')
.orderBy('from', 'desc')
.with('room')
.limit(3)
.limit(4)
.fetch();

bookings = bookings.toJSON();
Expand Down
2 changes: 0 additions & 2 deletions app/Controllers/Http/RoomController.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,6 @@ class RoomController {

async searchRooms ({ request, view }) {
const options = request.all();
options.from = moment(options.from, 'HH:mm A').format('HH:mm');
options.to = moment(options.to, 'HH:mm A').format('HH:mm');

const duration = Number(options.hour) * 60;
const difference = Math.abs(moment.duration(moment(options.from, 'HH:mm').diff(moment(options.to, 'HH:mm'))).asMinutes());
Expand Down
22 changes: 22 additions & 0 deletions app/Outlook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,28 @@ module.exports = class Outlook {
}
}

/**
* Authenticate an Outlook account.
*
* @param {String} email
* @param {String} password
*/
async authUser ({ email, password }) {
if (Env.get('DEV_OUTLOOK', 'prod') === 'prod') {
try {
const res = await axios.post(`${Env.get('EXCHANGE_AGENT_SERVER', 'localhost:3000')}/auth`, {
email,
password
});

return res.data;
} catch (err) {
console.log(err);
return null;
}
}
}

async findAvail ({ room, start, end, duration, floor }) {
const res = await axios.post(`${Env.get('EXCHANGE_AGENT_SERVER', 'http://localhost:3000')}/findAvail`, {
room,
Expand Down
4 changes: 2 additions & 2 deletions public/js/timepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ $(function () {

$('#from').on("change.datetimepicker", function (e) {
if($('#to').datetimepicker('date').isSameOrBefore(e.date))
$('#to').datetimepicker('date', e.date.add(1, 'hour').format('HH:mm'));
$('#to').datetimepicker('date', e.date.add(0.5, 'hour').format('HH:mm'));
});
});

$(function () {
$('#to').datetimepicker({
format: 'HH:mm',
stepping: 30,
defaultDate: moment(round(moment()), 'HH:mm').add(1, 'h')
defaultDate: moment(round(moment()), 'HH:mm').add(0.5, 'h')
});
});
8 changes: 4 additions & 4 deletions resources/views/partials/searchForm.edge
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>
{{-- Meeting time from --}}
<div class='row'>
<div class='col col-sm-4 form-group mb-4 mr-3'>
<div class='col col-sm-4 form-group mb-4'>
<label for='from' aria-labelledby='from-error'>{{ antl.formatMessage('roomDetails.bookingStart') }} <strong class='text-danger'>*</strong></label>
{{-- If field is not filled correctly show an error box --}}
<div class='timePicker' style='display: flex;'>
Expand Down Expand Up @@ -72,7 +72,7 @@
<div id='from-error' class='invalid-feedback show-invalid'>{{ getErrorFor('from')}}</div>
@endif
</div>
<div class='col col-sm-4 form-group mb-4 mr-3'>
<div class='col col-sm-4 form-group mb-4'>
<label for='to' aria-labelledby='to-error' data-toggle='tooltip'>{{ antl.formatMessage('roomDetails.bookingEnd') }} <strong class='text-danger'>*</strong></label>
<div style='display: flex;' class='timePicker'>
<!--
Expand Down Expand Up @@ -102,11 +102,11 @@
<div id='to-error' class='invalid-feedback show-invalid'>{{ getErrorFor('to')}}</div>
@endif
</div>
<div class='col col-sm-3 form-group mb-1'>
<div class='col col-sm-4 form-group mb-1'>
<label for='duration'>{{ antl.formatMessage('searchForm.duration') }} </label> <strong class='text-danger'>*</strong>
<div class='form-group'>
<div class='input-group mb-3'>
<input class='form-control duration-input' name='hour' type='number' min=0.5 max=10 step=0.5 value='{{ old('hour', '1') }}'>
<input class='form-control duration-input' name='hour' type='number' min=0.5 max=10 step=0.5 value='{{ old('hour', '0.5') }}'>
<div class="input-group-append">
<span class="input-group-text duration-append">hr</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion start/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Route.on('/manageBookings').render('userPages/manageBookings').as('manageBooking
// Rendering Results
Route.get('/results', 'RoomController.findSpecific').as('results').middleware(['auth']).validator('SearchRoom').middleware(['isUser']);
Route.get('/recurringResults', 'RoomController.searchRecurring2').as('recurringResults');
Route.get('/findAvailable', 'RoomController.searchRooms').as('findAvailable');
Route.get('/findAvailable', 'RoomController.searchRooms').as('findAvailable').validator('SearchRoom');

// Booking a Room
Route.post('/confirmBooking', 'BookingController.confirmBooking').as('confirmBooking').validator('BookRoom').middleware(['isUser']);
Expand Down

0 comments on commit 683da34

Please sign in to comment.