SAPUI5/Javascript Interval 30 sec, Display MessageBox as a Popup when new changes occur on the DB
up vote
0
down vote
favorite
I want to display an error messageBox for every "102" status.
onInit: function () {
var counter = ;
var sUrl = "/api/equipmentReport/getMachineOverview.xsjs";
var oModel = new JSONModel();
this.modelRefresh = setInterval(this.refreshModel.bind(this), 30000, sUrl, oModel);
oModel.attachRequestCompleted(function (oEvent)
this.buildComboBox(oEvent.getSource().getData());
if (oEvent.getParameter("success") === true)
var oModelData = oEvent.getSource().getData();
oModelData.equipments.forEach(function(o)
// o.iotTimestampDate = o.iotTimestamp !== null ? new Date(o.iotTimestamp) : "";
counter[o.registeredProductId] = o.telemetryStatus;
)
this.getPopupMessageForOfflineMachines(counter);
oEvent.getSource().updateBindings(true);
this.getView().setModel(oModel, "rootModel");
.bind(this));
oModel.attachEventOnce('requestCompleted',
oModel: oModel
, this.restoreApplicationState.bind(this));
oModel.loadData(sUrl, false);
oModel.setSizeLimit(1000000);
sap.ui.getCore().setModel(oModel);
this.oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.oRouter.attachRouteMatched(this.handleRouteMatched, this);
var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
var sHash = oHashChanger.getHash();
if (sHash)
var sAppStateKey = /(?:sap-iapp-state=)([^&=]+)/.exec(sHash)[1];
if (sAppStateKey)
sap.ushell.Container
.getService("CrossApplicationNavigation")
.getAppState(this.getOwnerComponent(), sAppStateKey)
.done(this.restoreAppState.bind(this));
this.getView().setModel(oModel);
so firstly I am creating an object(registeredProductId -> status)
40000000.H: "102"
40000001.H: "113"
40000002.H: "113"
40000003.H: "113"
40000004.H: "113"
40000005.H: "113"
40000006.H: "113"
40000007.H: "113"
40000008.H: "113"
40000009.H: "113"
40000010.H: "101"
40000011.H: "113"
40000012.H: "113"
40000015.H: "103"
40000023.H: "103"
40000026.H: "103"
40000027.H: "113"
40000028.H: "102"
40000029.H: "103"
after that in my function I get status 102, and I need to check somehow the object. If the registeredProductId is already there and if it has status !== 102, it is warning-relevant, so that the Popup appears only once per Status and only when the service data changes.
getPopupMessageForOfflineMachines: function(counter)
console.log(counter);
for (var key in counter)
if(counter[key] == "102")
MessageBox.warning(key);
,
if so, it is warning-relevant
The problem is that the model/service refreshes every 30 seconds and my Popup comes out every 30 seconds.
I would really appreciate any pointers on this issue.
javascript sapui5
add a comment |
up vote
0
down vote
favorite
I want to display an error messageBox for every "102" status.
onInit: function () {
var counter = ;
var sUrl = "/api/equipmentReport/getMachineOverview.xsjs";
var oModel = new JSONModel();
this.modelRefresh = setInterval(this.refreshModel.bind(this), 30000, sUrl, oModel);
oModel.attachRequestCompleted(function (oEvent)
this.buildComboBox(oEvent.getSource().getData());
if (oEvent.getParameter("success") === true)
var oModelData = oEvent.getSource().getData();
oModelData.equipments.forEach(function(o)
// o.iotTimestampDate = o.iotTimestamp !== null ? new Date(o.iotTimestamp) : "";
counter[o.registeredProductId] = o.telemetryStatus;
)
this.getPopupMessageForOfflineMachines(counter);
oEvent.getSource().updateBindings(true);
this.getView().setModel(oModel, "rootModel");
.bind(this));
oModel.attachEventOnce('requestCompleted',
oModel: oModel
, this.restoreApplicationState.bind(this));
oModel.loadData(sUrl, false);
oModel.setSizeLimit(1000000);
sap.ui.getCore().setModel(oModel);
this.oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.oRouter.attachRouteMatched(this.handleRouteMatched, this);
var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
var sHash = oHashChanger.getHash();
if (sHash)
var sAppStateKey = /(?:sap-iapp-state=)([^&=]+)/.exec(sHash)[1];
if (sAppStateKey)
sap.ushell.Container
.getService("CrossApplicationNavigation")
.getAppState(this.getOwnerComponent(), sAppStateKey)
.done(this.restoreAppState.bind(this));
this.getView().setModel(oModel);
so firstly I am creating an object(registeredProductId -> status)
40000000.H: "102"
40000001.H: "113"
40000002.H: "113"
40000003.H: "113"
40000004.H: "113"
40000005.H: "113"
40000006.H: "113"
40000007.H: "113"
40000008.H: "113"
40000009.H: "113"
40000010.H: "101"
40000011.H: "113"
40000012.H: "113"
40000015.H: "103"
40000023.H: "103"
40000026.H: "103"
40000027.H: "113"
40000028.H: "102"
40000029.H: "103"
after that in my function I get status 102, and I need to check somehow the object. If the registeredProductId is already there and if it has status !== 102, it is warning-relevant, so that the Popup appears only once per Status and only when the service data changes.
getPopupMessageForOfflineMachines: function(counter)
console.log(counter);
for (var key in counter)
if(counter[key] == "102")
MessageBox.warning(key);
,
if so, it is warning-relevant
The problem is that the model/service refreshes every 30 seconds and my Popup comes out every 30 seconds.
I would really appreciate any pointers on this issue.
javascript sapui5
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to display an error messageBox for every "102" status.
onInit: function () {
var counter = ;
var sUrl = "/api/equipmentReport/getMachineOverview.xsjs";
var oModel = new JSONModel();
this.modelRefresh = setInterval(this.refreshModel.bind(this), 30000, sUrl, oModel);
oModel.attachRequestCompleted(function (oEvent)
this.buildComboBox(oEvent.getSource().getData());
if (oEvent.getParameter("success") === true)
var oModelData = oEvent.getSource().getData();
oModelData.equipments.forEach(function(o)
// o.iotTimestampDate = o.iotTimestamp !== null ? new Date(o.iotTimestamp) : "";
counter[o.registeredProductId] = o.telemetryStatus;
)
this.getPopupMessageForOfflineMachines(counter);
oEvent.getSource().updateBindings(true);
this.getView().setModel(oModel, "rootModel");
.bind(this));
oModel.attachEventOnce('requestCompleted',
oModel: oModel
, this.restoreApplicationState.bind(this));
oModel.loadData(sUrl, false);
oModel.setSizeLimit(1000000);
sap.ui.getCore().setModel(oModel);
this.oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.oRouter.attachRouteMatched(this.handleRouteMatched, this);
var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
var sHash = oHashChanger.getHash();
if (sHash)
var sAppStateKey = /(?:sap-iapp-state=)([^&=]+)/.exec(sHash)[1];
if (sAppStateKey)
sap.ushell.Container
.getService("CrossApplicationNavigation")
.getAppState(this.getOwnerComponent(), sAppStateKey)
.done(this.restoreAppState.bind(this));
this.getView().setModel(oModel);
so firstly I am creating an object(registeredProductId -> status)
40000000.H: "102"
40000001.H: "113"
40000002.H: "113"
40000003.H: "113"
40000004.H: "113"
40000005.H: "113"
40000006.H: "113"
40000007.H: "113"
40000008.H: "113"
40000009.H: "113"
40000010.H: "101"
40000011.H: "113"
40000012.H: "113"
40000015.H: "103"
40000023.H: "103"
40000026.H: "103"
40000027.H: "113"
40000028.H: "102"
40000029.H: "103"
after that in my function I get status 102, and I need to check somehow the object. If the registeredProductId is already there and if it has status !== 102, it is warning-relevant, so that the Popup appears only once per Status and only when the service data changes.
getPopupMessageForOfflineMachines: function(counter)
console.log(counter);
for (var key in counter)
if(counter[key] == "102")
MessageBox.warning(key);
,
if so, it is warning-relevant
The problem is that the model/service refreshes every 30 seconds and my Popup comes out every 30 seconds.
I would really appreciate any pointers on this issue.
javascript sapui5
I want to display an error messageBox for every "102" status.
onInit: function () {
var counter = ;
var sUrl = "/api/equipmentReport/getMachineOverview.xsjs";
var oModel = new JSONModel();
this.modelRefresh = setInterval(this.refreshModel.bind(this), 30000, sUrl, oModel);
oModel.attachRequestCompleted(function (oEvent)
this.buildComboBox(oEvent.getSource().getData());
if (oEvent.getParameter("success") === true)
var oModelData = oEvent.getSource().getData();
oModelData.equipments.forEach(function(o)
// o.iotTimestampDate = o.iotTimestamp !== null ? new Date(o.iotTimestamp) : "";
counter[o.registeredProductId] = o.telemetryStatus;
)
this.getPopupMessageForOfflineMachines(counter);
oEvent.getSource().updateBindings(true);
this.getView().setModel(oModel, "rootModel");
.bind(this));
oModel.attachEventOnce('requestCompleted',
oModel: oModel
, this.restoreApplicationState.bind(this));
oModel.loadData(sUrl, false);
oModel.setSizeLimit(1000000);
sap.ui.getCore().setModel(oModel);
this.oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.oRouter.attachRouteMatched(this.handleRouteMatched, this);
var oHashChanger = sap.ui.core.routing.HashChanger.getInstance();
var sHash = oHashChanger.getHash();
if (sHash)
var sAppStateKey = /(?:sap-iapp-state=)([^&=]+)/.exec(sHash)[1];
if (sAppStateKey)
sap.ushell.Container
.getService("CrossApplicationNavigation")
.getAppState(this.getOwnerComponent(), sAppStateKey)
.done(this.restoreAppState.bind(this));
this.getView().setModel(oModel);
so firstly I am creating an object(registeredProductId -> status)
40000000.H: "102"
40000001.H: "113"
40000002.H: "113"
40000003.H: "113"
40000004.H: "113"
40000005.H: "113"
40000006.H: "113"
40000007.H: "113"
40000008.H: "113"
40000009.H: "113"
40000010.H: "101"
40000011.H: "113"
40000012.H: "113"
40000015.H: "103"
40000023.H: "103"
40000026.H: "103"
40000027.H: "113"
40000028.H: "102"
40000029.H: "103"
after that in my function I get status 102, and I need to check somehow the object. If the registeredProductId is already there and if it has status !== 102, it is warning-relevant, so that the Popup appears only once per Status and only when the service data changes.
getPopupMessageForOfflineMachines: function(counter)
console.log(counter);
for (var key in counter)
if(counter[key] == "102")
MessageBox.warning(key);
,
if so, it is warning-relevant
The problem is that the model/service refreshes every 30 seconds and my Popup comes out every 30 seconds.
I would really appreciate any pointers on this issue.
javascript sapui5
javascript sapui5
edited Nov 11 at 12:19
Vega
11.7k113251
11.7k113251
asked Nov 11 at 12:10
Fiodor Smirnov
11
11
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
You can keep track of and compare with the previous values. Concretely, add a variable e.g. previousCounter
, and then in your getPopupMessageForOfflineMachines
function, use
if(counter[key] == "102" && counter[key] !== previousCounter[key])
MessageBox.warning(key);
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
Can you please elaborate?
– rikusv
Nov 11 at 13:50
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
You can keep track of and compare with the previous values. Concretely, add a variable e.g. previousCounter
, and then in your getPopupMessageForOfflineMachines
function, use
if(counter[key] == "102" && counter[key] !== previousCounter[key])
MessageBox.warning(key);
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
Can you please elaborate?
– rikusv
Nov 11 at 13:50
add a comment |
up vote
0
down vote
You can keep track of and compare with the previous values. Concretely, add a variable e.g. previousCounter
, and then in your getPopupMessageForOfflineMachines
function, use
if(counter[key] == "102" && counter[key] !== previousCounter[key])
MessageBox.warning(key);
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
Can you please elaborate?
– rikusv
Nov 11 at 13:50
add a comment |
up vote
0
down vote
up vote
0
down vote
You can keep track of and compare with the previous values. Concretely, add a variable e.g. previousCounter
, and then in your getPopupMessageForOfflineMachines
function, use
if(counter[key] == "102" && counter[key] !== previousCounter[key])
MessageBox.warning(key);
You can keep track of and compare with the previous values. Concretely, add a variable e.g. previousCounter
, and then in your getPopupMessageForOfflineMachines
function, use
if(counter[key] == "102" && counter[key] !== previousCounter[key])
MessageBox.warning(key);
answered Nov 11 at 12:46
rikusv
27515
27515
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
Can you please elaborate?
– rikusv
Nov 11 at 13:50
add a comment |
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
Can you please elaborate?
– rikusv
Nov 11 at 13:50
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
thank you for the answer, but it didnt help :(
– Fiodor Smirnov
Nov 11 at 13:17
Can you please elaborate?
– rikusv
Nov 11 at 13:50
Can you please elaborate?
– rikusv
Nov 11 at 13:50
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53248601%2fsapui5-javascript-interval-30-sec-display-messagebox-as-a-popup-when-new-change%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown