From 998a63612f4ea95cc4748ee6bc568c9262bd7273 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 26 Jun 2018 11:50:23 -0400 Subject: [PATCH] domain rules page implementation --- src/app/settings/domain-rules.component.html | 77 ++++++++++++++++---- src/app/settings/domain-rules.component.ts | 59 +++++++++++++-- src/app/vault/add-edit.component.html | 4 +- src/locales/en/messages.json | 31 +++++++- src/scss/styles.scss | 11 ++- 5 files changed, 156 insertions(+), 26 deletions(-) diff --git a/src/app/settings/domain-rules.component.html b/src/app/settings/domain-rules.component.html index 588367e3f1..9d6d9676e0 100644 --- a/src/app/settings/domain-rules.component.html +++ b/src/app/settings/domain-rules.component.html @@ -2,19 +2,64 @@

{{'domainRules' | i18n}}

{{'domainRulesDesc' | i18n}}

-

{{'customEqDomains' | i18n}}

- - - - - - -
-

{{'globalEqDomains' | i18n}}

- - - - - - -
+
+

{{'customEqDomains' | i18n}}

+

+ +

+ +
+
+ + +
+ +
+ + {{'newCustomDomainDesc' | i18n}} +
+ +

{{'globalEqDomains' | i18n}}

+

+ +

+ + + + + + + +
{{d.domains}} + +
+ +
diff --git a/src/app/settings/domain-rules.component.ts b/src/app/settings/domain-rules.component.ts index ccee37614a..5dd76a15a2 100644 --- a/src/app/settings/domain-rules.component.ts +++ b/src/app/settings/domain-rules.component.ts @@ -7,9 +7,9 @@ import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { ApiService } from 'jslib/abstractions/api.service'; -import { CryptoService } from 'jslib/abstractions/crypto.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; -import { MessagingService } from 'jslib/abstractions/messaging.service'; + +import { UpdateDomainsRequest } from 'jslib/models/request/updateDomainsRequest'; @Component({ selector: 'app-domain-rules', @@ -18,19 +18,68 @@ import { MessagingService } from 'jslib/abstractions/messaging.service'; export class DomainRulesComponent implements OnInit { loading = true; custom: string[] = []; - global: string[] = []; + global: any[] = []; formPromise: Promise; constructor(private apiService: ApiService, private i18nService: I18nService, - private analytics: Angulartics2, private toasterService: ToasterService, - private cryptoService: CryptoService, private messagingService: MessagingService) { } + private analytics: Angulartics2, private toasterService: ToasterService) { } async ngOnInit() { const response = await this.apiService.getSettingsDomains(); this.loading = false; + if (response.equivalentDomains != null) { + this.custom = response.equivalentDomains.map((d) => d.join(', ')); + } + if (response.globalEquivalentDomains != null) { + this.global = response.globalEquivalentDomains.map((d) => { + return { + domains: d.domains.join(', '), + excluded: d.excluded, + key: d.type, + }; + }); + } + } + + toggleExcluded(globalDomain: any) { + globalDomain.excluded = !globalDomain.excluded; + } + + customize(globalDomain: any) { + globalDomain.excluded = true; + this.custom.push(globalDomain.domains); + } + + remove(index: number) { + this.custom.splice(index, 1); + } + + add() { + this.custom.push(''); } async submit() { + const request = new UpdateDomainsRequest(); + request.excludedGlobalEquivalentDomains = this.global.filter((d) => d.excluded) + .map((d) => d.key); + if (request.excludedGlobalEquivalentDomains.length === 0) { + request.excludedGlobalEquivalentDomains = null; + } + request.equivalentDomains = this.custom.filter((d) => d != null && d.trim() !== '') + .map((d) => d.split(' ').join('').split(',')); + if (request.equivalentDomains.length === 0) { + request.equivalentDomains = null; + } + try { + this.formPromise = this.apiService.putSettingsDomains(request); + await this.formPromise; + this.analytics.eventTrack.next({ action: 'Saved Equivalent Domains' }); + this.toasterService.popAsync('success', null, this.i18nService.t('domainsUpdated')); + } catch { } + } + + indexTrackBy(index: number, obj: any): any { + return index; } } diff --git a/src/app/vault/add-edit.component.html b/src/app/vault/add-edit.component.html index 6f57dfa599..51b54158f4 100644 --- a/src/app/vault/add-edit.component.html +++ b/src/app/vault/add-edit.component.html @@ -125,7 +125,7 @@ - @@ -328,7 +328,7 @@ - diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index dfd6b3eec8..0d1cfd9642 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -924,10 +924,37 @@ "domainRulesDesc": { "message": "If you have the same login across multiple different website domains, you can mark the website as \"equivalent\". \"Global\" domains are ones already created for you by Bitwarden." }, - "globalEqRules": { + "globalEqDomains": { "message": "Global Equivalent Domains" }, - "customEqRules": { + "customEqDomains": { "message": "Custom Equivalent Domains" + }, + "exclude": { + "message": "Exclude" + }, + "include": { + "message": "Include" + }, + "customize": { + "message": "Customize" + }, + "newCustomDomain": { + "message": "New Custom Domain" + }, + "newCustomDomainDesc": { + "message": "Only \"base\" domains are allowed. Do not enter subdomains. For example, enter \"google.com\" instead of \"www.google.com\". You can also enter \"androidapp://package.name\" to associate an android app with other website domains." + }, + "customDomainX": { + "message": "Custom Domain $INDEX$", + "placeholders": { + "index": { + "content": "$1", + "example": "2" + } + } + }, + "domainsUpdated": { + "message": "Domains updated" } } diff --git a/src/scss/styles.scss b/src/scss/styles.scss index db559a6c21..ff696d8230 100644 --- a/src/scss/styles.scss +++ b/src/scss/styles.scss @@ -49,6 +49,7 @@ $navbar-dark-hover-color: rgba(#ffffff, .9); $input-bg: #fbfbfb; $input-focus-bg: #ffffff; $input-disabled-bg: #e0e0e0; +$input-placeholder-color: #b4b4b4; $table-accent-bg: rgba(#000000, .02); $table-hover-bg: rgba(#000000, .03); @@ -229,7 +230,10 @@ label:not(.form-check-label) { td { vertical-align: middle; - line-height: 1; + + &:not(.normal-lh) { + line-height: 1; + } small, > .fa, .icon { color: $text-muted; @@ -273,6 +277,11 @@ label:not(.form-check-label) { width: 35px; max-width: 35px; } + + td.table-list-strike { + color: $text-muted; + text-decoration: line-through; + } } app-vault-groupings {