diff --git a/backend/app/Http/Controllers/UserController.php b/backend/app/Http/Controllers/UserController.php index 6be69f8..664cdf8 100644 --- a/backend/app/Http/Controllers/UserController.php +++ b/backend/app/Http/Controllers/UserController.php @@ -11,9 +11,13 @@ class UserController extends Controller /** * Display a listing of the resource. */ - public function index() + public function index(Request $request) { + $requestedCols = ['id', 'chief', 'last_access', 'name', 'available', 'driver', 'services', 'availability_minutes']; + if($request->user()->isAbleTo("users-read")) $requestedCols[] = "phone_number"; + return User::where('hidden', 0) + ->select($requestedCols) ->orderBy('available', 'desc') ->orderBy('chief', 'desc') ->orderBy('services', 'asc') diff --git a/frontend/src/app/_components/modal-alert/modal-alert.component.html b/frontend/src/app/_components/modal-alert/modal-alert.component.html index 401b79e..a755b2f 100644 --- a/frontend/src/app/_components/modal-alert/modal-alert.component.html +++ b/frontend/src/app/_components/modal-alert/modal-alert.component.html @@ -42,7 +42,7 @@ - + + \ No newline at end of file diff --git a/frontend/src/app/_components/modal-alert/modal-alert.component.ts b/frontend/src/app/_components/modal-alert/modal-alert.component.ts index ba3485f..9013aab 100644 --- a/frontend/src/app/_components/modal-alert/modal-alert.component.ts +++ b/frontend/src/app/_components/modal-alert/modal-alert.component.ts @@ -60,7 +60,7 @@ export class ModalAlertComponent implements OnInit, OnDestroy { } saveAlertSettings() { - if(!this.auth.profile.hasRole('SUPER_EDITOR')) return; + if(!this.auth.profile.can('users-read')) return; this.api.post(`alerts/${this.id}/settings`, { notes: this.notes }).then((response) => { @@ -69,7 +69,7 @@ export class ModalAlertComponent implements OnInit, OnDestroy { } deleteAlert() { - if(!this.auth.profile.hasRole('SUPER_EDITOR')) return; + if(!this.auth.profile.can('users-read')) return; Swal.fire({ title: "Sei sicuro di voler ritirare l'allarme?", text: "I vigili verranno avvisati dell'azione", diff --git a/frontend/src/app/_components/table/table.component.html b/frontend/src/app/_components/table/table.component.html index 94fc6ff..1c626b3 100644 --- a/frontend/src/app/_components/table/table.component.html +++ b/frontend/src/app/_components/table/table.component.html @@ -5,7 +5,7 @@ {{ 'name'|translate|titlecase }} {{ 'available'|translate|titlecase }} {{ 'driver'|translate|titlecase }} - + {{ 'call'|translate|titlecase }} {{ 'services'|translate|titlecase }} @@ -16,7 +16,7 @@ - + red helmet red helmet {{ row.name }} @@ -29,8 +29,10 @@ driver - - + + + + {{ row.services }} {{ row.availability_minutes }} diff --git a/frontend/src/app/_components/table/table.component.ts b/frontend/src/app/_components/table/table.component.ts index 391e855..9ac16bd 100644 --- a/frontend/src/app/_components/table/table.component.ts +++ b/frontend/src/app/_components/table/table.component.ts @@ -68,7 +68,7 @@ export class TableComponent implements OnInit, OnDestroy { } onChangeAvailability(user: number, newState: 0|1) { - if(this.auth.profile.hasRole('SUPER_EDITOR')) { + if(this.auth.profile.can('users-read')) { this.changeAvailability.emit({user, newState}); } } diff --git a/frontend/src/app/_routes/list/list.component.html b/frontend/src/app/_routes/list/list.component.html index d71e801..69d4540 100644 --- a/frontend/src/app/_routes/list/list.component.html +++ b/frontend/src/app/_routes/list/list.component.html @@ -18,7 +18,7 @@ -
+