Skip to content
Snippets Groups Projects
Commit 89d19325 authored by efalcy's avatar efalcy
Browse files

dev #64203 refacto progress bar

parent b9bff8fb
Branches
Tags
2 merge requests!2345Dev#64203 urgent probleme de connexion pour les abonnes ayant plusieurs sites de rattachement suite dedoublonnage sous nanook dans les 4 phases de migration,!2329Dev#64203 urgent probleme de connexion pour les abonnes ayant plusieurs sites de rattachement suite dedoublonnage sous nanook dans les 4 phases de migration
Pipeline #2448 passed with stage
in 20 minutes and 47 seconds
......@@ -100,10 +100,7 @@ class Admin_UsersController extends ZendAfi_Controller_Action {
$done = $total - $db_double_finder->countDouble();
return $this->_helper->json(['total' => $total,
'done' => $done,
'cursor' => $new_cursor,
'run' => $continue]);
return $this->_helper->progressbar($total, $done, $new_cursor, $continue);
}
......
......@@ -16,19 +16,10 @@ echo $this->button((new Class_Entity())
['style' => 'filter: invert();']))
->setText($this->_('Retour à la gestion des utilisateurs')));
echo $this->button((new Class_Entity())
->setAttribs([
'id' => 'dedupe-users-button',
'onclick' => sprintf('dedupeUsers(\'%s\', %d);',
Class_Url::relative('/admin/users/delete-double'),
$this->double_manager->countDouble())])
->setImage($this->tagImg(Class_Admin_Skin::current()
->getIconUrl('actions',
'test'),
['style' => 'filter: invert();']))
->setText($this->_('Lancer le dédoublonnage automatique')
. $this->tag('span', '')));
echo $this->button((new Class_ButtonDescription())
->beProgressbar($this, Class_Url::relative('/admin/users/delete-double'),
$this->double_manager->countDouble(),
$this->_('Lancer le dédoublonnage automatique')));
echo $this->button((new Class_Entity())
......
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_ButtonDescription extends Class_Entity {
public function beProgressbar($view, $url, $total, $text) {
Class_ScriptLoader::getInstance()->addAdminScript('progressbar.js');
$id = md5(implode(',',$this->_attribs));
$this->setAttribs([
'id' => $id,
'onclick' => sprintf('progressbar(\'%s\',\'%s\', %d);',
$id, $url,$total)
])
->setImage($view->tagImg(Class_Admin_Skin::current()
->getIconUrl('actions',
'test'),
['style' => 'filter: invert();']))
->setText($text.$view->tag('span', ''));
return $this;
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_Controller_Action_Helper_Progressbar extends Zend_Controller_Action_Helper_Abstract {
public function progressbar($total, $done, $cursor, $run) {
$this->getActionController()
->getHelper('json')
->direct( ['total' => $total,
'done' => $done,
'cursor' => $cursor,
'run' => $run]);
}
public function direct($total, $done, $cursor, $run) {
return $this->progressbar($total, $done, $cursor, $run);
}
}
......@@ -71,4 +71,5 @@ class ZendAfi_View_Helper_Admin_Button extends ZendAfi_View_Helper_Button {
return $button->getElement();
}
}
\ No newline at end of file
......@@ -152,33 +152,3 @@ var updateSelectWidget = function(element) {
}
var dedupeUsers = function(url, total, cursor = 0) {
var run;
$.ajax({
type: 'GET',
url: url,
data: {'total': total,
'cursor': cursor},
success: function(data)
{
var percent = data.done * 100 / total;
var new_cursor = data.cursor;
run = data.run;
percent = percent ? percent : 1;
$("#dedupe-users-button span")
.progressbar({value: percent});
if(run)
dedupeUsers(url, total, new_cursor);
},
complete: function(event, ui) {
if(run)
return;
$("#dedupe-users-button span")
.progressbar({value: 100});
location.reload();
}});
}
var progressbar = function(id, url, total, cursor = 0) {
var run;
var tag = $("#" + id + " span");
$.ajax({
type: 'GET',
url: url,
data: {'total': total,
'cursor': cursor},
success: function(data)
{
var percent = data.done * 100 / total;
var new_cursor = data.cursor;
run = data.run;
percent = percent ? percent : 1;
tag.progressbar({value: percent});
if(run)
progressbar(id, url, total, new_cursor);
},
complete: function(event, ui) {
if(run)
return;
tag.progressbar({value: 100});
location.reload();
}});
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment