new: [GalaxyPicking] Choose the galaxy namespace first before showing

related galaxies
pull/3347/head
Sami Mokaddem 2018-06-12 13:11:29 +00:00
parent 5f36725ede
commit 635d1fcc5d
2 changed files with 19 additions and 3 deletions

View File

@ -64,14 +64,30 @@ class GalaxiesController extends AppController {
}
}
public function selectGalaxy($target_id, $target_type='event') {
$galaxies = $this->Galaxy->find('all', array('recursive' => -1));
public function selectGalaxy($target_id, $target_type='event', $namespace='misp') {
$conditions = $namespace == '0' ? array() : array('namespace' => $namespace);
$galaxies = $this->Galaxy->find('all', array(
'recursive' => -1,
'conditions' => $conditions,
));
$this->set('galaxies', $galaxies);
$this->set('target_id', $target_id);
$this->set('target_type', $target_type);
$this->render('ajax/galaxy_choice');
}
public function selectGalaxyNamespace($target_id, $target_type='event') {
$namespaces = $this->Galaxy->find('list', array(
'recursive' => -1,
'fields' => array('namespace'),
'group' => array('namespace')
));
$this->set('namespaces', $namespaces);
$this->set('target_id', $target_id);
$this->set('target_type', $target_type);
$this->render('ajax/galaxy_namespace_choice');
}
public function selectCluster($target_id, $target_type = 'event', $selectGalaxy = false) {
$conditions = array();
if ($selectGalaxy) {

View File

@ -3093,7 +3093,7 @@ $('.galaxy-toggle-button').click(function() {
$('.addGalaxy').click(function() {
var target_type = $(this).data('target-type');
var target_id = $(this).data('target-id');
getPopup(target_type + '/' + target_id, 'galaxies', 'selectGalaxy');
getPopup(target_type + '/' + target_id, 'galaxies', 'selectGalaxyNamespace');
});
function quickSubmitGalaxyForm(event_id, cluster_id) {