From 5ca28dd774c20686a621d20b4b093212690db9ad Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Fri, 23 Jun 2017 12:22:06 +0200 Subject: [PATCH 1/3] Add button to register apps by path Allow user to register path and stay on app registration page. #close WINDUP-1387 --- .../register-application-form.component.html | 5 ++- .../register-application-form.component.ts | 37 +++++-------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.html b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.html index a86d3d369..7984925c2 100644 --- a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.html +++ b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.html @@ -88,6 +88,9 @@

{{labels.heading}}

+
+ +
@@ -96,7 +99,7 @@

{{labels.heading}}

- +
diff --git a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts index 8e1413f1b..b52499a8d 100644 --- a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts +++ b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts @@ -43,7 +43,7 @@ export class RegisterApplicationFormComponent extends FormComponent implements O labels = { heading: 'Add Applications', - uploadButton: 'Upload' + uploadButton: 'Done' }; constructor( @@ -138,36 +138,28 @@ 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.fileInputPath = '', error => this.handleError(error) ); } else { this._registeredApplicationService.registerByPath(this.project, this.fileInputPath, this.isDirWithExplodedApp).subscribe( - application => this.navigateOnSuccess(), + () => this.fileInputPath = '', error => this.handleError(error) ) } @@ -224,7 +216,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' @@ -246,17 +238,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'); From 7af3ae31dc6af11d181bef5353eea129f091039f Mon Sep 17 00:00:00 2001 From: Jess Sightler Date: Tue, 27 Jun 2017 14:16:11 -0400 Subject: [PATCH 2/3] Added a changedetector ref to notify angular of changes --- .../edit-application-form.component.ts | 7 ++++--- .../register-application-form.component.ts | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ui/src/main/webapp/src/app/registered-application/edit-application-form.component.ts b/ui/src/main/webapp/src/app/registered-application/edit-application-form.component.ts index 67103705f..1bbb185af 100644 --- a/ui/src/main/webapp/src/app/registered-application/edit-application-form.component.ts +++ b/ui/src/main/webapp/src/app/registered-application/edit-application-form.component.ts @@ -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"; @@ -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'; diff --git a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts index b52499a8d..7ae7234b9 100644 --- a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts +++ b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts @@ -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"; @@ -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(); @@ -154,12 +155,20 @@ export class RegisterApplicationFormComponent extends FormComponent implements O if (type_ === "DIRECTORY" && !this.isDirWithExplodedApp) { //this.isDirWithApps this._registeredApplicationService.registerApplicationInDirectoryByPath(this.project, this.fileInputPath) .subscribe( - () => this.fileInputPath = '', + () => { + this.fileInputPath = ''; + // Make sure angular is aware of changes (avoids an angular exception in debug mode otherwise) + this._changeDetectorRef.detectChanges(); + }, error => this.handleError(error) ); } else { this._registeredApplicationService.registerByPath(this.project, this.fileInputPath, this.isDirWithExplodedApp).subscribe( - () => this.fileInputPath = '', + () => { + // Make sure angular is aware of changes (avoids an angular exception in debug mode otherwise) + this.fileInputPath = ''; + this._changeDetectorRef.detectChanges(); + }, error => this.handleError(error) ) } From a9cd0fcca6288012f169834fb5e0d62aa60749ee Mon Sep 17 00:00:00 2001 From: David Klingenberg Date: Wed, 28 Jun 2017 10:11:15 +0200 Subject: [PATCH 3/3] Create method for clearing input path --- .../register-application-form.component.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts index 7ae7234b9..389e7e932 100644 --- a/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts +++ b/ui/src/main/webapp/src/app/registered-application/register-application-form.component.ts @@ -155,26 +155,24 @@ export class RegisterApplicationFormComponent extends FormComponent implements O if (type_ === "DIRECTORY" && !this.isDirWithExplodedApp) { //this.isDirWithApps this._registeredApplicationService.registerApplicationInDirectoryByPath(this.project, this.fileInputPath) .subscribe( - () => { - this.fileInputPath = ''; - // Make sure angular is aware of changes (avoids an angular exception in debug mode otherwise) - this._changeDetectorRef.detectChanges(); - }, + () => this.clearFileInputPath(), error => this.handleError(error) ); } else { this._registeredApplicationService.registerByPath(this.project, this.fileInputPath, this.isDirWithExplodedApp).subscribe( - () => { - // Make sure angular is aware of changes (avoids an angular exception in debug mode otherwise) - this.fileInputPath = ''; - this._changeDetectorRef.detectChanges(); - }, + () => this.clearFileInputPath(), error => this.handleError(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.");