Skip to content

Commit

Permalink
feat: Allow custom labels for profiles
Browse files Browse the repository at this point in the history
fixes #1294

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
  • Loading branch information
marcelklehr committed May 22, 2024
1 parent 3174cbb commit f8524d0
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 11 deletions.
6 changes: 6 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -722,5 +722,11 @@
},
"LabelTelemetrydisable": {
"message": "Do not send error data to floccus developers"
},
"LabelAccountlabel": {
"message": "Profile label"
},
"DescriptionAccountlabel": {
"message": "Give this profile a name so you can recognize it more easily"
}
}
1 change: 1 addition & 0 deletions src/lib/Account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default class Account {
nestedSync: false,
failsafe: true,
allowNetwork: false,
label: '',
}
const data = Object.assign(defaults, this.server.getData())
if (data.type === 'nextcloud-folders') {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/adapters/Caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class CachingAdapter implements Adapter, BulkImportResource {

getLabel():string {
const data = this.getData()
return data.username + '@' + new URL(data.url).hostname
return data.label || data.username + '@' + new URL(data.url).hostname
}

async getBookmarksTree(): Promise<Folder> {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/adapters/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class GitAdapter extends CachingAdapter {
const data = this.getData()
const url = new URL(data.url)
url.protocol = ''
return data.username + '@' + url.hostname + ':' + data.bookmark_file
return data.label || data.username + '@' + url.hostname + ':' + data.bookmark_file
}

getData() {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/adapters/GoogleDrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default class GoogleDriveAdapter extends CachingAdapter {
}

getLabel():string {
return 'Google Drive: ' + this.server.bookmark_file
return this.server.label || 'Google Drive: ' + this.server.bookmark_file
}

static getDefaultValues() {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/adapters/NextcloudBookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes

getLabel():string {
const data = this.getData()
return data.label || data.username.includes('@') ? data.username + ' on ' + new URL(data.url).hostname : data.username + '@' + new URL(data.url).hostname
return data.label || (data.username.includes('@') ? data.username + ' on ' + new URL(data.url).hostname : data.username + '@' + new URL(data.url).hostname)
}

acceptsBookmark(bm: Bookmark):boolean {
Expand Down
1 change: 1 addition & 0 deletions src/lib/interfaces/AccountStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface IAccountData {
failsafe?: boolean
username?: string
password?: string
label?: string
[p:string]: any
}

Expand Down
18 changes: 14 additions & 4 deletions src/ui/components/OptionsGit.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<v-container>
<div>
<v-text-field
append-icon="mdi-label"
class="mt-2 mb-2"
:value="label"
:label="t('LabelAccountlabel')"
:hint="t('DescriptionAccountlabel')"
:persistent-hint="true"
@input="$emit('update:label', $event)" />
</div>
<v-card class="mb-4">
<v-card-text
id="server"
Expand Down Expand Up @@ -35,9 +45,9 @@
:value="bookmark_file_type"
@input="$emit('update:bookmark_file_type', $event)" />
<v-text-field
v-model="branch"
class="mb-2"
:label="t('LabelGitbranch')" />
v-model="branch"
class="mb-2"
:label="t('LabelGitbranch')" />
</v-card-text>
</v-card>

Expand Down Expand Up @@ -147,7 +157,7 @@ import OptionExportBookmarks from './OptionExportBookmarks.vue'
export default {
name: 'OptionsGit',
components: { OptionExportBookmarks, OptionAllowNetwork, OptionDownloadLogs, OptionAllowRedirects, OptionClientCert, OptionFailsafe, OptionSyncFolder, OptionDeleteAccount, OptionSyncStrategy, OptionResetCache, OptionSyncInterval, OptionNestedSync, OptionFileType },
props: ['url', 'username', 'password', 'branch', 'includeCredentials', 'serverRoot', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'bookmark_file', 'nestedSync', 'failsafe', 'allowRedirects', 'bookmark_file_type', 'enabled'],
props: ['url', 'username', 'password', 'branch', 'includeCredentials', 'serverRoot', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'bookmark_file', 'nestedSync', 'failsafe', 'allowRedirects', 'bookmark_file_type', 'enabled', 'label'],
data() {
return {
panels: [0, 1],
Expand Down
12 changes: 11 additions & 1 deletion src/ui/components/OptionsGoogleDrive.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<v-container>
<div>
<v-text-field
append-icon="mdi-label"
class="mt-2 mb-2"
:value="label"
:label="t('LabelAccountlabel')"
:hint="t('DescriptionAccountlabel')"
:persistent-hint="true"
@input="$emit('update:label', $event)" />
</div>
<v-card class="mb-4">
<v-card-title
id="server"
Expand Down Expand Up @@ -136,7 +146,7 @@ import OptionExportBookmarks from './OptionExportBookmarks.vue'
export default {
name: 'OptionsGoogleDrive',
components: { OptionExportBookmarks, OptionPassphrase, OptionAllowNetwork, OptionDownloadLogs, OptionFailsafe, OptionSyncFolder, OptionDeleteAccount, OptionSyncStrategy, OptionResetCache, OptionSyncInterval, OptionNestedSync },
props: ['username', 'password', 'refreshToken', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'bookmark_file', 'nestedSync', 'failsafe', 'enabled'],
props: ['username', 'password', 'refreshToken', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'bookmark_file', 'nestedSync', 'failsafe', 'enabled', 'label'],
data() {
return {
panels: [0, 1],
Expand Down
12 changes: 11 additions & 1 deletion src/ui/components/OptionsNextcloudBookmarks.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<v-container>
<div>
<v-text-field
append-icon="mdi-label"
class="mt-2 mb-2"
:value="label"
:label="t('LabelAccountlabel')"
:hint="t('DescriptionAccountlabel')"
:persistent-hint="true"
@input="$emit('update:label', $event)" />
</div>
<v-card class="mb-4">
<v-card-title
id="server">
Expand Down Expand Up @@ -137,7 +147,7 @@ import OptionExportBookmarks from './OptionExportBookmarks.vue'
export default {
name: 'OptionsNextcloudBookmarks',
components: { OptionExportBookmarks, OptionAllowNetwork, OptionDownloadLogs, OptionAllowRedirects, OptionClientCert, OptionFailsafe, OptionNestedSync, NextcloudLogin, OptionSyncFolder, OptionDeleteAccount, OptionSyncStrategy, OptionResetCache, OptionSyncInterval },
props: ['url', 'username', 'password', 'includeCredentials', 'serverRoot', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'nestedSync', 'failsafe', 'allowRedirects', 'enabled'],
props: ['url', 'username', 'password', 'includeCredentials', 'serverRoot', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'nestedSync', 'failsafe', 'allowRedirects', 'enabled', 'label'],
data() {
return {
panels: [0, 1]
Expand Down
12 changes: 11 additions & 1 deletion src/ui/components/OptionsWebdav.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
<template>
<v-container>
<div>
<v-text-field
append-icon="mdi-label"
class="mt-2 mb-2"
:value="label"
:label="t('LabelAccountlabel')"
:hint="t('DescriptionAccountlabel')"
:persistent-hint="true"
@input="$emit('update:label', $event)" />
</div>
<v-card class="mb-4">
<v-card-text
id="server"
Expand Down Expand Up @@ -147,7 +157,7 @@ import OptionPassphrase from './OptionPassphrase.vue'
export default {
name: 'OptionsWebdav',
components: { OptionExportBookmarks, OptionAllowNetwork, OptionDownloadLogs, OptionAllowRedirects, OptionClientCert, OptionFailsafe, OptionSyncFolder, OptionDeleteAccount, OptionSyncStrategy, OptionResetCache, OptionSyncInterval, OptionNestedSync, OptionFileType, OptionPassphrase },
props: ['url', 'username', 'password','passphrase', 'includeCredentials', 'serverRoot', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'bookmark_file', 'nestedSync', 'failsafe', 'allowRedirects', 'bookmark_file_type', 'enabled'],
props: ['url', 'username', 'password','passphrase', 'includeCredentials', 'serverRoot', 'localRoot', 'allowNetwork', 'syncInterval', 'strategy', 'bookmark_file', 'nestedSync', 'failsafe', 'allowRedirects', 'bookmark_file_type', 'enabled', 'label'],
data() {
return {
panels: [0, 1],
Expand Down

0 comments on commit f8524d0

Please sign in to comment.