• 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

10.26
/src/upload/file-select-base.ts
1
import { isNumber } from 'ngx-tethys/util';
2
import { Directive, ElementRef, Input, NgZone, numberAttribute, inject, Inject, input, OutputEmitterRef } from '@angular/core';
3
import { ThyFileSelectEvent, ThySizeExceedsHandler } from './types';
4
import { THY_UPLOAD_DEFAULT_OPTIONS, ThyUploadConfig } from './upload.config';
5
import { mimeTypeConvert } from './util';
6

7
/**
8
 * @private
9
 */
10
@Directive()
1✔
11
export class FileSelectBaseDirective {
UNCOV
12
    readonly thySizeThreshold = input(this.defaultConfig.sizeThreshold, {
×
UNCOV
13
        transform: (inputValue: string | number) => {
×
UNCOV
14
            const sizeThreshold = numberAttribute(inputValue);
×
15
            if (isNumber(sizeThreshold)) {
UNCOV
16
                return sizeThreshold;
×
UNCOV
17
            }
×
UNCOV
18
            return this.defaultConfig.sizeThreshold;
×
19
        }
20
    });
×
21

22
    readonly thySizeExceedsHandler = input(this.defaultConfig.sizeExceedsHandler, {
UNCOV
23
        transform: (inputValue: ThySizeExceedsHandler) => {
×
24
            if (inputValue) {
UNCOV
25
                return inputValue;
×
UNCOV
26
            }
×
27
            return this.defaultConfig.sizeExceedsHandler;
28
        }
×
29
    });
30

UNCOV
31
    /**
×
32
     * 指定文件后缀类型(MIME_Map),例如".xls,xlsx","[".doc",".docx"]"
UNCOV
33
     */
×
34
    thyAcceptType = input(mimeTypeConvert(this.defaultConfig.acceptType), {
35
        transform: (inputValue: Array<string> | string) => {
36
            return mimeTypeConvert(inputValue);
37
        }
UNCOV
38
    });
×
UNCOV
39

×
UNCOV
40
    constructor(
×
41
        public elementRef: ElementRef,
42
        @Inject(THY_UPLOAD_DEFAULT_OPTIONS) public defaultConfig: ThyUploadConfig
43
    ) {}
44

45
    handleSizeExceeds(event: Event, files: File[]) {
UNCOV
46
        let sizeExceedsFiles = files.filter(item => item.size / 1024 > this.thySizeThreshold());
×
47
        if (sizeExceedsFiles.length > 0) {
UNCOV
48
            const sizeExceedContext = {
×
49
                files: files,
50
                exceedsFiles: sizeExceedsFiles,
UNCOV
51
                nativeEvent: event,
×
UNCOV
52
                sizeThreshold: this.thySizeThreshold()
×
UNCOV
53
            };
×
54
            return this.thySizeExceedsHandler()(sizeExceedContext);
UNCOV
55
        }
×
UNCOV
56
        return files;
×
57
    }
58

59
    selectFiles(event: Event, files: File[], eventEmitter: OutputEmitterRef<ThyFileSelectEvent>) {
60
        let successFiles: File[] | void = files;
61
        if (this.thySizeThreshold() && this.thySizeThreshold() > 0) {
62
            successFiles = this.handleSizeExceeds(event, files);
1✔
63
        }
64
        if (successFiles) {
65
            eventEmitter.emit({
66
                files: successFiles,
1✔
67
                nativeEvent: event
68
            });
69
        }
70
    }
71
}
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