logSettingsForm = async (req) => {
  const hoursFuture = (nhrs) => {
    const t = new Date();
    t.setHours(t.getHours() + nhrs);
    return t;
  };
  const fields = [
    {
      input_type: "section_header",
      label: req.__("Periodic trigger timing (next event)"),
    },
    {
      name: "next_hourly_event",
      label: req.__("Hourly"),
      input_type: "date",
      attributes: { minDate: new Date(), maxDate: hoursFuture(2) },
    },
    {
      name: "next_daily_event",
      label: req.__("Daily"),
      input_type: "date",
      attributes: { minDate: new Date(), maxDate: hoursFuture(48) },
    },
    {
      name: "next_weekly_event",
      label: req.__("Weekly"),
      input_type: "date",
      attributes: { minDate: new Date(), maxDate: hoursFuture(24 * 7 * 2) },
    },
    {
      input_type: "section_header",
      label: req.__("Delete old workflow runs with status after days"),
    },
    {
      name: "delete_finished_workflows_days",
      label: req.__("Finished"),
      type: "Integer",
    },
    {
      name: "delete_error_workflows_days",
      label: req.__("Error"),
      type: "Integer",
    },
    {
      name: "delete_waiting_workflows_days",
      label: req.__("Waiting"),
      type: "Integer",
    },

    {
      name: "delete_running_workflows_days",
      label: req.__("Running"),
      type: "Integer",
    },
    {
      input_type: "section_header",
      label: req.__("Which events should be logged?"),
    },
  ];
  for (const w of Trigger.when_options) {
    fields.push({
      name: w,
      label: w,
      type: "Bool",
    });
    if (EventLog.hasTable(w)) {
      const tables = await Table.find({}, { orderBy: "name" });
      for (const table of tables) {
        fields.push({
          name: `${w}_${table.name}`,
          label: `&nbsp;&nbsp;&nbsp;${w} ${table.name}`,
          type: "Bool",
          showIf: { [w]: true },
        });
      }
    }
    if (EventLog.hasChannel(w))
      fields.push({
        name: w + "_channel",
        label: w + " channel",
        sublabel: req.__(
          "Channels to create events for. Separate by comma; leave blank for all"
        ),
        type: "String",
        showIf: { [w]: true },
      });
  }
  return new Form({
    action: "/eventlog/settings",
    noSubmitButton: true,
    onChange: "saveAndContinue(this)",
    fields,
  });
}
@param {object} req
@returns {Promise<Form>}