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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

5.56
/src/notify/notify.service.ts
1
import { isString } from 'ngx-tethys/util';
2
import { Injectable, Injector, inject } 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 { ThyNotifyContainer } 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({
UNCOV
15
    providedIn: 'root'
×
UNCOV
16
})
×
UNCOV
17
export class ThyNotifyService extends ThyAbstractMessageService<ThyNotifyContainer> {
×
UNCOV
18
    private notifyQueue: ThyNotifyQueue;
×
UNCOV
19
    protected config = inject(THY_NOTIFY_DEFAULT_CONFIG);
×
UNCOV
20

×
UNCOV
21
    private _lastNotifyId = 0;
×
UNCOV
22

×
UNCOV
23
    private defaultConfig: ThyGlobalNotifyConfig;
×
24

25
    constructor() {
26
        const overlay = inject(Overlay);
27
        const injector = inject(Injector);
28
        const notifyQueue = inject(ThyNotifyQueue);
29

30
        super(overlay, injector, notifyQueue);
31
        this.notifyQueue = notifyQueue;
UNCOV
32
        const config = this.config;
×
UNCOV
33

×
UNCOV
34
        this.defaultConfig = {
×
UNCOV
35
            ...THY_NOTIFY_DEFAULT_CONFIG_VALUE,
×
UNCOV
36
            ...config
×
37
        };
38
    }
39

40
    /**
41
     * 打开自定义配置的 Notify
UNCOV
42
     */
×
43
    public show(config: ThyNotifyConfig): ThyNotifyRef {
×
44
        this.container = this.createContainer(ThyNotifyContainer);
45

×
46
        const notifyConfig = this.formatOptions(config);
×
47
        const notifyRef = new ThyNotifyRef(notifyConfig, this.overlayRef, this.notifyQueue);
48
        this.notifyQueue.add(notifyRef);
49
        return notifyRef;
50
    }
51

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

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

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

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

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