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

juice-shop / juice-shop / 17414317889

02 Sep 2025 07:48PM UTC coverage: 85.066% (-0.01%) from 85.079%
17414317889

push

github

web-flow
Merge pull request #2725 from juice-shop/fix/update-to-juicy-chat-bot-0-9-0

Update juicy-chat-bot version to 0.9.0

1243 of 1675 branches covered (74.21%)

Branch coverage included in aggregate %.

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

1 existing line in 1 file now uncovered.

5148 of 5838 relevant lines covered (88.18%)

40.84 hits per line

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

88.37
/frontend/src/app/data-export/data-export.component.ts
1
/*
2
 * Copyright (c) 2014-2025 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { Component, type OnInit } from '@angular/core'
7
import { UntypedFormControl, Validators, FormsModule, ReactiveFormsModule } from '@angular/forms'
8
import { ImageCaptchaService } from '../Services/image-captcha.service'
9
import { DataSubjectService } from '../Services/data-subject.service'
10
import { DomSanitizer } from '@angular/platform-browser'
11
import { MatButtonModule } from '@angular/material/button'
12
import { MatInputModule } from '@angular/material/input'
13
import { MatLabel, MatFormFieldModule, MatHint, MatError } from '@angular/material/form-field'
14
import { MatRadioGroup, MatRadioButton } from '@angular/material/radio'
15

16
import { TranslateModule } from '@ngx-translate/core'
17
import { MatCardModule } from '@angular/material/card'
18

19
import { MatIconModule } from '@angular/material/icon'
20

21
@Component({
22
  selector: 'app-data-export',
23
  templateUrl: './data-export.component.html',
24
  styleUrls: ['./data-export.component.scss'],
25
  imports: [MatCardModule, TranslateModule, MatRadioGroup, FormsModule, ReactiveFormsModule, MatLabel, MatRadioButton, MatFormFieldModule, MatInputModule, MatHint, MatError, MatButtonModule, MatIconModule]
26
})
27
export class DataExportComponent implements OnInit {
1✔
28
  public captchaControl: UntypedFormControl = new UntypedFormControl('', [Validators.required, Validators.minLength(5)])
7✔
29
  public formatControl: UntypedFormControl = new UntypedFormControl('', [Validators.required])
7✔
30
  public captcha: any
31
  private dataRequest: any = undefined
7✔
32
  public confirmation: any
33
  public error: any
34
  public lastSuccessfulTry: any
35
  public presenceOfCaptcha: boolean = false
7✔
36
  public userData: any
37

38
  constructor (public sanitizer: DomSanitizer, private readonly imageCaptchaService: ImageCaptchaService, private readonly dataSubjectService: DataSubjectService) { }
7✔
39
  ngOnInit (): void {
40
    this.needCaptcha()
7✔
41
    this.dataRequest = {}
7✔
42
  }
43

44
  needCaptcha () {
45
    const nowTime = new Date()
7✔
46
    const timeOfCaptcha = localStorage.getItem('lstdtxprt') ? new Date(JSON.parse(String(localStorage.getItem('lstdtxprt')))) : new Date(0)
7✔
47
    if (nowTime.getTime() - timeOfCaptcha.getTime() < 300000) {
7✔
48
      this.getNewCaptcha()
5✔
49
      this.presenceOfCaptcha = true
5✔
50
    }
51
  }
52

53
  getNewCaptcha () {
54
    this.imageCaptchaService.getCaptcha().subscribe((data: any) => {
6✔
55
      this.captcha = this.sanitizer.bypassSecurityTrustHtml(data.image)
6✔
56
    })
57
  }
58

59
  save () {
60
    if (this.presenceOfCaptcha) {
2!
UNCOV
61
      this.dataRequest.answer = this.captchaControl.value
×
62
    }
63
    this.dataRequest.format = this.formatControl.value
2✔
64
    this.dataSubjectService.dataExport(this.dataRequest).subscribe({
2✔
65
      next: (data: any) => {
66
        this.error = null
1✔
67
        this.confirmation = data.confirmation
1✔
68
        this.userData = data.userData
1✔
69
        window.open('', '_blank', 'width=500')?.document.write(this.userData)
1✔
70
        this.lastSuccessfulTry = new Date()
1✔
71
        localStorage.setItem('lstdtxprt', JSON.stringify(this.lastSuccessfulTry))
1✔
72
        this.ngOnInit()
1✔
73
        this.resetForm()
1✔
74
      },
75
      error: (error) => {
76
        this.error = error.error
1✔
77
        this.confirmation = null
1✔
78
        this.resetFormError()
1✔
79
      }
80
    })
81
  }
82

83
  resetForm () {
84
    this.captchaControl.markAsUntouched()
1✔
85
    this.captchaControl.markAsPristine()
1✔
86
    this.captchaControl.setValue('')
1✔
87
    this.formatControl.markAsUntouched()
1✔
88
    this.formatControl.markAsPristine()
1✔
89
    this.formatControl.setValue('')
1✔
90
  }
91

92
  resetFormError () {
93
    this.captchaControl.markAsUntouched()
×
94
    this.captchaControl.markAsPristine()
×
95
    this.captchaControl.setValue('')
×
96
  }
97
}
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

© 2026 Coveralls, Inc