Skip to content

Commit 3f30d15

Browse files
committed
timeout fix from Pizzo
1 parent 66f0370 commit 3f30d15

File tree

4 files changed

+88
-10
lines changed

4 files changed

+88
-10
lines changed

src/components/mixins/toponimo.mixin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ export default {
398398
return "primary";
399399
}
400400
},
401-
getStatoColorScript(stato) {
401+
/* getStatoColorScript(stato) {
402402
switch (stato) {
403403
case -1:
404404
return "warning";
@@ -425,7 +425,7 @@ export default {
425425
default:
426426
return "";
427427
}
428-
},
428+
}, */
429429
getStatoString(stato, validazione) {
430430
switch (stato) {
431431
case 1:

src/services/elencoScript/elencoScript.service.js

+14
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ class ElencoScriptService extends AbstractService {
1919
});
2020
}
2121
}
22+
findScriptRunningByUser() {
23+
{
24+
return axiosRegedit
25+
.get(this.endpoint + "/log-linkage-probabilistico-last-proc")
26+
.then(res => {
27+
var data = res.data ? res.data : {};
28+
//console.log(data);
29+
return data;
30+
})
31+
.catch(err => {
32+
throw err;
33+
});
34+
}
35+
}
2236
}
2337

2438
export const elencoScriptService = new ElencoScriptService("/regedit");

src/store/modules/elencoScript/elencoScript.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import { elencoScriptService } from "@/services";
22
import { getUserId } from "@/common";
33

44
const state = {
5-
elencoScript: null
5+
elencoScript: null,
6+
lastScriptRunning: null
67
};
78

89
const mutations = {
910
SET_ELENCO(state, elenco) {
1011
state.elencoScript = elenco;
12+
},
13+
SET_SCRIPTRUNNING(state, scriptRunning) {
14+
state.lastScriptRunning = scriptRunning;
1115
}
1216
};
1317

@@ -30,12 +34,30 @@ const actions = {
3034
console.log(err);
3135
});
3236
}
37+
},
38+
findScriptRunningByUser({ commit }) {
39+
//get user from store
40+
let userId = getUserId();
41+
if (userId > 0) {
42+
return elencoScriptService
43+
.findScriptRunningByUser(userId)
44+
.then(data => {
45+
//console.log(data);
46+
commit("SET_SCRIPTRUNNING", data);
47+
})
48+
.catch(err => {
49+
console.log(err);
50+
});
51+
}
3352
}
3453
};
3554

3655
const getters = {
3756
elencoScript: state => {
3857
return state.elencoScript;
58+
},
59+
lastScriptRunning: state => {
60+
return state.lastScriptRunning;
3961
}
4062
};
4163

src/views/catalogue/toponimo/ToponimoList.vue

+49-7
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ export default {
285285
values: [],
286286
returnValueScript: "",
287287
intervalId: null,
288+
intervalIdScriptRunning: null,
288289
btnLabel: () => "Elenco Province",
289290
filters: [
290291
{
@@ -324,6 +325,7 @@ export default {
324325
...mapGetters("archivio", ["archivioCodes"]),
325326
...mapGetters("tabella", ["tabellaScript"]),
326327
...mapGetters("elenco", ["elencoScript"]),
328+
...mapGetters("elenco", ["lastScriptRunning"]),
327329
328330
province: {
329331
get: function() {
@@ -373,13 +375,16 @@ export default {
373375
this.intervalId = setInterval(() => {
374376
this.updateElenco();
375377
}, 3000);
378+
this.intervalIdScriptRunning = setInterval(() => {
379+
this.verifyScriptRunning();
380+
}, 5000);
376381
this.$store.dispatch("scriptRunning/setScriptRunning", true);
377382
await this.$store.dispatch("valueScript/execScript", payload);
378383
this.$store.dispatch("elenco/findElencoByUser");
379384
//this.spinnerVisible = false;
380-
if (this.elencoScript[0].stato == 0) {
385+
/* if (this.elencoScript[0].stato == 0) {
381386
this.$store.dispatch("scriptRunning/setScriptRunning", false);
382-
}
387+
} */
383388
this.$store.dispatch("tabella/findTabellaByUser");
384389
} else {
385390
this.$store.dispatch(
@@ -401,10 +406,47 @@ export default {
401406
this.$store.dispatch("elenco/findElencoByUser");
402407
}
403408
},
409+
getStatoColorScript(stato) {
410+
switch (stato) {
411+
case -1:
412+
return "warning";
413+
case 0:
414+
return "danger";
415+
case 1:
416+
return "success";
417+
default:
418+
return "primary";
419+
}
420+
},
421+
getStatoStringScript(stato, indice) {
422+
switch (stato) {
423+
case -1:
424+
return "Errore script";
425+
case 0:
426+
if (indice > 1) {
427+
return "Esecuzione abortita";
428+
}
429+
return "Esecuzione in corso..";
430+
431+
case 1:
432+
return "Completato";
433+
default:
434+
return "";
435+
}
436+
},
404437
updateElenco() {
405438
this.$store.dispatch("elenco/findElencoByUser");
406439
clearInterval(this.intervalId);
407440
},
441+
async verifyScriptRunning() {
442+
console.log("Verifica in Corso......");
443+
await this.$store.dispatch("elenco/findScriptRunningByUser");
444+
if (this.lastScriptRunning.stato && this.lastScriptRunning.stato != 0) {
445+
this.$store.dispatch("scriptRunning/setScriptRunning", false);
446+
this.$store.dispatch("elenco/findElencoByUser");
447+
clearInterval(this.intervalIdScriptRunning);
448+
}
449+
},
408450
elencoProvince() {
409451
return this.values.map(val => {
410452
return val.name;
@@ -530,14 +572,14 @@ export default {
530572
this.$store.dispatch("dug/findAll");
531573
}
532574
533-
/* mounted() {
534-
this.intervalId = setInterval(() => {
535-
this.updateElenco();
575+
/* mounted() {
576+
this.intervalIdScriptRunning = setInterval(() => {
577+
this.verifyScriptRunning();
536578
}, 5000);
537579
},
538580
onUnmounted() {
539-
clearInterval(this.intervalId);
540-
}*/
581+
clearInterval(this.intervalIdScriptRunning);
582+
} */
541583
};
542584
</script>
543585

0 commit comments

Comments
 (0)