@testgorilla/tgo-coding-test 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/testgorilla-tgo-coding-test.mjs +4526 -0
- package/fesm2022/testgorilla-tgo-coding-test.mjs.map +1 -0
- package/{src/index.ts → index.d.ts} +2 -19
- package/lib/components/code-editor/code-editor.component.d.ts +54 -0
- package/lib/components/code-editor/code-editor.service.d.ts +12 -0
- package/lib/components/code-editor/helpers/c-helper.d.ts +11 -0
- package/lib/components/code-editor/helpers/code-editor-helper.base.d.ts +8 -0
- package/lib/components/code-editor/helpers/code-editor-helper.model.d.ts +62 -0
- package/lib/components/code-editor/helpers/cpp-helper.d.ts +11 -0
- package/lib/components/code-editor/helpers/csharp-helper.d.ts +12 -0
- package/lib/components/code-editor/helpers/go-helper.d.ts +12 -0
- package/lib/components/code-editor/helpers/java-helper.d.ts +12 -0
- package/lib/components/code-editor/helpers/javascript-helper.d.ts +10 -0
- package/lib/components/code-editor/helpers/kotlin-helper.d.ts +12 -0
- package/lib/components/code-editor/helpers/php-helper.d.ts +10 -0
- package/lib/components/code-editor/helpers/python-helper.d.ts +10 -0
- package/lib/components/code-editor/helpers/r-helper.d.ts +10 -0
- package/lib/components/code-editor/helpers/ruby-helper.d.ts +10 -0
- package/lib/components/code-editor/helpers/scala-helper.d.ts +12 -0
- package/lib/components/code-editor/helpers/sql-helper.d.ts +10 -0
- package/lib/components/code-editor/helpers/swift-helper.d.ts +11 -0
- package/lib/components/code-editor/helpers/typescript-helper.d.ts +11 -0
- package/lib/components/code-editor/models/code-editor.model.d.ts +8 -0
- package/lib/components/code-editor/models/coding-snapshot.model.d.ts +4 -0
- package/lib/components/coding-question/coding-question.component.d.ts +45 -0
- package/lib/components/coding-section/coding-section.component.d.ts +52 -0
- package/lib/components/common/truncated-text/truncated-text.component.d.ts +13 -0
- package/lib/components/configurations/configurations.component.d.ts +40 -0
- package/lib/components/instructions/instructions.component.d.ts +48 -0
- package/lib/components/panel/panel.component.d.ts +12 -0
- package/lib/components/runnable-editor/runnable-editor.component.d.ts +53 -0
- package/lib/components/tests/test-cases/test-cases.component.d.ts +46 -0
- package/lib/components/tests/test-cases-content/test-cases-content.component.d.ts +26 -0
- package/lib/components/tests/test-cases-status/test-cases-status.component.d.ts +9 -0
- package/lib/components/tests/test-results.component.d.ts +33 -0
- package/lib/components/tgo-coding-test/tgo-coding-test.component.d.ts +69 -0
- package/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.d.ts +101 -0
- package/{src/lib/config/index.ts → lib/config/index.d.ts} +0 -1
- package/lib/config/tgo-coding-test.config.d.ts +24 -0
- package/{src/lib/config/tgo-coding-test.provider.ts → lib/config/tgo-coding-test.provider.d.ts} +6 -18
- package/lib/config/tgo-coding-test.token.d.ts +9 -0
- package/lib/models/auto-saved-data.d.ts +42 -0
- package/lib/models/code-event.d.ts +15 -0
- package/lib/models/coderunner-execution-results.d.ts +51 -0
- package/lib/models/configs.d.ts +15 -0
- package/lib/models/language-change-action.d.ts +4 -0
- package/lib/models/lat-languages.d.ts +8 -0
- package/lib/models/mixpanel-events.d.ts +3 -0
- package/lib/models/mode.d.ts +5 -0
- package/lib/models/paste-data.d.ts +4 -0
- package/lib/models/programming-language.d.ts +8 -0
- package/lib/models/test-cases.d.ts +67 -0
- package/lib/models/theme.d.ts +4 -0
- package/lib/models/translations.d.ts +1 -0
- package/lib/models/view-mode.d.ts +6 -0
- package/{src/lib/pipes/memoize-func.pipe.ts → lib/pipes/memoize-func.pipe.d.ts} +6 -14
- package/lib/services/candidate-coding-test-services/candidature-api.service.d.ts +10 -0
- package/lib/services/candidate-coding-test-services/coderunner-api.service.d.ts +18 -0
- package/lib/services/candidate-coding-test-services/coding-test-tour.service.d.ts +22 -0
- package/lib/services/candidate-coding-test-services/coding-test.service.d.ts +68 -0
- package/{src/lib/services/candidate-coding-test-services/index.ts → lib/services/candidate-coding-test-services/index.d.ts} +1 -1
- package/lib/services/coding-test-config.service.d.ts +38 -0
- package/lib/services/configurations.service.d.ts +37 -0
- package/lib/services/lib-coding-test.service.d.ts +69 -0
- package/lib/services/storage.service.d.ts +83 -0
- package/lib/services/test-cases.service.d.ts +12 -0
- package/lib/services/theme.service.d.ts +17 -0
- package/lib/utils/additional-languages/erlang.d.ts +37 -0
- package/lib/utils/resize-element.d.ts +2 -0
- package/lib/utils/time-to-ms.util.d.ts +1 -0
- package/package.json +17 -3
- package/shared/index.d.ts +4 -0
- package/shared/lib/components/audio-animation/audio-animation.component.d.ts +27 -0
- package/shared/lib/components/audio-animation/index.d.ts +1 -0
- package/shared/lib/components/index.d.ts +2 -0
- package/shared/lib/components/vimeo-video/index.d.ts +1 -0
- package/shared/lib/components/vimeo-video/vimeo-video.component.d.ts +24 -0
- package/shared/lib/models/answer.d.ts +17 -0
- package/shared/lib/models/assessment.d.ts +80 -0
- package/shared/lib/models/environment.d.ts +1 -0
- package/shared/lib/models/index.d.ts +8 -0
- package/shared/lib/models/question-component.d.ts +54 -0
- package/shared/lib/models/question.d.ts +102 -0
- package/shared/lib/models/test.d.ts +81 -0
- package/shared/lib/models/translations.d.ts +1 -0
- package/shared/lib/models/window.d.ts +6 -0
- package/shared/lib/services/api/api.service.d.ts +25 -0
- package/shared/lib/services/api/mocked-api.service.d.ts +35 -0
- package/shared/lib/services/environment/environment.service.d.ts +6 -0
- package/shared/lib/services/index.d.ts +9 -0
- package/shared/lib/services/localization/languages.model.d.ts +15 -0
- package/shared/lib/services/localization/transloco-lazy-module-utils.d.ts +11 -0
- package/shared/lib/services/localization/transloco-testing.module.d.ts +2 -0
- package/shared/lib/services/media/media.service.d.ts +29 -0
- package/shared/lib/services/mixpanel/mixpanel.service.d.ts +10 -0
- package/shared/lib/services/theme/theme.service.d.ts +8 -0
- package/shared/test-mocks/assessment-test.mock.d.ts +21 -0
- package/shared/test-mocks/index.d.ts +2 -0
- package/shared/test-mocks/tgo-ui.mock.d.ts +21 -0
- package/.eslintrc.json +0 -46
- package/jest.config.ts +0 -26
- package/ng-package.json +0 -14
- package/project.json +0 -48
- package/src/lib/components/.gitkeep +0 -0
- package/src/lib/components/code-editor/code-editor.component.html +0 -10
- package/src/lib/components/code-editor/code-editor.component.scss +0 -21
- package/src/lib/components/code-editor/code-editor.component.spec.ts +0 -136
- package/src/lib/components/code-editor/code-editor.component.ts +0 -368
- package/src/lib/components/code-editor/code-editor.mocks.ts +0 -28
- package/src/lib/components/code-editor/code-editor.service.spec.ts +0 -160
- package/src/lib/components/code-editor/code-editor.service.ts +0 -94
- package/src/lib/components/code-editor/helpers/c-helper.spec.ts +0 -39
- package/src/lib/components/code-editor/helpers/c-helper.ts +0 -51
- package/src/lib/components/code-editor/helpers/code-editor-helper.base.spec.ts +0 -30
- package/src/lib/components/code-editor/helpers/code-editor-helper.base.ts +0 -16
- package/src/lib/components/code-editor/helpers/code-editor-helper.mocks.ts +0 -24
- package/src/lib/components/code-editor/helpers/code-editor-helper.model.ts +0 -67
- package/src/lib/components/code-editor/helpers/cpp-helper.spec.ts +0 -40
- package/src/lib/components/code-editor/helpers/cpp-helper.ts +0 -52
- package/src/lib/components/code-editor/helpers/csharp-helper.spec.ts +0 -42
- package/src/lib/components/code-editor/helpers/csharp-helper.ts +0 -55
- package/src/lib/components/code-editor/helpers/go-helper.spec.ts +0 -41
- package/src/lib/components/code-editor/helpers/go-helper.ts +0 -54
- package/src/lib/components/code-editor/helpers/java-helper.spec.ts +0 -41
- package/src/lib/components/code-editor/helpers/java-helper.ts +0 -54
- package/src/lib/components/code-editor/helpers/javascript-helper.spec.ts +0 -39
- package/src/lib/components/code-editor/helpers/javascript-helper.ts +0 -32
- package/src/lib/components/code-editor/helpers/kotlin-helper.spec.ts +0 -41
- package/src/lib/components/code-editor/helpers/kotlin-helper.ts +0 -54
- package/src/lib/components/code-editor/helpers/php-helper.spec.ts +0 -39
- package/src/lib/components/code-editor/helpers/php-helper.ts +0 -32
- package/src/lib/components/code-editor/helpers/python-helper.spec.ts +0 -39
- package/src/lib/components/code-editor/helpers/python-helper.ts +0 -32
- package/src/lib/components/code-editor/helpers/r-helper.spec.ts +0 -39
- package/src/lib/components/code-editor/helpers/r-helper.ts +0 -32
- package/src/lib/components/code-editor/helpers/ruby-helper.spec.ts +0 -39
- package/src/lib/components/code-editor/helpers/ruby-helper.ts +0 -32
- package/src/lib/components/code-editor/helpers/scala-helper.spec.ts +0 -41
- package/src/lib/components/code-editor/helpers/scala-helper.ts +0 -53
- package/src/lib/components/code-editor/helpers/sql-helper.spec.ts +0 -87
- package/src/lib/components/code-editor/helpers/sql-helper.ts +0 -44
- package/src/lib/components/code-editor/helpers/swift-helper.spec.ts +0 -40
- package/src/lib/components/code-editor/helpers/swift-helper.ts +0 -51
- package/src/lib/components/code-editor/helpers/typescript-helper.spec.ts +0 -40
- package/src/lib/components/code-editor/helpers/typescript-helper.ts +0 -52
- package/src/lib/components/code-editor/models/code-editor.model.ts +0 -9
- package/src/lib/components/code-editor/models/coding-snapshot.model.ts +0 -4
- package/src/lib/components/coding-question/coding-question.component.html +0 -78
- package/src/lib/components/coding-question/coding-question.component.scss +0 -75
- package/src/lib/components/coding-question/coding-question.component.spec.ts +0 -85
- package/src/lib/components/coding-question/coding-question.component.ts +0 -101
- package/src/lib/components/coding-section/coding-section.component.html +0 -82
- package/src/lib/components/coding-section/coding-section.component.scss +0 -64
- package/src/lib/components/coding-section/coding-section.component.spec.ts +0 -257
- package/src/lib/components/coding-section/coding-section.component.ts +0 -186
- package/src/lib/components/coding-test.module.ts +0 -124
- package/src/lib/components/common/truncated-text/truncated-text.component.html +0 -6
- package/src/lib/components/common/truncated-text/truncated-text.component.scss +0 -18
- package/src/lib/components/common/truncated-text/truncated-text.component.spec.ts +0 -84
- package/src/lib/components/common/truncated-text/truncated-text.component.ts +0 -36
- package/src/lib/components/configurations/configurations.component.html +0 -57
- package/src/lib/components/configurations/configurations.component.scss +0 -42
- package/src/lib/components/configurations/configurations.component.spec.ts +0 -186
- package/src/lib/components/configurations/configurations.component.ts +0 -97
- package/src/lib/components/instructions/instructions.component.html +0 -41
- package/src/lib/components/instructions/instructions.component.scss +0 -173
- package/src/lib/components/instructions/instructions.component.spec.ts +0 -106
- package/src/lib/components/instructions/instructions.component.ts +0 -137
- package/src/lib/components/panel/panel.component.html +0 -19
- package/src/lib/components/panel/panel.component.scss +0 -41
- package/src/lib/components/panel/panel.component.spec.ts +0 -40
- package/src/lib/components/panel/panel.component.ts +0 -33
- package/src/lib/components/runnable-editor/runnable-editor.component.html +0 -75
- package/src/lib/components/runnable-editor/runnable-editor.component.scss +0 -55
- package/src/lib/components/runnable-editor/runnable-editor.component.spec.ts +0 -124
- package/src/lib/components/runnable-editor/runnable-editor.component.ts +0 -154
- package/src/lib/components/tests/test-cases/test-cases.component.html +0 -135
- package/src/lib/components/tests/test-cases/test-cases.component.scss +0 -220
- package/src/lib/components/tests/test-cases/test-cases.component.spec.ts +0 -401
- package/src/lib/components/tests/test-cases/test-cases.component.ts +0 -204
- package/src/lib/components/tests/test-cases-content/test-cases-content.component.html +0 -94
- package/src/lib/components/tests/test-cases-content/test-cases-content.component.scss +0 -103
- package/src/lib/components/tests/test-cases-content/test-cases-content.component.spec.ts +0 -122
- package/src/lib/components/tests/test-cases-content/test-cases-content.component.ts +0 -101
- package/src/lib/components/tests/test-cases-status/test-cases-status.component.html +0 -16
- package/src/lib/components/tests/test-cases-status/test-cases-status.component.scss +0 -49
- package/src/lib/components/tests/test-cases-status/test-cases-status.component.spec.ts +0 -22
- package/src/lib/components/tests/test-cases-status/test-cases-status.component.ts +0 -17
- package/src/lib/components/tests/test-results.component.html +0 -119
- package/src/lib/components/tests/test-results.component.scss +0 -189
- package/src/lib/components/tests/test-results.component.spec.ts +0 -140
- package/src/lib/components/tests/test-results.component.ts +0 -97
- package/src/lib/components/tgo-coding-test/tgo-coding-test.component.html +0 -96
- package/src/lib/components/tgo-coding-test/tgo-coding-test.component.scss +0 -6
- package/src/lib/components/tgo-coding-test/tgo-coding-test.component.spec.ts +0 -599
- package/src/lib/components/tgo-coding-test/tgo-coding-test.component.ts +0 -278
- package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.html +0 -36
- package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.scss +0 -183
- package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.spec.ts +0 -883
- package/src/lib/components/tgo-coding-test-candidate-view/tgo-coding-test-candidate-view.component.ts +0 -578
- package/src/lib/config/tgo-coding-test.config.ts +0 -26
- package/src/lib/config/tgo-coding-test.token.ts +0 -21
- package/src/lib/models/.gitkeep +0 -0
- package/src/lib/models/auto-saved-data.ts +0 -51
- package/src/lib/models/code-event.ts +0 -17
- package/src/lib/models/coderunner-execution-results.ts +0 -58
- package/src/lib/models/coding-lib.mocks.ts +0 -246
- package/src/lib/models/configs.ts +0 -18
- package/src/lib/models/language-change-action.ts +0 -4
- package/src/lib/models/lat-languages.ts +0 -12
- package/src/lib/models/mixpanel-events.ts +0 -3
- package/src/lib/models/mode.ts +0 -5
- package/src/lib/models/paste-data.ts +0 -4
- package/src/lib/models/programming-language.ts +0 -9
- package/src/lib/models/test-cases.ts +0 -74
- package/src/lib/models/theme.ts +0 -5
- package/src/lib/models/translations.ts +0 -1
- package/src/lib/models/view-mode.ts +0 -6
- package/src/lib/services/.gitkeep +0 -0
- package/src/lib/services/candidate-coding-test-services/candidature-api.service.spec.ts +0 -40
- package/src/lib/services/candidate-coding-test-services/candidature-api.service.ts +0 -15
- package/src/lib/services/candidate-coding-test-services/coderunner-api.service.spec.ts +0 -134
- package/src/lib/services/candidate-coding-test-services/coderunner-api.service.ts +0 -105
- package/src/lib/services/candidate-coding-test-services/coding-test-tour.service.spec.ts +0 -161
- package/src/lib/services/candidate-coding-test-services/coding-test-tour.service.ts +0 -100
- package/src/lib/services/candidate-coding-test-services/coding-test.service.spec.ts +0 -1524
- package/src/lib/services/candidate-coding-test-services/coding-test.service.ts +0 -843
- package/src/lib/services/coding-test-config.service.ts +0 -48
- package/src/lib/services/configurations.service.mocks.ts +0 -77
- package/src/lib/services/configurations.service.spec.ts +0 -79
- package/src/lib/services/configurations.service.ts +0 -111
- package/src/lib/services/index.ts +0 -0
- package/src/lib/services/lib-coding-test.service.spec.ts +0 -265
- package/src/lib/services/lib-coding-test.service.ts +0 -157
- package/src/lib/services/local-storage.service.mocks.ts +0 -22
- package/src/lib/services/storage.service.spec.ts +0 -1119
- package/src/lib/services/storage.service.ts +0 -729
- package/src/lib/services/test-cases.service.spec.ts +0 -53
- package/src/lib/services/test-cases.service.ts +0 -29
- package/src/lib/services/theme.service.spec.ts +0 -76
- package/src/lib/services/theme.service.ts +0 -34
- package/src/lib/styles/mixins.scss +0 -86
- package/src/lib/styles/styles.scss +0 -112
- package/src/lib/styles/variables.scss +0 -105
- package/src/lib/utils/.gitkeep +0 -0
- package/src/lib/utils/additional-languages/erlang.ts +0 -115
- package/src/lib/utils/resize-element.ts +0 -15
- package/src/lib/utils/time-to-ms.util.ts +0 -10
- package/src/test-setup.ts +0 -3
- package/tsconfig.json +0 -19
- package/tsconfig.lib.json +0 -19
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
- /package/{src/assets → assets}/i18n/en.json +0 -0
- /package/{src/lib/components/code-editor/helpers/index.ts → lib/components/code-editor/helpers/index.d.ts} +0 -0
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChangeDetectionStrategy,
|
|
3
|
-
ChangeDetectorRef,
|
|
4
|
-
Component,
|
|
5
|
-
EventEmitter,
|
|
6
|
-
inject,
|
|
7
|
-
Input,
|
|
8
|
-
OnDestroy,
|
|
9
|
-
OnInit,
|
|
10
|
-
Output,
|
|
11
|
-
} from '@angular/core';
|
|
12
|
-
import { CommonModule } from '@angular/common';
|
|
13
|
-
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
|
14
|
-
import { map } from 'rxjs';
|
|
15
|
-
import { MatCardModule } from '@angular/material/card';
|
|
16
|
-
import { AngularSplitModule } from 'angular-split';
|
|
17
|
-
import { ApplicationTheme, ButtonComponentModule } from '@testgorilla/tgo-ui';
|
|
18
|
-
import { LATLanguages } from '../../models/lat-languages';
|
|
19
|
-
import { Modes } from '../../models/mode';
|
|
20
|
-
import { ExampleTestCase } from '../../models/test-cases';
|
|
21
|
-
import { Themes } from '../../models/theme';
|
|
22
|
-
import { ConfigurationsService } from '../../services/configurations.service';
|
|
23
|
-
import { LibCodingTestService } from '../../services/lib-coding-test.service';
|
|
24
|
-
import {
|
|
25
|
-
CodeEditorFuncParam,
|
|
26
|
-
CodeEditorLanguages,
|
|
27
|
-
CodeEditorTypesMap,
|
|
28
|
-
} from '../code-editor/helpers/code-editor-helper.model';
|
|
29
|
-
import { PasteData } from '../code-editor/models/code-editor.model';
|
|
30
|
-
import { InstructionsComponent } from '../instructions/instructions.component';
|
|
31
|
-
import { RunnableEditorComponent } from '../runnable-editor/runnable-editor.component';
|
|
32
|
-
|
|
33
|
-
@UntilDestroy()
|
|
34
|
-
@Component({
|
|
35
|
-
selector: 'tgo-coding-question',
|
|
36
|
-
templateUrl: './coding-question.component.html',
|
|
37
|
-
styleUrls: ['./coding-question.component.scss'],
|
|
38
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
39
|
-
imports: [
|
|
40
|
-
CommonModule,
|
|
41
|
-
MatCardModule,
|
|
42
|
-
AngularSplitModule,
|
|
43
|
-
ButtonComponentModule,
|
|
44
|
-
InstructionsComponent,
|
|
45
|
-
RunnableEditorComponent,
|
|
46
|
-
]
|
|
47
|
-
})
|
|
48
|
-
export class CodingQuestionComponent implements OnInit, OnDestroy {
|
|
49
|
-
private readonly changeDetectorRef = inject(ChangeDetectorRef);
|
|
50
|
-
private readonly libCodingTestService = inject(LibCodingTestService);
|
|
51
|
-
private readonly configurationsService = inject(ConfigurationsService);
|
|
52
|
-
|
|
53
|
-
@Input() initCode: string;
|
|
54
|
-
@Input() functionParams: CodeEditorFuncParam[];
|
|
55
|
-
@Input() functionName: string;
|
|
56
|
-
@Input() returnType: keyof CodeEditorTypesMap;
|
|
57
|
-
@Input() isLAT: boolean;
|
|
58
|
-
@Input() isSQL: boolean;
|
|
59
|
-
@Input() canAddCustomTestCases: boolean;
|
|
60
|
-
@Input() languages: LATLanguages;
|
|
61
|
-
@Input() autoHeight: boolean;
|
|
62
|
-
@Input() translations: Record<string, unknown>;
|
|
63
|
-
@Input() questionText: string;
|
|
64
|
-
@Input() mode: Modes;
|
|
65
|
-
@Input() companyColor: string;
|
|
66
|
-
@Input() testCasesStatus: any;
|
|
67
|
-
@Input() loading: boolean;
|
|
68
|
-
@Input() hideTestCases: boolean;
|
|
69
|
-
@Input() runTestResponse = [];
|
|
70
|
-
@Input() exampleTestCases: ExampleTestCase[];
|
|
71
|
-
@Input() applicationTheme: ApplicationTheme;
|
|
72
|
-
|
|
73
|
-
@Output() pasteEvent = new EventEmitter<PasteData>();
|
|
74
|
-
@Output() codeChange = new EventEmitter<string>();
|
|
75
|
-
@Output() runTestClick = new EventEmitter<boolean>();
|
|
76
|
-
@Output() languageChange = new EventEmitter<CodeEditorLanguages>();
|
|
77
|
-
|
|
78
|
-
isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
79
|
-
|
|
80
|
-
isFullscreenMode: boolean;
|
|
81
|
-
|
|
82
|
-
GUTTER_SIZE = 1;
|
|
83
|
-
|
|
84
|
-
isDarkTheme$ = this.configurationsService.colorTheme$.pipe(map(theme => theme === Themes.Dark));
|
|
85
|
-
|
|
86
|
-
ngOnInit(): void {
|
|
87
|
-
this.libCodingTestService.isFullscreen$.pipe(untilDestroyed(this)).subscribe(isFullscreen => {
|
|
88
|
-
this.isFullscreenMode = isFullscreen;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
ngOnDestroy(): void {
|
|
93
|
-
this.configurationsService.setCodeComponentDestroyed(true);
|
|
94
|
-
this.configurationsService.setColorTheme(Themes.Default);
|
|
95
|
-
this.configurationsService.closeConfigPanel();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
enableFullScreenMode(): void {
|
|
99
|
-
this.libCodingTestService.setFullscreen(true);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
<section class="section">
|
|
2
|
-
<header *ngIf="isFullViewMode || isRunnableWithLangSelector" class="section-header">
|
|
3
|
-
<h2 class="heading">{{ translations['HEADINGS']['CODING'] }}</h2>
|
|
4
|
-
<div class="header-controls" [class.is-full-screen]="isFullscreenMode$ | async">
|
|
5
|
-
<form *ngIf="isLAT" [formGroup]="headerForm" class="header-form">
|
|
6
|
-
<ui-tooltip [message]="languages.length === 1 ? translations['TOOLTIPS']['DISABLE_LANGUAGE'] : null">
|
|
7
|
-
<ui-dropdown
|
|
8
|
-
id="language-dropdown"
|
|
9
|
-
class="language-dropdown"
|
|
10
|
-
formControlName="language"
|
|
11
|
-
[valueList]="languagesFormattedList"
|
|
12
|
-
[showBottomContent]="false"
|
|
13
|
-
[allowClear]="false"
|
|
14
|
-
[applicationTheme]="applicationTheme"
|
|
15
|
-
></ui-dropdown>
|
|
16
|
-
</ui-tooltip>
|
|
17
|
-
</form>
|
|
18
|
-
<ui-button
|
|
19
|
-
[variant]="'icon-button'"
|
|
20
|
-
[iconName]="'Reset'"
|
|
21
|
-
[tooltip]="translations['TOOLTIPS']['RESET_CODE']"
|
|
22
|
-
[disabled]="hasNoCodeChanges"
|
|
23
|
-
[applicationTheme]="applicationTheme"
|
|
24
|
-
(buttonClickEvent)="resetCode()"
|
|
25
|
-
class="themed-button"
|
|
26
|
-
>
|
|
27
|
-
</ui-button>
|
|
28
|
-
<ui-button
|
|
29
|
-
*ngIf="isLAT && !isMobile && !isRunnableWithLangSelector"
|
|
30
|
-
[variant]="'icon-button'"
|
|
31
|
-
[iconName]="'Help'"
|
|
32
|
-
[tooltip]="translations['TOOLTIPS']['HELP']"
|
|
33
|
-
[applicationTheme]="applicationTheme"
|
|
34
|
-
(buttonClickEvent)="startGuidedTour()"
|
|
35
|
-
class="themed-button"
|
|
36
|
-
>
|
|
37
|
-
</ui-button>
|
|
38
|
-
<ui-button
|
|
39
|
-
*ngIf="!isRunnableWithLangSelector"
|
|
40
|
-
[variant]="'icon-button'"
|
|
41
|
-
[iconName]="'Settings'"
|
|
42
|
-
[tooltip]="translations['TOOLTIPS']['CONFIGURATIONS']"
|
|
43
|
-
[applicationTheme]="applicationTheme"
|
|
44
|
-
id="configuration-ide-button"
|
|
45
|
-
class="themed-button"
|
|
46
|
-
(buttonClickEvent)="openConfigPanel()"
|
|
47
|
-
>
|
|
48
|
-
</ui-button>
|
|
49
|
-
|
|
50
|
-
<ui-button
|
|
51
|
-
*ngIf="(isFullscreenMode$ | async) && !isMobile"
|
|
52
|
-
[variant]="'icon-button'"
|
|
53
|
-
[iconName]="'Minimize'"
|
|
54
|
-
[tooltip]="translations['TOOLTIPS']['MINIMIZE']"
|
|
55
|
-
[tooltipPosition]="'left'"
|
|
56
|
-
[applicationTheme]="applicationTheme"
|
|
57
|
-
class="themed-button"
|
|
58
|
-
(buttonClickEvent)="disableFullscreen()"
|
|
59
|
-
>
|
|
60
|
-
</ui-button>
|
|
61
|
-
</div>
|
|
62
|
-
</header>
|
|
63
|
-
|
|
64
|
-
<div class="ide" [class.spinner]="isLAT | memoizeFunc: isCodeLoading$ : this | async">
|
|
65
|
-
<tgo-code-editor
|
|
66
|
-
*ngIf="(isLAT | memoizeFunc: isCodeLoading$ : this | async) === false; else showSpinner"
|
|
67
|
-
[initCode]="initCode"
|
|
68
|
-
[functionParams]="functionParams"
|
|
69
|
-
[functionName]="functionName"
|
|
70
|
-
[returnType]="returnType"
|
|
71
|
-
[shouldGenerateInitCode]="!isFullViewMode && !isRunnableWithLangSelector && shouldGenerateInitCode"
|
|
72
|
-
[hasCodingConfigPanel]="isFullViewMode"
|
|
73
|
-
[autoHeight]="autoHeight"
|
|
74
|
-
(pasteEvent)="pasteEvent.emit($event)"
|
|
75
|
-
(codeChange)="parseCodeChange($event)"
|
|
76
|
-
>
|
|
77
|
-
</tgo-code-editor>
|
|
78
|
-
<ng-template #showSpinner>
|
|
79
|
-
<ui-spinner [isLoader]="false" class="code-loading-spinner"></ui-spinner>
|
|
80
|
-
</ng-template>
|
|
81
|
-
</div>
|
|
82
|
-
</section>
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
.section {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
height: 100%;
|
|
5
|
-
overflow-y: hidden;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.section-header {
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: space-between;
|
|
11
|
-
align-items: center;
|
|
12
|
-
padding: 8px 16px;
|
|
13
|
-
border-bottom: 1px solid #E0E0E0;
|
|
14
|
-
max-height: 67px;
|
|
15
|
-
|
|
16
|
-
.header-controls {
|
|
17
|
-
display: flex;
|
|
18
|
-
width: 100%;
|
|
19
|
-
max-width: 265px;
|
|
20
|
-
justify-content: flex-end;
|
|
21
|
-
align-items: center;
|
|
22
|
-
flex: 1 1 auto;
|
|
23
|
-
|
|
24
|
-
.header-form {
|
|
25
|
-
flex: 1;
|
|
26
|
-
padding-right: 1em;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
&.is-full-screen {
|
|
30
|
-
max-width: 305px;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.heading {
|
|
36
|
-
margin: 0;
|
|
37
|
-
padding: 10px 8px;
|
|
38
|
-
flex: 0 0 auto;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.ide {
|
|
42
|
-
flex: 1 0 auto;
|
|
43
|
-
|
|
44
|
-
@media screen and (max-width: 959px) {
|
|
45
|
-
flex: 1 0 350px;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
&.spinner {
|
|
49
|
-
display: flex;
|
|
50
|
-
align-items: center;
|
|
51
|
-
|
|
52
|
-
.code-loading-spinner {
|
|
53
|
-
margin: 0 auto;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.icon {
|
|
59
|
-
::ng-deep {
|
|
60
|
-
svg, path {
|
|
61
|
-
fill: var(--icon-bg-color);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core';
|
|
2
|
-
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
|
|
3
|
-
|
|
4
|
-
import { MockProvider } from 'ng-mocks';
|
|
5
|
-
import { MonacoEditorModule } from 'ngx-monaco-editor-v2';
|
|
6
|
-
import { BehaviorSubject, Subject } from 'rxjs';
|
|
7
|
-
import { MemoizeFuncPipe } from '../../pipes/memoize-func.pipe';
|
|
8
|
-
import { LibCodingTestService } from '../../services/lib-coding-test.service';
|
|
9
|
-
import { CodeEditorLanguages } from '../code-editor/helpers/code-editor-helper.model';
|
|
10
|
-
import { CodingSectionComponent } from './coding-section.component';
|
|
11
|
-
import { ConfigurationsService } from '../../services/configurations.service';
|
|
12
|
-
import { CONFIGURATIONS_SERVICE_MOCK } from '../../services/configurations.service.mocks';
|
|
13
|
-
import { FormBuilder } from '@angular/forms';
|
|
14
|
-
import { StorageCodingService } from '../../services/storage.service';
|
|
15
|
-
import { LanguageChangeAction } from '../../models/language-change-action';
|
|
16
|
-
|
|
17
|
-
describe('CodingSectionComponent', () => {
|
|
18
|
-
let component: CodingSectionComponent;
|
|
19
|
-
let fixture: ComponentFixture<CodingSectionComponent>;
|
|
20
|
-
let libCodingTestService: LibCodingTestService;
|
|
21
|
-
let configurationsService: ConfigurationsService;
|
|
22
|
-
let changeCurrentCodeSpy: jest.SpyInstance;
|
|
23
|
-
const initCode = 'init code';
|
|
24
|
-
|
|
25
|
-
beforeEach(waitForAsync(() => {
|
|
26
|
-
TestBed.configureTestingModule({
|
|
27
|
-
imports: [CodingSectionComponent, MonacoEditorModule.forRoot(), MemoizeFuncPipe],
|
|
28
|
-
schemas: [NO_ERRORS_SCHEMA],
|
|
29
|
-
providers: [
|
|
30
|
-
MockProvider(LibCodingTestService, {
|
|
31
|
-
codeChange$: new Subject(),
|
|
32
|
-
changeCurrentCode(code: string) {
|
|
33
|
-
this.codeChange$.next(code);
|
|
34
|
-
},
|
|
35
|
-
isBoilerplateLoading$: new Subject(),
|
|
36
|
-
setBoilerplateLoadingStatus(value: boolean) {
|
|
37
|
-
this.isBoilerplateLoading$.next(value);
|
|
38
|
-
},
|
|
39
|
-
languageChange$: new Subject(),
|
|
40
|
-
codeReset$: new Subject(),
|
|
41
|
-
getInitCode: () => initCode,
|
|
42
|
-
currentLanguage$: new BehaviorSubject<CodeEditorLanguages>(CodeEditorLanguages.Javascript),
|
|
43
|
-
}),
|
|
44
|
-
MockProvider(ConfigurationsService, CONFIGURATIONS_SERVICE_MOCK),
|
|
45
|
-
FormBuilder,
|
|
46
|
-
MockProvider(StorageCodingService),
|
|
47
|
-
],
|
|
48
|
-
})
|
|
49
|
-
.overrideComponent(CodingSectionComponent, {
|
|
50
|
-
set: {
|
|
51
|
-
template: '',
|
|
52
|
-
},
|
|
53
|
-
})
|
|
54
|
-
.compileComponents();
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
fixture = TestBed.createComponent(CodingSectionComponent);
|
|
59
|
-
component = fixture.componentInstance;
|
|
60
|
-
component.translations = {
|
|
61
|
-
HEADINGS: {},
|
|
62
|
-
TOOLTIPS: {},
|
|
63
|
-
};
|
|
64
|
-
component.languages = [
|
|
65
|
-
{
|
|
66
|
-
value: CodeEditorLanguages.Python,
|
|
67
|
-
label: 'python',
|
|
68
|
-
version: '1',
|
|
69
|
-
},
|
|
70
|
-
];
|
|
71
|
-
component.initCode = 'sample python code';
|
|
72
|
-
libCodingTestService = TestBed.inject(LibCodingTestService);
|
|
73
|
-
configurationsService = TestBed.inject(ConfigurationsService);
|
|
74
|
-
changeCurrentCodeSpy = jest.spyOn(libCodingTestService, 'changeCurrentCode');
|
|
75
|
-
|
|
76
|
-
fixture.detectChanges();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('when the component is initialized', () => {
|
|
80
|
-
describe('and when isLAT is true', () => {
|
|
81
|
-
beforeEach(() => {
|
|
82
|
-
component.isLAT = true;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should initialize header form when isLAT is true', () => {
|
|
86
|
-
component.ngOnInit();
|
|
87
|
-
|
|
88
|
-
expect(component.headerForm).toBeDefined();
|
|
89
|
-
expect(component.headerForm.get('language')).toBeDefined();
|
|
90
|
-
expect(component.headerForm.get('language').value).toBe(CodeEditorLanguages.Javascript);
|
|
91
|
-
expect(component.headerForm.get('language').disabled).toBe(true);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should NOT disable language control of headerForm', () => {
|
|
95
|
-
component.languages = [
|
|
96
|
-
...component.languages,
|
|
97
|
-
{
|
|
98
|
-
value: CodeEditorLanguages.Java,
|
|
99
|
-
label: 'java',
|
|
100
|
-
},
|
|
101
|
-
];
|
|
102
|
-
|
|
103
|
-
component.ngOnInit();
|
|
104
|
-
|
|
105
|
-
expect(component.headerForm).toBeDefined();
|
|
106
|
-
expect(component.headerForm.get('language').enabled).toBe(true);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('should set previousLanguage to languageControl value', () => {
|
|
110
|
-
component.ngOnInit();
|
|
111
|
-
|
|
112
|
-
expect(component.previousLanguage).toBe(CodeEditorLanguages.Javascript);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('should emit languageChange value when language form value is changed', fakeAsync(() => {
|
|
116
|
-
const languageChangeEmitSpy = jest.spyOn(component.languageChange, 'emit');
|
|
117
|
-
|
|
118
|
-
component.ngOnInit();
|
|
119
|
-
component.language.patchValue(CodeEditorLanguages.Cpp);
|
|
120
|
-
tick();
|
|
121
|
-
|
|
122
|
-
expect(languageChangeEmitSpy).toHaveBeenCalledWith(CodeEditorLanguages.Cpp);
|
|
123
|
-
}));
|
|
124
|
-
|
|
125
|
-
it('should set language control value to previousLang if LanguageChangeAction.Cancel', fakeAsync(() => {
|
|
126
|
-
component.ngOnInit();
|
|
127
|
-
component.previousLanguage = CodeEditorLanguages.Php;
|
|
128
|
-
(libCodingTestService.languageChange$ as Subject<LanguageChangeAction>).next(LanguageChangeAction.Cancel);
|
|
129
|
-
tick();
|
|
130
|
-
|
|
131
|
-
expect(component.language.value).toBe(CodeEditorLanguages.Php);
|
|
132
|
-
}));
|
|
133
|
-
|
|
134
|
-
describe('and when LanguageChangeAction.Confirm is emitted', () => {
|
|
135
|
-
it('should set prevLanguage to language control value and changeCurrentLanguage is called', fakeAsync(() => {
|
|
136
|
-
const changeCurrentLanguageSpy = jest.spyOn(libCodingTestService, 'changeCurrentLanguage');
|
|
137
|
-
|
|
138
|
-
component.ngOnInit();
|
|
139
|
-
component.previousLanguage = CodeEditorLanguages.Php;
|
|
140
|
-
component.language.patchValue(CodeEditorLanguages.Python);
|
|
141
|
-
(libCodingTestService.languageChange$ as Subject<LanguageChangeAction>).next(LanguageChangeAction.Confirm);
|
|
142
|
-
tick();
|
|
143
|
-
|
|
144
|
-
expect(component.previousLanguage).toBe(CodeEditorLanguages.Python);
|
|
145
|
-
expect(changeCurrentLanguageSpy).toHaveBeenCalledWith(CodeEditorLanguages.Python);
|
|
146
|
-
}));
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
describe('when initCode changes', () => {
|
|
152
|
-
it('should call the necessary setters', () => {
|
|
153
|
-
const codeChangeSpy = jest.spyOn(component.codeChange, 'emit');
|
|
154
|
-
const oldInitCode = component.initCode;
|
|
155
|
-
const newInitCode = 'sample java code';
|
|
156
|
-
component.initCode = newInitCode;
|
|
157
|
-
const changes: SimpleChanges = {
|
|
158
|
-
initCode: new SimpleChange(oldInitCode, newInitCode, false),
|
|
159
|
-
};
|
|
160
|
-
component.ngOnChanges(changes);
|
|
161
|
-
|
|
162
|
-
expect(codeChangeSpy).toBeCalledWith(newInitCode);
|
|
163
|
-
expect(changeCurrentCodeSpy).toBeCalledWith(newInitCode);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
describe('when parseCodeChange is called', () => {
|
|
168
|
-
it('should emit code change event with new code string', () => {
|
|
169
|
-
const code = 'new code';
|
|
170
|
-
const emitSpy = jest.spyOn(component.codeChange, 'emit');
|
|
171
|
-
|
|
172
|
-
component.parseCodeChange(code);
|
|
173
|
-
|
|
174
|
-
expect(emitSpy).toHaveBeenCalledWith(code);
|
|
175
|
-
expect(changeCurrentCodeSpy).toHaveBeenCalledWith(code);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('should set hasNoCodeChanges to false if code is different from initial code', () => {
|
|
179
|
-
const code = 'new code';
|
|
180
|
-
|
|
181
|
-
component.parseCodeChange(code);
|
|
182
|
-
|
|
183
|
-
expect(component.hasNoCodeChanges).toBe(false);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
it('should set hasNoCodeChanges to true if code is the same as initial code', () => {
|
|
187
|
-
const code = initCode;
|
|
188
|
-
|
|
189
|
-
component.parseCodeChange(code);
|
|
190
|
-
|
|
191
|
-
expect(component.hasNoCodeChanges).toBe(true);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
describe('when the code is reset', () => {
|
|
196
|
-
let resetCodeSpy: jest.SpyInstance;
|
|
197
|
-
|
|
198
|
-
beforeEach(() => {
|
|
199
|
-
resetCodeSpy = jest.spyOn(libCodingTestService, 'resetCode');
|
|
200
|
-
component.resetCode();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
it('should call service reset code method', () => {
|
|
204
|
-
expect(resetCodeSpy).toBeCalled();
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe('when the guided tour is triggered', () => {
|
|
209
|
-
let startGuidedTourSpy: jest.SpyInstance;
|
|
210
|
-
|
|
211
|
-
beforeEach(() => {
|
|
212
|
-
startGuidedTourSpy = jest.spyOn(libCodingTestService, 'startGuidedTour');
|
|
213
|
-
component.startGuidedTour();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('should call service reset code method', () => {
|
|
217
|
-
expect(startGuidedTourSpy).toBeCalled();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
describe('when disableFullscreen is called', () => {
|
|
222
|
-
it('should call setFullscreen method with false', () => {
|
|
223
|
-
const setFullScreenSpy = jest.spyOn(libCodingTestService, 'setFullscreen');
|
|
224
|
-
component.disableFullscreen();
|
|
225
|
-
|
|
226
|
-
expect(setFullScreenSpy).toHaveBeenCalledWith(false);
|
|
227
|
-
});
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
describe('when openConfigPanel is called', () => {
|
|
231
|
-
it('should call openConfigPanel method of ConfigurationsService', () => {
|
|
232
|
-
const openConfigPanelSpy = jest.spyOn(configurationsService, 'openConfigPanel');
|
|
233
|
-
component.openConfigPanel();
|
|
234
|
-
|
|
235
|
-
expect(openConfigPanelSpy).toHaveBeenCalled();
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
|
|
239
|
-
describe('when isCodeLoading$ is called', () => {
|
|
240
|
-
it('should return false observable if test is NOT LAT', done => {
|
|
241
|
-
component.isLAT = false;
|
|
242
|
-
component.isCodeLoading$(component.isLAT).subscribe(val => {
|
|
243
|
-
expect(val).toEqual(false);
|
|
244
|
-
done();
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
it('should return boilerplate loading status if test is LAT', done => {
|
|
248
|
-
component.isLAT = true;
|
|
249
|
-
const boilerplateLoadingStatus = true;
|
|
250
|
-
component.isCodeLoading$(component.isLAT).subscribe(val => {
|
|
251
|
-
expect(val).toEqual(boilerplateLoadingStatus);
|
|
252
|
-
done();
|
|
253
|
-
});
|
|
254
|
-
libCodingTestService.setBoilerplateLoadingStatus(boilerplateLoadingStatus);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
});
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { ChangeDetectionStrategy, Component, EventEmitter, inject, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { AbstractControl, FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
4
|
-
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
|
|
5
|
-
import { distinctUntilChanged, Observable, of, take, tap } from 'rxjs';
|
|
6
|
-
import {
|
|
7
|
-
ApplicationTheme,
|
|
8
|
-
OptionType,
|
|
9
|
-
TooltipComponentModule,
|
|
10
|
-
DropdownComponentModule,
|
|
11
|
-
ButtonComponentModule,
|
|
12
|
-
SpinnerComponentModule,
|
|
13
|
-
} from '@testgorilla/tgo-ui';
|
|
14
|
-
|
|
15
|
-
import { LanguageChangeAction } from '../../models/language-change-action';
|
|
16
|
-
import { LATLanguages } from '../../models/lat-languages';
|
|
17
|
-
import { ConfigurationsService } from '../../services/configurations.service';
|
|
18
|
-
import { LibCodingTestService } from '../../services/lib-coding-test.service';
|
|
19
|
-
import { StorageCodingService } from '../../services/storage.service';
|
|
20
|
-
import {
|
|
21
|
-
CodeEditorFuncParam,
|
|
22
|
-
CodeEditorLanguages,
|
|
23
|
-
CodeEditorTypesMap,
|
|
24
|
-
} from '../code-editor/helpers/code-editor-helper.model';
|
|
25
|
-
import { PasteData } from '../code-editor/models/code-editor.model';
|
|
26
|
-
import { MemoizeFuncPipe } from '../../pipes/memoize-func.pipe';
|
|
27
|
-
import { CodeEditorComponent } from '../code-editor/code-editor.component';
|
|
28
|
-
|
|
29
|
-
@UntilDestroy()
|
|
30
|
-
@Component({
|
|
31
|
-
selector: 'tgo-coding-section',
|
|
32
|
-
templateUrl: './coding-section.component.html',
|
|
33
|
-
styleUrls: ['./coding-section.component.scss'],
|
|
34
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
35
|
-
imports: [
|
|
36
|
-
CommonModule,
|
|
37
|
-
ReactiveFormsModule,
|
|
38
|
-
TooltipComponentModule,
|
|
39
|
-
DropdownComponentModule,
|
|
40
|
-
ButtonComponentModule,
|
|
41
|
-
SpinnerComponentModule,
|
|
42
|
-
MemoizeFuncPipe,
|
|
43
|
-
CodeEditorComponent,
|
|
44
|
-
]
|
|
45
|
-
})
|
|
46
|
-
export class CodingSectionComponent implements OnInit, OnChanges {
|
|
47
|
-
private readonly configurationsService = inject(ConfigurationsService);
|
|
48
|
-
private readonly libCodingTestService = inject(LibCodingTestService);
|
|
49
|
-
private readonly StorageCodingService = inject(StorageCodingService);
|
|
50
|
-
private readonly fb = inject(FormBuilder);
|
|
51
|
-
|
|
52
|
-
@Input() initCode: string;
|
|
53
|
-
@Input() functionParams: CodeEditorFuncParam[];
|
|
54
|
-
@Input() functionName: string;
|
|
55
|
-
@Input() returnType: keyof CodeEditorTypesMap;
|
|
56
|
-
@Input() isLAT = false;
|
|
57
|
-
@Input() languages: LATLanguages;
|
|
58
|
-
@Input() isFullViewMode: boolean;
|
|
59
|
-
@Input() shouldGenerateInitCode: boolean;
|
|
60
|
-
@Input() isRunnableWithLangSelector: boolean;
|
|
61
|
-
@Input() autoHeight: boolean;
|
|
62
|
-
@Input() translations: Record<string, unknown>;
|
|
63
|
-
@Input() isMobile: boolean;
|
|
64
|
-
@Input() applicationTheme: ApplicationTheme;
|
|
65
|
-
|
|
66
|
-
@Output() pasteEvent = new EventEmitter<PasteData>();
|
|
67
|
-
@Output() codeChange = new EventEmitter<string>();
|
|
68
|
-
@Output() languageChange = new EventEmitter<CodeEditorLanguages>();
|
|
69
|
-
|
|
70
|
-
headerForm: FormGroup;
|
|
71
|
-
isFullscreenMode$ = this.libCodingTestService.isFullscreen$;
|
|
72
|
-
previousLanguage: CodeEditorLanguages;
|
|
73
|
-
code: string;
|
|
74
|
-
|
|
75
|
-
languagesFormattedList: OptionType[];
|
|
76
|
-
|
|
77
|
-
ngOnInit() {
|
|
78
|
-
if (this.isLAT) {
|
|
79
|
-
this.createHeaderForm().subscribe(() => {
|
|
80
|
-
this.initializeLanguage();
|
|
81
|
-
this.listenLanguageDropdownChanges();
|
|
82
|
-
this.handleLanguageChangeModal();
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
ngOnChanges(changes: SimpleChanges): void {
|
|
88
|
-
if (typeof changes.initCode?.currentValue === 'string') {
|
|
89
|
-
this.codeChange.emit(changes.initCode.currentValue);
|
|
90
|
-
this.libCodingTestService.changeCurrentCode(changes.initCode.currentValue);
|
|
91
|
-
}
|
|
92
|
-
if (changes.languages?.currentValue) {
|
|
93
|
-
this.languagesFormattedList = this.languages.map(({ value, label }) => ({
|
|
94
|
-
value,
|
|
95
|
-
displayValue: label,
|
|
96
|
-
}));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
private createHeaderForm(): Observable<CodeEditorLanguages> {
|
|
101
|
-
return this.libCodingTestService.currentLanguage$.pipe(
|
|
102
|
-
take(1),
|
|
103
|
-
tap(lastLanguage => {
|
|
104
|
-
this.headerForm = this.fb.group({
|
|
105
|
-
language: lastLanguage ? lastLanguage : this.languages[0].value,
|
|
106
|
-
});
|
|
107
|
-
if (this.languages.length === 1) {
|
|
108
|
-
this.language.disable();
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
private initializeLanguage() {
|
|
115
|
-
this.previousLanguage = this.language.value as CodeEditorLanguages;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private listenLanguageDropdownChanges() {
|
|
119
|
-
this.language.valueChanges
|
|
120
|
-
.pipe(untilDestroyed(this), distinctUntilChanged())
|
|
121
|
-
.subscribe((value: CodeEditorLanguages) => {
|
|
122
|
-
if (value !== this.previousLanguage) {
|
|
123
|
-
this.languageChange.emit(value);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
private handleLanguageChangeModal() {
|
|
129
|
-
this.libCodingTestService.languageChange$.pipe(untilDestroyed(this)).subscribe(value => {
|
|
130
|
-
if (value === LanguageChangeAction.Cancel) {
|
|
131
|
-
// Revert language to previous selection if user cancels
|
|
132
|
-
this.language.setValue(this.previousLanguage);
|
|
133
|
-
} else if (value === LanguageChangeAction.Confirm) {
|
|
134
|
-
this.previousLanguage = this.language.value as CodeEditorLanguages;
|
|
135
|
-
// Update current language if user confirms the new selection
|
|
136
|
-
this.libCodingTestService.changeCurrentLanguage(this.language.value as CodeEditorLanguages);
|
|
137
|
-
this.setVersion();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
parseCodeChange(code: string): void {
|
|
143
|
-
this.codeChange.emit(code);
|
|
144
|
-
this.libCodingTestService.changeCurrentCode(code);
|
|
145
|
-
this.code = code;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
get hasNoCodeChanges(): boolean {
|
|
149
|
-
return this.code === this.libCodingTestService.getInitCode();
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
resetCode(): void {
|
|
153
|
-
this.libCodingTestService.resetCode();
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
startGuidedTour(): void {
|
|
157
|
-
this.libCodingTestService.startGuidedTour();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
disableFullscreen(): void {
|
|
161
|
-
this.libCodingTestService.setFullscreen(false);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
openConfigPanel(): void {
|
|
165
|
-
this.configurationsService.openConfigPanel();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
isCodeLoading$(isLAT: boolean): Observable<boolean> {
|
|
169
|
-
if (isLAT) {
|
|
170
|
-
return this.libCodingTestService.isBoilerplateLoading$;
|
|
171
|
-
}
|
|
172
|
-
return of(false);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
get language(): AbstractControl {
|
|
176
|
-
return this.headerForm.controls.language;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private setVersion() {
|
|
180
|
-
const version = this.languages.find(x => x.value === this.language.value).version;
|
|
181
|
-
this.libCodingTestService.setVersion(version);
|
|
182
|
-
if (this.isFullViewMode) {
|
|
183
|
-
this.StorageCodingService.updateVersion(version);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|