PMCORE-2560:Update the counters in the sideBar

cr
This commit is contained in:
fabio
2020-12-16 19:00:37 -04:00
parent df40b1c7c6
commit b57d37122e
4 changed files with 41 additions and 3 deletions

View File

@@ -1,6 +1,4 @@
import axios from "axios";
import headerData from "./../mocks/casesHeader.json";
import startedCasesFaker from "./../mocks/startedCasesFaker.js";
import Api from "./Api.js";
export let cases = {

View File

@@ -2,11 +2,26 @@ import axios from 'axios';
export let menu = {
get() {
return axios.get(window.config.SYS_SERVER + '/api/1.0/' + window.config.SYS_WORKSPACE + '/home/menu', {
return axios.get(
window.config.SYS_SERVER +
'/api/1.0/' +
window.config.SYS_WORKSPACE +
'/home/menu', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken
}
});
},
getCounters() {
return axios.get(
window.config.SYS_SERVER +
'/api/1.0/' +
window.config.SYS_WORKSPACE +
'/home/tasks/counter', {
headers: {
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken
}
});
}
};

View File

@@ -86,6 +86,7 @@ export default {
window.addEventListener("resize", this.onResize);
this.getMenu();
this.listenerIframe();
window.setInterval(this.setCounter, parseInt(window.config.FORMATS.casesListRefreshTime) * 1000);
},
methods: {
/**
@@ -111,6 +112,7 @@ export default {
.get()
.then((response) => {
this.menu = this.mappingMenu(response.data);
this.setCounter();
})
.catch((e) => {
console.error(e);
@@ -155,6 +157,28 @@ export default {
this.page = item.item.id || "MyCases";
}
},
setCounter() {
let that = this,
counters = [];
if (that.menu.length > 0) {
api.menu
.getCounters()
.then((response) => {
var i,
j,
data = response.data;
that.counters = data;
for (i = 0; i < that.menu.length; i += 1) {
if (that.menu[i].id && data[that.menu[i].id]) {
that.menu[i].badge.text = data[that.menu[i].id];
}
}
})
.catch((e) => {
console.error(e);
});
}
},
/**
* Update page component
*/

View File

@@ -149,6 +149,7 @@ ScriptVariables::add('SYS_WORKSPACE', config("system.workspace"));
ScriptVariables::add('SYS_URI', SYS_URI);
ScriptVariables::add('SYS_LANG', SYS_LANG);
ScriptVariables::add('TRANSLATIONS', $translation);
ScriptVariables::add('FORMATS', $conf->getFormats());
echo View::make('Views::home.home', compact("userCanAccess"))->render();
/*----------------------------------********---------------------------------*/