Commit b4cb03ed authored by Samson's avatar Samson
Browse files

done

parent e3a39fc7
......@@ -33,7 +33,7 @@
## Sovelluksen yleiskuvaus
Tarkoituksena on suunnitella ja toteuttaa websovelluksen imaginääristä liikuntapalveluja tarjoavaa yritystä. Palvelun käyttäjät voisivat tehdä liikuntatuntivarauksia ja palvelun ylläpitäjät/vetäjät pystyisivät poistaamaan köyttäjiä tai antaamaan nille varauskieltoa.
Tarkoituksena on suunnitella ja toteuttaa websovelluksen imaginääristä liikuntapalveluja tarjoavaa yritystä varten. Palvelun käyttäjät voisivat tehdä liikuntatuntivarauksia ja palvelun ylläpitäjät/vetäjät pystyisivät poistaamaan käyttäjiä, antaamaan nille varauskieltoa ja lisäämään tulevia liikuntatunteja.
## Kohdeyleisö
......@@ -335,6 +335,12 @@ Sain asennettu komponentin, mutta en saanut siihen dataa tietokannasta.
* Bookings sivulla pääsee selaamaan omat tulevat liikuntatunnit.
* Pystyy myös peruuttaamaan ne
### 'My Courses'-sivu
<img src="links/courses.JPG" alt="FinessStudio" width="700" style="border: 1px solid black">
* Pääsee selailee kirjautuneen admin / master käyttäjän vetämät liikuntatunnit
* Pystyy myös peruuttaamaan ne
### 'Settings'-sivu
<img src="links/settings.JPG" alt="FinessStudio" width="700" style="border: 1px solid black">
......@@ -379,7 +385,7 @@ Tietokantaan on luotu pari näkymää.
```sql
CREATE VIEW calendar AS
SELECT class_is_available.id, class.class_name as class, class.capacity as capacity, class.class_description as description, users.name as teacher, class_is_available.start_time as start, class_is_available.end_time as end
SELECT class_is_available.id, class_is_available.teacher_id as teacher_id, class.class_name as class, class.capacity as capacity, class.difficulty as difficulty, class.class_description as description, users.name as teacher, class_is_available.start_time as start, class_is_available.end_time as end
FROM class_is_available
INNER JOIN class
ON class.id = class_is_available.class_id
......@@ -413,6 +419,8 @@ Suurin ongelma oli se Reactin kalenterikomponentti, johon suhteen luovutin pitk
#### Liikuntatuntien poistaminen
Toinen ongelma oli liikuntatuntien poistaminen Classes sivulla, Laravel ja React ei suostunut tekemään yhteistyötä. FORBIDDEN DELETE METHOD 403. Tämän ominaisuuden voi siirtää ihan puhtaaseen Laraveliin. Teen sen, jos jää aikaa.
PÄIVITYS: Ehdin tekemään tämän.
#### Inputissa datetime-local
Jostain syystä näytti koulukoneella aika jenkkiformatissa, omalla koneella kuitenkin toimii normaalisti. Täytyy tutkia.
......
......@@ -3,6 +3,9 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Auth;
use Illuminate\Support\Facades\DB;
use App\ClassIsAvailable;
class CalendarController extends Controller
{
......@@ -10,4 +13,12 @@ class CalendarController extends Controller
{
return view('calendar');
}
public function my_courses()
{
$courses = DB::table('calendar')
->where('teacher_id','=',Auth::id())
->get();
return view('courses')->with('courses', $courses);
}
}
<?php
namespace App\Http\Controllers;
use App\ClassIsAvailable;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
class ClassIsAvailableController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$class_is_available = ClassIsAvailable::find($id)
->delete();
return redirect()->route('admin.courses')->with('success', 'The Class has beed Deleted');
}
}
......@@ -154,7 +154,7 @@ INNER JOIN booking
```sql
CREATE VIEW calendar AS
SELECT class_is_available.id, class.class_name as class, class.capacity as capacity, class.class_description as description, users.name as teacher, class_is_available.start_time as start, class_is_available.end_time as end
SELECT class_is_available.id, class_is_available.teacher_id as teacher_id, class.class_name as class, class.capacity as capacity, class.difficulty as difficulty, class.class_description as description, users.name as teacher, class_is_available.start_time as start, class_is_available.end_time as end
FROM class_is_available
INNER JOIN class
ON class.id = class_is_available.class_id
......
......@@ -88362,7 +88362,7 @@ function (_Component) {
placeholder: "Search by class name.."
}), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("table", {
className: "table table-hover"
}, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("thead", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("tr", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Name"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Teacher"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Start time"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "End time"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Duration"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Capacity"))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("tbody", null, this.state.courses.map(function (course, index) {
}, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("thead", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("tr", null, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Name"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Teacher"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Start time"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "End time"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Duration"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Difficulty"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("th", null, "Capacity"))), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("tbody", null, this.state.courses.map(function (course, index) {
//console.log(this.state.courses);
if (new Date(course.start) > new Date()) return react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("tr", {
key: index,
......@@ -88370,7 +88370,7 @@ function (_Component) {
onClick: function onClick() {
return _this7.showClass(course.id);
}
}, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, course["class"]), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, course.teacher), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, moment__WEBPACK_IMPORTED_MODULE_3___default()(course.start).format('MMMM Do YYYY, HH:mm:ss')), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, moment__WEBPACK_IMPORTED_MODULE_3___default()(course.end).format('MMMM Do YYYY, HH:mm:ss')), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, (new Date(course.end) - new Date(course.start)) / 60000 + 'min'), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, _this7.countBookings(course.id), "/", course.capacity));
}, react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, course["class"]), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, course.teacher), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, moment__WEBPACK_IMPORTED_MODULE_3___default()(course.start).format('MMMM Do YYYY, HH:mm:ss')), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, moment__WEBPACK_IMPORTED_MODULE_3___default()(course.end).format('MMMM Do YYYY, HH:mm:ss')), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, (new Date(course.end) - new Date(course.start)) / 60000 + 'min'), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, course.difficulty, "/5"), react__WEBPACK_IMPORTED_MODULE_0___default.a.createElement("td", null, _this7.countBookings(course.id), "/", course.capacity));
})))));
}
}]);
......@@ -369,6 +369,7 @@ export default class Course extends Component {
<th>Start time</th>
<th>End time</th>
<th>Duration</th>
<th>Difficulty</th>
<th>Capacity</th>
</tr>
</thead>
......@@ -384,6 +385,7 @@ export default class Course extends Component {
<td>{moment(course.start).format('MMMM Do YYYY, HH:mm:ss')}</td>
<td>{moment(course.end).format('MMMM Do YYYY, HH:mm:ss')}</td>
<td>{((new Date(course.end) - new Date(course.start))/60000+'min')}</td>
<td>{course.difficulty}/5</td>
<td>{this.countBookings(course.id)}/{course.capacity}</td>
</tr>
)}
......
@extends('layouts.app')
@section('content')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading"><h2>Booking Control Panel</h2></div>
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{$message}}</p>
</div>
@endif
@if (session('info'))
<div class="alert alert-info">
{{ session('info') }}
</div>
@endif
<div class="panel-body">
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Booking ID</th>
<th scope="col">Class Name</th>
<th scope="col">Teacher</th>
<th scope="col">Start at</th>
<th scope="col">End at</th>
<th scope="col">Cancel</th>
</tr>
</thead>
<tbody>
@foreach ($courses as $course)
@if($course->start > Carbon\Carbon::now())
<tr>
<th scope="row">{{ $course->id }}</th>
<td>{{ $course->class }}</td>
<td>{{ $course->teacher }}</td>
<td>{{ $course->start }}</td>
<td>{{ $course->end }}</td>
<td>
<form method="post" class="edit-form" action="{{ action('ClassIsAvailableController@destroy', $course->id) }}">
{{csrf_field()}}
<input type="hidden" name="_method" value="DELETE" />
<button type="submit" class="btn btn-danger">Cancel</button>
</form>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$('.delete_form').on('submit', function(){
if(confirm("Are you sure you want to delete it?"))
{
return true;
}
else
{
return false;
}
});
});
</script>
@endsection
\ No newline at end of file
......@@ -50,6 +50,8 @@
@if (Auth::user()->group !== null)
<li><a class="dropdown-item" href="{{ url('/users') }}">Users</a></li>
<li class="divider"></li>
<li><a class="dropdown-item" href="{{ route('admin.courses') }}">My Courses</a></li>
<li class="divider"></li>
@endif
<li><a class="dropdown-item" href="{{ url('/bookings') }}">Bookings</a></li>
</ul>
......
......@@ -14,7 +14,16 @@
<div class="card">
<div class="card-header">{{ __('Welcome, now you can be as jacked as me!') }}</div>
<img class="front-img" src="images\welcome.jpg" style="width:300px; margin:10px; border:1px solid gray">
<div class="container-fluid">
<div class="row" style="padding: 10px;">
<div class="column">
<img src="images\welcome.jpg" style="width:300px; margin:10px; border:1px solid gray; float:left">
</div>
<div class="column">
<img src="images\bjj.jpg" style="width:300px; margin:10px; border:1px solid gray; float:left">
</div>
</div>
</div>
<div class="card-body">
<h3>Fitness Studio v0.1</h3><br>
Physical fitness is a state of health and well-being and, more specifically, the ability to perform aspects of sports, occupations and daily activities. Physical fitness is generally achieved through proper nutrition, moderate-vigorous physical exercise, and sufficient rest.
......
......@@ -46,3 +46,8 @@ Route::post('change-password', 'Auth\ChangePasswordController@changePassword')->
Route::get('change-email', 'Auth\ChangePasswordController@email')->name('email.change');
Route::post('change-email', 'Auth\ChangePasswordController@changeEmail')->name('email.update');
Route::group(['middleware' => ['auth', 'admin']], function() {
Route::get('courses', 'CalendarController@my_courses')->name('admin.courses');
});
Route::delete('courses/{id}', 'ClassIsAvailableController@destroy')->name('delete.course');
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment