
onCustomWidgetAfterUpdate(changedProperties) {
console.log(changedProperties);
var that = this;
if (this._firstLoadLib === 0) {
this._firstLoadLib = 1;
let pubnubjs = "http://localhost/SAC/sacnotificationlistitem/pubnub.4.29.9.js";
async function LoadLibs() {
try {
await loadScript(pubnubjs, _shadowRoot);
} catch (e) {
alert(e);
} finally {
letsGo(that, changedProperties);
}
}
LoadLibs();
}
}
function letsGo(that, changedProperties) {
// Update this block with your publish/subscribe keys
pubnub = new PubNub({
publishKey: "REPLACE_WITH_YOUR_PUBLISH_KEY",
subscribeKey: "REPLACE_WITH_YOUR_SUBSCRIBE_KEY",
uuid: "REPLACE_WITH_RANDOM_STRING"
})
pubnub.addListener({
status: function(statusEvent) {},
message: function(msg) {
loadthis(that, changedProperties, msg);
},
presence: function(presenceEvent) {}
})
console.log("Subscribing...");
pubnub.subscribe({
channels: ['sac']
});
loadthis(that, changedProperties, "");
};
onInit: function() {
console.log("-------oninit--------");
if (that._firstConnection === 0) {
that._firstConnection = 1;
var oModel = new JSONModel({
"headers": []
});
this.getView().setModel(oModel);
sap.ui.getCore().setModel(oModel, "core");
} else {
console.log("----after---");
var oModel = sap.ui.getCore().getModel("core");
var data = new JSONModel(msg.message);
oModel.setProperty("/headers", data.oData.headers);
this.getView().setModel(data);
oModel.refresh(true);
}
}
const PubNub = require('pubnub');
const pubnub = new PubNub({
publishKey: "REPLACE_WITH_YOUR_PUBLISHKEY",
subscribeKey: "REPLACE_WITH_YOUR_SUBSCRIBE_KEY",
uuid: "REPLACE_WITH_RANDOM_STRING",
});
async function publishSampleMessage() {
console.log(
"Since we're publishing on subscribe connectEvent, we're sure we'll receive the following publish."
);
const result = await pubnub.publish({
channel: "sac",
message: {
"headers": [{
"heading": "SAC Notification List Custom Widget",
"datetime": "1 hr",
"authorName": "Marie Khan",
"authorPicture": "http://localhost/SAC/sacnotificationlistitem/Woman_04.png",
"id": "ID1",
"items": [{
"id": "item1",
"title": "New order (#2524)",
"Descr": "Short description",
"datetime": "3 days",
"priority": "Low",
"authorName": "Ferry Djaja",
"authorPicture": "sap-icon://group"
}, {
"id": "item2",
"title": "New order (#2525) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc.",
"Descr": "And with a very long description and long labels of the action buttons - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc.",
"datetime": "2 hr",
"priority": "High",
"authorName": "JS",
"authorPicture": "sap-icon://person-placeholder"
},{
"id": "item3",
"title": "New order (#2525) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc.",
"Descr": "And with a very long description and long labels of the action buttons - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc.",
"datetime": "2 hr",
"priority": "Medium",
"authorName": "Linda",
"authorPicture": "sap-icon://person-placeholder"
},{
"id": "item4",
"title": "New order (#2525) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc.",
"Descr": "And with a very long description and long labels of the action buttons - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc.",
"datetime": "2 hr",
"priority": "None",
"authorName": "Linda",
"authorPicture": "sap-icon://person-placeholder"
}]
}],
},
});
console.log(result);
}
console.log("Subscribing..");
publishSampleMessage();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
7 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |