Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Management: use url helpers #10288

Merged
merged 2 commits into from
Jun 1, 2019
Merged
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
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function store(StoreUserRequest $request)
$this->updateDashboard($user, $request->get('dashboard'));

if ($user->save()) {
Toastr::success(__('User :username created', ['username', $user->username]));
Toastr::success(__('User :username created', ['username' => $user->username]));
return redirect(route('users.index'));
}

Expand Down
3 changes: 2 additions & 1 deletion resources/views/user/create.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
@section('content')
<div class="container">
<div class="row">
<form action="users" method="POST" role="form" class="form-horizontal col-md-8 col-md-offset-2">
<form action="{{ route('users.store') }}" method="POST" role="form"
class="form-horizontal col-md-8 col-md-offset-2">
<legend>@lang('Create User')</legend>

<div class="form-group @if($errors->has('username')) has-error @endif">
Expand Down
3 changes: 2 additions & 1 deletion resources/views/user/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
@section('content')
<div class="container">
<div class="row">
<form action="users/{{ $user->user_id }}" method="POST" role="form" class="form-horizontal col-md-8 col-md-offset-2">
<form action="{{ route('users.update', $user->user_id)}}" method="POST" role="form"
class="form-horizontal col-md-8 col-md-offset-2">
<legend>@lang('Edit User'): {{ $user->username }}</legend>
{{ method_field('PUT') }}

Expand Down
10 changes: 5 additions & 5 deletions resources/views/user/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
user_grid.bootgrid({
formatters: {
actions: function (column, row) {
var edit_button = '<form action="users/' + row['user_id'] + '/edit" method="GET">' +
var edit_button = '<form action="{{ route('users.edit', ':user_id') }}'.replace(':user_id', row['user_id']) + '" method="GET">' +
'<button type="submit" title="@lang('Edit')" class="btn btn-sm btn-warning"><i class="fa fa-pencil"></i></button>' +
'</form> ';

var delete_button = '<button type="button" title="@lang('Delete')" class="btn btn-sm btn-danger" onclick="return delete_user(' + row['user_id'] + ', \'' + row['username'] + '\');">' +
'<i class="fa fa-trash"></i></button> ';

var manage_button = '<form action="edituser/" method="GET"';
var manage_button = '<form action="{{ url('edituser') }}/" method="GET"';

if (row['level'] >= 5) {
manage_button += ' style="visibility:hidden;"'
Expand Down Expand Up @@ -89,17 +89,17 @@
});

@if(\LibreNMS\Config::get('auth_mechanism') == 'mysql')
$('.actionBar').append('<div class="pull-left"><a href="users/create" type="button" class="btn btn-primary">@lang('Add User')</a></div>');
$('.actionBar').append('<div class="pull-left"><a href="{{ route('users.create') }}" type="button" class="btn btn-primary">@lang('Add User')</a></div>');
@endif

user_grid.css('display', 'table'); // done loading, show
});

function delete_user(user_id, username)
function delete_user(user_id, username, url)
{
if (confirm('@lang('Are you sure you want to delete ')' + username + '?')) {
$.ajax({
url: 'users/' + user_id,
url: '{{ route('users.destroy', ':user_id') }}'.replace(':user_id', user_id),
type: 'DELETE',
success: function (msg) {
$("#users").bootgrid("remove", [user_id]);
Expand Down