Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
#91 Fix error if fromTemplate action called twice and remove unused css
Browse files Browse the repository at this point in the history
  • Loading branch information
lbassin committed Jun 18, 2018
1 parent b8ae2a7 commit 44c004d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/app/components/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@
<p class="home-description" [ngClass]="{'home-description-transition': redirection}">
The simplest application to create your docker projects.
</p>
<a (click)="goToSearch()" [ngClass]="{'home-button-transition': redirection}" class="home-button">Start Here</a>
<a (click)="goToTemplate()" [ngClass]="{'home-button-transition': redirection}" class="home-button">Template</a>
<a (click)="goToSearch()"
[ngClass]="{'home-button-transition': redirection, 'hide': templateSelected}"
class="home-button">Empty project</a>
<a (click)="goToTemplate()"
[ngClass]="{'home-button-transition': redirection, 'hide': searchSelected}"
class="home-button">From template</a>
</div>
16 changes: 10 additions & 6 deletions src/app/components/home/home.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
.docker-container-1 {
width: 45px;
position: absolute;
top: 0%;
top: 0;
left: 50px;
opacity: 0;

Expand All @@ -87,7 +87,7 @@
.docker-container-2 {
width: 45px;
position: absolute;
top: 0%;
top: 0;
right: 50px;
opacity: 0;

Expand All @@ -113,7 +113,7 @@
.docker-container-3 {
width: 45px;
position: absolute;
right: 0%;
right: 0;
top: calc(50% - 30px);
opacity: 0;

Expand All @@ -139,7 +139,7 @@
width: 45px;
position: absolute;
right: 50px;
bottom: 0%;
bottom: 0;
opacity: 0;

animation: docker4 6s infinite;
Expand All @@ -165,7 +165,7 @@
width: 45px;
position: absolute;
left: 50px;
bottom: 0%;
bottom: 0;
opacity: 0;

animation: docker5 6s infinite;
Expand All @@ -191,7 +191,7 @@
width: 45px;
position: absolute;
top: calc(50% - 30px);
left: 0%;
left: 0;
opacity: 0;

animation: docker6 6s infinite;
Expand Down Expand Up @@ -298,6 +298,10 @@
animation-fill-mode: forwards;
animation-delay: 1.1s;

&:not(:first-child) {
margin-left: 12px;
}

&:hover {
cursor: pointer;
background-color: rgba(255, 255, 255, 0.3);
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class HomeComponent implements OnInit, OnDestroy {
redirection = false;
sidebarVisible = false;

searchSelected = false;
templateSelected = false;

constructor(
private router: Router,
private elRef: ElementRef,
Expand All @@ -39,13 +42,15 @@ export class HomeComponent implements OnInit, OnDestroy {

goToSearch() {
this.redirection = true;
this.searchSelected = true;
setTimeout(() => {
this.router.navigate(['/search']);
}, 1100);
}

goToTemplate(): void {
this.redirection = true;
this.templateSelected = true;
setTimeout(() => {
this.router.navigate(['/template']);
}, 1100);
Expand Down
8 changes: 8 additions & 0 deletions src/app/components/template/template.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ export class TemplateComponent implements OnInit {
}

ngOnInit(): void {
if (this.projectService.getContainers().length > 0 && this.projectService.isFromTemplate()) {
this.projectService.reset();

this.router.navigate(['/template']);
return;
}

this.template.containers.forEach(async (element: Container) => {
const container = await this.containerService.getContainerConfig(element.configPath);
container.output = element.output;

this.projectService.addContainer(element.containerId, container);
});

this.projectService.setFromTemplate(true);
this.router.navigate(['/review']);
}
}
23 changes: 21 additions & 2 deletions src/app/services/project.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import { SidebarService } from './sidebar.service';
@Injectable()
export class ProjectService {

private containersSubject: Subject<Array<Container>> = new Subject<Array<Container>>();
private containers: Container[] = [];
private containersSubject: Subject<Array<Container>>;

private fromTemplate: boolean;
private containers: Container[];

constructor(private sidebarService: SidebarService) {
this.containersSubject = new Subject<Array<Container>>();
this.containers = [];
this.fromTemplate = false;
}

addContainer(id: string, container: Container): boolean {
Expand Down Expand Up @@ -91,4 +96,18 @@ export class ProjectService {
return element.containerId === container.containerId;
});
}

setFromTemplate(isFromTemplate: boolean) {
this.fromTemplate = isFromTemplate;
}

isFromTemplate(): boolean {
return this.fromTemplate;
}

reset() {
this.containers = [];
this.sidebarService.hide();
this.containersSubject.next(this.containers);
}
}

0 comments on commit 44c004d

Please sign in to comment.