Add CalDAV and ICS calendar setup wizards
This commit is contained in:
1 parent
c5de63d473
commit
7ae1058b42
3 files changed
+768
No files matched your search
@@ -0,0 +1,517 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { action } from '@ember/object';
|
||||
import { service } from '@ember/service';
|
||||
import { fn } from '@ember/helper';
|
||||
import { on } from '@ember/modifier';
|
||||
import { classifyCalendarError } from '../../../config/calendar';
|
||||
import {
|
||||
normalizeSockethubUrl,
|
||||
DEFAULT_SOCKETHUB_URL,
|
||||
} from '../../../config/sockethub';
|
||||
import { normalizeCaldavUrl } from '../../../config/caldav';
|
||||
|
||||
// Multi-step setup for a CalDAV account: server URL, account credentials, then
|
||||
// the calendars to display. On edit it opens on the calendar selection and
|
||||
// refreshes the list with the stored credentials.
|
||||
export default class SettingsIntegrationsCalendarCaldavForm extends Component {
|
||||
@service calendar;
|
||||
@service sockethub;
|
||||
|
||||
@tracked step = 1;
|
||||
@tracked serverUrlDraft = null;
|
||||
@tracked caldavUrlDraft = null;
|
||||
@tracked usernameDraft = null;
|
||||
@tracked password = '';
|
||||
@tracked calendars = [];
|
||||
@tracked selectedIds = [];
|
||||
@tracked error = null;
|
||||
@tracked submitting = false;
|
||||
@tracked refreshing = false;
|
||||
|
||||
constructor(owner, args) {
|
||||
super(owner, args);
|
||||
|
||||
const integration = args.props?.integration;
|
||||
|
||||
if (args.props?.mode === 'edit' && integration) {
|
||||
this.calendars = integration.calendars ?? [];
|
||||
this.selectedIds = integration.selectedCalendarIds ?? [];
|
||||
this.step = 3;
|
||||
this.refreshCalendars();
|
||||
}
|
||||
}
|
||||
|
||||
get integration() {
|
||||
return this.args.props?.integration;
|
||||
}
|
||||
|
||||
get isEdit() {
|
||||
return this.args.props?.mode === 'edit';
|
||||
}
|
||||
|
||||
get title() {
|
||||
return this.isEdit ? 'Edit CalDAV Calendar' : 'Add CalDAV Calendar';
|
||||
}
|
||||
|
||||
get serverUrl() {
|
||||
return this.serverUrlDraft ?? this.sockethub.url ?? DEFAULT_SOCKETHUB_URL;
|
||||
}
|
||||
|
||||
get caldavUrl() {
|
||||
return this.caldavUrlDraft ?? this.integration?.url ?? '';
|
||||
}
|
||||
|
||||
get username() {
|
||||
return this.usernameDraft ?? this.integration?.username ?? '';
|
||||
}
|
||||
|
||||
// Calendars that can hold events (unknown component lists are kept).
|
||||
get eventCalendars() {
|
||||
return this.calendars.filter(
|
||||
(calendar) =>
|
||||
calendar.components.length === 0 ||
|
||||
calendar.components.includes('event')
|
||||
);
|
||||
}
|
||||
|
||||
get isServerStep() {
|
||||
return this.step === 1;
|
||||
}
|
||||
|
||||
get isAccountStep() {
|
||||
return this.step === 2;
|
||||
}
|
||||
|
||||
@action
|
||||
isSelected(id) {
|
||||
return this.selectedIds.includes(id);
|
||||
}
|
||||
|
||||
@action
|
||||
updateServerUrl(event) {
|
||||
this.serverUrlDraft = event.target.value;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
updateCaldavUrl(event) {
|
||||
this.caldavUrlDraft = event.target.value;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
updateUsername(event) {
|
||||
this.usernameDraft = event.target.value;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
updatePassword(event) {
|
||||
this.password = event.target.value;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
toggle(id) {
|
||||
this.selectedIds = this.selectedIds.includes(id)
|
||||
? this.selectedIds.filter((selected) => selected !== id)
|
||||
: [...this.selectedIds, id];
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
back() {
|
||||
this.error = null;
|
||||
this.step -= 1;
|
||||
}
|
||||
|
||||
@action
|
||||
async submitServer(event) {
|
||||
event.preventDefault();
|
||||
this.error = null;
|
||||
|
||||
const url = normalizeSockethubUrl(this.serverUrl);
|
||||
|
||||
if (!url) {
|
||||
this.error = 'Please enter a valid Sockethub server URL';
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
|
||||
try {
|
||||
await this.sockethub.setUrl(url);
|
||||
this.step = 2;
|
||||
} catch (err) {
|
||||
this.error = classifyCalendarError(err);
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async submitAccount(event) {
|
||||
event.preventDefault();
|
||||
this.error = null;
|
||||
|
||||
const url = normalizeCaldavUrl(this.caldavUrl);
|
||||
|
||||
if (!url) {
|
||||
this.error = 'Please enter a valid CalDAV URL';
|
||||
return;
|
||||
}
|
||||
|
||||
const username = this.username.trim();
|
||||
if (!username) {
|
||||
this.error = 'Please enter your username';
|
||||
return;
|
||||
}
|
||||
|
||||
// On edit a blank password keeps the stored one.
|
||||
const password = this.password.trim() || this.integration?.password;
|
||||
if (!password) {
|
||||
this.error = 'Please enter your password';
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
|
||||
try {
|
||||
const calendars = await this.calendar.fetchCalendars({
|
||||
url,
|
||||
username,
|
||||
password,
|
||||
});
|
||||
|
||||
this.calendars = calendars;
|
||||
|
||||
const ids = new Set(calendars.map((calendar) => calendar.id));
|
||||
this.selectedIds = this.selectedIds.filter((id) => ids.has(id));
|
||||
this.step = 3;
|
||||
} catch (err) {
|
||||
this.error = classifyCalendarError(err);
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async finish(event) {
|
||||
event.preventDefault();
|
||||
this.error = null;
|
||||
|
||||
if (!this.selectedIds.length) {
|
||||
this.error = 'Select at least one calendar';
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
|
||||
try {
|
||||
await this.calendar.configureCaldav(
|
||||
{
|
||||
url: normalizeCaldavUrl(this.caldavUrl),
|
||||
username: this.username.trim(),
|
||||
password: this.password.trim() || this.integration?.password,
|
||||
calendars: this.calendars,
|
||||
selectedCalendarIds: this.selectedIds,
|
||||
},
|
||||
this.integration?.id
|
||||
);
|
||||
|
||||
this.args.close?.();
|
||||
} catch (err) {
|
||||
this.error = classifyCalendarError(err);
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
async refreshCalendars() {
|
||||
const integration = this.integration;
|
||||
if (!integration) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.refreshing = true;
|
||||
|
||||
try {
|
||||
const calendars = await this.calendar.fetchCalendars({
|
||||
url: integration.url,
|
||||
username: integration.username,
|
||||
password: integration.password,
|
||||
});
|
||||
|
||||
if (calendars.length) {
|
||||
this.calendars = calendars;
|
||||
const ids = new Set(calendars.map((calendar) => calendar.id));
|
||||
this.selectedIds = this.selectedIds.filter((id) => ids.has(id));
|
||||
}
|
||||
} catch {
|
||||
// Keep the stored calendars if the refresh fails.
|
||||
} finally {
|
||||
this.refreshing = false;
|
||||
}
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<h3
|
||||
id="modal-title"
|
||||
class="text-base font-semibold leading-6 text-gray-900"
|
||||
>{{this.title}}</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-gray-500">
|
||||
Connect a CalDAV account to show upcoming events on your dashboard.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{#if this.isServerStep}}
|
||||
<form {{on "submit" this.submitServer}} class="mt-5">
|
||||
<div>
|
||||
<label
|
||||
for="caldav-server-url"
|
||||
class="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
Sockethub server URL
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
type="text"
|
||||
inputmode="url"
|
||||
id="caldav-server-url"
|
||||
name="server-url"
|
||||
value={{this.serverUrl}}
|
||||
{{on "input" this.updateServerUrl}}
|
||||
placeholder={{DEFAULT_SOCKETHUB_URL}}
|
||||
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-500">
|
||||
The Sockethub instance Dashtab talks to. Leave as-is unless you
|
||||
self-host it.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{#if this.error}}
|
||||
<p class="mt-4 text-sm text-red-600">{{this.error}}</p>
|
||||
{{/if}}
|
||||
|
||||
<div class="mt-5 sm:mt-6 flex gap-3">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={{this.submitting}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 disabled:opacity-50"
|
||||
>
|
||||
Continue
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" @close}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{{else if this.isAccountStep}}
|
||||
<form {{on "submit" this.submitAccount}} class="mt-5">
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label
|
||||
for="caldav-url"
|
||||
class="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
CalDAV URL
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
type="text"
|
||||
inputmode="url"
|
||||
id="caldav-url"
|
||||
name="caldav-url"
|
||||
value={{this.caldavUrl}}
|
||||
{{on "input" this.updateCaldavUrl}}
|
||||
placeholder="https://calendar.example/dav/"
|
||||
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="caldav-username"
|
||||
class="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
Username
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
type="text"
|
||||
id="caldav-username"
|
||||
name="username"
|
||||
autocomplete="username"
|
||||
value={{this.username}}
|
||||
{{on "input" this.updateUsername}}
|
||||
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label
|
||||
for="caldav-password"
|
||||
class="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
Password
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
type="password"
|
||||
id="caldav-password"
|
||||
name="password"
|
||||
autocomplete="current-password"
|
||||
value={{this.password}}
|
||||
{{on "input" this.updatePassword}}
|
||||
placeholder={{if
|
||||
this.isEdit
|
||||
"Leave blank to keep current"
|
||||
""
|
||||
}}
|
||||
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-500">
|
||||
Use an app password where your provider supports one.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if this.error}}
|
||||
<p class="mt-4 text-sm text-red-600">{{this.error}}</p>
|
||||
{{/if}}
|
||||
|
||||
<div class="mt-5 sm:mt-6 flex gap-3">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={{this.submitting}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 disabled:opacity-50"
|
||||
>
|
||||
Continue
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" this.back}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Back
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" @close}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<form {{on "submit" this.finish}} class="mt-5">
|
||||
{{#if this.eventCalendars.length}}
|
||||
<fieldset>
|
||||
<legend class="text-base font-semibold text-gray-900">
|
||||
Calendars
|
||||
</legend>
|
||||
<div
|
||||
class="mt-4 divide-y divide-gray-200 border-t border-b border-gray-200"
|
||||
>
|
||||
{{#each this.eventCalendars as |calendar index|}}
|
||||
<div class="relative flex gap-3 py-4">
|
||||
<div class="min-w-0 flex-1 text-sm/6">
|
||||
<label
|
||||
for="caldav-calendar-{{index}}"
|
||||
class="font-medium text-gray-900 select-none"
|
||||
>
|
||||
{{calendar.name}}
|
||||
</label>
|
||||
{{#if calendar.components.length}}
|
||||
<p class="text-xs text-gray-500">
|
||||
{{calendar.components}}
|
||||
</p>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="flex h-6 shrink-0 items-center">
|
||||
<div class="group grid size-4 grid-cols-1">
|
||||
<input
|
||||
id="caldav-calendar-{{index}}"
|
||||
type="checkbox"
|
||||
name="calendar-{{index}}"
|
||||
checked={{this.isSelected calendar.id}}
|
||||
{{on "change" (fn this.toggle calendar.id)}}
|
||||
class="col-start-1 row-start-1 appearance-none rounded-sm border border-gray-300 bg-white checked:border-indigo-600 checked:bg-indigo-600 indeterminate:border-indigo-600 indeterminate:bg-indigo-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto"
|
||||
/>
|
||||
<svg
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
class="pointer-events-none col-start-1 row-start-1 size-3.5 self-center justify-self-center stroke-white group-has-disabled:stroke-gray-950/25"
|
||||
>
|
||||
<path
|
||||
d="M3 8L6 11L11 3.5"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
class="opacity-0 group-has-checked:opacity-100"
|
||||
/>
|
||||
<path
|
||||
d="M3 7H11"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
class="opacity-0 group-has-indeterminate:opacity-100"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</fieldset>
|
||||
{{else}}
|
||||
<p class="text-sm text-gray-500">
|
||||
No calendars with events were found for this account.
|
||||
</p>
|
||||
{{/if}}
|
||||
|
||||
{{#if this.error}}
|
||||
<p class="mt-4 text-sm text-red-600">{{this.error}}</p>
|
||||
{{/if}}
|
||||
|
||||
<div class="mt-5 sm:mt-6 flex gap-3">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={{this.submitting}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 disabled:opacity-50"
|
||||
>
|
||||
{{if this.isEdit "Save" "Connect"}}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" this.back}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Back
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" @close}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
import Component from '@glimmer/component';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { action } from '@ember/object';
|
||||
import { service } from '@ember/service';
|
||||
import { on } from '@ember/modifier';
|
||||
import { classifyCalendarError } from '../../../config/calendar';
|
||||
import {
|
||||
DEFAULT_SOCKETHUB_URL,
|
||||
normalizeSockethubUrl,
|
||||
} from '../../../config/sockethub';
|
||||
import { normalizeFeedUrl } from '../../../config/ics';
|
||||
|
||||
// Setup for a published ICS/WebCal feed: the Sockethub server URL, then the
|
||||
// feed URL. The feed URL is often a secret link, so there are no credentials.
|
||||
export default class SettingsIntegrationsCalendarIcsForm extends Component {
|
||||
@service calendar;
|
||||
@service sockethub;
|
||||
|
||||
@tracked step = 1;
|
||||
@tracked serverUrlDraft = null;
|
||||
@tracked feedUrlDraft = null;
|
||||
@tracked error = null;
|
||||
@tracked submitting = false;
|
||||
|
||||
constructor(owner, args) {
|
||||
super(owner, args);
|
||||
|
||||
if (args.props?.mode === 'edit' && args.props?.integration) {
|
||||
this.step = 2;
|
||||
}
|
||||
}
|
||||
|
||||
get integration() {
|
||||
return this.args.props?.integration;
|
||||
}
|
||||
|
||||
get isEdit() {
|
||||
return this.args.props?.mode === 'edit';
|
||||
}
|
||||
|
||||
get title() {
|
||||
return this.isEdit
|
||||
? 'Edit ICS / WebCal Calendar'
|
||||
: 'Add ICS / WebCal Calendar';
|
||||
}
|
||||
|
||||
get serverUrl() {
|
||||
return this.serverUrlDraft ?? this.sockethub.url ?? DEFAULT_SOCKETHUB_URL;
|
||||
}
|
||||
|
||||
get feedUrl() {
|
||||
return this.feedUrlDraft ?? this.integration?.url ?? '';
|
||||
}
|
||||
|
||||
get isServerStep() {
|
||||
return this.step === 1;
|
||||
}
|
||||
|
||||
@action
|
||||
updateServerUrl(event) {
|
||||
this.serverUrlDraft = event.target.value;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
updateFeedUrl(event) {
|
||||
this.feedUrlDraft = event.target.value;
|
||||
this.error = null;
|
||||
}
|
||||
|
||||
@action
|
||||
back() {
|
||||
this.error = null;
|
||||
this.step = 1;
|
||||
}
|
||||
|
||||
@action
|
||||
async submitServer(event) {
|
||||
event.preventDefault();
|
||||
this.error = null;
|
||||
|
||||
const url = normalizeSockethubUrl(this.serverUrl);
|
||||
|
||||
if (!url) {
|
||||
this.error = 'Please enter a valid Sockethub server URL';
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
|
||||
try {
|
||||
await this.sockethub.setUrl(url);
|
||||
this.step = 2;
|
||||
} catch (err) {
|
||||
this.error = classifyCalendarError(err);
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
async submitFeed(event) {
|
||||
event.preventDefault();
|
||||
this.error = null;
|
||||
|
||||
const url = normalizeFeedUrl(this.feedUrl);
|
||||
|
||||
if (!url) {
|
||||
this.error = 'Please enter a valid .ics or webcal:// link';
|
||||
return;
|
||||
}
|
||||
|
||||
this.submitting = true;
|
||||
|
||||
try {
|
||||
const { name } = await this.calendar.verifyFeed(url);
|
||||
|
||||
await this.calendar.configureIcs({ url, name }, this.integration?.id);
|
||||
|
||||
this.args.close?.();
|
||||
} catch (err) {
|
||||
this.error = classifyCalendarError(err);
|
||||
} finally {
|
||||
this.submitting = false;
|
||||
}
|
||||
}
|
||||
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<h3
|
||||
id="modal-title"
|
||||
class="text-base font-semibold leading-6 text-gray-900"
|
||||
>{{this.title}}</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-gray-500">
|
||||
Add a published calendar link to show upcoming events on your
|
||||
dashboard.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{#if this.isServerStep}}
|
||||
<form {{on "submit" this.submitServer}} class="mt-5">
|
||||
<div>
|
||||
<label
|
||||
for="ics-server-url"
|
||||
class="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
Sockethub server URL
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
type="text"
|
||||
inputmode="url"
|
||||
id="ics-server-url"
|
||||
name="server-url"
|
||||
value={{this.serverUrl}}
|
||||
{{on "input" this.updateServerUrl}}
|
||||
placeholder={{DEFAULT_SOCKETHUB_URL}}
|
||||
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-500">
|
||||
The Sockethub instance Dashtab talks to. Leave as-is unless you
|
||||
self-host it.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{#if this.error}}
|
||||
<p class="mt-4 text-sm text-red-600">{{this.error}}</p>
|
||||
{{/if}}
|
||||
|
||||
<div class="mt-5 sm:mt-6 flex gap-3">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={{this.submitting}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 disabled:opacity-50"
|
||||
>
|
||||
Continue
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" @close}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{{else}}
|
||||
<form {{on "submit" this.submitFeed}} class="mt-5">
|
||||
<div>
|
||||
<label
|
||||
for="ics-feed-url"
|
||||
class="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
Calendar link
|
||||
</label>
|
||||
<div class="mt-2">
|
||||
<input
|
||||
type="text"
|
||||
inputmode="url"
|
||||
id="ics-feed-url"
|
||||
name="feed-url"
|
||||
value={{this.feedUrl}}
|
||||
{{on "input" this.updateFeedUrl}}
|
||||
placeholder="https://example.org/holidays.ics"
|
||||
class="block w-full rounded-md border-0 px-3 py-2 text-sm text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600"
|
||||
/>
|
||||
</div>
|
||||
<p class="mt-2 text-sm text-gray-500">
|
||||
A read-only .ics link or webcal:// address. If it is private, keep
|
||||
the secret link safe.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{#if this.error}}
|
||||
<p class="mt-4 text-sm text-red-600">{{this.error}}</p>
|
||||
{{/if}}
|
||||
|
||||
<div class="mt-5 sm:mt-6 flex gap-3">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={{this.submitting}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 disabled:opacity-50"
|
||||
>
|
||||
{{if this.isEdit "Save" "Connect"}}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" this.back}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Back
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
{{on "click" @close}}
|
||||
class="inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import FeedbinForm from '../components/settings/integrations/feedbin-form.gjs';
|
||||
import GithubForm from '../components/settings/integrations/github-form.gjs';
|
||||
import GiteaForm from '../components/settings/integrations/gitea-form.gjs';
|
||||
import HomeAssistantForm from '../components/settings/integrations/home-assistant-form.gjs';
|
||||
import CalendarCaldavForm from '../components/settings/integrations/calendar-caldav-form.gjs';
|
||||
import CalendarIcsForm from '../components/settings/integrations/calendar-ics-form.gjs';
|
||||
|
||||
const FORMS = {
|
||||
discourse: DiscourseForm,
|
||||
@@ -12,6 +14,8 @@ const FORMS = {
|
||||
github: GithubForm,
|
||||
gitea: GiteaForm,
|
||||
homeassistant: HomeAssistantForm,
|
||||
'calendar-caldav': CalendarCaldavForm,
|
||||
'calendar-ics': CalendarIcsForm,
|
||||
};
|
||||
|
||||
export function formFor(type) {
|
||||
|
||||
Reference in new issue
Block a user