From 9cd47ccebc4aba15545284296973a5bc858a2363 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sat, 14 Aug 2021 22:21:27 +0530 Subject: [PATCH 1/2] add option for editing submission guidelines and leaderboard description --- .../challengesettings.component.html | 12 ++++ .../challengesettings.component.ts | 71 +++++++++++++++++++ .../challengesubmit.component.html | 7 +- .../challengesubmit.component.ts | 40 ----------- 4 files changed, 84 insertions(+), 46 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 9c6ef3f5ba..40f22c3d01 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -170,6 +170,12 @@
Challenge Settings
+      + + Submission Guidelines + + + @@ -201,6 +207,12 @@
Challenge Settings
     + + Leaderboard Description + + + +      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..5155be6dcd 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -914,6 +914,40 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { } } + /** + * Edit submission guidelines + */ + editSubmissionGuidelines() { + const SELF = this; + SELF.apiCall = (params) => { + const BODY = JSON.stringify(params); + SELF.apiService + .patchUrl(SELF.endpointsService.editChallengeDetailsURL(SELF.challenge.creator.id, SELF.challenge.id), BODY) + .subscribe( + (data) => { + SELF.challenge.submission_guidelines = data.submission_guidelines; + SELF.globalService.showToast('success', 'The submission guidelines are successfully updated!', 5); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + }, + () => {} + ); + }; + + const PARAMS = { + title: 'Edit Submission Guidelines', + label: 'submission_guidelines', + isEditorRequired: true, + editorContent: this.challenge.submission_guidelines, + confirm: 'Submit', + deny: 'Cancel', + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showModal(PARAMS); + } + // Edit Leaderboard Details -> /** @@ -1000,6 +1034,43 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { } } + /** + * Edit leaderboard description of the challenge + */ + editLeaderboardDescription() { + const SELF = this; + SELF.apiCall = (params) => { + const BODY = JSON.stringify(params); + SELF.apiService + .patchUrl(SELF.endpointsService.editChallengeDetailsURL(SELF.challenge.creator.id, SELF.challenge.id), BODY) + .subscribe( + (data) => { + SELF.challenge.leaderboard_description = data.leaderboard_description; + SELF.globalService.showToast('success', 'The leaderboard description is successfully updated!', 5); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + }, + () => this.logger.info('Edit Leaderboard Description') + ); + }; + + /** + * Parameters of the modal + */ + const PARAMS = { + title: 'Edit Leaderboard Description', + label: 'leaderboard_description', + isEditorRequired: true, + editorContent: this.challenge.leaderboard_description, + confirm: 'Submit', + deny: 'Cancel', + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showModal(PARAMS); + } + // Edit Evaluation Script and Criteria -> /** diff --git a/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.html b/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.html index 5d3e6b3e0b..26796e163a 100644 --- a/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.html +++ b/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.html @@ -13,12 +13,7 @@
Submission Guidelines

-
- -
- -  edit - +
diff --git a/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts b/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts index f3cc067088..af2bd19842 100644 --- a/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts @@ -93,11 +93,6 @@ export class ChallengesubmitComponent implements OnInit { */ submissionError = ''; - /** - * Guidelines text - */ - submissionGuidelines = ''; - /** * Stores the attributes format and phase ID for all the phases of a challenge. */ @@ -248,7 +243,6 @@ export class ChallengesubmitComponent implements OnInit { this.challengeService.currentChallenge.subscribe((challenge) => { this.challenge = challenge; this.isActive = this.challenge['is_active']; - this.submissionGuidelines = this.challenge['submission_guidelines']; if (this.challenge.cli_version !== null) { this.cliVersion = this.challenge.cli_version; } @@ -603,40 +597,6 @@ export class ChallengesubmitComponent implements OnInit { this.globalService.showToast('success', 'Command copied to clipboard'); } - /** - * Edit submission guidelines - */ - editSubmissionGuideline() { - const SELF = this; - SELF.apiCall = (params) => { - const BODY = JSON.stringify(params); - SELF.apiService - .patchUrl(SELF.endpointsService.editChallengeDetailsURL(SELF.challenge.creator.id, SELF.challenge.id), BODY) - .subscribe( - (data) => { - SELF.submissionGuidelines = data.submission_guidelines; - SELF.globalService.showToast('success', 'The submission guidelines is successfully updated!', 5); - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - }, - () => {} - ); - }; - - const PARAMS = { - title: 'Edit Submission Guidelines', - label: 'submission_guidelines', - isEditorRequired: true, - editorContent: this.challenge.submission_guidelines, - confirm: 'Submit', - deny: 'Cancel', - confirmCallback: SELF.apiCall, - }; - SELF.globalService.showModal(PARAMS); - } - validateInput(inputValue) { const regex = new RegExp(/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?/); const validExtensions = ['json', 'zip', 'txt', 'tsv', 'gz', 'csv', 'h5', 'npy']; From 6914b706569bf81a60ef92092d7f4bd9c4fab347 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sat, 21 Aug 2021 11:06:54 +0530 Subject: [PATCH 2/2] add buttons for edit --- .../challengesettings.component.html | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 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 40f22c3d01..3da6748a28 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -134,8 +134,26 @@
Challenge Settings
- - + + +
+
+ + +
+
Edit Phase @@ -170,12 +188,6 @@
Challenge Settings
-      - - Submission Guidelines - - -
@@ -206,13 +218,7 @@
Challenge Settings
-      - - Leaderboard Description - - - -      +