PMCORE-2560:Update the counters in the sideBar
cr
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import headerData from "./../mocks/casesHeader.json";
|
|
||||||
import startedCasesFaker from "./../mocks/startedCasesFaker.js";
|
|
||||||
import Api from "./Api.js";
|
import Api from "./Api.js";
|
||||||
|
|
||||||
export let cases = {
|
export let cases = {
|
||||||
|
|||||||
@@ -2,11 +2,26 @@ import axios from 'axios';
|
|||||||
|
|
||||||
export let menu = {
|
export let menu = {
|
||||||
get() {
|
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: {
|
headers: {
|
||||||
'Authorization': 'Bearer ' + window.config.SYS_CREDENTIALS.accessToken
|
'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);
|
window.addEventListener("resize", this.onResize);
|
||||||
this.getMenu();
|
this.getMenu();
|
||||||
this.listenerIframe();
|
this.listenerIframe();
|
||||||
|
window.setInterval(this.setCounter, parseInt(window.config.FORMATS.casesListRefreshTime) * 1000);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/**
|
/**
|
||||||
@@ -111,6 +112,7 @@ export default {
|
|||||||
.get()
|
.get()
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
this.menu = this.mappingMenu(response.data);
|
this.menu = this.mappingMenu(response.data);
|
||||||
|
this.setCounter();
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
@@ -155,6 +157,28 @@ export default {
|
|||||||
this.page = item.item.id || "MyCases";
|
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
|
* Update page component
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ ScriptVariables::add('SYS_WORKSPACE', config("system.workspace"));
|
|||||||
ScriptVariables::add('SYS_URI', SYS_URI);
|
ScriptVariables::add('SYS_URI', SYS_URI);
|
||||||
ScriptVariables::add('SYS_LANG', SYS_LANG);
|
ScriptVariables::add('SYS_LANG', SYS_LANG);
|
||||||
ScriptVariables::add('TRANSLATIONS', $translation);
|
ScriptVariables::add('TRANSLATIONS', $translation);
|
||||||
|
ScriptVariables::add('FORMATS', $conf->getFormats());
|
||||||
echo View::make('Views::home.home', compact("userCanAccess"))->render();
|
echo View::make('Views::home.home', compact("userCanAccess"))->render();
|
||||||
|
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
|
|||||||
Reference in New Issue
Block a user