How to pause an OpenWhisk trigger - ibm-cloud

Following the documentation at https://github.com/apache/openwhisk/blob/master/docs/feeds.md
I have implemented a feed, and am capturing trigger livecycleEvent events. From the command line and from the console in IBM Cloud I am able to test the CREATE and DELETE.
What I have not been able to figure out is how to invoke the PAUSE and by extension the UNPAUSE.
wsk trigger
doesn't appear to have this option.
function main (args) {
let event = args.lifecycleEvent;
let triggerName = args.triggerName;
let authKey = args.authKey;
if ('CREATE' === event) {
console.log('Create event for trigger ', triggerName);
...
} else if ('DELETE' === event) {
console.log('Delete event for trigger ', triggerName);
...
} else if ('PAUSE' === event) {
console.log('Pause event for trigger ', triggerName);
...
} else if ('UNPAUSE' === event) {
...
} else {
console.log('Check for other non lifecycle actions ');
}
return {};
}

You cannot pause a trigger, just create and delete.
I feel you are thinking about wsk rule disable? (https://github.com/apache/openwhisk/blob/master/docs/triggers_rules.md)

Related

Unity3D - Button not triggered once?

I have some issues for match the string and the InputField.text it's triggering multiple times after Active or Dead Active Gameobject when press Submit button(in this case is "Cek Jawaban").
this my script
public void Answer(int index)
{
inputPanel.SetActive(true);
inputField.text = "";
inputPanel.transform.Find("KunciBtn").GetComponent<Button>().onClick.AddListener(() =>
{
if (inputField.text != "")
{
if (inputField.text == jawaban[index])
{
Debug.Log("Right");
}
else
{
Debug.Log("Wrong");
}
inputPanel.SetActive(false);
}
else
{
Debug.Log("jangan kosong");
}
});
}
[![Many Buttons][1]][1]
as you can see on the console at the first that triggers once but after the second time its triggers twice. Also, my Answer() called on every button.
The issue is that you are adding listeners to the onClick of the button every time Answer is called, but you are never removing them. So the second time you click the button, a second listener has been added and it will look like you have pressed the button twice.
To fix this, you either need to remove the listener after you have handled the button logic:
...
else
{
Debug.Log("jangan kosong");
}
inputPanel.transform.Find("KunciBtn").GetComponent<Button>().onClick.RemoveAllListeners();
Or add the listener on Start() so that it is set once and then remove it in either OnDisable() or OnDestroy().

How to disable past days in ZK Calendar?

I'm using ZK CE-9.0.0 & zk-calendar-2.1.5 source code.
Currently all the days are enabled in the calendar.
I need to disable the past days (greyed out & no click event), from all the views(Day/Week/Month), but not able to find any such feature directly available.
Can anyone help me with this please?
Thanks,
RAS
I don't think there is such feature.
A workaround would be to disable event click on past days and change the color.
1 . Catch clicks in your controller :
#Wire("#course-calendar")
private Calendars courseCalendar;
#Listen("onEventCreate = #course-calendar")
public void clickCreateEvent(CalendarsEvent event) {
if (event.getBeginDate().before(new Date())) {
// disable click if event is before now
} else {
//do something on event create
}
}
#Listen("onEventEdit = #course-calendar")
public void clickEditEvent(CalendarsEvent event) {
if (event.getBeginDate().before(new Date())) {
// disable click if event is before now
} else {
// do something on event edit
}
}
Grey out events on event creation :
for (MyEvent me : myManager.getEvents()) {
final SimpleCalendarEvent simpleCalendarEvent = new SimpleCalendarEvent();
// set grey color event before now
if (me.startDate < new Date()) {
simpleCalendarEvent.setContentColor("#aaaaaa");
simpleCalendarEvent.setHeaderColor("#aaaaaa");
simpleCalendarEvent.setLocked(true);
} else {
simpleCalendarEvent.setContentColor("#4363d8");
simpleCalendarEvent.setHeaderColor("#4363d8");
simpleCalendarEvent.setLocked(false);
}
simpleCalendarEvent.setContent(me.getContent());
simpleCalendarEvent.setBeginDate(me.startDate);
simpleCalendarEvent.setEndDate(me.endDate);
simpleCalendarEvent.setTitle(me.getTitle());
getSimpleCalendarModel().add(simpleCalendarEvent);
}

CodeMirror - Catch Pick event for show hints

I am trying to run a function when the "pick" object from CodeMirror's show hints pick function is triggered.
I have tried (among a lot of other options):
CodeMirror.commands.pick = function (cm) {
console.log(cm)
}
CodeMirror.on("pick", function (cm) { console.log(cm) } );
var completion = cm.state.completionActive;
console.log('handling the completion object:', completion);
var pick = completion.pick;
completion.pick = function (data, i) {
var completion = data.list[i];
console.log('picked', data, completion);
pick.apply(this, arguments);
}
In the documentation on codemirror it is described as:
"pick" (completion)
Fired when a completion is picked. Passed the completion value (string or object).
and I can see in the code for the show hints that this is triggered:
CodeMirror.signal(data, "pick", completion);
But how do I monitor that signal and react to it.

Show confirmation box in dhtmlx scheduler onbeforeviewchange

I want to show the confirmation box before view change. So when user change date for scheduler I want to show confirmation box whether user want to redirect to another date or not.
The simplest solution would be to use window.confirm
It pauses code execution until user choses any option, so you can use simple if-else statement:
scheduler.attachEvent("onBeforeViewChange", function (oldMode, oldDate, mode, date) {
if (oldMode && oldDate) {
if (oldMode !== mode || oldDate.valueOf() !== date.valueOf()) {
if (confirm("are you sure?")) {
return true;
}
return false;
}
}
return true;
});
demo: https://snippet.dhtmlx.com/140d2ff31
If you want a custom confirmation popup, which doesn't block the browser, you'll need to do a small workaround, since scheduler API doesn't support async event handlers:
1) when code enters onBeforeViewChange, you display the dialog and always return false from the handler in order to keep the same date
2) when the user confirms view change - you set some flag to temporary disable step 1 and call scheduler.setCurrentView from the callback. onBeforeViewChange runs again, you check the flag you've set and return true this time, allowing date change.
var callbackViewChange = false;
scheduler.attachEvent("onBeforeViewChange", function (oldMode, oldDate, mode, date) {
if (oldMode && oldDate) {
//
if (!callbackViewChange && (oldMode !== mode || oldDate.valueOf() !== date.valueOf())) {
dhtmlx.confirm({
text: "are you sure?",
callback: function (result) {
if (result) {
// set the flag in order to allow view change
callbackViewChange = true;
scheduler.setCurrentView(date, mode);
callbackViewChange = false;
}
}
});
// cancel view change while we wait for user action
return false;
}
}
return true;
});
demo: https://snippet.dhtmlx.com/a2b8b09b9

Fire rule when Enter Key is pressed. Adobe DTM

I have this code in my Custom code section of an event based rule in DTM. I am trying to fire the rule upon the Enter key press. The input is not within a form element. How to I get the Keycode scoped into my custom page code? Any help would be appreciated!
jQuery(this).keypress(function (e) {
if (e.keyCode == 13) {
var frmData = 'search:new:submit';
var inpData = jQuery(this).siblings('input').val().trim().toLowerCase();
_satellite.setVar('frmData', frmData);
_satellite.setVar('inpData', inpData);
return true;
}
});
I got it to fire by switching the event type to Keypress and using this simple code. -cheers
if (event.keyCode == 13){
return true;
}