• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.0
/src/image/image.service.ts
1
import { Inject, Injectable, OnDestroy, Optional } from '@angular/core';
2
import { ThyImagePreviewConfig, THY_IMAGE_DEFAULT_PREVIEW_OPTIONS } from './image.config';
3
import { ThyImageInfo, ThyImagePreviewOptions } from './image.class';
4
import { ThyImagePreviewComponent } from './preview/image-preview.component';
5
import { ThyDialog, ThyDialogSizes } from 'ngx-tethys/dialog';
6
import { ThyImagePreviewRef } from './preview/image-preview-ref';
7
import { Observable, Subject } from 'rxjs';
8
import { takeUntil } from 'rxjs/operators';
9

10
/**
11
 * 图片预览服务
12
 */
1✔
13
@Injectable()
14
export class ThyImageService implements OnDestroy {
×
15
    /**
×
16
     * 图片预览默认配置,外部可通过注入 THY_IMAGE_DEFAULT_PREVIEW_OPTIONS 进行配置
×
17
     */
×
18
    defaultConfig: ThyImagePreviewConfig;
19

20
    private downloadClicked$ = new Subject<ThyImageInfo>();
21

22
    private ngUnsubscribe$ = new Subject<void>();
23

×
24
    constructor(
×
25
        public thyDialog: ThyDialog,
26
        @Optional()
27
        @Inject(THY_IMAGE_DEFAULT_PREVIEW_OPTIONS)
×
28
        defaultConfig: ThyImagePreviewConfig
29
    ) {
30
        this.defaultConfig = defaultConfig;
31
    }
32

33
    /**
34
     * 图片预览方法
35
     */
×
36
    preview(images: ThyImageInfo[], options?: ThyImagePreviewOptions & { startIndex?: number }): ThyImagePreviewRef {
×
37
        const config = { ...this.defaultConfig, ...options };
38
        const dialogRef = this.thyDialog.open(ThyImagePreviewComponent, {
39
            initialState: {
40
                images,
×
41
                previewIndex: options?.startIndex >= 0 && options?.startIndex < images.length ? options.startIndex : 0,
42
                previewConfig: config
×
43
            },
44
            backdropClass: 'thy-image-preview-backdrop',
45
            panelClass: 'thy-image-preview-container',
×
46
            size: ThyDialogSizes.full,
47
            ...config
48
        });
×
49
        const imagePreviewRef = new ThyImagePreviewRef(dialogRef.componentInstance, { ...this.defaultConfig, ...options }, dialogRef);
×
50
        imagePreviewRef
51
            .downloadClicked()
1✔
52
            .pipe(takeUntil(this.ngUnsubscribe$))
53
            .subscribe(image => {
54
                this.downloadClicked$.next(image);
55
            });
56
        return imagePreviewRef;
1✔
57
    }
58

59
    downloadClicked(): Observable<ThyImageInfo> {
60
        return this.downloadClicked$.asObservable();
61
    }
62

63
    ngOnDestroy() {
64
        this.ngUnsubscribe$.next();
65
        this.ngUnsubscribe$.complete();
66
    }
67
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc