Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, OnInit} from "@angular/core";
import {ChangeDetectorRef, Component, OnInit} from "@angular/core";
import {FormBuilder, Validators} from "@angular/forms";
import {ActivatedRoute, Router} from "@angular/router";
import {RegisteredApplication, RegistrationType} from "../generated/windup-services";
Expand Down Expand Up @@ -27,10 +27,11 @@ export class EditApplicationFormComponent extends RegisterApplicationFormCompone
_routeFlattener: RouteFlattenerService,
_eventBus: EventBusService,
_migrationProjectService: MigrationProjectService,
_notificationService: NotificationService
_notificationService: NotificationService,
_changeDetectorRef: ChangeDetectorRef
) {
super(_router, _activatedRoute, _fileService, _registeredApplicationService, _formBuilder, _routeFlattener,
_eventBus, _migrationProjectService, _notificationService);
_eventBus, _migrationProjectService, _notificationService, _changeDetectorRef);

this.labels.heading = 'Update application';
this.labels.uploadButton = 'Update';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ <h1>{{labels.heading}}</h1>
</label>
</div>
</div>
<div class="col-md-12">
<button class="btn btn-primary" [disabled]="!registrationForm.pending && !isValid">Register Path</button>
</div>
</div>
</wu-tab>
</wu-tab-container>
Expand All @@ -96,7 +99,7 @@ <h1>{{labels.heading}}</h1>
<div class="col-md-12">
<div class="button-container">
<button *ngIf="isInWizard" (click)="cancelRegistration()" type="button" class="btn btn-default">{{isInWizard ? 'Back' : 'Cancel'}}</button>
<button [disabled]="!registrationForm.pending && !isValid" class="btn btn-primary" type="submit">{{isInWizard ? 'Next' : labels.uploadButton}}</button>
<button [disabled]="!projectHasApplications()" class="btn btn-primary" (click)="navigateOnSuccess()">{{isInWizard ? 'Next' : labels.uploadButton}}</button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy} from "@angular/core";
import {Component, OnInit, OnDestroy, ChangeDetectorRef} from "@angular/core";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {ActivatedRoute, Router, NavigationEnd} from "@angular/router";
import {FileUploader} from "ng2-file-upload/ng2-file-upload";
Expand Down Expand Up @@ -43,7 +43,7 @@ export class RegisterApplicationFormComponent extends FormComponent implements O

labels = {
heading: 'Add Applications',
uploadButton: 'Upload'
uploadButton: 'Done'
};

constructor(
Expand All @@ -55,7 +55,8 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
protected _routeFlattener: RouteFlattenerService,
protected _eventBus: EventBusService,
protected _migrationProjectService: MigrationProjectService,
protected _notificationService: NotificationService
protected _notificationService: NotificationService,
protected _changeDetectorRef: ChangeDetectorRef
) {
super();

Expand Down Expand Up @@ -138,42 +139,40 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
}

register() {
if (!this.isValid) {
return false;
}

if (this.mode == "PATH") {
this.registerPath();
} else {
this.navigateOnSuccess();
return false;
}
}

private registerPath() {
/**
* If there are already some uploaded applications, we consider form to be valid
* But if user is on Register Path section, clicking submit button triggers registering app by path with invalid
* path.
* To avoid that, treat it as success and do the navigation right away, even when no input path is set.
*/
if ((!this.fileInputPath || this.fileInputPath.length === 0) && this.isValid) {
this.navigateOnSuccess();
return;
}

public registerPath() {
this._fileService.queryServerPathTargetType(this.fileInputPath).subscribe((type_: string) => {
if (type_ === "DIRECTORY" && !this.isDirWithExplodedApp) { //this.isDirWithApps
this._registeredApplicationService.registerApplicationInDirectoryByPath(this.project, this.fileInputPath)
.subscribe(
application => this.navigateOnSuccess(),
() => this.clearFileInputPath(),
error => this.handleError(error)
);
} else {
this._registeredApplicationService.registerByPath(this.project, this.fileInputPath, this.isDirWithExplodedApp).subscribe(
application => this.navigateOnSuccess(),
() => this.clearFileInputPath(),
error => this.handleError(<any>error)
)
}
});
}

protected clearFileInputPath() {
this.fileInputPath = '';
// Make sure angular is aware of changes (avoids an angular exception in debug mode otherwise)
this._changeDetectorRef.detectChanges();
}

private registerUploaded() {
if (this.multipartUploader.getNotUploadedItems().length == 0) {
this.handleError("Please select the file to upload.");
Expand Down Expand Up @@ -224,7 +223,7 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
this.mode = mode;

if (this.mode === 'PATH') {
this.labels.uploadButton = 'Upload';
this.labels.uploadButton = 'Done';
} else if (this.mode === 'UPLOADED') {
// this is not really nice, but when using UPLOADED mode, upload is done automatically
// so no action is actually being executed, so label is 'Done'
Expand All @@ -246,17 +245,6 @@ export class RegisterApplicationFormComponent extends FormComponent implements O
}

public get isValid() {
/**
* If project already has some applications,
* form is always valid for "upload" tab and also for empty path in "server path" tab.
*
* This allows us to have 'Back' step in wizard and not requiring
* user to upload new application.
*/
if (this.isInWizard && this.projectHasApplications() && this.fileInputPath.length === 0) {
return true;
}

if (this.mode === 'PATH') {
const appPathField = this.registrationForm.get('appPathToRegister');

Expand Down