mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
inspector delete application (#4521)
This commit is contained in:
@@ -17,6 +17,7 @@ use Alchemy\Phrasea\Core\Event\Record\Structure\StatusBitUpdatedEvent;
|
||||
use Alchemy\Phrasea\Databox\Subdef\MediaSubdefRepository;
|
||||
use Alchemy\Phrasea\Exception\SessionNotFound;
|
||||
use Alchemy\Phrasea\Model\Entities\ApiApplication;
|
||||
use Alchemy\Phrasea\Model\Manipulator\ApiApplicationManipulator;
|
||||
use Alchemy\Phrasea\Model\Manipulator\ApiOauthTokenManipulator;
|
||||
use Alchemy\Phrasea\Model\Repositories\ApiAccountRepository;
|
||||
use Alchemy\Phrasea\Model\Repositories\ApiOauthTokenRepository;
|
||||
@@ -507,6 +508,13 @@ class RootController extends Controller
|
||||
return $this->app->json(['success' => true]);
|
||||
}
|
||||
|
||||
public function deleteApplication(Request $request, ApiApplication $application)
|
||||
{
|
||||
$this->getApiApplicationManipulator()->delete($application);
|
||||
|
||||
return $this->app->json(['success' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ApiOauthTokenRepository
|
||||
*/
|
||||
@@ -582,4 +590,12 @@ class RootController extends Controller
|
||||
'off_databoxes' => $off_databoxes,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ApiApplicationManipulator
|
||||
*/
|
||||
private function getApiApplicationManipulator()
|
||||
{
|
||||
return $this->app['manipulator.api-application'];
|
||||
}
|
||||
}
|
||||
|
@@ -94,6 +94,11 @@ class Root implements ControllerProviderInterface, ServiceProviderInterface
|
||||
->assert('application', '\d+')
|
||||
->bind('admin_inspector_application_token');
|
||||
|
||||
$controllers->post('/inspector/application/{application}/delete/', 'controller.admin.root:deleteApplication')
|
||||
->before($app['middleware.api-application.converter'])
|
||||
->assert('application', '\d+')
|
||||
->bind('admin_inspector_application_delete');
|
||||
|
||||
return $controllers;
|
||||
}
|
||||
}
|
||||
|
@@ -82,6 +82,7 @@
|
||||
<th>{{ 'admin::inspector: api creation date' | trans }}</th>
|
||||
<th>{{ 'admin::inspector: api modification date' | trans }}</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for apiApplication in apiApplications %}
|
||||
@@ -133,6 +134,9 @@
|
||||
<button class="generate_token btn btn-warning btn-small" data-app-id="{{ apiApplication.getId() }}" href="{{ path('admin_inspector_application_token', { 'application' : apiApplication.getId(), 'user_id' : apiApplication.getCreator().getId() }) }}">{{ 'generate token' }}</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<button class="delete_application btn btn-danger btn-small" data-app-id="{{ apiApplication.getId() }}" href="{{ path('admin_inspector_application_delete', { 'application' : apiApplication.getId() }) }}">{{ 'delete' }}</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@@ -237,7 +241,7 @@
|
||||
$('button.generate_token').bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
if (confirm('Your are about to generate token for application with ID: ' + $this.data('app-id'))) {
|
||||
if (confirm('You are about to generate token for application with ID: ' + $this.data('app-id'))) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.attr('href'),
|
||||
@@ -251,5 +255,32 @@
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('button.delete_application').bind('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
if (confirm('You are about to delete application with ID: ' + $this.data('app-id'))) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: $this.attr('href'),
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if (data.success) {
|
||||
$('#tree li.selected a').trigger('click');
|
||||
|
||||
setTimeout(function(){
|
||||
$('li a[href="#api-info"]').trigger('click');
|
||||
}
|
||||
, 500
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user