Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Modified challenge create page #150

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
04ad7bb
Changes in app component
sanketbansal Jun 5, 2019
c8fdf72
Modified app loader component
sanketbansal Jun 5, 2019
7d6f704
Ported image assets
sanketbansal Jun 1, 2019
6c0fe96
Added styles from angularjs
sanketbansal Jun 4, 2019
b885567
Modified angular.json file
sanketbansal Jun 5, 2019
ec393e1
changes in style files
sanketbansal Jun 10, 2019
ae9e129
Modified auth service
sanketbansal Jun 5, 2019
231c791
Removed routing from auth service
sanketbansal Jun 5, 2019
8434281
Modified footer
sanketbansal Jun 10, 2019
c9fa048
Modified footer component
sanketbansal Jun 4, 2019
c19e1dd
Added simple header component
sanketbansal Jun 10, 2019
f7c0e02
Added side bar component
sanketbansal Jun 5, 2019
cf71243
Added dash footer component
sanketbansal Jun 6, 2019
f6b4ca7
Modifications in simple header component
sanketbansal Jun 12, 2019
3d4501c
Modified app component
sanketbansal Jun 14, 2019
509b456
Modified challenge create component
sanketbansal Jun 15, 2019
2e86b64
Moved styles in challenge-create component
sanketbansal Jun 29, 2019
9800399
Fixed lint error in angular.json file
sanketbansal Jul 14, 2019
233ef29
Removed unused css from main.scss
sanketbansal Jul 19, 2019
d055931
Removed unused assets and styles folder
sanketbansal Jul 19, 2019
e59a4f8
Removed unused and duplicate code
sanketbansal Jul 19, 2019
cacd573
Added style files
sanketbansal Jul 19, 2019
b602568
Removed unused css from main.scss
sanketbansal Jul 19, 2019
d59a542
removed basic.scss file
sanketbansal Jul 19, 2019
d4e4c57
Added basic styles
sanketbansal Jul 19, 2019
b75ae8e
Removed duplicate styles
sanketbansal Jul 19, 2019
e424d30
Removed logs
sanketbansal Jul 19, 2019
d800edc
Removed main.scss file
sanketbansal Jul 19, 2019
8b9259d
Added component specific styles
sanketbansal Jul 19, 2019
9fe9dd8
changes made in html files
sanketbansal Jul 19, 2019
6456296
Modified app loader component
sanketbansal Jul 20, 2019
723e6b8
Added feature to start stop loader
sanketbansal Jun 22, 2019
e663563
Added styles for loading component
sanketbansal Jul 20, 2019
8d5a2b4
Added loader component
sanketbansal Jul 20, 2019
fb4e327
Removed comments
sanketbansal Jul 20, 2019
b63855b
changes in challenge-create page
sanketbansal Jul 24, 2019
bf1a67d
Merge branch 'master' into modified-challengeCreate
lunayach Jul 31, 2019
c475e70
Merge branch 'master' into modified-challengeCreate
lunayach Aug 1, 2019
c5d45ae
Changes in challenge-create component
sanketbansal Aug 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 46 additions & 19 deletions src/app/components/challenge-create/challenge-create.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
<app-header-static>
</app-header-static>
<div class="container-top">
<div class="create-challenge-container">
<div class="create-challenge-title">
Create Challenge
</div>
<app-forcelogin [path]="'/challenge-create'" *ngIf="!authServicePublic.isLoggedIn()"></app-forcelogin>
<div class="card card-light" *ngIf="authServicePublic.isLoggedIn()">

<div class="create-form">
<div class="title">Please upload zip file to create a challenge!</div>
<app-input [isRequired]="true" [label]="'zip_configuration'" [placeholder]="'Upload File *'" [type]="'file'" [theme]="'dark'" #formcreate></app-input>
<div class="submit-btn-div">
<span class="btn btn-filter selected" (click)="formValidate('formcreate')">Submit</span>
<app-side-bar *ngIf="authService.isAuth"></app-side-bar>
<app-header-static></app-header-static>
<div class="web-container" [style.center]="!authService.isAuth">
<div class="challenge-create-flex">
<div class="challenge-create-content">

<section class="ev-md-container text-center ">
<div class="row">
<div class="col s12 m9 offset-m3">
<div class="zip-file-title">Please upload zip file to create a challenge!</div>
<div class="file-field input-field col s6">
<form name="ChallengeCreateForm" #ChallengeCreateForm="ngForm" (ngSubmit)="challengeCreate()" novalidate>
<div class="waves-effect waves-dark btn ev-btn-dark w-300 fs-14">
<span>Upload File</span>
<input name="input_file" (change)="handleUpload($event)" accept=".json, .zip, .txt" type="file" class="text-dark-black dark-autofill w-400" [(ngModel)]="ChallengeCreateForm['input_file']">
</div>

<div class="file-path-wrapper">
<input disabled class="file-path validate" name="file_path" type="text">
<div *ngIf="isFormError" class="wrn-msg text-highlight fs-12"> Please Upload File </div>
</div>

<div class="align-left reg-control">
<button class="btn ev-btn-dark waves-effect waves-dark grad-btn grad-btn-dark fs-14" type="submit" value="Submit">Submit</button>
</div>

</form>
</div>
</div>
</div>
</div>
<div>
<i class="fas fa-info-circle"></i>
<div class="row">
<div class="col s12 m9 offset-m3">
<i class="fa fa-info-circle"></i>
To know how to create a challenge using zip file configuration, please see our documentation
<a href="https://evalai.readthedocs.io/en/latest/challenge_creation.html#challenge-creation-using-zip-configuration" class="highlight-link" target="_blank">here.</a>.
</div>
</div>
<div *ngIf="isSyntaxErrorInYamlFile" class="row">
<hr class="hr-line">
<div class="col s12 m9 offset-m3">
<div class="syntax-wrn-msg text-highlight">
The YAML file in the challenge configuration contains the following error - <br>
{{syntaxErrorInYamlFile}}
</div>
</div>
</div>
</section>

</div>
<app-footer [isDash]="true" *ngIf="authService.isAuth"></app-footer>
</div>
</div>
<app-footer></app-footer>

<app-footer *ngIf="!authService.isAuth"></app-footer>
101 changes: 67 additions & 34 deletions src/app/components/challenge-create/challenge-create.component.scss
Original file line number Diff line number Diff line change
@@ -1,38 +1,71 @@
@import './variables.scss';
@import './mixins.scss';

.create-challenge-container {
@include box-shadow(0px, 0px, 5px, 0px, $overlay-light);
width:90%;
margin: 0 auto;
background:$gray-lighter;
color:$gray-darker;
border-radius:10px;
margin-top:50px;
margin-bottom:100px;
padding:20px;
text-align:center;
.create-challenge-title {
font-size:$fs-24;
}
.card {
display:inline-block;
padding:30px;
text-align:center;
max-width:500px;
@import "styles/variables";

.challenge-create-flex {
display: flex;
flex-direction: column;
min-height: 100vh;
}

.challenge-create-content {
flex: 1;
min-height: 100vh;
}

.web-container {
width: calc(100vw - 223px);
float: right;
padding-top: 70px;
overflow-x: hidden;
&.center {
float: none;
margin: 0 auto;
text-align: left;
overflow: hidden;
}
.create-form {
text-align:left;
display:inline-block;
margin:30px;
.title {
margin-bottom:10px;
}
}

.zip-file-title {
margin-bottom: 20px;
margin-left: 11px;
}

.syntax-wrn-msg {
font-size: 1em;
}

.hr-line {
line-height: 1em;
position: relative;
outline: 0;
border: 0;
color: black;
text-align: center;
height: 1.5em;
opacity: .5;
&:before {
content: '';
background: linear-gradient(to right, transparent, #818078, transparent);
position: absolute;
left: 0;
top: 50%;
width: 100%;
height: 1px;
}
.submit-btn-div {
.btn {
margin-left:0;
}
&:after {
content: '';
position: relative;
display: inline-block;
padding: 0 .5em;
line-height: 1.5em;
color: #818078;
background-color: #fcfcfa;
}
}

}
/*media queries*/

@media only screen and (max-width: $med-screen) {
.web-container {
width: 100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { HttpClientModule } from '@angular/common/http';
import {Router, Routes} from '@angular/router';
import {NotFoundComponent} from '../not-found/not-found.component';
import {FormsModule} from '@angular/forms';

const routes: Routes = [
{
Expand All @@ -39,7 +40,7 @@ describe('ChallengecreateComponent', () => {
TestBed.configureTestingModule({
declarations: [ ChallengeCreateComponent, HeaderStaticComponent, FooterComponent, NotFoundComponent ],
schemas: [ NO_ERRORS_SCHEMA ],
imports: [ RouterTestingModule.withRoutes(routes), HttpClientModule ],
imports: [ RouterTestingModule.withRoutes(routes), HttpClientModule, FormsModule],
providers: [ GlobalService, AuthService, ApiService, ChallengeService, EndpointsService ]
})
.compileComponents();
Expand Down
90 changes: 59 additions & 31 deletions src/app/components/challenge-create/challenge-create.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Component, OnInit, ViewChildren, QueryList } from '@angular/core';
import {Component, OnInit, ViewChildren, QueryList, Inject} from '@angular/core';
import { AuthService } from '../../services/auth.service';
import { ApiService } from '../../services/api.service';
import { GlobalService } from '../../services/global.service';
import { ChallengeService } from '../../services/challenge.service';
import { Router, ActivatedRoute } from '@angular/router';
import {DOCUMENT} from '@angular/common';

/**
* Component Class
Expand All @@ -15,6 +16,14 @@ import { Router, ActivatedRoute } from '@angular/router';
})
export class ChallengeCreateComponent implements OnInit {

isFormError = false;
isSyntaxErrorInYamlFile = false;
ChallengeCreateForm = {
input_file: null,
file_path: null
};
syntaxErrorInYamlFile = {};

/**
* Auth Service public instance
*/
Expand All @@ -31,32 +40,33 @@ export class ChallengeCreateComponent implements OnInit {
routerPublic = null;

/**
* Form fields name
* Selected Host team object
*/
submitForm = 'formcreate';
hostTeam: any = null;

/**
* Selected Host team object
* Route for hosted challenges
*/
hostTeam: any = null;
hostedChallengesRoute = '/challenges/me';

/**
* Component Class
* Route path for host teams
*/
@ViewChildren('formcreate')
components: QueryList<ChallengeCreateComponent>;
hostTeamsRoute = '/teams/hosts';

/**
* Constructor.
* @param route ActivatedRoute Injection.
* @param router Router Injection.
* @param authService AuthService Injection.
* @param document
* @param globalService GlobalService Injection.
* @param apiService ApiService Injection.
* @param challengeService ChallengeService Injection.
*/
constructor(private authService: AuthService, private router: Router, private route: ActivatedRoute,
private challengeService: ChallengeService, private globalService: GlobalService, private apiService: ApiService) { }
constructor(public authService: AuthService, private router: Router, private route: ActivatedRoute,
private challengeService: ChallengeService, @Inject(DOCUMENT) private document,
private globalService: GlobalService, private apiService: ApiService) { }

/**
* Component on initialized.
Expand All @@ -73,33 +83,51 @@ export class ChallengeCreateComponent implements OnInit {
setTimeout(() => {
this.globalService.showToast('info', 'Please select a host team');
}, 1000);
this.router.navigate(['/teams/hosts']);
this.router.navigate([this.hostTeamsRoute]);
}
});
}

/**
* Form Validate function.
*/
formValidate(formname) {
this.globalService.formValidate(this.components, this.formSubmit, this);
challengeCreate() {
if (this.ChallengeCreateForm['input_file'] !== null) {
const FORM_DATA: FormData = new FormData();
FORM_DATA.append('status', 'submitting');
FORM_DATA.append('zip_configuration', this.ChallengeCreateForm['input_file']);
this.globalService.startLoader('Creating Challenge');
this.challengeService.challengeCreate(
this.hostTeam['id'],
FORM_DATA,
).subscribe(
data => {
this.globalService.stopLoader();
this.globalService.showToast('success', 'Successfuly sent to EvalAI admin for approval.');
this.router.navigate([this.hostedChallengesRoute]);
},
err => {
this.globalService.stopLoader();
this.globalService.showToast('error', err.error.error);
this.isSyntaxErrorInYamlFile = true;
this.syntaxErrorInYamlFile = err.error.error;
},
() => {}
);
} else {
this.isFormError = true;
this.globalService.showToast('error', 'Please Upload File');
}
}

/**
* Form Submit function (Called after validation).
*/
formSubmit(self) {
const FORM_DATA: FormData = new FormData();
FORM_DATA.append('status', 'submitting');
FORM_DATA.append('zip_configuration', self.globalService.formItemForLabel(self.components, 'zip_configuration').fileSelected);
const SUCCESS_CALLBACK = () => {
self.router.navigate(['/challenges/me']);
};
self.challengeService.challengeCreate(
self.hostTeam['id'],
FORM_DATA,
SUCCESS_CALLBACK
);
handleUpload(event) {
const files = event.target.files;

if (files.length >= 1) {
this.isFormError = false;
this.ChallengeCreateForm['input_file'] = event.target.files[0];
this.ChallengeCreateForm['file_path'] = event.target.files[0]['name'];
this.document.getElementsByClassName('file-path')[0].value = event.target.files[0]['name'];
} else {
this.isFormError = true;
}
}

}
13 changes: 1 addition & 12 deletions src/app/services/challenge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,18 +352,7 @@ export class ChallengeService {
*/
challengeCreate(hostTeam, formData, callback = () => {}) {
const API_PATH = this.endpointsService.challengeCreateURL(hostTeam);
const SELF = this;
this.apiService.postFileUrl(API_PATH, formData).subscribe(
data => {
SELF.globalService.showToast('success', 'Successfuly sent to EvalAI admin for approval.');
callback();
},
err => {
SELF.globalService.showToast('error', err.error);
},
() => {
console.log('Challenge Creation Zip Uploaded');
});
return this.apiService.postFileUrl(API_PATH, formData);
}


Expand Down