| 1 | {* |
|---|
| 2 | {combine_script id="jquery.ui" path="themes/default/js/ui/minified/jquery.ui.core.min.js"} |
|---|
| 3 | {combine_script id="jquery.ui.dialog" path="themes/default/js/ui/minified/jquery.ui.dialog.min.js"} |
|---|
| 4 | *} |
|---|
| 5 | |
|---|
| 6 | {literal} |
|---|
| 7 | <script type="text/javascript"> |
|---|
| 8 | var processAnalyze = { |
|---|
| 9 | step:0, |
|---|
| 10 | lists:new Array(), |
|---|
| 11 | timeStart:0, |
|---|
| 12 | timeEnd:0 |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | function init() |
|---|
| 16 | { |
|---|
| 17 | formatNbItemPerRequest({/literal}{$datas.NumberOfItemsPerRequest}{literal}); |
|---|
| 18 | /*$("#iamd_nb_item_per_request_slider").slider( |
|---|
| 19 | { |
|---|
| 20 | min:5, |
|---|
| 21 | max:150, |
|---|
| 22 | steps:29, |
|---|
| 23 | startValue:{/literal}{$datas.NumberOfItemsPerRequest}{literal}, |
|---|
| 24 | slide: function(event, ui) { formatNbItemPerRequest(ui.value); } |
|---|
| 25 | } |
|---|
| 26 | );*/ |
|---|
| 27 | getStatus(); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | function formatNbItemPerRequest(nbItems) |
|---|
| 31 | { |
|---|
| 32 | $("#iamd_NumberOfItemsPerRequest").val(nbItems); |
|---|
| 33 | $("#iamd_nb_item_per_request_display").html(nbItems); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | function getStatus() |
|---|
| 37 | { |
|---|
| 38 | $.ajax( |
|---|
| 39 | { |
|---|
| 40 | type: "POST", |
|---|
| 41 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 42 | async: true, |
|---|
| 43 | data: { ajaxfct:"admin.makeStats.getStatus" }, |
|---|
| 44 | success: function (msg) { |
|---|
| 45 | list=msg.split(";"); |
|---|
| 46 | $("#ianalyzestatus").html("<ul><li>"+list[0]+"</li><li>"+list[1]+"</li><li>"+list[2]+"</li></ul>"); |
|---|
| 47 | } |
|---|
| 48 | } |
|---|
| 49 | ); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | function doAnalyze() |
|---|
| 53 | { |
|---|
| 54 | mode="all"; |
|---|
| 55 | modeLabel=""; |
|---|
| 56 | |
|---|
| 57 | if($("#ianalyze_action0").get(0).checked) |
|---|
| 58 | { |
|---|
| 59 | mode="notAnalyzed"; |
|---|
| 60 | modeLabel="{/literal}{'g003_analyze_not_analyzed_pictures'|@translate}{literal}"; |
|---|
| 61 | } |
|---|
| 62 | else if($("#ianalyze_action1").get(0).checked) |
|---|
| 63 | { |
|---|
| 64 | mode="all"; |
|---|
| 65 | modeLabel="{/literal}{'g003_analyze_all_pictures'|@translate}{literal}"; |
|---|
| 66 | } |
|---|
| 67 | else if($("#ianalyze_action2").get(0).checked) |
|---|
| 68 | { |
|---|
| 69 | mode="caddieAdd"; |
|---|
| 70 | modeLabel="{/literal}{'g003_analyze_caddie_add_pictures'|@translate}{literal}"; |
|---|
| 71 | } |
|---|
| 72 | else if($("#ianalyze_action3").get(0).checked) |
|---|
| 73 | { |
|---|
| 74 | mode="caddieReplace"; |
|---|
| 75 | modeLabel="{/literal}{'g003_analyze_caddie_replace_pictures'|@translate}{literal}"; |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | doAnalyzeDialog="<br><form id='iDialogProgress' class='formtable'>"+ |
|---|
| 80 | "<div id='iprogressbar_contener' class='gcBorderInput'>"+ |
|---|
| 81 | "<span id='iprogressbar_bg' class='gcBgInput' style='width:0%;'> </span>"+ |
|---|
| 82 | "<span id='iprogressbar_fg' class='gcLink'>0%</span>"+ |
|---|
| 83 | "</div><p>{/literal}{'g003_analyze_in_progress'|@translate}{literal}"+ |
|---|
| 84 | "<br><img src='./plugins/GrumPluginClasses/icons/processing.gif'>" |
|---|
| 85 | "</p></form>"; |
|---|
| 86 | |
|---|
| 87 | $("#dialog") |
|---|
| 88 | .html("") |
|---|
| 89 | .dialog( |
|---|
| 90 | { |
|---|
| 91 | resizable: false, |
|---|
| 92 | width:480, |
|---|
| 93 | height:120, |
|---|
| 94 | modal: true, |
|---|
| 95 | draggable:true, |
|---|
| 96 | dialogClass: 'gcBgTabSheet gcBorder', |
|---|
| 97 | title: '{/literal}{"g003_updating_metadata"|@translate}{literal} ('+modeLabel+')', |
|---|
| 98 | } |
|---|
| 99 | ).html(doAnalyzeDialog); |
|---|
| 100 | |
|---|
| 101 | NumberOfItemsPerRequest=$("#iamd_NumberOfItemsPerRequest").val(); |
|---|
| 102 | |
|---|
| 103 | $.ajax( |
|---|
| 104 | { |
|---|
| 105 | type: "POST", |
|---|
| 106 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 107 | async: true, |
|---|
| 108 | data: { ajaxfct:"admin.makeStats.getList", selectMode:mode, numOfItems:NumberOfItemsPerRequest }, |
|---|
| 109 | success: function(msg) |
|---|
| 110 | { |
|---|
| 111 | processAnalyze.step=0; |
|---|
| 112 | processAnalyze.lists=msg.split(";"); |
|---|
| 113 | processAnalyze.timeStart=new Date(); |
|---|
| 114 | doStep_processList(); |
|---|
| 115 | }, |
|---|
| 116 | error: function() |
|---|
| 117 | { |
|---|
| 118 | alert('error'); |
|---|
| 119 | } |
|---|
| 120 | } |
|---|
| 121 | ); |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | function displayTime(eTime) |
|---|
| 126 | { |
|---|
| 127 | seconds=(eTime%60).toFixed(2); |
|---|
| 128 | minutes=((eTime-seconds)/60).toFixed(0); |
|---|
| 129 | returned=seconds+"s"; |
|---|
| 130 | if(minutes>0) returned=minutes+"m"+returned; |
|---|
| 131 | return(returned); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | function doStep_processList() |
|---|
| 135 | { |
|---|
| 136 | if(processAnalyze.step < processAnalyze.lists.length) |
|---|
| 137 | { |
|---|
| 138 | $.ajax({ |
|---|
| 139 | type: "POST", |
|---|
| 140 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 141 | async: true, |
|---|
| 142 | data: { ajaxfct:"admin.makeStats.doAnalyze", imagesList:processAnalyze.lists[processAnalyze.step] }, |
|---|
| 143 | success: function(msg) |
|---|
| 144 | { |
|---|
| 145 | processAnalyze.step++; |
|---|
| 146 | doStep_processList(); |
|---|
| 147 | }, |
|---|
| 148 | }); |
|---|
| 149 | |
|---|
| 150 | pct=100*(processAnalyze.step+1)/processAnalyze.lists.length; |
|---|
| 151 | $("#iprogressbar_bg").css("width", pct+"%"); |
|---|
| 152 | $("#iprogressbar_fg").html(Math.round(pct)+"%"); |
|---|
| 153 | } |
|---|
| 154 | else |
|---|
| 155 | { |
|---|
| 156 | // list completely processed |
|---|
| 157 | tmp = $.ajax({ |
|---|
| 158 | type: "POST", |
|---|
| 159 | url: "{/literal}{$datas.urlRequest}{literal}", |
|---|
| 160 | async: false, |
|---|
| 161 | data: { ajaxfct:"admin.makeStats.consolidate" } |
|---|
| 162 | }).responseText; |
|---|
| 163 | |
|---|
| 164 | processAnalyze.timeEnd = new Date(); |
|---|
| 165 | timeElapsed=processAnalyze.timeEnd.getTime()-processAnalyze.timeStart.getTime(); |
|---|
| 166 | |
|---|
| 167 | $("#dialog") |
|---|
| 168 | .dialog("destroy") |
|---|
| 169 | .html("") |
|---|
| 170 | .get(0).removeAttribute('style'); |
|---|
| 171 | |
|---|
| 172 | $("#dialog") |
|---|
| 173 | .dialog( |
|---|
| 174 | { |
|---|
| 175 | resizable: false, |
|---|
| 176 | width:480, |
|---|
| 177 | height:120, |
|---|
| 178 | modal: true, |
|---|
| 179 | draggable:true, |
|---|
| 180 | dialogClass: 'gcBgTabSheet gcBorder', |
|---|
| 181 | title: '{/literal}{"g003_updating_metadata"|@translate}{literal}', |
|---|
| 182 | dialogClass: 'gcBgTabSheet gcBorder', |
|---|
| 183 | open: function(event, ui) |
|---|
| 184 | { |
|---|
| 185 | bH=$("div.ui-dialog-buttonpane").get(0).clientHeight; |
|---|
| 186 | $("#dialog").css('height', (this.clientHeight-bH)+"px"); |
|---|
| 187 | }, |
|---|
| 188 | buttons: |
|---|
| 189 | { |
|---|
| 190 | '{/literal}{"g003_ok"|@translate}{literal}': |
|---|
| 191 | function() |
|---|
| 192 | { |
|---|
| 193 | $(this).dialog('destroy').html("").get(0).removeAttribute('style'); |
|---|
| 194 | } |
|---|
| 195 | } |
|---|
| 196 | } |
|---|
| 197 | ) |
|---|
| 198 | .html("<br>{/literal}{'g003_analyze_is_finished'|@translate}{literal} ("+displayTime(timeElapsed/1000)+")"); |
|---|
| 199 | |
|---|
| 200 | getStatus(); |
|---|
| 201 | } |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | </script> |
|---|
| 207 | {/literal} |
|---|
| 208 | |
|---|
| 209 | <h2>{'g003_status_of_database'|@translate}</h2> |
|---|
| 210 | |
|---|
| 211 | <div id="dialog"></div> |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | <div id="ianalyzestatus"> |
|---|
| 215 | <ul> |
|---|
| 216 | <li>{'g003_loading'|@translate}</li> |
|---|
| 217 | <li>{'g003_loading'|@translate}</li> |
|---|
| 218 | <li>{'g003_loading'|@translate}</li> |
|---|
| 219 | </ul> |
|---|
| 220 | </div> |
|---|
| 221 | |
|---|
| 222 | <div class="nfo"> |
|---|
| 223 | <ul> |
|---|
| 224 | <li>{'g003_warning_on_analyze_4a'|@translate}</li> |
|---|
| 225 | <li>{'g003_warning_on_analyze_4b'|@translate}</li> |
|---|
| 226 | </ul> |
|---|
| 227 | </div> |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | <div id='ianalyzearea'> |
|---|
| 231 | <fieldset> |
|---|
| 232 | <legend>{'g003_update_metadata'|@translate}</legend> |
|---|
| 233 | <form class="formtable"> |
|---|
| 234 | <div class="nfo"> |
|---|
| 235 | <p>{'g003_warning_on_analyze_3'|@translate}</p> |
|---|
| 236 | <ul> |
|---|
| 237 | <li>{'g003_warning_on_analyze_3a'|@translate}</li> |
|---|
| 238 | <li>{'g003_warning_on_analyze_3b'|@translate}</li> |
|---|
| 239 | </ul> |
|---|
| 240 | |
|---|
| 241 | <p>{'g003_warning_on_analyze_5'|@translate}</p> |
|---|
| 242 | </div> |
|---|
| 243 | |
|---|
| 244 | <label> |
|---|
| 245 | <input type="radio" value="caddieAdd" name="fAMD_analyze_action" id="ianalyze_action2" checked> |
|---|
| 246 | {'g003_analyze_caddie_add_pictures'|@translate} |
|---|
| 247 | </label><br> |
|---|
| 248 | |
|---|
| 249 | <label> |
|---|
| 250 | <input type="radio" value="caddieReplace" name="fAMD_analyze_action" id="ianalyze_action3"> |
|---|
| 251 | {'g003_analyze_caddie_replace_pictures'|@translate} |
|---|
| 252 | </label><br> |
|---|
| 253 | |
|---|
| 254 | |
|---|
| 255 | <label> |
|---|
| 256 | <input type="radio" value="notAnalayzed" name="fAMD_analyze_action" id="ianalyze_action0"> |
|---|
| 257 | {'g003_analyze_not_analyzed_pictures'|@translate} |
|---|
| 258 | </label><br> |
|---|
| 259 | |
|---|
| 260 | <label> |
|---|
| 261 | <input type="radio" value="all" name="fAMD_analyze_action" id="ianalyze_action1"> |
|---|
| 262 | {'g003_analyze_all_pictures'|@translate} |
|---|
| 263 | </label><br> |
|---|
| 264 | |
|---|
| 265 | <div class="warning"> |
|---|
| 266 | <p style="font-weight:bold; font-size:+2;">{'g003_warning_on_analyze_0'|@translate}</p> |
|---|
| 267 | <p>{'g003_warning_on_analyze_1'|@translate}</p> |
|---|
| 268 | <p style="font-weight:bold;">{'g003_warning_on_analyze_2'|@translate}</p> |
|---|
| 269 | </div> |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | <br> |
|---|
| 273 | <input type="hidden" id="iamd_NumberOfItemsPerRequest" value="{$datas.NumberOfItemsPerRequest}"> |
|---|
| 274 | <!-- |
|---|
| 275 | {'g003_setting_nb_items_per_request'|@translate} |
|---|
| 276 | <div id="iamd_nb_item_per_request_slider"></div> |
|---|
| 277 | <div id="iamd_nb_item_per_request_display"></div> |
|---|
| 278 | <br><br> |
|---|
| 279 | --> |
|---|
| 280 | |
|---|
| 281 | <input type="button" value="{'g003_analyze'|@translate}" onclick="doAnalyze();"> |
|---|
| 282 | |
|---|
| 283 | </form> |
|---|
| 284 | </fieldset> |
|---|
| 285 | |
|---|
| 286 | </div> |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | |
|---|
| 291 | <script type="text/javascript"> |
|---|
| 292 | init(); |
|---|
| 293 | </script> |
|---|