PMCORE-2560:Update the counters in the sideBar
cr
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user