Skip to content

Commit

Permalink
refresh cache ajax action
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorarnau committed Jul 22, 2019
1 parent 3a38f13 commit e9f1b16
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 13 deletions.
38 changes: 33 additions & 5 deletions src/admin/accions/admin_ajax_actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use Omatech\Editora\Admin\Models\Security;
use Omatech\Editora\Admin\Models\Relations;
use Omatech\Editora\Admin\Models\Instances;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

class AdminAjaxActions extends AuthController
{
Expand All @@ -27,15 +30,40 @@ public function render()
}
if ($r->order_relation($_REQUEST['instance_id'], $values)) {
$sended = true;
}
if ($sended) {
echo getMessage('saved');
}else {
echo getMessage('saved_wrong');
}
}elseif($_REQUEST['ajax'] == 'refresh_view'){

if (config('editora-admin.curl-refresh-command')!='') {
$curl_command = config('editora-admin.curl-refresh-command');

$inst_id = $_REQUEST['inst_id'];

$array_langs = config('editora-admin.languages');
$instances = new Instances;
foreach($array_langs as $language){
$lanice= $instances->get_niceurl($inst_id, $language);
$niceurl = '/'.$language.'/'.$lanice;

$process = new Process($curl_command.$niceurl);
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
}



}
}
}

if ($sended) {
echo getMessage('saved');
}else {
echo getMessage('saved_wrong');
}

}

die();
Expand Down
11 changes: 6 additions & 5 deletions src/admin/accions/admin_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ public function render()
{
$security = new Security();
if ($security->login($_REQUEST['p_username'], $_REQUEST['p_password'], $_REQUEST['u_lang'])==1) {
if (isset($_SESSION['last_page']) && $_SESSION['last_page']!='') {
redirect_action($_SESSION['last_page']);
} else {
redirect_action(route('editora.action', 'get_main'));
}
redirect_action(route('editora.action', 'get_main'));
// if (isset($_SESSION['last_page']) && $_SESSION['last_page']!='') {
// redirect_action($_SESSION['last_page']);
// } else {
// redirect_action(route('editora.action', 'get_main'));
// }
} else {
$_SESSION['error_login'] = getMessage('info_error');
redirect_action(route('editora.action', '/'));
Expand Down
9 changes: 9 additions & 0 deletions src/admin/models/instances.php
Original file line number Diff line number Diff line change
Expand Up @@ -1284,4 +1284,13 @@ function check_urlnice($p_inst_id)

return true;
}


function get_niceurl($id, $lang='ca')
{
$sql="select niceurl from omp_niceurl n, omp_instances i where i.id=inst_id and inst_id=".$id." and (language='".$lang."' or language='ALL')";

$Row = parent::get_one($sql);
return $Row['niceurl'];
}
}
30 changes: 28 additions & 2 deletions src/admin/views/pages/instance.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
@if(isset($parents) && !empty($parents))
<li><button class="btn-square clr-dark" id="btn-toggle-relations"><i class="icon-link-rel"></i><span class="sr-only">Objetos padre</span></button></li>
@endif
{{--<li><button class="btn-square clr-dark"><i class="icon-information-outline"></i><span class="sr-only">Información</span></button></li>--}}
{{--<li><button class="btn-square clr-dark"><i class="icon-settings"></i><span class="sr-only">configuración</span></button></li>--}}


@if($_SESSION['user_type']=='O' && $_SESSION['rol_id']==1 )
{{-- <li><button class="btn-square clr-dark"><i class="icon-information-outline"></i><span class="sr-only">Información</span></button></li> --}}
@endif

{{--<li><button class="btn-square clr-dark"><i class="icon-eye"></i><span class="sr-only">Previsionalizar</span></button></li>--}}
@if($p_mode=='V')
<li class="dropdown related-dropdown">
Expand All @@ -34,6 +38,11 @@
@if($instance['status']!="O")
<a href="{{route('editora.action', 'delete_instance/?p_pagina=1&p_class_id='.$instance['class_id'].'&p_inst_id='.$instance['id'])}}" class="dropdown-item"><i class="icon-delete"></i>Eliminar</a>
@endif

<a onclick="refreshView({{$instance['id']}});" class="dropdown-item"><i class="icon-refresh"></i>Refresh View</a>



</div>
</div>
</li>
Expand Down Expand Up @@ -219,5 +228,22 @@
$(this).parent().addClass('active');
});
});
function refreshView(inst_id) {
info = 'ajax=refresh_view&inst_id='+inst_id;
$.ajax({
url: '{{route('editora.action', 'ajax_actions')}}',
type: "GET",
data: info,
success: function(data){
alert( "Refresh ok" );
}
});
}
</script>


@endsection
3 changes: 2 additions & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
'prefix' => 'editora',
],
'uploads-storage' => 'public',
'url-storage-relative' => true
'url-storage-relative' => true,
'curl-refresh-command' => ''
];

0 comments on commit e9f1b16

Please sign in to comment.