• 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

6.0
/src/notify/notify.service.ts
1
import { isString } from 'ngx-tethys/util';
2
import { Inject, Injectable, Injector } from '@angular/core';
3
import { ThyGlobalNotifyConfig, ThyNotifyConfig, THY_NOTIFY_DEFAULT_CONFIG, THY_NOTIFY_DEFAULT_CONFIG_VALUE } from './notify.config';
4
import { Overlay } from '@angular/cdk/overlay';
5
import { ThyNotifyRef } from './notify-ref';
6
import { ThyNotifyContainerComponent } from './notify-container.component';
7
import { ThyNotifyQueue } from './notify-queue.service';
8
import { ThyAbstractMessageService } from 'ngx-tethys/message';
9
import { ComponentTypeOrTemplateRef } from 'ngx-tethys/core';
10

11
/**
12
 * @order 20
13
 */
1✔
14
@Injectable({
15
    providedIn: 'root'
×
16
})
×
17
export class ThyNotifyService extends ThyAbstractMessageService<ThyNotifyContainerComponent> {
×
18
    private _lastNotifyId = 0;
×
19

×
20
    private defaultConfig: ThyGlobalNotifyConfig;
21

22
    constructor(
23
        overlay: Overlay,
24
        injector: Injector,
25
        private notifyQueue: ThyNotifyQueue,
26
        @Inject(THY_NOTIFY_DEFAULT_CONFIG) protected config: ThyGlobalNotifyConfig
27
    ) {
28
        super(overlay, injector, notifyQueue);
×
29
        this.defaultConfig = {
×
30
            ...THY_NOTIFY_DEFAULT_CONFIG_VALUE,
×
31
            ...config
×
32
        };
×
33
    }
34

35
    /**
36
     * 打开自定义配置的 Notify
37
     */
38
    public show(config: ThyNotifyConfig): ThyNotifyRef {
×
39
        this.container = this.createContainer(ThyNotifyContainerComponent);
×
40

41
        const notifyConfig = this.formatOptions(config);
×
42
        const notifyRef = new ThyNotifyRef(notifyConfig, this.overlayRef, this.notifyQueue);
×
43
        this.notifyQueue.add(notifyRef);
44
        return notifyRef;
45
    }
46

47
    /**
48
     * 打开类型为"success"的 Notify
49
     */
×
50
    public success(title?: string, content?: string | ComponentTypeOrTemplateRef<any>, config?: ThyNotifyConfig) {
×
51
        return this.show({
52
            ...(config || {}),
×
53
            type: 'success',
×
54
            title: title || config?.title || '成功',
55
            content: content || config?.content
56
        });
57
    }
58

59
    /**
60
     * 打开类型为"info"的 Notify
×
61
     */
×
62
    public info(title?: string, content?: string | ComponentTypeOrTemplateRef<any>, config?: ThyNotifyConfig) {
63
        return this.show({
×
64
            ...(config || {}),
×
65
            type: 'info',
66
            title: title || config?.title || '提示',
67
            content: content || config?.content
68
        });
69
    }
70

71
    /**
×
72
     * 打开类型为"warning"的 Notify
×
73
     */
74
    public warning(title?: string, content?: string | ComponentTypeOrTemplateRef<any>, config?: ThyNotifyConfig) {
×
75
        return this.show({
×
76
            ...(config || {}),
77
            type: 'warning',
78
            title: title || config?.title || '警告',
79
            content: content || config?.content
×
80
        });
×
81
    }
82

×
83
    /**
84
     * 打开类型为"error"的 Notify
1✔
85
     */
86
    public error(title?: string, content?: string | ComponentTypeOrTemplateRef<any>, config?: ThyNotifyConfig) {
87
        return this.show({
88
            ...(config || {}),
89
            type: 'error',
90
            title: title || config?.title || '警告',
91
            content: content || config?.content
1✔
92
        });
93
    }
94

95
    private formatOptions(config: ThyNotifyConfig) {
96
        if (isString(config.detail)) {
97
            config = { ...config, detail: { link: '[详情]', content: config.detail as string } };
98
        }
99
        return Object.assign({ type: 'blank' }, { id: String(this._lastNotifyId++) }, this.defaultConfig, config);
100
    }
101
}
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