From 4a690294b51712e8108b500d01988d37a2367ed7 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sat, 14 Aug 2021 23:50:04 +0530 Subject: [PATCH 1/7] move test annotations to edit phase section --- .../editphasemodal.component.html | 18 +------ .../challengesettings.component.html | 7 +++ .../challengesettings.component.ts | 48 +++++++++++++++++++ 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.html b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.html index 924da573c7..8ac4ec51fb 100644 --- a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.html +++ b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.html @@ -172,23 +172,7 @@ - -
-
- -
-
- -
- +
diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html index 9c6ef3f5ba..b2c2cf352c 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -171,6 +171,13 @@
Challenge Settings
+

+ + Test Annotations + + + +
diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts index e4de5f05b1..f8839614a9 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -707,6 +707,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { phaseSelected() { const SELF = this; return (phase) => { + console.log(phase); SELF.selectedPhase = phase; SELF.isPhasePublic = SELF.selectedPhase['is_public']; SELF.isSubmissionPublic = SELF.selectedPhase['is_submission_public']; @@ -914,6 +915,53 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { } } + /** + * Edit test annotations of the phase + */ + editTestAnnotations() { + const SELF = this; + SELF.apiCall = (params) => { + const FORM_DATA: FormData = new FormData(); + FORM_DATA.append('test_annotation', params['test_annotation']); + SELF.apiService + .patchFileUrl( + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.selectedPhase['challenge'], SELF.selectedPhase['id']), + FORM_DATA + ) + .subscribe( + (data) => { + SELF.globalService.showToast('success', 'The test annotations are successfully updated!'); + }, + (err) => { + SELF.globalService.showToast('error', err); + }, + () => this.logger.info('EDIT-TEST-ANNOTATION-FINISHED') + ); + }; + + /** + * Parameters of the modal + */ + const PARAMS = { + title: 'Edit Test Annotations', + confirm: 'Submit', + deny: 'Cancel', + form: [ + { + name: 'testAnnotation', + isRequired: true, + label: 'test_annotation', + placeholder: '', + type: 'file', + value: '', + }, + ], + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showModal(PARAMS); + } + + // Edit Leaderboard Details -> /** From 864110ae4a86951c5b410b63ed7a95416c0e6f3c Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sun, 15 Aug 2021 00:06:09 +0530 Subject: [PATCH 2/7] remove console --- .../challenge/challengesettings/challengesettings.component.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts index f8839614a9..cd2eb308e5 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -707,7 +707,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { phaseSelected() { const SELF = this; return (phase) => { - console.log(phase); SELF.selectedPhase = phase; SELF.isPhasePublic = SELF.selectedPhase['is_public']; SELF.isSubmissionPublic = SELF.selectedPhase['is_submission_public']; @@ -961,7 +960,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.globalService.showModal(PARAMS); } - // Edit Leaderboard Details -> /** From ba68584f752b2335033084b42f3145405c24bca2 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sat, 21 Aug 2021 15:10:08 +0530 Subject: [PATCH 3/7] add modal for cli instructions --- .../challengesettings.component.html | 9 +++ .../challengesettings.component.scss | 4 ++ .../challengesettings.component.ts | 13 ++++ ...challengeviewallsubmissions.component.html | 2 +- .../utility/modal/modal.component.html | 59 ++++++++++++++++++- .../utility/modal/modal.component.scss | 9 +++ .../utility/modal/modal.component.ts | 45 +++++++++++++- 7 files changed, 137 insertions(+), 4 deletions(-) diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html index b2c2cf352c..7581aee55f 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -137,6 +137,15 @@
Challenge Settings
+
+
+

+ Note: For test annotations > 100MB, please use + evalai-cli to update the test annotations. + View Instructions +

+
+
Edit Phase
diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss index 1984bb61be..67143fdf08 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss @@ -25,6 +25,10 @@ input { border-bottom: none; } +p { + margin:0px 0px 25px 0px; +} + :host ::ng-deep .mat-tab-label .mat-tab-label-content{ font-weight: $fw-light !important; font-size: $fs-16 !important; diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts index cd2eb308e5..2fc4b109cc 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -730,6 +730,19 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { }; } + showCliInstructions() { + const SELF = this; + /** + * Parameters of the modal + */ + const PARAMS = { + title: 'Cli Instructions for updating test annotations', + label: 'evaluation_details', + isCliInstructions: true + }; + SELF.globalService.showModal(PARAMS); + } + /** * Edit Phase Details function */ diff --git a/frontend_v2/src/app/components/challenge/challengeviewallsubmissions/challengeviewallsubmissions.component.html b/frontend_v2/src/app/components/challenge/challengeviewallsubmissions/challengeviewallsubmissions.component.html index b2afdd5a5f..71599b8c14 100644 --- a/frontend_v2/src/app/components/challenge/challengeviewallsubmissions/challengeviewallsubmissions.component.html +++ b/frontend_v2/src/app/components/challenge/challengeviewallsubmissions/challengeviewallsubmissions.component.html @@ -7,7 +7,7 @@

Note: Results are greater than 5k, please use the get_all_submissions API to download results. -

+

diff --git a/frontend_v2/src/app/components/utility/modal/modal.component.html b/frontend_v2/src/app/components/utility/modal/modal.component.html index 1fbafcaff5..28f390116c 100644 --- a/frontend_v2/src/app/components/utility/modal/modal.component.html +++ b/frontend_v2/src/app/components/utility/modal/modal.component.html @@ -1,10 +1,13 @@
- + Upload New Image
@@ -28,7 +28,12 @@
Challenge Settings
{{ challenge['title'] }} - + @@ -44,7 +49,7 @@
Challenge Settings
- +
@@ -78,10 +83,10 @@
Challenge Settings

- - {{ publishChallenge.state }} - - + + {{ publishChallenge.state }} + +
Challenge Settings
- - + +
@@ -135,17 +140,8 @@
Challenge Settings
- +
-
-
-

- Note: For test annotations > 100MB, please use - evalai-cli to update the test annotations. - View Instructions -

-
-
Edit Phase
@@ -160,20 +156,20 @@
Challenge Settings
#phaseselect >
- -
+ +
Phase Details - -      +      Is Public - -      +      Submission Visibility @@ -185,11 +181,23 @@
Challenge Settings
Test Annotations - +
- -
+
+
+
+

+ Note: For test annotations > 100MB, please use + evalai-cli + to update the test annotations. + View Instructions +

+
+
+
@@ -215,18 +223,17 @@
Challenge Settings
Leaderboard Visibility - -      +      - - +
@@ -241,8 +248,8 @@
Evaluation script
Evaluation Criteria - -    +    Evaluation Script @@ -293,7 +300,6 @@
Submission worker logs
-
From aeec81ce153a89dfafd629aea3ca5131b57962c3 Mon Sep 17 00:00:00 2001 From: Gautam Jajoo Date: Fri, 27 Aug 2021 13:59:54 +0530 Subject: [PATCH 7/7] remove linting changes --- .../challengesettings.component.ts | 391 ++++++++---------- 1 file changed, 170 insertions(+), 221 deletions(-) diff --git a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts index 0e1d73f085..c246aae9ff 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -18,6 +18,7 @@ import { SelectphaseComponent } from '../../utility/selectphase/selectphase.comp styleUrls: ['./challengesettings.component.scss'], }) export class ChallengesettingsComponent implements OnInit, OnDestroy { + /** * Phase select card components */ @@ -54,11 +55,11 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ filteredPhases = []; - /** - * Phase splits filtered - */ + /** + * Phase splits filtered + */ filteredPhaseSplits = []; - + /** * Currently selected phase */ @@ -69,25 +70,25 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ phaseSelectionType = 'selectBox'; - /** - * Select box list type - */ + /** + * Select box list type + */ phaseSelectionListType = 'phase'; /** * If the submission is public */ - isSubmissionPublic: boolean = false; + isSubmissionPublic : boolean = false; - /** - * If the phase is public - */ - isPhasePublic: boolean = false; + /** + * If the phase is public + */ + isPhasePublic : boolean = false; /** * If leaderboard is public */ - isLeaderboardPublic: boolean = false; + isLeaderboardPublic : boolean = false; /** * Currently selected phase split @@ -99,9 +100,9 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ phaseLeaderboardSelectionType = 'selectBox'; - /** - * Select box list type - */ + /** + * Select box list type + */ phaseLeaderboardSelectionListType = 'settingsPhaseSplit'; /** @@ -110,27 +111,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { * 3 -> public */ isPhaseSplitLeaderboardPublic: number = 1; - - /** - * Leaderboard precision value - */ - leaderboardPrecisionValue = 2; - - /** - * Set leaderboard precision value - */ - setLeaderboardPrecisionValue = '1.2-2'; - - /** - * If leaderboard precision value is equal to 0 - */ - minusDisabled = false; - - /** - * If leaderboard precision value is equal to 20 - */ - plusDisabled = false; - + /** * store worker logs */ @@ -175,7 +156,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { submissionVisibility = { state: 'Private', icon: 'fa fa-toggle-off grey-text text-darken-1', - }; + }; /** * phase visibility state and it's icon @@ -228,35 +209,37 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { this.challengeService.isChallengeHost.subscribe((status) => { this.isChallengeHost = status; }); - + this.challengeService.currentChallengePublishState.subscribe((publishChallenge) => { this.publishChallenge.state = publishChallenge.state; this.publishChallenge.icon = publishChallenge.icon; }); - if (!this.challenge['remote_evaluation']) { + if (!this.challenge["remote_evaluation"]) { this.fetchWorkerLogs(); this.startLoadingLogs(); } - + this.challengeService.currentPhases.subscribe((phases) => { this.phases = phases; for (let i = 0; i < this.phases.length; i++) { if (this.phases[i].is_public === false) { this.phases[i].showPrivate = true; - } else { + } + else { this.phases[i].showPrivate = false; } } this.filteredPhases = this.phases; - }); + }); this.challengeService.currentPhaseSplit.subscribe((phaseSplits) => { this.phaseSplits = phaseSplits; for (let i = 0; i < this.phaseSplits.length; i++) { if (this.phaseSplits[i].visibility !== 3) { this.phaseSplits[i].showPrivate = true; - } else { + } + else { this.phaseSplits[i].showPrivate = false; } } @@ -473,7 +456,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { }; SELF.globalService.showModal(PARAMS); } - + /** * Edit challenge start and end date function */ @@ -731,29 +714,31 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { if (SELF.isPhasePublic) { SELF.phaseVisibility.state = 'Public'; SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; - } else { + } + else { SELF.phaseVisibility.state = 'Private'; SELF.phaseVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; } if (SELF.isSubmissionPublic) { SELF.submissionVisibility.state = 'Public'; SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; - } else { + } + else { SELF.submissionVisibility.state = 'Private'; SELF.submissionVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; } }; - } + } showCliInstructions() { const SELF = this; /** * Parameters of the modal - */ - const PARAMS = { + */ + const PARAMS = { title: 'Instructions', label: 'evaluation_details', - isCliInstructions: true, + isCliInstructions: true }; SELF.globalService.showModal(PARAMS); } @@ -777,17 +762,15 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { ) .subscribe( (data) => { - for (var attrname in data) { - SELF.selectedPhase[attrname] = data[attrname]; + for (var attrname in data) { + SELF.selectedPhase[attrname] = data[attrname]; } SELF.globalService.showToast('success', 'The challenge phase details are successfully updated!'); }, (err) => { SELF.globalService.showToast('error', err); }, - () => { - this.logger.info('PHASE-UPDATE-FINISHED'); - } + () => {this.logger.info('PHASE-UPDATE-FINISHED')} ); }; @@ -802,13 +785,13 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { maxSubmissionsPerMonth: SELF.selectedPhase['max_submissions_per_month'], maxSubmissions: SELF.selectedPhase['max_submissions'], maxConcurrentSubmissionsAllowed: SELF.selectedPhase['max_concurrent_submissions_allowed'], - allowedSubmissionFileTypes: SELF.selectedPhase['allowed_submission_file_types'], + allowedSubmissionFileTypes: SELF.selectedPhase['allowed_submission_file_types'], confirm: 'Submit', deny: 'Cancel', confirmCallback: SELF.apiCall, }; SELF.globalService.showEditPhaseModal(PARAMS); - } +} /** * Phase Visibility toggle function @@ -827,64 +810,68 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.phaseVisibility.state = 'Public'; SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; } - const BODY: FormData = new FormData(); - BODY.append('is_public', isPublic); - SELF.apiService + const BODY: FormData = new FormData(); + BODY.append("is_public", isPublic); + SELF.apiService .patchFileUrl( SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.selectedPhase['challenge'], SELF.selectedPhase['id']), BODY ) - .subscribe( - (data) => { - SELF.selectedPhase['is_public'] = data.is_public; - SELF.selectedPhase['showPrivate'] = !data.is_public; - SELF.challengeService.changePhaseSelected(true); - if (!SELF.selectedPhase['is_public']) { - for (let i = 0; i < SELF.phaseSplits.length; i++) { - if ( - SELF.phaseSplits[i]['challenge_phase_name'] === SELF.selectedPhase['name'] && - SELF.phaseSplits[i]['visibility'] == 3 - ) { - let visibility: any = 1; - const BODY: FormData = new FormData(); - BODY.append('visibility', visibility); - SELF.apiService - .patchFileUrl(SELF.endpointsService.particularChallengePhaseSplitUrl(SELF.phaseSplits[i]['id']), BODY) - .subscribe( - (data) => { - SELF.phaseSplits[i]['visibility'] = data.visibility; - SELF.challengeService.changePhaseSplitSelected(true); - SELF.phaseSplits[i]['showPrivate'] = true; - if (SELF.selectedPhaseSplit === SELF.phaseSplits[i]) { - SELF.leaderboardVisibility.state = 'Private'; - SELF.leaderboardVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; - } - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - }, - () => this.logger.info('Change leaderboard visibility after phase is updated') - ); + .subscribe( + (data) => { + SELF.selectedPhase['is_public'] = data.is_public; + SELF.selectedPhase['showPrivate'] = !data.is_public; + SELF.challengeService.changePhaseSelected(true); + if(!SELF.selectedPhase['is_public']) { + for(let i = 0; i < SELF.phaseSplits.length; i++) { + if(SELF.phaseSplits[i]['challenge_phase_name'] === SELF.selectedPhase['name'] && SELF.phaseSplits[i]['visibility'] == 3) { + let visibility: any = 1; + const BODY: FormData = new FormData(); + BODY.append("visibility", visibility); + SELF.apiService + .patchFileUrl( + SELF.endpointsService.particularChallengePhaseSplitUrl(SELF.phaseSplits[i]['id']), + BODY + ) + .subscribe( + (data) => { + SELF.phaseSplits[i]['visibility'] = data.visibility; + SELF.challengeService.changePhaseSplitSelected(true); + SELF.phaseSplits[i]['showPrivate'] = true; + if(SELF.selectedPhaseSplit === SELF.phaseSplits[i]) { + SELF.leaderboardVisibility.state = 'Private'; + SELF.leaderboardVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; + } + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + }, + () => this.logger.info('Change leaderboard visibility after phase is updated') + ); + } } } - } - SELF.globalService.showToast('success', 'The phase was successfully made ' + togglePhaseVisibilityState, 5); - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - if (isPublic) { - SELF.phaseVisibility.state = 'Private'; - SELF.phaseVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; - } else { - SELF.phaseVisibility.state = 'Public'; - SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; - } - }, - () => this.logger.info('PHASE-VISIBILITY-UPDATE-FINISHED') - ); + SELF.globalService.showToast( + 'success', + 'The phase was successfully made ' + togglePhaseVisibilityState, + 5 + ); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + if (isPublic) { + SELF.phaseVisibility.state = 'Private'; + SELF.phaseVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; + } else { + SELF.phaseVisibility.state = 'Public'; + SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; + } + }, + () => this.logger.info('PHASE-VISIBILITY-UPDATE-FINISHED') + ); } /** @@ -892,7 +879,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ toggleSubmissionVisibility() { const SELF = this; - if (SELF.isLeaderboardPublic == true) { + if(SELF.isLeaderboardPublic == true) { let toggleSubmissionVisibilityState, isSubmissionPublic; if (SELF.submissionVisibility.state === 'Public') { toggleSubmissionVisibilityState = 'private'; @@ -905,40 +892,38 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.submissionVisibility.state = 'Public'; SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; } - const BODY: FormData = new FormData(); - BODY.append('is_submission_public', isSubmissionPublic); - SELF.apiService + const BODY: FormData = new FormData(); + BODY.append("is_submission_public", isSubmissionPublic); + SELF.apiService .patchFileUrl( - SELF.endpointsService.updateChallengePhaseDetailsURL( - SELF.selectedPhase['challenge'], - SELF.selectedPhase['id'] - ), + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.selectedPhase['challenge'], SELF.selectedPhase['id']), BODY ) - .subscribe( - (data) => { - SELF.selectedPhase['is_submission_public'] = data.is_submission_public; - SELF.globalService.showToast( - 'success', - 'The submissions were successfully made ' + toggleSubmissionVisibilityState, - 5 - ); - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - if (isSubmissionPublic) { - SELF.submissionVisibility.state = 'Private'; - SELF.submissionVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; - } else { - SELF.submissionVisibility.state = 'Public'; - SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; - } - }, - () => this.logger.info('SUBMISSION-VISIBILITY-UPDATE-FINISHED') - ); - } else { - SELF.globalService.showToast('error', 'Leaderboard is private, please make the leaderbaord public'); + .subscribe( + (data) => { + SELF.selectedPhase['is_submission_public'] = data.is_submission_public; + SELF.globalService.showToast( + 'success', + 'The submissions were successfully made ' + toggleSubmissionVisibilityState, + 5 + ); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + if (isSubmissionPublic) { + SELF.submissionVisibility.state = 'Private'; + SELF.submissionVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; + } else { + SELF.submissionVisibility.state = 'Public'; + SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; + } + }, + () => this.logger.info('SUBMISSION-VISIBILITY-UPDATE-FINISHED') + ); + } + else { + SELF.globalService.showToast('error', "Leaderboard is private, please make the leaderbaord public"); } } @@ -950,12 +935,9 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.apiCall = (params) => { const FORM_DATA: FormData = new FormData(); FORM_DATA.append('test_annotation', params['test_annotation']); - SELF.apiService + SELF.apiService .patchFileUrl( - SELF.endpointsService.updateChallengePhaseDetailsURL( - SELF.selectedPhase['challenge'], - SELF.selectedPhase['id'] - ), + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.selectedPhase['challenge'], SELF.selectedPhase['id']), FORM_DATA ) .subscribe( @@ -1009,17 +991,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.leaderboardVisibility.state = 'Private'; SELF.leaderboardVisibility.icon = 'fa fa fa-toggle-off grey-text text-darken-1'; } - const API_PATH = SELF.endpointsService.particularChallengePhaseSplitUrl(this.selectedPhaseSplit['id']); - SELF.apiService.getUrl(API_PATH).subscribe( - (data) => { - SELF.leaderboardPrecisionValue = data.leaderboard_decimal_precision; - SELF.setLeaderboardPrecisionValue = `1.${ SELF.leaderboardPrecisionValue }-${ SELF.leaderboardPrecisionValue }`; - }, - (err) => { - SELF.globalService.handleApiError(err); - }, - () => {} - ); } } @@ -1029,12 +1000,12 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { toggleLeaderboardVisibility() { const SELF = this; let toggleLeaderboardVisibilityState, visibility, phaseIsPublic; - for (let i = 0; i < SELF.filteredPhases.length; i++) { - if (SELF.filteredPhases[i]['name'] === SELF.selectedPhaseSplit['challenge_phase_name']) { + for(let i = 0; i < SELF.filteredPhases.length; i++) { + if(SELF.filteredPhases[i]['name'] === SELF.selectedPhaseSplit['challenge_phase_name']) { phaseIsPublic = SELF.filteredPhases[i]['is_public']; } } - if (phaseIsPublic) { + if(phaseIsPublic) { if (SELF.leaderboardVisibility.state === 'Public') { toggleLeaderboardVisibilityState = 'private'; visibility = 1; @@ -1047,70 +1018,47 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.leaderboardVisibility.icon = 'fa fa-toggle-on green-text'; } const BODY: FormData = new FormData(); - BODY.append('visibility', visibility); + BODY.append("visibility", visibility); SELF.apiService - .patchFileUrl(SELF.endpointsService.particularChallengePhaseSplitUrl(SELF.selectedPhaseSplit['id']), BODY) - .subscribe( - (data) => { - SELF.selectedPhaseSplit['visibility'] = data.visibility; - SELF.challengeService.changePhaseSplitSelected(true); - if (visibility == 3) { - SELF.selectedPhaseSplit['showPrivate'] = false; - SELF.leaderboardVisibility.state = 'Public'; - SELF.leaderboardVisibility.icon = 'fa fa-toggle-on green-text'; - } else { - SELF.selectedPhaseSplit['showPrivate'] = true; - SELF.leaderboardVisibility.state = 'Private'; - SELF.leaderboardVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; - } - SELF.globalService.showToast( - 'success', - 'The phase split was successfully made ' + toggleLeaderboardVisibilityState, - 5 - ); - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - if (visibility == 3) { - SELF.leaderboardVisibility.state = 'Private'; - SELF.leaderboardVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; - } else { - SELF.leaderboardVisibility.state = 'Public'; - SELF.leaderboardVisibility.icon = 'fa fa-toggle-on green-text'; - } - }, - () => this.logger.info('LEADERBOARD-VISIBILITY-UPDATE-FINISHED') - ); - } else { + .patchFileUrl(SELF.endpointsService.particularChallengePhaseSplitUrl(SELF.selectedPhaseSplit['id']),BODY) + .subscribe( + (data) => { + SELF.selectedPhaseSplit['visibility'] = data.visibility; + SELF.challengeService.changePhaseSplitSelected(true); + if (visibility == 3) { + SELF.selectedPhaseSplit['showPrivate'] = false; + SELF.leaderboardVisibility.state = 'Public'; + SELF.leaderboardVisibility.icon = 'fa fa-toggle-on green-text'; + } else { + SELF.selectedPhaseSplit['showPrivate'] = true; + SELF.leaderboardVisibility.state = 'Private'; + SELF.leaderboardVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; + } + SELF.globalService.showToast( + 'success', + 'The phase split was successfully made ' + toggleLeaderboardVisibilityState, + 5 + ); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + if (visibility == 3) { + SELF.leaderboardVisibility.state = 'Private'; + SELF.leaderboardVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; + } else { + SELF.leaderboardVisibility.state = 'Public'; + SELF.leaderboardVisibility.icon = 'fa fa-toggle-on green-text'; + } + }, + () => this.logger.info('LEADERBOARD-VISIBILITY-UPDATE-FINISHED') + ); + } + else { SELF.globalService.showToast('error', 'The phase is private, please make the phase public'); } } - /** - * Update leaderboard decimal precision value - * @param updatedLeaderboardPrecisionValue new leaderboard precision value - */ - updateLeaderboardDecimalPrecision(updatedLeaderboardPrecisionValue) { - const API_PATH = this.endpointsService.particularChallengePhaseSplitUrl(this.selectedPhaseSplit['id']); - const SELF = this; - SELF.leaderboardPrecisionValue = updatedLeaderboardPrecisionValue; - SELF.setLeaderboardPrecisionValue = '1.' + SELF.leaderboardPrecisionValue + '-' + SELF.leaderboardPrecisionValue; - const BODY = JSON.stringify({ - leaderboard_decimal_precision: SELF.leaderboardPrecisionValue, - }); - SELF.apiService.patchUrl(API_PATH, BODY).subscribe( - (data) => { - this.minusDisabled = SELF.leaderboardPrecisionValue === 0 ? true : false; - this.plusDisabled = SELF.leaderboardPrecisionValue === 20 ? true : false; - }, - (err) => { - SELF.globalService.handleApiError(err, true); - }, - () => this.logger.info('EDIT-LEADERBOARD-PRECISION-VALUE-FINISHED') - ); - } - // Edit Evaluation Script and Criteria -> /** @@ -1224,7 +1172,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { // Get the logs from worker if submissions are failing. fetchWorkerLogs() { - if (this.challenge['id']) { + if(this.challenge['id']) { const API_PATH = this.endpointsService.getLogsURL(this.challenge['id']); const SELF = this; SELF.apiService.getUrl(API_PATH, true, false).subscribe( @@ -1249,11 +1197,12 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.fetchWorkerLogs(); }, 5000); } - + /** * Component on destroyed. */ ngOnDestroy() { clearInterval(this.pollingInterval); } + }