From 8dd6922ce06106834db76c10e6e3f6b800da01e9 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Mon, 21 Jun 2021 00:20:36 +0530 Subject: [PATCH 01/12] add max_concurrent_submissions and allowed_file_types --- .../editphasemodal.component.html | 38 +++++++++++++++++++ .../editphasemodal.component.ts | 16 ++++++++ .../challengesettings.component.ts | 2 + 3 files changed, 56 insertions(+) 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 6af6dac21a..b242a83c50 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 @@ -76,6 +76,7 @@ +
Submissions/day @@ -135,6 +136,43 @@
+
+
+ Max Concurrent Submissions Allowed + +
+
+
+ +
+
+
+
Allowed Submission File Types
+ +
+
+
+
Date: Thu, 24 Jun 2021 15:15:19 +0530 Subject: [PATCH 02/12] add phase visibility edit option --- .../editphasemodal.component.html | 12 ++ .../editphasemodal.component.ts | 103 +++++++++++++++++- .../challengesettings.component.ts | 4 +- 3 files changed, 117 insertions(+), 2 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 b242a83c50..ff0e6a8bba 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 @@ -21,6 +21,18 @@ >
+
+
+
Phase Visibility    + + + {{ phaseVisibility.state }} + + + +
+
+
diff --git a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts index 32e3b60635..e0e916c4dd 100644 --- a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts +++ b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts @@ -1,6 +1,12 @@ import { ViewChildren, QueryList, Component, Input, OnInit } from '@angular/core'; import { GlobalService } from '../../../../services/global.service'; import { InputComponent } from '../../../utility/input/input.component'; +import { NGXLogger } from 'ngx-logger'; + +import { EndpointsService } from '../../../../services/endpoints.service'; +import { ApiService } from '../../../../services/api.service'; +import { ChallengeService } from '../../../../services/challenge.service'; + @Component({ selector: 'app-editphasemodal', @@ -13,6 +19,21 @@ export class EditphasemodalComponent implements OnInit { */ @Input() params: any; + /** + * To call the API inside modal for editing the challenge details + */ + apiCall: any; + + /** + * Challenge object + */ + challenge: any; + + /** + * Challenge object + */ + phase: any; + /** * Modal title */ @@ -123,6 +144,14 @@ export class EditphasemodalComponent implements OnInit { */ editPhaseDetails = true; + /** + * publish challenge state and it's icon + */ + phaseVisibility = { + state: 'Private', + icon: 'fa fa-eye-slash red-text', + }; + /** * Quill editor style */ @@ -151,13 +180,29 @@ export class EditphasemodalComponent implements OnInit { * Constructor. * @param globalService GlobalService Injection. */ - constructor(private globalService: GlobalService) {} + constructor( + private globalService: GlobalService, + private apiService: ApiService, + private endpointsService: EndpointsService, + private challengeService: ChallengeService, + private logger: NGXLogger + ) {} ngOnInit() { if (this.params) { if (this.params['title']) { this.title = this.params['title']; } + if (this.params['challenge']) { + this.challenge = this.params['challenge']; + } + if (this.params['phase']) { + this.phase = this.params['phase']; + } + if (this.params['isPublic']) { + this.phaseVisibility.state = 'Public'; + this.phaseVisibility.icon = 'fa fa-eye green-text'; + } if (this.params['label']) { this.label = this.params['label']; } @@ -204,6 +249,62 @@ export class EditphasemodalComponent implements OnInit { this.todayDateTime = new Date(); } + /** + * Phase Visibility click function + */ + togglePhaseVisibility() { + const SELF = this; + let togglePhaseVisibilityState, isPublic; + if (this.phaseVisibility.state === 'Public') { + togglePhaseVisibilityState = 'private'; + isPublic = false; + } else { + togglePhaseVisibilityState = 'public'; + isPublic = true; + } + SELF.apiCall = () => { + const BODY: FormData = new FormData(); + BODY.append("is_public", isPublic); + SELF.apiService + .patchFileUrl( + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.params['challenge'], SELF.params['phase']), + BODY + ) + .subscribe( + (data) => { + SELF.challengeService.fetchPhases(SELF.params['challenge']); + SELF.denied(); + if (isPublic) { + this.phaseVisibility.state = 'Public'; + this.phaseVisibility.icon = 'fa fa-eye green-text'; + } else { + this.phaseVisibility.state = 'Private'; + this.phaseVisibility.icon = 'fa fa-eye-slash red-text'; + } + SELF.globalService.showToast( + 'success', + 'The phase was successfully made ' + togglePhaseVisibilityState, + 5 + ); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + }, + () => this.logger.info('PHASE-VISIBILITY-UPDATE-FINISHED') + ); + }; + + const PARAMS = { + title: 'Make this phase ' + togglePhaseVisibilityState + '?', + content: '', + confirm: "Yes, I'm sure", + deny: 'No', + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showConfirm(PARAMS); + } + /** * Form Validate function. */ 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 ce29de8fcd..06b4b5f7ca 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -188,7 +188,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { const SELF = this; return (phase) => { SELF.selectedPhase = phase; - SELF.apiCall = (params) => { const FORM_DATA: FormData = new FormData(); for (const key in params) { @@ -216,6 +215,9 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { const PARAMS = { title: 'Edit Challenge Phase Details', + phase: SELF.selectedPhase['id'], + challenge: SELF.selectedPhase['challenge'], + isPublic: SELF.selectedPhase['is_public'], name: SELF.selectedPhase['name'], label: 'description', description: SELF.selectedPhase['description'], From 8cf98c9c03e044f25bffcc8bec1bb180396640d5 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Thu, 24 Jun 2021 21:31:33 +0530 Subject: [PATCH 03/12] add submission visibility edit feature --- apps/challenges/serializers.py | 1 + .../editphasemodal.component.html | 12 +++ .../editphasemodal.component.ts | 82 +++++++++++++++++++ .../challengesettings.component.ts | 2 + .../challengesubmissions.component.html | 2 +- 5 files changed, 98 insertions(+), 1 deletion(-) diff --git a/apps/challenges/serializers.py b/apps/challenges/serializers.py index 5562f680d5..807802145c 100644 --- a/apps/challenges/serializers.py +++ b/apps/challenges/serializers.py @@ -102,6 +102,7 @@ class Meta: "allowed_submission_file_types", "default_submission_meta_attributes", "allowed_email_ids", + "is_submission_public", ) 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 ff0e6a8bba..9668f15702 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 @@ -33,6 +33,18 @@
+
+
+
Submission Visibility    + + + {{ submissionVisibility.state }} + + + +
+
+
diff --git a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts index e0e916c4dd..17cd80a5e2 100644 --- a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts +++ b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts @@ -119,6 +119,11 @@ export class EditphasemodalComponent implements OnInit { */ PerMonthSubmissionValidationMessage = ''; + /** + * If leaderboard is public + */ + isLeaderboardPublic : boolean = false; + /** * Modal accept button */ @@ -152,6 +157,14 @@ export class EditphasemodalComponent implements OnInit { icon: 'fa fa-eye-slash red-text', }; + /** + * publish challenge state and it's icon + */ + submissionVisibility = { + state: 'Private', + icon: 'fa fa-eye-slash red-text', + }; + /** * Quill editor style */ @@ -203,6 +216,10 @@ export class EditphasemodalComponent implements OnInit { this.phaseVisibility.state = 'Public'; this.phaseVisibility.icon = 'fa fa-eye green-text'; } + if (this.params['isSubmissionPublic']) { + this.submissionVisibility.state = 'Public'; + this.submissionVisibility.icon = 'fa fa-eye green-text'; + } if (this.params['label']) { this.label = this.params['label']; } @@ -212,6 +229,9 @@ export class EditphasemodalComponent implements OnInit { if (this.params['description']) { this.description = this.params['description']; } + if(this.params['isLeaderboardPublic']) { + this.isLeaderboardPublic = this.params['isLeaderboardPublic']; + } if (this.params['startDate']) { this.startDate = this.params['startDate']; } @@ -305,6 +325,68 @@ export class EditphasemodalComponent implements OnInit { SELF.globalService.showConfirm(PARAMS); } + /** + * Submission Visibility click function + */ + toggleSubmissionVisibility() { + const SELF = this; + if(this.isLeaderboardPublic == true) { + let toggleSubmissionVisibilityState, isSubmissionPublic; + if (this.submissionVisibility.state === 'Public') { + toggleSubmissionVisibilityState = 'private'; + isSubmissionPublic = false; + } else { + toggleSubmissionVisibilityState = 'public'; + isSubmissionPublic = true; + } + SELF.apiCall = () => { + const BODY: FormData = new FormData(); + BODY.append("is_submission_public", isSubmissionPublic); + SELF.apiService + .patchFileUrl( + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.params['challenge'], SELF.params['phase']), + BODY + ) + .subscribe( + (data) => { + SELF.challengeService.fetchPhases(SELF.params['challenge']); + SELF.denied(); + if (isSubmissionPublic) { + this.submissionVisibility.state = 'Public'; + this.submissionVisibility.icon = 'fa fa-eye green-text'; + } else { + this.submissionVisibility.state = 'Private'; + this.submissionVisibility.icon = 'fa fa-eye-slash red-text'; + } + SELF.globalService.showToast( + 'success', + 'The submissions were successfully made ' + toggleSubmissionVisibilityState, + 5 + ); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + }, + () => this.logger.info('SUBMISSION-VISIBILITY-UPDATE-FINISHED') + ); + }; + + const PARAMS = { + title: 'Make the submissions ' + toggleSubmissionVisibilityState + '?', + content: '', + confirm: "Yes, I'm sure", + deny: 'No', + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showConfirm(PARAMS); + } + else { + SELF.globalService.showToast('error', "Leaderboard is private, please make the leaderbaord public"); + SELF.denied(); + } + } + /** * Form Validate function. */ 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 06b4b5f7ca..a83108aec7 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -218,6 +218,8 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { phase: SELF.selectedPhase['id'], challenge: SELF.selectedPhase['challenge'], isPublic: SELF.selectedPhase['is_public'], + isSubmissionPublic: SELF.selectedPhase['is_submission_public'], + isLeaderboardPublic: SELF.selectedPhase['leaderboard_public'], name: SELF.selectedPhase['name'], label: 'description', description: SELF.selectedPhase['description'], diff --git a/frontend_v2/src/app/components/challenge/challengesubmissions/challengesubmissions.component.html b/frontend_v2/src/app/components/challenge/challengesubmissions/challengesubmissions.component.html index 5b61795a72..e633b57a7b 100644 --- a/frontend_v2/src/app/components/challenge/challengesubmissions/challengesubmissions.component.html +++ b/frontend_v2/src/app/components/challenge/challengesubmissions/challengesubmissions.component.html @@ -139,7 +139,7 @@
My Submissions
Show on leaderboard From 76461ccd27cc224569201a471e5780d1d78024f5 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Thu, 24 Jun 2021 21:32:30 +0530 Subject: [PATCH 04/12] edit submit page for submission visibility --- .../challengesubmit/challengesubmit.component.html | 3 ++- .../challenge/challengesubmit/challengesubmit.component.ts | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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 458ae03599..c18a55e034 100644 --- a/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.html +++ b/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.html @@ -286,13 +286,14 @@
Make Submission
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 6a5746b031..b19619d9dd 100644 --- a/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesubmit/challengesubmit.component.ts @@ -53,6 +53,11 @@ export class ChallengesubmitComponent implements OnInit { */ isPublicSubmission:boolean = true; + /** + * Is submittion allowed by host + */ + isSubmissionPublic:boolean = false; + /** * Challenge object */ @@ -467,6 +472,7 @@ export class ChallengesubmitComponent implements OnInit { const SELF = this; return (phase) => { SELF.selectedPhase = phase; + SELF.isSubmissionPublic = phase['is_submission_public']; if (SELF.challenge['id'] && phase['id']) { SELF.getMetaDataDetails(SELF.challenge['id'], phase['id']); SELF.fetchRemainingSubmissions(SELF.challenge['id'], phase['id']); From e431540f3dfa1628ce40a86bb53b305cefc76745 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sat, 26 Jun 2021 14:42:52 +0530 Subject: [PATCH 05/12] fix tests --- tests/unit/challenges/test_views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/unit/challenges/test_views.py b/tests/unit/challenges/test_views.py index 6e9e352d33..004fab0d2d 100644 --- a/tests/unit/challenges/test_views.py +++ b/tests/unit/challenges/test_views.py @@ -2038,6 +2038,7 @@ def test_get_challenge_phase(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, }, { "id": self.private_challenge_phase.id, @@ -2065,6 +2066,7 @@ def test_get_challenge_phase(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.private_challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, }, ] @@ -2100,6 +2102,7 @@ def test_get_challenge_phase_when_user_is_not_authenticated(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, } ] self.client.force_authenticate(user=None) @@ -2145,6 +2148,7 @@ def test_get_challenge_phase_when_user_is_host(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, }, { "id": self.private_challenge_phase.id, @@ -2172,6 +2176,7 @@ def test_get_challenge_phase_when_user_is_host(self): "is_partial_submission_evaluation_enabled": self.private_challenge_phase.is_partial_submission_evaluation_enabled, "default_submission_meta_attributes": self.private_challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.private_challenge_phase.allowed_email_ids, + "is_submission_public": self.private_challenge_phase.is_submission_public, }, ] @@ -2521,6 +2526,7 @@ def test_get_particular_challenge_phase_if_user_is_participant(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, } self.client.force_authenticate(user=self.participant_user) response = self.client.get(self.url, {}) @@ -2547,7 +2553,7 @@ def test_get_particular_challenge_phase_if_user_is_challenge_host(self): "codename": "Phase Code Name", "max_submissions_per_day": self.challenge_phase.max_submissions_per_day, "max_submissions": self.challenge_phase.max_submissions, - "max_submissions_per_month": self.challenge_phase.max_submissions_per_month, + "max_submissions_per_month": self.challenge_phase.max_submiessions_per_month, "max_concurrent_submissions_allowed": self.challenge_phase.max_concurrent_submissions_allowed, "test_annotation": "http://testserver%s" % (self.challenge_phase.test_annotation.url), @@ -2621,6 +2627,7 @@ def test_update_challenge_phase_when_user_is_its_creator(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, } response = self.client.put( self.url, {"name": new_name, "description": new_description} @@ -2721,6 +2728,7 @@ def test_particular_challenge_phase_partial_update(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, } response = self.client.patch(self.url, self.partial_update_data) self.assertEqual(response.data, expected) @@ -4238,6 +4246,7 @@ def test_get_challenge_phase_by_pk(self): "allowed_submission_file_types": self.challenge_phase.allowed_submission_file_types, "default_submission_meta_attributes": self.challenge_phase.default_submission_meta_attributes, "allowed_email_ids": self.challenge_phase.allowed_email_ids, + "is_submission_public": self.challenge_phase.is_submission_public, } response = self.client.get(self.url, {}) self.assertEqual(response.data, expected) From b3908ed2cce0b997873bc26942d1311a19e21c8f Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sat, 26 Jun 2021 15:38:01 +0530 Subject: [PATCH 06/12] fix typo --- tests/unit/challenges/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/challenges/test_views.py b/tests/unit/challenges/test_views.py index 004fab0d2d..5c8e92bb2e 100644 --- a/tests/unit/challenges/test_views.py +++ b/tests/unit/challenges/test_views.py @@ -2553,7 +2553,7 @@ def test_get_particular_challenge_phase_if_user_is_challenge_host(self): "codename": "Phase Code Name", "max_submissions_per_day": self.challenge_phase.max_submissions_per_day, "max_submissions": self.challenge_phase.max_submissions, - "max_submissions_per_month": self.challenge_phase.max_submiessions_per_month, + "max_submissions_per_month": self.challenge_phase.max_submissions_per_month, "max_concurrent_submissions_allowed": self.challenge_phase.max_concurrent_submissions_allowed, "test_annotation": "http://testserver%s" % (self.challenge_phase.test_annotation.url), From 3c3749463dd540149996a03b0a118497f349c417 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Mon, 28 Jun 2021 21:32:57 +0530 Subject: [PATCH 07/12] move buttons to settings tab --- .../editphasemodal.component.html | 24 -- .../editphasemodal.component.ts | 159 ------------ .../challengesettings.component.html | 27 +- .../challengesettings.component.scss | 4 + .../challengesettings.component.ts | 230 +++++++++++++++--- 5 files changed, 223 insertions(+), 221 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 9668f15702..b242a83c50 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 @@ -21,30 +21,6 @@ >
-
-
-
Phase Visibility    - - - {{ phaseVisibility.state }} - - - -
-
-
-
-
-
Submission Visibility    - - - {{ submissionVisibility.state }} - - - -
-
-
diff --git a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts index 17cd80a5e2..4f7f5e3fbb 100644 --- a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts +++ b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts @@ -1,11 +1,6 @@ import { ViewChildren, QueryList, Component, Input, OnInit } from '@angular/core'; import { GlobalService } from '../../../../services/global.service'; import { InputComponent } from '../../../utility/input/input.component'; -import { NGXLogger } from 'ngx-logger'; - -import { EndpointsService } from '../../../../services/endpoints.service'; -import { ApiService } from '../../../../services/api.service'; -import { ChallengeService } from '../../../../services/challenge.service'; @Component({ @@ -119,11 +114,6 @@ export class EditphasemodalComponent implements OnInit { */ PerMonthSubmissionValidationMessage = ''; - /** - * If leaderboard is public - */ - isLeaderboardPublic : boolean = false; - /** * Modal accept button */ @@ -149,22 +139,6 @@ export class EditphasemodalComponent implements OnInit { */ editPhaseDetails = true; - /** - * publish challenge state and it's icon - */ - phaseVisibility = { - state: 'Private', - icon: 'fa fa-eye-slash red-text', - }; - - /** - * publish challenge state and it's icon - */ - submissionVisibility = { - state: 'Private', - icon: 'fa fa-eye-slash red-text', - }; - /** * Quill editor style */ @@ -195,10 +169,6 @@ export class EditphasemodalComponent implements OnInit { */ constructor( private globalService: GlobalService, - private apiService: ApiService, - private endpointsService: EndpointsService, - private challengeService: ChallengeService, - private logger: NGXLogger ) {} ngOnInit() { @@ -212,14 +182,6 @@ export class EditphasemodalComponent implements OnInit { if (this.params['phase']) { this.phase = this.params['phase']; } - if (this.params['isPublic']) { - this.phaseVisibility.state = 'Public'; - this.phaseVisibility.icon = 'fa fa-eye green-text'; - } - if (this.params['isSubmissionPublic']) { - this.submissionVisibility.state = 'Public'; - this.submissionVisibility.icon = 'fa fa-eye green-text'; - } if (this.params['label']) { this.label = this.params['label']; } @@ -229,9 +191,6 @@ export class EditphasemodalComponent implements OnInit { if (this.params['description']) { this.description = this.params['description']; } - if(this.params['isLeaderboardPublic']) { - this.isLeaderboardPublic = this.params['isLeaderboardPublic']; - } if (this.params['startDate']) { this.startDate = this.params['startDate']; } @@ -269,124 +228,6 @@ export class EditphasemodalComponent implements OnInit { this.todayDateTime = new Date(); } - /** - * Phase Visibility click function - */ - togglePhaseVisibility() { - const SELF = this; - let togglePhaseVisibilityState, isPublic; - if (this.phaseVisibility.state === 'Public') { - togglePhaseVisibilityState = 'private'; - isPublic = false; - } else { - togglePhaseVisibilityState = 'public'; - isPublic = true; - } - SELF.apiCall = () => { - const BODY: FormData = new FormData(); - BODY.append("is_public", isPublic); - SELF.apiService - .patchFileUrl( - SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.params['challenge'], SELF.params['phase']), - BODY - ) - .subscribe( - (data) => { - SELF.challengeService.fetchPhases(SELF.params['challenge']); - SELF.denied(); - if (isPublic) { - this.phaseVisibility.state = 'Public'; - this.phaseVisibility.icon = 'fa fa-eye green-text'; - } else { - this.phaseVisibility.state = 'Private'; - this.phaseVisibility.icon = 'fa fa-eye-slash red-text'; - } - SELF.globalService.showToast( - 'success', - 'The phase was successfully made ' + togglePhaseVisibilityState, - 5 - ); - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - }, - () => this.logger.info('PHASE-VISIBILITY-UPDATE-FINISHED') - ); - }; - - const PARAMS = { - title: 'Make this phase ' + togglePhaseVisibilityState + '?', - content: '', - confirm: "Yes, I'm sure", - deny: 'No', - confirmCallback: SELF.apiCall, - }; - SELF.globalService.showConfirm(PARAMS); - } - - /** - * Submission Visibility click function - */ - toggleSubmissionVisibility() { - const SELF = this; - if(this.isLeaderboardPublic == true) { - let toggleSubmissionVisibilityState, isSubmissionPublic; - if (this.submissionVisibility.state === 'Public') { - toggleSubmissionVisibilityState = 'private'; - isSubmissionPublic = false; - } else { - toggleSubmissionVisibilityState = 'public'; - isSubmissionPublic = true; - } - SELF.apiCall = () => { - const BODY: FormData = new FormData(); - BODY.append("is_submission_public", isSubmissionPublic); - SELF.apiService - .patchFileUrl( - SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.params['challenge'], SELF.params['phase']), - BODY - ) - .subscribe( - (data) => { - SELF.challengeService.fetchPhases(SELF.params['challenge']); - SELF.denied(); - if (isSubmissionPublic) { - this.submissionVisibility.state = 'Public'; - this.submissionVisibility.icon = 'fa fa-eye green-text'; - } else { - this.submissionVisibility.state = 'Private'; - this.submissionVisibility.icon = 'fa fa-eye-slash red-text'; - } - SELF.globalService.showToast( - 'success', - 'The submissions were successfully made ' + toggleSubmissionVisibilityState, - 5 - ); - }, - (err) => { - SELF.globalService.handleApiError(err, true); - SELF.globalService.showToast('error', err); - }, - () => this.logger.info('SUBMISSION-VISIBILITY-UPDATE-FINISHED') - ); - }; - - const PARAMS = { - title: 'Make the submissions ' + toggleSubmissionVisibilityState + '?', - content: '', - confirm: "Yes, I'm sure", - deny: 'No', - confirmCallback: SELF.apiCall, - }; - SELF.globalService.showConfirm(PARAMS); - } - else { - SELF.globalService.showToast('error', "Leaderboard is private, please make the leaderbaord public"); - SELF.denied(); - } - } - /** * Form Validate function. */ 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 3c46c561a7..3acd616685 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -96,9 +96,32 @@
Challenge Settings
[phaseSelected]="phaseSelected()" #phaseselect > -
- + +
+
+ + + +
+
+ +
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 0de5a6dbb1..f8ba62a738 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss @@ -13,6 +13,10 @@ } } +.phase-card { + width:50vw; +} + @include screen-medium { .settings-section { padding: 10px 20px !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 a83108aec7..920ec1632f 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -89,6 +89,37 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { * Email error message */ message: string; + + /** + * If the submission is public + */ + isSubmissionPublic : boolean = false; + + /** + * If the phase is public + */ + isPhasePublic : boolean = false; + + /** + * If leaderboard is public + */ + isLeaderboardPublic : boolean = false; + + /** + * phase visibility state and it's icon + */ + phaseVisibility = { + state: 'Private', + icon: 'fa fa-eye-slash red-text', + }; + + /** + * submission visibility state and it's icon + */ + submissionVisibility = { + state: 'Private', + icon: 'fa fa-eye-slash red-text', + }; /** * publish challenge state and it's icon @@ -188,55 +219,182 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { const SELF = this; return (phase) => { SELF.selectedPhase = phase; - SELF.apiCall = (params) => { - const FORM_DATA: FormData = new FormData(); - for (const key in params) { - if (params[key]) { - FORM_DATA.append(key, params[key]); - } + SELF.isPhasePublic = SELF.selectedPhase['is_public']; + SELF.isSubmissionPublic = SELF.selectedPhase['is_submission_public']; + SELF.isLeaderboardPublic = SELF.selectedPhase['leaderboard_public']; + if (SELF.isPhasePublic) { + this.phaseVisibility.state = 'Public'; + this.phaseVisibility.icon = 'fa fa-eye green-text'; + } + if (SELF.isSubmissionPublic) { + this.submissionVisibility.state = 'Public'; + this.submissionVisibility.icon = 'fa fa-eye green-text'; + } + }; + } + + editPhaseDetails() { + const SELF = this; + SELF.apiCall = (params) => { + const FORM_DATA: FormData = new FormData(); + for (const key in params) { + if (params[key]) { + FORM_DATA.append(key, params[key]); } + } + SELF.apiService + .patchFileUrl( + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.challenge.id, SELF.selectedPhase['id']), + FORM_DATA + ) + .subscribe( + (data) => { + SELF.selectedPhase = data; + SELF.challengeService.fetchPhases(SELF.challenge['id']); + SELF.globalService.showToast('success', 'The challenge phase details are successfully updated!'); + }, + (err) => { + SELF.globalService.showToast('error', err); + }, + () => {this.logger.info('PHASE-UPDATE-FINISHED')} + ); + }; + + const PARAMS = { + title: 'Edit Challenge Phase Details', + phase: SELF.selectedPhase['id'], + challenge: SELF.selectedPhase['challenge'], + name: SELF.selectedPhase['name'], + label: 'description', + description: SELF.selectedPhase['description'], + startDate: SELF.selectedPhase['start_date'], + endDate: SELF.selectedPhase['end_date'], + maxSubmissionsPerDay: SELF.selectedPhase['max_submissions_per_day'], + 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'], + confirm: 'Submit', + deny: 'Cancel', + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showEditPhaseModal(PARAMS); +} + + /** + * Phase Visibility toggle function + */ + togglePhaseVisibility() { + const SELF = this; + let togglePhaseVisibilityState, isPublic; + if (this.phaseVisibility.state === 'Public') { + togglePhaseVisibilityState = 'private'; + isPublic = false; + } else { + togglePhaseVisibilityState = 'public'; + isPublic = true; + } + SELF.apiCall = () => { + 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.challengeService.fetchPhases(SELF.selectedPhase['challenge']); + if (isPublic) { + this.phaseVisibility.state = 'Public'; + this.phaseVisibility.icon = 'fa fa-eye green-text'; + } else { + this.phaseVisibility.state = 'Private'; + this.phaseVisibility.icon = 'fa fa-eye-slash red-text'; + } + SELF.globalService.showToast( + 'success', + 'The phase was successfully made ' + togglePhaseVisibilityState, + 5 + ); + }, + (err) => { + SELF.globalService.handleApiError(err, true); + SELF.globalService.showToast('error', err); + }, + () => this.logger.info('PHASE-VISIBILITY-UPDATE-FINISHED') + ); + }; + + const PARAMS = { + title: 'Make this phase ' + togglePhaseVisibilityState + '?', + content: '', + confirm: "Yes, I'm sure", + deny: 'No', + confirmCallback: SELF.apiCall, + }; + SELF.globalService.showConfirm(PARAMS); + } + + /** + * Submission Visibility toggle function + */ + toggleSubmissionVisibility() { + const SELF = this; + if(this.isLeaderboardPublic == true) { + let toggleSubmissionVisibilityState, isSubmissionPublic; + if (this.submissionVisibility.state === 'Public') { + toggleSubmissionVisibilityState = 'private'; + isSubmissionPublic = false; + } else { + toggleSubmissionVisibilityState = 'public'; + isSubmissionPublic = true; + } + SELF.apiCall = () => { + const BODY: FormData = new FormData(); + BODY.append("is_submission_public", isSubmissionPublic); SELF.apiService - .patchFileUrl( - SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.challenge.id, SELF.selectedPhase['id']), - FORM_DATA - ) + .patchFileUrl( + SELF.endpointsService.updateChallengePhaseDetailsURL(SELF.selectedPhase['challenge'], SELF.selectedPhase['id']), + BODY + ) .subscribe( (data) => { - SELF.selectedPhase = data; - SELF.challengeService.fetchPhases(SELF.challenge['id']); - SELF.globalService.showToast('success', 'The challenge phase details are successfully updated!'); + SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); + if (isSubmissionPublic) { + this.submissionVisibility.state = 'Public'; + this.submissionVisibility.icon = 'fa fa-eye green-text'; + } else { + this.submissionVisibility.state = 'Private'; + this.submissionVisibility.icon = 'fa fa-eye-slash red-text'; + } + SELF.globalService.showToast( + 'success', + 'The submissions were successfully made ' + toggleSubmissionVisibilityState, + 5 + ); }, (err) => { + SELF.globalService.handleApiError(err, true); SELF.globalService.showToast('error', err); }, - () => {this.logger.info('PHASE-UPDATE-FINISHED')} + () => this.logger.info('SUBMISSION-VISIBILITY-UPDATE-FINISHED') ); }; - + const PARAMS = { - title: 'Edit Challenge Phase Details', - phase: SELF.selectedPhase['id'], - challenge: SELF.selectedPhase['challenge'], - isPublic: SELF.selectedPhase['is_public'], - isSubmissionPublic: SELF.selectedPhase['is_submission_public'], - isLeaderboardPublic: SELF.selectedPhase['leaderboard_public'], - name: SELF.selectedPhase['name'], - label: 'description', - description: SELF.selectedPhase['description'], - startDate: SELF.selectedPhase['start_date'], - endDate: SELF.selectedPhase['end_date'], - maxSubmissionsPerDay: SELF.selectedPhase['max_submissions_per_day'], - 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'], - confirm: 'Submit', - deny: 'Cancel', + title: 'Make the submissions ' + toggleSubmissionVisibilityState + '?', + content: '', + confirm: "Yes, I'm sure", + deny: 'No', confirmCallback: SELF.apiCall, }; - SELF.globalService.showEditPhaseModal(PARAMS); - }; - } + SELF.globalService.showConfirm(PARAMS); + } + else { + SELF.globalService.showToast('error', "Leaderboard is private, please make the leaderbaord public"); + } + } /** * Remove banned email chip From f880797e7040596e3de9a6719e673c8b6e6e61da Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Thu, 1 Jul 2021 14:14:07 +0530 Subject: [PATCH 08/12] change phaseName after details are updated --- .../editphasemodal.component.html | 36 +++++++++---------- .../editphasemodal.component.ts | 6 ---- .../challengesettings.component.ts | 16 +++++++++ .../selectphase/selectphase.component.ts | 15 +++++++- .../src/app/services/challenge.service.ts | 10 ++++++ 5 files changed, 58 insertions(+), 25 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 b242a83c50..924da573c7 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 @@ -135,8 +135,10 @@ >
+ -
+
+
Max Concurrent Submissions Allowed
-
-
-
-
-
Allowed Submission File Types
- -
+
+
+
Allowed Submission File Types
+
+
diff --git a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts index 4f7f5e3fbb..f594a79857 100644 --- a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts +++ b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts @@ -2,7 +2,6 @@ import { ViewChildren, QueryList, Component, Input, OnInit } from '@angular/core import { GlobalService } from '../../../../services/global.service'; import { InputComponent } from '../../../utility/input/input.component'; - @Component({ selector: 'app-editphasemodal', templateUrl: './editphasemodal.component.html', @@ -14,11 +13,6 @@ export class EditphasemodalComponent implements OnInit { */ @Input() params: any; - /** - * To call the API inside modal for editing the challenge details - */ - apiCall: any; - /** * Challenge object */ 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 920ec1632f..4a22fee3ad 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -105,6 +105,11 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ isLeaderboardPublic : boolean = false; + /** + * If leaderboard is public + */ + isPhaseSelected : boolean = false; + /** * phase visibility state and it's icon */ @@ -226,10 +231,18 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { this.phaseVisibility.state = 'Public'; this.phaseVisibility.icon = 'fa fa-eye green-text'; } + else { + this.phaseVisibility.state = 'Private'; + this.phaseVisibility.icon = 'fa fa-eye-slash red-text'; + } if (SELF.isSubmissionPublic) { this.submissionVisibility.state = 'Public'; this.submissionVisibility.icon = 'fa fa-eye green-text'; } + else { + this.submissionVisibility.state = 'Private'; + this.submissionVisibility.icon = 'fa fa-eye-slash red-text'; + } }; } @@ -251,6 +264,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { (data) => { SELF.selectedPhase = data; SELF.challengeService.fetchPhases(SELF.challenge['id']); + SELF.challengeService.changePhaseSelected(true); SELF.globalService.showToast('success', 'The challenge phase details are successfully updated!'); }, (err) => { @@ -305,6 +319,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { .subscribe( (data) => { SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); + SELF.challengeService.changePhaseSelected(true); if (isPublic) { this.phaseVisibility.state = 'Public'; this.phaseVisibility.icon = 'fa fa-eye green-text'; @@ -361,6 +376,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { .subscribe( (data) => { SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); + SELF.challengeService.changePhaseSelected(true); if (isSubmissionPublic) { this.submissionVisibility.state = 'Public'; this.submissionVisibility.icon = 'fa fa-eye green-text'; diff --git a/frontend_v2/src/app/components/utility/selectphase/selectphase.component.ts b/frontend_v2/src/app/components/utility/selectphase/selectphase.component.ts index e24b401af4..6abdfe0c55 100644 --- a/frontend_v2/src/app/components/utility/selectphase/selectphase.component.ts +++ b/frontend_v2/src/app/components/utility/selectphase/selectphase.component.ts @@ -46,6 +46,11 @@ export class SelectphaseComponent implements OnInit, OnChanges { */ phaseVisibility = false; + /** + * If phase selected + */ + isPhaseSelected : boolean = false; + /** * Currently selected phase */ @@ -86,7 +91,15 @@ export class SelectphaseComponent implements OnInit, OnChanges { * Component on changes detected in Input. * @param change changes detected */ - ngOnChanges(change) {} + ngOnChanges(change) { + this.challengeService.isPhaseSelected.subscribe((isPhaseSelected) => { + this.isPhaseSelected = isPhaseSelected; + }); + if(this.isPhaseSelected == true) { + this.challengeService.changePhaseSelected(false); + this.phaseName = ''; + } + } /** * Select a particular phase. diff --git a/frontend_v2/src/app/services/challenge.service.ts b/frontend_v2/src/app/services/challenge.service.ts index 3e78be9cf6..942b3317b8 100644 --- a/frontend_v2/src/app/services/challenge.service.ts +++ b/frontend_v2/src/app/services/challenge.service.ts @@ -33,6 +33,8 @@ export class ChallengeService { currentHostTeam = this.hostTeamSource.asObservable(); private challengeHostSource = new BehaviorSubject(false); isChallengeHost = this.challengeHostSource.asObservable(); + private phaseSelected = new BehaviorSubject(false); + isPhaseSelected = this.phaseSelected.asObservable(); private challengePublishSource = new BehaviorSubject(this.defaultPublishChallenge); currentChallengePublishState = this.challengePublishSource.asObservable(); @@ -66,6 +68,14 @@ export class ChallengeService { this.challengeHostSource.next(isChallengeHost); } + /** + * Update the status for selectPhase component after details are updated + * @param selectedPhase new updated phase details status + */ + changePhaseSelected(selectedPhase: boolean) { + this.phaseSelected.next(selectedPhase); + } + /** * Update challenge publish state and icon for current challenge. * @param publishChallenge new challenge publish status and icon. From 87d2d08f89e81e0a8e072823d83bfc8112ceb673 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Thu, 1 Jul 2021 14:24:15 +0530 Subject: [PATCH 09/12] remove unnecessary variable --- .../challengesettings.component.ts | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 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 4a22fee3ad..b5c3585baa 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -105,11 +105,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ isLeaderboardPublic : boolean = false; - /** - * If leaderboard is public - */ - isPhaseSelected : boolean = false; - /** * phase visibility state and it's icon */ @@ -228,20 +223,20 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.isSubmissionPublic = SELF.selectedPhase['is_submission_public']; SELF.isLeaderboardPublic = SELF.selectedPhase['leaderboard_public']; if (SELF.isPhasePublic) { - this.phaseVisibility.state = 'Public'; - this.phaseVisibility.icon = 'fa fa-eye green-text'; + SELF.phaseVisibility.state = 'Public'; + SELF.phaseVisibility.icon = 'fa fa-eye green-text'; } else { - this.phaseVisibility.state = 'Private'; - this.phaseVisibility.icon = 'fa fa-eye-slash red-text'; + SELF.phaseVisibility.state = 'Private'; + SELF.phaseVisibility.icon = 'fa fa-eye-slash red-text'; } if (SELF.isSubmissionPublic) { - this.submissionVisibility.state = 'Public'; - this.submissionVisibility.icon = 'fa fa-eye green-text'; + SELF.submissionVisibility.state = 'Public'; + SELF.submissionVisibility.icon = 'fa fa-eye green-text'; } else { - this.submissionVisibility.state = 'Private'; - this.submissionVisibility.icon = 'fa fa-eye-slash red-text'; + SELF.submissionVisibility.state = 'Private'; + SELF.submissionVisibility.icon = 'fa fa-eye-slash red-text'; } }; } @@ -265,6 +260,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.selectedPhase = data; SELF.challengeService.fetchPhases(SELF.challenge['id']); SELF.challengeService.changePhaseSelected(true); + SELF.selectedPhase = false; SELF.globalService.showToast('success', 'The challenge phase details are successfully updated!'); }, (err) => { @@ -301,7 +297,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { togglePhaseVisibility() { const SELF = this; let togglePhaseVisibilityState, isPublic; - if (this.phaseVisibility.state === 'Public') { + if (SELF.phaseVisibility.state === 'Public') { togglePhaseVisibilityState = 'private'; isPublic = false; } else { @@ -321,12 +317,13 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); SELF.challengeService.changePhaseSelected(true); if (isPublic) { - this.phaseVisibility.state = 'Public'; - this.phaseVisibility.icon = 'fa fa-eye green-text'; + SELF.phaseVisibility.state = 'Public'; + SELF.phaseVisibility.icon = 'fa fa-eye green-text'; } else { - this.phaseVisibility.state = 'Private'; - this.phaseVisibility.icon = 'fa fa-eye-slash red-text'; + SELF.phaseVisibility.state = 'Private'; + SELF.phaseVisibility.icon = 'fa fa-eye-slash red-text'; } + SELF.selectedPhase = false; SELF.globalService.showToast( 'success', 'The phase was successfully made ' + togglePhaseVisibilityState, @@ -356,9 +353,9 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ toggleSubmissionVisibility() { const SELF = this; - if(this.isLeaderboardPublic == true) { + if(SELF.isLeaderboardPublic == true) { let toggleSubmissionVisibilityState, isSubmissionPublic; - if (this.submissionVisibility.state === 'Public') { + if (SELF.submissionVisibility.state === 'Public') { toggleSubmissionVisibilityState = 'private'; isSubmissionPublic = false; } else { @@ -378,12 +375,13 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); SELF.challengeService.changePhaseSelected(true); if (isSubmissionPublic) { - this.submissionVisibility.state = 'Public'; - this.submissionVisibility.icon = 'fa fa-eye green-text'; + SELF.submissionVisibility.state = 'Public'; + SELF.submissionVisibility.icon = 'fa fa-eye green-text'; } else { - this.submissionVisibility.state = 'Private'; - this.submissionVisibility.icon = 'fa fa-eye-slash red-text'; + SELF.submissionVisibility.state = 'Private'; + SELF.submissionVisibility.icon = 'fa fa-eye-slash red-text'; } + SELF.selectedPhase = false; SELF.globalService.showToast( 'success', 'The submissions were successfully made ' + toggleSubmissionVisibilityState, From ef49376b1578456cde9e06e3727e591a1719f82f Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Thu, 1 Jul 2021 14:27:11 +0530 Subject: [PATCH 10/12] remove the challenge and phase id from editphase modal --- .../editphasemodal/editphasemodal.component.ts | 16 ---------------- .../challengesettings.component.ts | 2 -- 2 files changed, 18 deletions(-) diff --git a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts index f594a79857..b74a9fab77 100644 --- a/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts +++ b/frontend_v2/src/app/components/challenge/challengephases/editphasemodal/editphasemodal.component.ts @@ -13,16 +13,6 @@ export class EditphasemodalComponent implements OnInit { */ @Input() params: any; - /** - * Challenge object - */ - challenge: any; - - /** - * Challenge object - */ - phase: any; - /** * Modal title */ @@ -170,12 +160,6 @@ export class EditphasemodalComponent implements OnInit { if (this.params['title']) { this.title = this.params['title']; } - if (this.params['challenge']) { - this.challenge = this.params['challenge']; - } - if (this.params['phase']) { - this.phase = this.params['phase']; - } if (this.params['label']) { this.label = this.params['label']; } 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 b5c3585baa..829ea37f6b 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -272,8 +272,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { const PARAMS = { title: 'Edit Challenge Phase Details', - phase: SELF.selectedPhase['id'], - challenge: SELF.selectedPhase['challenge'], name: SELF.selectedPhase['name'], label: 'description', description: SELF.selectedPhase['description'], From e054b68d90e1e35cc866bee27f710976b11a2f21 Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Fri, 9 Jul 2021 12:47:16 +0530 Subject: [PATCH 11/12] add toggle feature --- .../challengesettings.component.html | 48 +++++++------ .../challengesettings.component.scss | 4 ++ .../challengesettings.component.ts | 72 ++++++++----------- 3 files changed, 58 insertions(+), 66 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 3acd616685..dd11701aaf 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -89,35 +89,37 @@
Challenge Settings

- - -
-
+
+ - -
+ +
+ + Phase Visibility + + + +      + + Submission Visibility + + + +
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 f8ba62a738..543e84f175 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.scss @@ -17,6 +17,10 @@ width:50vw; } +.phase-button { + margin-left: 25px; +} + @include screen-medium { .settings-section { padding: 10px 20px !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 829ea37f6b..494c5b9772 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.ts @@ -110,7 +110,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ phaseVisibility = { state: 'Private', - icon: 'fa fa-eye-slash red-text', + icon: 'fa fa-toggle-off', }; /** @@ -118,7 +118,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ submissionVisibility = { state: 'Private', - icon: 'fa fa-eye-slash red-text', + icon: 'fa fa-toggle-off', }; /** @@ -126,7 +126,7 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { */ publishChallenge = { state: 'Not Published', - icon: 'fa fa-eye-slash red-text', + icon: 'fa fa-toggle-off', }; /** @@ -224,19 +224,19 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { SELF.isLeaderboardPublic = SELF.selectedPhase['leaderboard_public']; if (SELF.isPhasePublic) { SELF.phaseVisibility.state = 'Public'; - SELF.phaseVisibility.icon = 'fa fa-eye green-text'; + SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; } else { SELF.phaseVisibility.state = 'Private'; - SELF.phaseVisibility.icon = 'fa fa-eye-slash red-text'; + SELF.phaseVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; } if (SELF.isSubmissionPublic) { SELF.submissionVisibility.state = 'Public'; - SELF.submissionVisibility.icon = 'fa fa-eye green-text'; + SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; } else { SELF.submissionVisibility.state = 'Private'; - SELF.submissionVisibility.icon = 'fa fa-eye-slash red-text'; + SELF.submissionVisibility.icon = 'fa fa-toggle-off grey-text text-darken-1'; } }; } @@ -298,11 +298,14 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { if (SELF.phaseVisibility.state === 'Public') { togglePhaseVisibilityState = 'private'; isPublic = false; + SELF.phaseVisibility.state = 'Private'; + SELF.phaseVisibility.icon = 'fa fa-toggle-off'; } else { togglePhaseVisibilityState = 'public'; isPublic = true; + SELF.phaseVisibility.state = 'Public'; + SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; } - SELF.apiCall = () => { const BODY: FormData = new FormData(); BODY.append("is_public", isPublic); SELF.apiService @@ -314,13 +317,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { (data) => { SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); SELF.challengeService.changePhaseSelected(true); - if (isPublic) { - SELF.phaseVisibility.state = 'Public'; - SELF.phaseVisibility.icon = 'fa fa-eye green-text'; - } else { - SELF.phaseVisibility.state = 'Private'; - SELF.phaseVisibility.icon = 'fa fa-eye-slash red-text'; - } SELF.selectedPhase = false; SELF.globalService.showToast( 'success', @@ -331,19 +327,16 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { (err) => { SELF.globalService.handleApiError(err, true); SELF.globalService.showToast('error', err); + if (isPublic) { + SELF.phaseVisibility.state = 'Private'; + SELF.phaseVisibility.icon = 'fa fa-toggle-off'; + } else { + SELF.phaseVisibility.state = 'Public'; + SELF.phaseVisibility.icon = 'fa fa-toggle-on green-text'; + } }, () => this.logger.info('PHASE-VISIBILITY-UPDATE-FINISHED') ); - }; - - const PARAMS = { - title: 'Make this phase ' + togglePhaseVisibilityState + '?', - content: '', - confirm: "Yes, I'm sure", - deny: 'No', - confirmCallback: SELF.apiCall, - }; - SELF.globalService.showConfirm(PARAMS); } /** @@ -356,11 +349,14 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { if (SELF.submissionVisibility.state === 'Public') { toggleSubmissionVisibilityState = 'private'; isSubmissionPublic = false; + SELF.submissionVisibility.state = 'Private'; + SELF.submissionVisibility.icon = 'fa fa-toggle-off'; } else { toggleSubmissionVisibilityState = 'public'; isSubmissionPublic = true; + SELF.submissionVisibility.state = 'Public'; + SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; } - SELF.apiCall = () => { const BODY: FormData = new FormData(); BODY.append("is_submission_public", isSubmissionPublic); SELF.apiService @@ -372,13 +368,6 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { (data) => { SELF.challengeService.fetchPhases(SELF.selectedPhase['challenge']); SELF.challengeService.changePhaseSelected(true); - if (isSubmissionPublic) { - SELF.submissionVisibility.state = 'Public'; - SELF.submissionVisibility.icon = 'fa fa-eye green-text'; - } else { - SELF.submissionVisibility.state = 'Private'; - SELF.submissionVisibility.icon = 'fa fa-eye-slash red-text'; - } SELF.selectedPhase = false; SELF.globalService.showToast( 'success', @@ -389,19 +378,16 @@ export class ChallengesettingsComponent implements OnInit, OnDestroy { (err) => { SELF.globalService.handleApiError(err, true); SELF.globalService.showToast('error', err); + if (isSubmissionPublic) { + SELF.submissionVisibility.state = 'Private'; + SELF.submissionVisibility.icon = 'fa fa-toggle-off'; + } else { + SELF.submissionVisibility.state = 'Public'; + SELF.submissionVisibility.icon = 'fa fa-toggle-on green-text'; + } }, () => this.logger.info('SUBMISSION-VISIBILITY-UPDATE-FINISHED') ); - }; - - const PARAMS = { - title: 'Make the submissions ' + toggleSubmissionVisibilityState + '?', - content: '', - confirm: "Yes, I'm sure", - deny: 'No', - confirmCallback: SELF.apiCall, - }; - SELF.globalService.showConfirm(PARAMS); } else { SELF.globalService.showToast('error', "Leaderboard is private, please make the leaderbaord public"); From 82d28e3fe5ff8cad0cfa40a10ac2a5537ed359cb Mon Sep 17 00:00:00 2001 From: gautamjajoo Date: Sun, 11 Jul 2021 02:04:01 +0530 Subject: [PATCH 12/12] fix toggle buttons --- .../challengesettings/challengesettings.component.html | 8 ++++---- 1 file changed, 4 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 0914500cc3..796a9092f8 100644 --- a/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html +++ b/frontend_v2/src/app/components/challenge/challengesettings/challengesettings.component.html @@ -125,16 +125,16 @@
Challenge Settings
- - Phase Visibility + + Is Public - +      Submission Visibility - +