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

juice-shop / juice-shop / 16707578486

03 Aug 2025 05:26PM UTC coverage: 85.111% (+0.04%) from 85.067%
16707578486

push

github

J12934
Pin to typescript 5.8.x

Automatic upgrade to 5.9.x broke the build

1243 of 1674 branches covered (74.25%)

Branch coverage included in aggregate %.

5131 of 5815 relevant lines covered (88.24%)

41.0 hits per line

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

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

6
import { TranslateService, TranslateModule } from '@ngx-translate/core'
7
import { ChallengeService } from '../Services/challenge.service'
8
import { ChangeDetectorRef, Component, NgZone, type OnInit } from '@angular/core'
9
import { CookieService } from 'ngy-cookie'
10
import { SocketIoService } from '../Services/socket-io.service'
11
import { MatIconModule } from '@angular/material/icon'
12
import { MatButtonModule } from '@angular/material/button'
13
import { MatCardModule, MatCardContent } from '@angular/material/card'
14
import { NgIf } from '@angular/common'
15

16
interface HackingProgress {
17
  autoRestoreMessage: string | null
18
  cleared: boolean
19
}
20

21
@Component({
22
  selector: 'app-server-started-notification',
23
  templateUrl: './server-started-notification.component.html',
24
  styleUrls: ['./server-started-notification.component.scss'],
25
  imports: [NgIf, MatCardModule, MatCardContent, TranslateModule, MatButtonModule, MatIconModule]
26
})
27
export class ServerStartedNotificationComponent implements OnInit {
1✔
28
  public hackingProgress: HackingProgress = {} as HackingProgress
11✔
29

30
  constructor (private readonly ngZone: NgZone, private readonly challengeService: ChallengeService, private readonly translate: TranslateService, private readonly cookieService: CookieService, private readonly ref: ChangeDetectorRef, private readonly io: SocketIoService) {
11✔
31
  }
32

33
  ngOnInit (): void {
34
    this.ngZone.runOutsideAngular(() => {
18✔
35
      this.io.socket().on('server started', () => {
18✔
36
        const continueCode = this.cookieService.get('continueCode')
17✔
37
        const continueCodeFindIt = this.cookieService.get('continueCodeFindIt')
17✔
38
        const continueCodeFixIt = this.cookieService.get('continueCodeFixIt')
17✔
39
        if (continueCode) {
17✔
40
          this.challengeService.restoreProgress(encodeURIComponent(continueCode)).subscribe({
6✔
41
            next: () => {
42
              this.translate.get('AUTO_RESTORED_PROGRESS').subscribe({
3✔
43
                next: (notificationServerStarted) => {
44
                  this.hackingProgress.autoRestoreMessage = notificationServerStarted
3✔
45
                },
46
                error: (translationId) => {
47
                  this.hackingProgress.autoRestoreMessage = translationId
×
48
                }
49
              })
50
            },
51
            error: (error) => {
52
              console.log(error)
3✔
53
              this.translate.get('AUTO_RESTORE_PROGRESS_FAILED', { error }).subscribe({
3✔
54
                next: (notificationServerStarted) => {
55
                  this.hackingProgress.autoRestoreMessage = notificationServerStarted
3✔
56
                },
57
                error: (translationId) => {
58
                  this.hackingProgress.autoRestoreMessage = translationId
×
59
                }
60
              })
61
            }
62
          })
63
        }
64
        if (continueCodeFindIt) {
17!
65
          this.challengeService.restoreProgressFindIt(encodeURIComponent(continueCodeFindIt)).subscribe({
×
66
            next: () => {
67
            },
68
            error: (error) => {
69
              console.log(error)
×
70
            }
71
          })
72
        }
73
        if (continueCodeFixIt) {
17!
74
          this.challengeService.restoreProgressFixIt(encodeURIComponent(continueCodeFixIt)).subscribe({
×
75
            next: () => {
76
            },
77
            error: (error) => {
78
              console.log(error)
×
79
            }
80
          })
81
        }
82
        this.ref.detectChanges()
17✔
83
      })
84
    })
85
  }
86

87
  closeNotification () {
88
    this.hackingProgress.autoRestoreMessage = null
1✔
89
  }
90

91
  clearProgress () {
92
    this.cookieService.remove('continueCode')
1✔
93
    this.cookieService.remove('continueCodeFixIt')
1✔
94
    this.cookieService.remove('continueCodeFindIt')
1✔
95
    this.cookieService.remove('token')
1✔
96
    sessionStorage.removeItem('bid')
1✔
97
    sessionStorage.removeItem('itemTotal')
1✔
98
    localStorage.removeItem('token')
1✔
99
    localStorage.removeItem('displayedDifficulties')
1✔
100
    localStorage.removeItem('showSolvedChallenges')
1✔
101
    localStorage.removeItem('showDisabledChallenges')
1✔
102
    localStorage.removeItem('showOnlyTutorialChallenges')
1✔
103
    localStorage.removeItem('displayedChallengeCategories')
1✔
104
    this.hackingProgress.cleared = true
1✔
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

© 2026 Coveralls, Inc