Commit 87f00b30 authored by Barbora Kompisova's avatar Barbora Kompisova
Browse files

added secrets module

parent 8d62f313
Loading
Loading
Loading
Loading
+33 −29
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import {SubmissionService} from '../services/submission.service';
import { AngularMultiSelectModule } from 'angular2-multiselect-dropdown';
import { CourseQueryParamResolver } from '../resolvers/course-query-param-resolver.service';
import { ProjectQueryParamResolver } from '../resolvers/project-query-param-resolver.service';
import { WorkerService } from '../services/worker.service';
import { SecretsModule } from '../secrets/secrets.module';

@NgModule({
  imports: [
@@ -47,7 +49,8 @@ import {ProjectQueryParamResolver} from '../resolvers/project-query-param-resolv
    AuthModule,
    CoreRoutingModule,
    AngularMultiSelectModule,
    SharedModule
    SharedModule,
    SecretsModule
  ],
  declarations: [
    PageNotFoundComponent,
@@ -57,6 +60,7 @@ import {ProjectQueryParamResolver} from '../resolvers/project-query-param-resolv
  providers: [
    AuthService,
    UserService,
    WorkerService,
    CourseService,
    ProjectService,
    PermissionsService,
+7 −6
Original line number Diff line number Diff line
import { Component, Input, LOCALE_ID, OnInit } from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { Project, ProjectConfig, User } from '../../../shared/models/models';
import { ProjectService } from '../../../services/project.service';
@@ -47,7 +47,8 @@ export class ProjectConfigComponent implements OnInit {
  }

  initFormValues() {

    const dateFormat = 'yyyy-MM-dd HH:mm';
    // TODO: revamp date -> date, time, validate input
    this.configData.setValue({
      testFilesSource: [ this.project.config.test_files_source ],
      fileWhitelist: [ this.project.config.file_whitelist ],
@@ -55,9 +56,9 @@ export class ProjectConfigComponent implements OnInit {
      postSubmitScript: [ this.project.config.post_submit_script ],
      submissionParameters: [ this.project.config.submission_parameters ],
      submissionSchedulerConfig: [ this.project.config.submission_scheduler_config ],
      submissionsAllowedFrom: [ this.datePipe.transform(this.project.config.submissions_allowed_from,) ],
      submissionsAllowedTo: [ this.datePipe.transform(this.project.config.submissions_allowed_to, 'yyyy-MM-ddTHH:mm') ],
      archiveFrom: [ this.datePipe.transform(this.project.config.archive_from, 'yyyy-MM-ddTHH:mm') ]
      submissionsAllowedFrom: [ this.datePipe.transform(this.project.config.submissions_allowed_from, dateFormat) ],
      submissionsAllowedTo: [ this.datePipe.transform(this.project.config.submissions_allowed_to, dateFormat) ],
      archiveFrom: [ this.datePipe.transform(this.project.config.archive_from, dateFormat) ]
    });
  }

@@ -83,7 +84,7 @@ export class ProjectConfigComponent implements OnInit {
    this.projectService.updateProjectConfig(newValues).subscribe(
      () => {
        this.router.onSameUrlNavigation = 'reload';
        this.router.navigate([ '.' ], { relativeTo: this.route }).then(() => {
        this.router.navigate([ '.' ], { relativeTo: this.route, preserveQueryParams: true }).then(() => {
          this.flashMessagesService.show('Configuration update successful.', { cssClass: 'alert-success' });
        });
      }, (error: any) => {
+83 −0
Original line number Diff line number Diff line
<div class="container">

  <div class="page-header">
    <h1>{{secret?.name}}</h1>

    <div class="row page-controls">
      <div class="col-lg-4" *ngIf="loggedInUser?.is_admin">
        <button
          data-toggle="modal"
          data-target="#delete_secret_modal" class="btn btn-danger pull-right">
          Delete
        </button>
      </div>
    </div>
  </div>


  <div class="col-md-9 page-body">
    <h3>{{secret?.name}}</h3>
    <form [formGroup]="formData">
      <div class="form-group row">
        <label for="name" class="col-lg-3 control-label">Name:</label>
        <div class="col-lg-8">
          <input type="text" id="name" formControlName="name" class="form-control" required>
        </div>
      </div>

      <div class="form-group row">
        <label for="created_at" class="col-lg-3 control-label">Created at:</label>
        <div class="col-lg-8">
          <input [attr.disabled]="true" type="text" id="created_at" formControlName="created_at" class="form-control" required>
        </div>
      </div>


      <div class="form-group row">
        <label for="expires_at" class="col-lg-3 control-label">Expires at:</label>
        <div class="col-lg-8">
          <input id="expires_at" formControlName="expires_at" class="form-control">
        </div>
      </div>


      <!--div class="form-group row">
        <div class="col-md-3">
          <button [attr.disabled]="formData?.status === 'VALID' ? null : true" class="btn btn-primary btn-signin"
                  type="submit"
                  (click)="updateProject()">
            Update
          </button>
        </div>
        <div class="col-md-3">
          <button class="btn btn-default" (click)="resetForm()">Revert</button>
        </div>
      </div-->
    </form>
  </div>
</div>

<div>

  <div id="delete_secret_modal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title">Delete secret</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>
        <div class="modal-body">
          <p>Do you wish to delete secret: <strong>{{secret?.name}}</strong>?
          </p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary" data-dismiss="modal" (click)="deleteSecret()">Yes</button>
          <button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
        </div>
      </div>
    </div>
  </div>
</div>
+0 −0

Empty file added.

+25 −0
Original line number Diff line number Diff line
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SecretDetailComponent } from './secret-detail.component';

describe('SecretDetailComponent', () => {
  let component: SecretDetailComponent;
  let fixture: ComponentFixture<SecretDetailComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ SecretDetailComponent ]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(SecretDetailComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });
});
Loading