diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index ca476f47b..8e9c587ed 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -103,9 +103,16 @@ "disableSuccess": "Two factor authentication was sucessfully disabled." }, "caldav": { - "title": "Caldav", - "howTo": "You can connect Vikunja to caldav clients to view and manage all tasks from different clients. Enter this url into your client:", - "more": "More information about caldav in Vikunja" + "title": "CalDAV", + "howTo": "You can connect Vikunja to CalDAV clients to view and manage all tasks from different clients. Enter this url into your client:", + "more": "More information about CalDAV in Vikunja", + "tokens": "CalDAV Tokens", + "tokensHowTo": "You can use a CalDAV token to use instead of a password to log in the above endpoint.", + "createToken": "Create a token", + "tokenCreated": "Here is your token: {token}", + "wontSeeItAgain": "Write it down, you won't be able to see it again.", + "mustUseToken": "You need to create a CalDAV token if you want to use CalDAV with a third party client. Use the token as the password.", + "usernameIs": "Your username is: {0}" }, "avatar": { "title": "Avatar", @@ -486,7 +493,10 @@ "hideMenu": "Hide the menu", "forExample": "For example:", "welcomeBack": "Welcome Back!", - "custom": "Custom" + "custom": "Custom", + "id": "ID", + "created": "Created at", + "actions": "Actions" }, "input": { "resetColor": "Reset Color", diff --git a/src/models/abstractModel.ts b/src/models/abstractModel.ts index 202ccde9d..fbf074e29 100644 --- a/src/models/abstractModel.ts +++ b/src/models/abstractModel.ts @@ -5,15 +5,13 @@ export default class AbstractModel { /** * The max right the user has on this object, as returned by the x-max-right header from the api. - * @type {number|null} */ - maxRight = null + maxRight: number | null = null /** * The abstract constructor takes an object and merges its data with the default data of this model. - * @param data */ - constructor(data) { + constructor(data : Object = {}) { data = objectToCamelCase(data) // Put all data in our model while overriding those with a value of null or undefined with their defaults @@ -26,9 +24,8 @@ export default class AbstractModel { /** * Default attributes that define the "empty" state. - * @return {{}} */ - defaults() { + defaults(): Object { return {} } } \ No newline at end of file diff --git a/src/models/caldavToken.ts b/src/models/caldavToken.ts new file mode 100644 index 000000000..2f8f1d547 --- /dev/null +++ b/src/models/caldavToken.ts @@ -0,0 +1,15 @@ +import AbstractModel from './abstractModel' + +export default class CaldavTokenModel extends AbstractModel { + constructor(data? : Object) { + super(data) + + /** @type {number} */ + this.id + + if (this.created) { + /** @type {Date} */ + this.created = new Date(this.created) + } + } +} \ No newline at end of file diff --git a/src/services/caldavToken.js b/src/services/caldavToken.js new file mode 100644 index 000000000..6e4397655 --- /dev/null +++ b/src/services/caldavToken.js @@ -0,0 +1,25 @@ +import {formatISO} from 'date-fns' +import CaldavTokenModel from '../models/caldavToken' +import AbstractService from './abstractService' + +export default class CaldavTokenService extends AbstractService { + constructor() { + super({ + getAll: '/user/settings/token/caldav', + create: '/user/settings/token/caldav', + delete: '/user/settings/token/caldav/{id}', + }) + } + + processModel(model) { + return { + ...model, + created: formatISO(new Date(model.created)), + } + } + + modelFactory(data) { + return new CaldavTokenModel(data) + } +} + \ No newline at end of file diff --git a/src/views/user/settings/Caldav.vue b/src/views/user/settings/Caldav.vue index 6c4cbc0a5..ca8518722 100644 --- a/src/views/user/settings/Caldav.vue +++ b/src/views/user/settings/Caldav.vue @@ -16,41 +16,94 @@ /> + +
+ {{ $t('user.settings.caldav.tokens') }} +
+

- + {{ isLocalUser ? $t('user.settings.caldav.tokensHowTo') : $t('user.settings.caldav.mustUseToken') }} + +

+ + + + + + + + + + + + +
{{ $t('misc.id') }}{{ $t('misc.created') }}{{ $t('misc.actions') }}
{{ tk.id }}{{ formatDateShort(tk.created) }} + + {{ $t('misc.delete') }} + +
+ + + {{ $t('user.settings.caldav.tokenCreated', {token: newToken.token}) }}
+ {{ $t('user.settings.caldav.wontSeeItAgain') }} +
+ + + {{ $t('user.settings.caldav.createToken') }} + + +

+ {{ $t('user.settings.caldav.more') }} - +

-