这是indexloc提供的服务,不要输入任何密码
Skip to content

Closes #43: Activate the monthly reminder when triggers for website status checks and/or status log extraction is set #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions src/websiteMonitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ function setupTrigger_(handlerFunction, frequencyKey, frequencyUnit) {
localMessage.replaceErrorInvalidFrequencyUnit(frequencyUnit)
);
}
// Set up a trigger for monthly reminders
setupReminderTrigger(true);
console.info('[setupTrigger_] Trigger set up complete.');
ui.alert(
localMessage.replaceAlertTitleCompleteTriggerSetup(handlerFunction),
Expand All @@ -213,12 +215,15 @@ function setupTrigger_(handlerFunction, frequencyKey, frequencyUnit) {
* Set time-based trigger for sending monthly reminders
* of active time-based triggers set by this user in this script.
* Trigger will be set for the first day of each month.
* @param {Boolean} muteUi Will not show any UI alerts when true. Defaults to false.
*/
function setupReminderTrigger() {
function setupReminderTrigger(muteUi = false) {
console.info(
'[setupReminderTrigger] Setting trigger for the monthly reminder...'
);
const ui = SpreadsheetApp.getUi();
if (!muteUi) {
var ui = SpreadsheetApp.getUi();
}
const localMessage = new LocalizedMessage(
SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetLocale()
);
Expand All @@ -233,16 +238,22 @@ function setupReminderTrigger() {
// Set new trigger
ScriptApp.newTrigger(handlerFunction).timeBased().onMonthDay(1).create();
console.info('[setupReminderTrigger] Trigger set up complete.');
ui.alert(
localMessage.replaceAlertTitleCompleteTriggerSetup(handlerFunction),
localMessage.replaceAlertMessageCompleteReminderTriggerSetup(
Session.getActiveUser().getEmail()
),
ui.ButtonSet.OK
);
if (!muteUi) {
ui.alert(
localMessage.replaceAlertTitleCompleteTriggerSetup(handlerFunction),
localMessage.replaceAlertMessageCompleteReminderTriggerSetup(
Session.getActiveUser().getEmail()
),
ui.ButtonSet.OK
);
}
} catch (e) {
console.error(e.stack);
ui.alert(e.stack);
if (!muteUi) {
ui.alert(e.stack);
} else {
throw e;
}
}
}

Expand Down