A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: some random frontend fixes and coverage
shamoon0c883d064ebd
diff --git a/src-ui/src/app/components/common/input/switch/switch.component.spec.ts b/src-ui/src/app/components/common/input/switch/switch.component.spec.tsindex 372bfd8ab..790330955 100644--- a/src-ui/src/app/components/common/input/switch/switch.component.spec.ts+++ b/src-ui/src/app/components/common/input/switch/switch.component.spec.ts@@ -38,8 +38,10 @@ describe('SwitchComponent', () => {expect(component.value).toBeFalsy()})- it('should show note if unset', () => {+ it('should correctly report unset', () => {component.value = nullexpect(component.isUnset).toBeTruthy()+ component.value = undefined+ expect(component.isUnset).toBeTruthy()})})diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.spec.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.spec.tsindex 95b12d7ec..8905d3ff2 100644--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.spec.ts+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.spec.ts@@ -120,4 +120,12 @@ describe('DocumentCardLargeComponent', () => {expect(fixture.nativeElement.textContent).toContain('bananas')expect(component.searchNoteHighlights).toContain('<span>bananas</span>')})++ it('should try to close the preview on mouse leave', () => {+ component.popupPreview = {+ close: jest.fn(),+ } as any+ component.mouseLeaveCard()+ expect(component.popupPreview.close).toHaveBeenCalled()+ })})diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.tsindex 99597ca5a..d33cef9f3 100644--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts@@ -108,12 +108,8 @@ export class DocumentCardLargeComponent extends ComponentWithPermissions {return this.documentService.getDownloadUrl(this.document.id)}- get previewUrl() {- return this.documentService.getPreviewUrl(this.document.id)- }-mouseLeaveCard() {- this.popupPreview.close()+ this.popupPreview?.close()}get contentTrimmed() {diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.tsindex 0c0c82103..7bdb0c3f8 100644--- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts+++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.spec.ts@@ -111,4 +111,12 @@ describe('DocumentCardSmallComponent', () => {fixture.debugElement.queryAll(By.directive(TagComponent))).toHaveLength(6)})++ it('should try to close the preview on mouse leave', () => {+ component.popupPreview = {+ close: jest.fn(),+ } as any+ component.mouseLeaveCard()+ expect(component.popupPreview.close).toHaveBeenCalled()+ })})diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.tsindex 7397159af..f8705fa8e 100644--- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts+++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts@@ -94,7 +94,7 @@ export class DocumentCardSmallComponent extends ComponentWithPermissions {}mouseLeaveCard() {- this.popupPreview.close()+ this.popupPreview?.close()}get notesEnabled(): boolean {diff --git a/src-ui/src/app/utils/color.spec.ts b/src-ui/src/app/utils/color.spec.tsindex 4dddb59a1..d31ad1b26 100644--- a/src-ui/src/app/utils/color.spec.ts+++ b/src-ui/src/app/utils/color.spec.ts@@ -1,8 +1,10 @@import {BRIGHTNESS,+ componentToHex,computeLuminance,estimateBrightnessForColor,hexToHsl,+ hslToRgb,randomColor,rgbToHsl,} from './color'@@ -44,7 +46,21 @@ describe('Color Utils', () => {expect(hsl).toEqual([0, 0, 0.5019607843137255])})+ it('should convert hsl to rgb', () => {+ let rgb = hslToRgb(0, 0, 0.5)+ expect(rgb).toEqual([127.5, 127.5, 127.5])+ expect(hslToRgb(0, 0, 0)).toEqual([0, 0, 0])+ expect(hslToRgb(0, 0, 1)).toEqual([255, 255, 255])+ })+it('should return a random color', () => {expect(randomColor()).not.toBeNull()})++ it('should convert component to hex', () => {+ expect(componentToHex(0)).toEqual('00')+ expect(componentToHex(255)).toEqual('ff')+ expect(componentToHex(128)).toEqual('80')+ expect(componentToHex(15)).toEqual('0f')+ })})diff --git a/src-ui/src/app/utils/color.ts b/src-ui/src/app/utils/color.tsindex e23a91c5f..b2899571e 100644--- a/src-ui/src/app/utils/color.ts+++ b/src-ui/src/app/utils/color.ts@@ -5,7 +5,7 @@ export const BRIGHTNESS = {DARK: 'dark',}-function componentToHex(c) {+export function componentToHex(c) {var hex = Math.floor(c).toString(16)return hex.length == 1 ? '0' + hex : hex}@@ -23,21 +23,22 @@ function componentToHex(c) {* @param Number l The lightness* @return Array The RGB representation*/-function hslToRgb(h, s, l) {++function hue2rgb(p, q, t) {+ if (t < 0) t += 1+ if (t > 1) t -= 1+ if (t < 1 / 6) return p + (q - p) * 6 * t+ if (t < 1 / 2) return q+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6+ return p+}++export function hslToRgb(h, s, l) {var r, g, bif (s == 0) {r = g = b = l // achromatic} else {- function hue2rgb(p, q, t) {- if (t < 0) t += 1- if (t > 1) t -= 1- if (t < 1 / 6) return p + (q - p) * 6 * t- if (t < 1 / 2) return q- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6- return p- }-var q = l < 0.5 ? l * (1 + s) : l + s - l * svar p = 2 * l - qr = hue2rgb(p, q, h + 1 / 3)