-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from dachcom-digital/feature/backend-ui
Feature/backend UI
- Loading branch information
Showing
16 changed files
with
286 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ds_opensearch_controller_admin_index_rebuild_mapping: | ||
path: /admin/ds-index-provider-opensearch/index/rebuild-mapping | ||
methods: [ POST ] | ||
defaults: { _controller: DsOpenSearchBundle\Controller\Admin\IndexController::rebuildMappingAction } | ||
options: | ||
expose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
|
||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: true | ||
|
||
DsOpenSearchBundle\Controller\Admin\IndexController: | ||
tags: | ||
- 'controller.service_arguments' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
services: | ||
|
||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
DsOpenSearchBundle\EventListener\Admin\AssetListener: | ||
tags: | ||
- { name: kernel.event_subscriber } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
|
||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
DsOpenSearchBundle\Manager\IndexManager: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
class DsIndexProviderOpensearch { | ||
|
||
addLayoutToDsSettings(event) { | ||
|
||
this.dsSettings = event.detail.subject; | ||
this.dsContextFullConfig = pimcore.globalmanager.get('dynamic_search.context.full_configuration') || {}; | ||
|
||
const dsActionsPanel = new Ext.panel.Panel({ | ||
layout: 'hbox', | ||
title: 'DsIndexProviderOpenSearch', | ||
bodyPadding: 10, | ||
items: [ | ||
|
||
] | ||
}); | ||
this.dsSettings.panel.add(dsActionsPanel); | ||
|
||
if (Object.keys(this.dsContextFullConfig).length === 0) { | ||
dsActionsPanel.add({ | ||
xtype: 'displayfield', | ||
value: 'Error: no dynamic search context configured' | ||
}); | ||
return; | ||
} | ||
|
||
dsActionsPanel.add({ | ||
xtype: 'toolbar', | ||
docked: 'top', | ||
items: [ | ||
{ | ||
scale: 'small', | ||
margin: '0 10 0 0', | ||
text: t('ds_index_provider_opensearch.actions.index.rebuild_mapping'), | ||
icon: '/bundles/pimcoreadmin/img/flat-color-icons/data_configuration.svg', | ||
menu: this.buildContextButtonMenu( 'rebuild_mapping'), | ||
} | ||
] | ||
}); | ||
|
||
} | ||
|
||
buildContextButtonMenu(action) { | ||
return Object.keys(this.dsContextFullConfig).map(function(context) { | ||
return { | ||
text: context, | ||
handler: function() { | ||
Ext.Msg.confirm( | ||
t(`ds_index_provider_opensearch.actions.index.${action}`) + ': ' + context, | ||
t(`ds_index_provider_opensearch.actions.index.${action}.confirmation.message`), | ||
function (confirmMsg) { | ||
|
||
if (confirmMsg !== 'yes') { | ||
return; | ||
} | ||
|
||
this.performContextIndexAction(context, action); | ||
|
||
}.bind(this) | ||
); | ||
}.bind(this) | ||
} | ||
}.bind(this)) | ||
} | ||
|
||
performContextIndexAction(context, action) { | ||
let url = ''; | ||
|
||
try { | ||
url = Routing.generate('ds_opensearch_controller_admin_index_' + action); | ||
} catch (e) { | ||
Ext.Msg.alert('Error', e.message); | ||
return; | ||
} | ||
|
||
Ext.Ajax.request({ | ||
url: url, | ||
method: 'POST', | ||
params: { | ||
context: context | ||
}, | ||
success: function(response) { | ||
if (response.status === 200) { | ||
pimcore.helpers.showNotification(t('success'), t(`ds_index_provider_opensearch.actions.index.${action}.success`), 'success'); | ||
} else { | ||
pimcore.helpers.showNotification(t('error'), response.responseText, 'error'); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
const dsIndexProviderOpensearch = new DsIndexProviderOpensearch(); | ||
|
||
document.addEventListener('dynamic_search.event.settings.postBuildLayout', dsIndexProviderOpensearch.addLayoutToDsSettings.bind(dsIndexProviderOpensearch)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace DsOpenSearchBundle\Controller\Admin; | ||
|
||
use DsOpenSearchBundle\Manager\IndexManager; | ||
use Pimcore\Bundle\AdminBundle\Controller\AdminAbstractController; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class IndexController extends AdminAbstractController | ||
{ | ||
public function __construct( | ||
protected IndexManager $indexManager | ||
) | ||
{ | ||
} | ||
|
||
public function rebuildMappingAction(Request $request): Response | ||
{ | ||
$contextName = $request->get('context'); | ||
|
||
if (empty($contextName)) { | ||
return new Response('no context given', 400); | ||
} | ||
|
||
try { | ||
$this->indexManager->rebuildIndex($contextName); | ||
} catch (\Throwable $e) { | ||
return new Response($e->getMessage(), 500); | ||
} | ||
|
||
return new Response(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace DsOpenSearchBundle\EventListener\Admin; | ||
|
||
use Pimcore\Event\BundleManager\PathsEvent; | ||
use Pimcore\Event\BundleManagerEvents; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
class AssetListener implements EventSubscriberInterface | ||
{ | ||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
BundleManagerEvents::JS_PATHS => 'addJsFiles' | ||
]; | ||
} | ||
|
||
public function addJsFiles(PathsEvent $event): void | ||
{ | ||
$event->addPaths([ | ||
'/bundles/dsopensearch/js/backend/settings.js', | ||
]); | ||
} | ||
|
||
} |
Oops, something went wrong.