mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-09 11:42:28 +01:00
Add link deletion
This commit is contained in:
parent
fb3a3dfe1c
commit
c2633d5ff4
@ -79,10 +79,25 @@ class AjaxController extends Controller {
|
||||
if (!$user) {
|
||||
abort(404, 'User not found.');
|
||||
}
|
||||
|
||||
$user->delete();
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public function deleteLink(Request $request) {
|
||||
self::ensureAdmin();
|
||||
|
||||
$link_ending = $request->input('link_ending');
|
||||
$link = LinkHelper::linkExists($link_ending);
|
||||
|
||||
if (!$link) {
|
||||
abort(404, 'Link not found.');
|
||||
}
|
||||
|
||||
$link->delete();
|
||||
return "OK";
|
||||
}
|
||||
|
||||
public function toggleLink(Request $request) {
|
||||
self::ensureAdmin();
|
||||
|
||||
|
@ -43,6 +43,7 @@ $app->post('/api/v2/admin/toggle_api_active', ['as' => 'api_toggle_api_active',
|
||||
$app->post('/api/v2/admin/generate_new_api_key', ['as' => 'api_generate_new_api_key', 'uses' => 'AjaxController@generateNewAPIKey']);
|
||||
$app->post('/api/v2/admin/delete_user', ['as' => 'api_generate_new_api_key', 'uses' => 'AjaxController@deleteUser']);
|
||||
$app->post('/api/v2/admin/toggle_link', ['as' => 'api_toggle_link', 'uses' => 'AjaxController@toggleLink']);
|
||||
$app->post('/api/v2/admin/delete_link', ['as' => 'api_delete_link', 'uses' => 'AjaxController@deleteLink']);
|
||||
|
||||
/* API shorten */
|
||||
$app->post('/api/v2/action/shorten', ['as' => 'api_shorten_url', 'uses' => 'Api\ApiLinkController@shortenLink']);
|
||||
|
@ -41,6 +41,19 @@ $(function () {
|
||||
});
|
||||
});
|
||||
|
||||
$('.delete-link').click(function () {
|
||||
var te = $(this);
|
||||
var link_ending = te.data('link-ending');
|
||||
|
||||
apiCall('admin/delete_link', {
|
||||
'link_ending': link_ending,
|
||||
}, function (new_status) {
|
||||
te.text('Deleted!');
|
||||
te.addClass('btn-disabled');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('.toggle-link').click(function () {
|
||||
var te = $(this);
|
||||
var link_ending = te.data('link-ending');
|
||||
|
@ -8,6 +8,7 @@
|
||||
@if ($role == 'admin')
|
||||
<th>Creator</th>
|
||||
<th>Disable</th>
|
||||
<th>Delete</th>
|
||||
@endif
|
||||
|
||||
</tr>
|
||||
@ -22,6 +23,7 @@
|
||||
|
||||
@if ($role == 'admin')
|
||||
<td>{{$link->creator}}</td>
|
||||
|
||||
<td>
|
||||
<a data-link-ending='{{$link->short_url}}' class='btn btn-sm @if($link->is_disabled) btn-success @else btn-danger @endif toggle-link'>
|
||||
@if ($link->is_disabled)
|
||||
@ -31,6 +33,13 @@
|
||||
@endif
|
||||
</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a data-link-ending='{{$link->short_url}}' class='btn btn-sm btn-danger delete-link'>
|
||||
Delete
|
||||
</a>
|
||||
</td>
|
||||
|
||||
@endif
|
||||
|
||||
</tr>
|
||||
|
Loading…
Reference in New Issue
Block a user