Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2,816 changes: 1,715 additions & 1,101 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.900.5",
"@angular/cli": "~9.0.4",
"@angular-devkit/build-angular": "^0.901.0",
"@angular/cli": "^9.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is wrong.

"@angular/compiler-cli": "~9.0.3",
"@angular/language-service": "~9.0.3",
"@types/jasmine": "~3.5.0",
Expand Down
8 changes: 5 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { NavbarComponent } from './modules/shared/components/navbar/navbar.component';
Expand All @@ -24,7 +23,8 @@ import { GroupByDatePipe } from './modules/shared/pipes/group-by-date/group-by-d
import { ActivitiesManagementComponent } from './modules/activities-management/pages/activities-management.component';
import { ActivityListComponent } from './modules/activities-management/components/activity-list/activity-list.component';
import { CreateActivityComponent } from './modules/activities-management/components/create-activity/create-activity.component';

import { FilterProjectPipe } from './modules/shared/pipes/filter-project/filter-project.pipe';
import { SearchProjectComponent } from './modules/shared/components/search-project/search-project.component';

@NgModule({
declarations: [
Expand All @@ -47,7 +47,9 @@ import { CreateActivityComponent } from './modules/activities-management/compone
GroupByDatePipe,
ActivitiesManagementComponent,
CreateActivityComponent,
ActivityListComponent
ActivityListComponent,
FilterProjectPipe,
SearchProjectComponent,
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<div class="card-body">
<div class="scroll">
<div class="accordion" id="accordionActivities">
<div *ngIf="activities?.length > 0; else notShow">
<div class="card" *ngFor="let activity of activities; let rowIndex = index">
<div class="card-header">
<h2 class="mb-0">
<a type="button" data-toggle="collapse" [attr.data-target]="'#row'+rowIndex">
{{activity.name}}
</a>
<div class="btn-group float-right" role="group">
<i class="far fa-edit btn btn-link"></i>
<i class="far fa-trash-alt btn btn-link"></i>
</div>
</h2>
</div>
<div class="scroll">
<div class="accordion" id="accordionActivities">
<div *ngIf="activities?.length > 0; else notShow">
<div class="card" *ngFor="let activity of activities; let rowIndex = index">
<div class="card-header">
<h2 class="mb-0">
<a type="button" data-toggle="collapse" [attr.data-target]="'#row'+rowIndex">
{{activity.name}}
</a>
<div class="btn-group float-right" role="group">
<i class="far fa-edit btn btn-link"></i>
<i class="far fa-trash-alt btn btn-link"></i>
</div>
</h2>
</div>

<div [id]="'row'+rowIndex" class="collapse" data-parent="#accordionActivities">
<div class="card-body">
<h5>Description:</h5>
<p>{{activity.description}}</p>
</div>
</div>
</div>
<div [id]="'row'+rowIndex" class="collapse" data-parent="#accordionActivities">
<div class="card-body">
<h5>Description:</h5>
<p>{{activity.description}}</p>
</div>
<ng-template #notShow>
<app-empty-state></app-empty-state>
</ng-template>
</div>
</div>
</div>
<ng-template #notShow>
<app-empty-state></app-empty-state>
</ng-template>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ <h1 class="card-title">Project</h1>
<div class="form-group">
<label for="name">Name:</label>
<input class="form-control" id="name" type="text" formControlName="name" required>
<p class="alert alert-danger" *ngIf="(name.dirty || name.touched) && name.invalid && name.errors.required">Name Project is required.</p>
<p class="alert alert-danger" *ngIf="(name.dirty || name.touched) && name.invalid && name.errors.required">NameProject is required.</p>
</div>

<div class="form-group">
<label for="details">Details:</label>
<textarea class="form-control" rows="3" id="details" type="text" formControlName="details" required></textarea>
<p class="alert alert-danger" *ngIf="(details.dirty || details.touched) && details.invalid && details.errors.required">Details Project is required.</p>
<p class="alert alert-danger" *ngIf="(details.dirty || details.touched) && details.invalid && details.errors.required">Details Project is
required.</p>
</div>

<div class="form-group">
<label for="status">Status:</label>
<select class="form-control" formControlName="status">
<option *ngFor="let status of projectStatus" [value]="status">{{status}}</option>
</select>
<p class="alert alert-danger" *ngIf="(status.dirty || status.touched) && status.invalid && status.errors.required">Status Project is required.</p>
<p class="alert alert-danger" *ngIf="(status.dirty || status.touched) && status.invalid && status.errors.required">Status Project is required.
</p>
</div>

<div class="form-group form-check" [hidden]="!projectToEdit">
Expand All @@ -35,4 +37,4 @@ <h1 class="card-title">Project</h1>
</div>
</div>
</form>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<div class="card-body">
<app-search-project (changeFilterProject)="filterProjects = $event"></app-search-project>
<hr>
<div class="scroll">
<div class="accordion" id="accordionProject">
<div *ngIf="projects?.length > 0; else notShow">
<div class="card" *ngFor="let project of projects; let rowIndex = index">
<div class="card" *ngFor="let project of projects | filterProject:filterProjects; let rowIndex = index">
<div class="card-header">
<h2 class="mb-0">
<a type="button" data-toggle="collapse" [attr.data-target]="'#row'+rowIndex" [attr.aria-controls]="'row'+rowIndex">
{{project.name}}
</a>
<div class="btn-group float-right" role="group" >
<div class="btn-group float-right" role="group">
<i (click)="editProject.emit(project.id)" class="far fa-edit btn btn-link"></i>
<i (click)="openModal(project)" data-toggle="modal" data-target="#deleteModal" class="far fa-trash-alt btn btn-link"></i>
</div>
Expand All @@ -34,8 +36,5 @@ <h5>Completed project:</h5>
</div>
</div>

<app-modal *ngIf = "openDeleteModal" class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-hidden="true"
[list] = "projectToDelete"
(removeList) = "removeProject($event)"
>
</app-modal>
<app-modal *ngIf="openDeleteModal" class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-hidden="true" [list]="projectToDelete" (removeList)="removeProject($event)">
</app-modal>
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ProjectListComponent } from './project-list.component';
import { FilterProjectPipe } from 'src/app/modules/shared/pipes/filter-project/filter-project.pipe';

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

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

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class ProjectListComponent implements OnInit {
projectToDelete: Project;
openDeleteModal = false;

filterProjects: string = '';

constructor() { }

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CreateProjectComponent, ProjectListComponent } from '../components';
import { Project } from '../../shared/models';
import { ProjectManagementComponent } from './project-management.component';
import { ProjectService } from '../services/project.service';
import { FilterProjectPipe } from '../../shared/pipes/filter-project/filter-project.pipe';

describe('ProjectManagementComponent', () => {
let component: ProjectManagementComponent;
Expand Down Expand Up @@ -44,14 +45,14 @@ describe('ProjectManagementComponent', () => {

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ProjectManagementComponent, CreateProjectComponent, ProjectListComponent ],
providers: [ { provide: ProjectService, useValue: projectServiceStub }],
declarations: [ProjectManagementComponent, CreateProjectComponent, ProjectListComponent, FilterProjectPipe],
providers: [{ provide: ProjectService, useValue: projectServiceStub }],
imports: [
FormsModule,
ReactiveFormsModule
]
})
.compileComponents();
.compileComponents();
}));

beforeEach(() => {
Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/shared/components/clock/clock.component.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class="row">
<div class="col mt-1 time-clock-color">
<i *ngIf="!displayTime" class="fas fa-sync-alt fa fa-spin"></i>
</div>
<div *ngIf="displayTime" class="col time-clock-color">
<h3>{{ hour | number: '2.0-2' }}:{{ minutes | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</h3>
</div>
<div class="col mt-1 time-clock-color">
<i *ngIf="!displayTime" class="fas fa-sync-alt fa fa-spin"></i>
</div>
<div *ngIf="displayTime" class="col time-clock-color">
<h3>{{ hour | number: '2.0-2' }}:{{ minutes | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</h3>
</div>
</div>
20 changes: 17 additions & 3 deletions src/app/modules/shared/components/clock/clock.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ describe('ClockComponent', () => {

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

beforeEach(() => {
Expand Down Expand Up @@ -44,4 +44,18 @@ describe('ClockComponent', () => {
expect(component.showClock).toHaveBeenCalled();
});

});
it('should be verify the init state of vars', () => {
expect(component.hour).toEqual(0);
expect(component.minutes).toEqual(0);
expect(component.seconds).toEqual(0);
expect(component.displayTime).toBeFalsy();
});

it('should enter if and assign the value to vars', () => {
component.showClock();
expect(component.hour).toEqual(0);
expect(component.minutes).toEqual(0);
expect(component.seconds).toEqual(0);
});

});
13 changes: 8 additions & 5 deletions src/app/modules/shared/components/clock/clock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ export class ClockComponent implements OnInit {
constructor() {
this.showClock();
this.displayTime = false;
this.hour = 0;
this.minutes = 0;
this.seconds = 0;
setTimeout(() => {
this.displayTime = true;
}, 3000);
}
}

showClock() {
showClock() {
const timenInterval = interval(1000);
timenInterval.subscribe( (data) => {
timenInterval.subscribe((data) => {
this.currentDate = new Date();
this.hour = this.currentDate.getHours();
this.minutes = this.currentDate.getMinutes();
this.seconds = this.currentDate.getSeconds();
});
}
}

ngOnInit(): void {
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="form-group">
<input (keyup)="changeFilterValue()" type="text" class="form-control" placeholder="&#xF002; Search projects..." name="filterProject" [(ngModel)]="filterProject" style="font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif, FontAwesome">
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { SearchProjectComponent } from './search-project.component';

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

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

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

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

it('called method', () => {
component.changeFilterProject.emit('angular');
component.filterProject = 'angular';
component.changeFilterValue();
expect(component.filterProject).toEqual('angular');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is not a good test because you are assigning the value in the variable and after you wait that your expect has that value.
You should test that emit has been called, you can is that example in project-list test.

});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core';

@Component({
selector: 'app-search-project',
templateUrl: './search-project.component.html',
styleUrls: ['./search-project.component.scss']
})
export class SearchProjectComponent implements OnInit {

filterProject: string;
@Output() changeFilterProject = new EventEmitter();

constructor() { }

ngOnInit(): void {
}

changeFilterValue() {
this.changeFilterProject.emit(this.filterProject);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { FilterProjectPipe } from './filter-project.pipe';

describe('FilterProjectPipe', () => {
it('create an instance', () => {
const pipe = new FilterProjectPipe();
expect(pipe).toBeTruthy();
});

it('test method of pipe', () => {
expect(new FilterProjectPipe().transform([], '')).toEqual([]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

improve the test, you can create a mock with projects data and test the transform method.

});
});
20 changes: 20 additions & 0 deletions src/app/modules/shared/pipes/filter-project/filter-project.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Pipe, PipeTransform } from '@angular/core';
import { Project } from 'src/app/modules/shared/models/project.model';

@Pipe({
name: 'filterProject'
})
export class FilterProjectPipe implements PipeTransform {

transform(value: Project[] = [], arg: string): string[] {
const restultProjects = [];
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < value.length; i++) {
if (value[i].name.toLowerCase().indexOf(arg.toLowerCase()) > -1) {
restultProjects.push(value[i]);
}
}
return restultProjects;
}

}
Loading