Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #412 from gashcrumb/tech-ext-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-bot[bot] authored Nov 27, 2017
2 parents 46ba941 + 4b190a0 commit 88b82b4
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 48 deletions.
2 changes: 2 additions & 0 deletions ui/src/app/customizations/customizations.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RouterModule, Routes } from '@angular/router';
import { ToolbarModule, ListModule } from 'patternfly-ng';
import { SyndesisCommonModule } from '../common/common.module';
import { PatternflyUIModule } from '../common/ui-patternfly/ui-patternfly.module';
import { FileUploadModule } from 'ng2-file-upload-base/src';

import { CustomizationsComponent } from './customizations.component';

Expand Down Expand Up @@ -62,6 +63,7 @@ const routes: Routes = [
ToolbarModule,
ListModule,
RouterModule.forChild(routes),
FileUploadModule,
SyndesisCommonModule
],
exports: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,82 @@
<div>WIP - Detail</div>
<div class="row toolbar-pf">
<div class="col-sm-12">
<div class="toolbar-pf-actions">
<div class="inline-block">
<ol class="breadcrumb no-bottom-margin">
<li>
<a [routerLink]="['/customizations']">
Customizations
</a>
</li>
<li>
<a [routerLink]="['..']">
Technical Extensions
</a>
</li>
<li class="active">
<strong>
Technical Extension Details
</strong>
</li>
</ol>
</div>
</div>
</div>
</div>
<syndesis-loading [loading]="loading$ | async">
<div class="row" *ngIf="extension$ | async; let extension">
<div class="col-xs-12">
<p></p>
<div class="panel panel-default">
<div class="panel-heading">
<h1 class="panel-title">
{{ extension.name }}
<small>({{ extension.id }})</small>
</h1>
</div>
<div class="panel-body">
<h4>Overview</h4>
<dl class="dl-horizontal">
<dt>
Name
</dt>
<dd>
{{ extension.name }}
</dd>
</dl>
<dl class="dl-horizontal">
<dt>
Description
</dt>
<dd>
{{ extension.description }}
</dd>
</dl>
<p></p>
<h4>Supported Steps</h4>
<div class="row">
<div class="col-xs-1">
</div>
<div class="col-xs-11">
<div *ngFor="let action of extension.actions">
<strong>
{{ action.name }}
</strong>
- {{ action.description }}
</div>
</div>
</div>
<p></p>
<h4>Usage</h4>
<div class="row">
<div class="col-xs-1">
</div>
<div class="col-xs-11">

</div>
</div>
</div>
</div>
</div>
</div>
</syndesis-loading>
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { Extension } from '../../../model';
import { ExtensionStore } from '../../../store/extension/extension.store';

@Component({
selector: 'syndesis-tech-extension-detail',
templateUrl: 'tech-extension-detail.component.html'
})
export class TechExtensionDetailComponent implements OnInit {
constructor(private store: ExtensionStore) { }
extension$: Observable<Extension>;
loading$: Observable<boolean>;
constructor(private extensionStore: ExtensionStore,
private router: Router,
private route: ActivatedRoute) {
this.loading$ = this.extensionStore.loading;
this.extension$ = this.extensionStore.resource;
}

ngOnInit() {
// WIP
this.route.paramMap.first(params => params.has('id')).subscribe(params => this.extensionStore.load(params.get('id')));
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,142 @@
<div>WIP - import</div>
<div class="row toolbar-pf">
<div class="col-sm-12">
<div class="toolbar-pf-actions">
<div class="inline-block">
<ol class="breadcrumb no-bottom-margin">
<li>
<a [routerLink]="['/customizations']">
Customizations
</a>
</li>
<li>
<a [routerLink]="['..']">
Technical Extensions
</a>
</li>
<li class="active">
<strong>
Import Technical Extension
</strong>
</li>
</ol>
</div>
<div class="toolbar-pf-action-right">
<div class="toolbar-pf-action-right-alignment">
<button class="btn btn-default"
[routerLink]="['..']">
Cancel
</button>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<p></p>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
Import Technical Extension
</h3>
</div>
<div class="panel-body">
<p>
To import a technical extension, it must be packaged as a .jar file. To update a technical extension in the breadcrumbs above,
click Technical Extensions and in the list of technical extensions, click Update for the appropriate technical
extension.
</p>
<ng-container *ngIf="error">
<div [class]="error.level" [innerHtml]="error.message">
</div>
</ng-container>
<dl class="dl-horizontal"
ng2FileDrop
[uploader]="uploader">
<dt>
Upload File
</dt>
<dd>
<div class="row">
<div class="col-md-6">
<input #fileSelect
type="file"
ng2FileSelect
[uploader]="uploader">
<p class="help-block">Accepted file type: .jar</p>
</div>
<div class="col-md-6">
<div *ngIf="uploader.queue.length">
<div *ngFor="let item of uploader.queue">
<p *ngIf="!item.isUploaded">
<span class="spinner spinner-lg spinner-inline"></span>
{{ item.file.name }}
</p>
</div>
</div>
</div>
</div>
</dd>
</dl>
<ng-container *ngIf="response">
<dl class="dl-horizontal">
<dt>
ID
</dt>
<dd>
{{ response.id }}
</dd>
</dl>
<dl class="dl-horizontal">
<dt>
Name
</dt>
<dd>
{{ response.name }}
</dd>
</dl>
<dl class="dl-horizontal">
<dt>
Description
</dt>
<dd>
{{ response.description }}
</dd>
</dl>
<dl class="dl-horizontal">
<dt>
Steps
</dt>
<dd>
<div *ngFor="let action of response.actions">
<strong>
{{ action.name }}
</strong>
- {{ action.description }}
</div>
</dd>
</dl>
<dl class="dl-horizontal">
<dt></dt>
<dd>
<button type="button"
class="btn btn-primary"
[disabled]="importing"
(click)="doImport()">
<span *ngIf="importing"
class="spinner spinner-sm spinner-inline"></span>
Import
</button>
<button *ngIf="!importing"
type="button"
class="btn btn-default"
[routerLink]="['..']">
Cancel
</button>
</dd>
</dl>
</ng-container>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,15 +1,113 @@
import { Component, OnInit } from '@angular/core';
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {
FileUploader,
FileItem,
FileLikeObject,
FilterFunction,
FileUploaderOptions,
ParsedResponseHeaders
} from 'ng2-file-upload-base/src';
import { NotificationType } from 'patternfly-ng';
import { Extension } from '../../../model';
import { ExtensionStore } from '../../../store/extension/extension.store';
import { NotificationService } from 'app/common/ui-patternfly/notification-service';

interface FileError {
level: string;
message: string;
}

@Component({
selector: 'syndesis-tech-extentions-import',
templateUrl: 'tech-extension-import.component.html'
})

export class TechExtensionImportComponent implements OnInit {
constructor(private store: ExtensionStore) { }

uploader: FileUploader;
response: Extension;
error: FileError;
importing = false;

@ViewChild('fileSelect') fileSelect: ElementRef;

constructor(private store: ExtensionStore,
private notificationService: NotificationService,
private router: Router,
private route: ActivatedRoute) { }

getGenericError() {
return {
level: 'alert alert-danger',
message: '<strong>This is not a valid file type.</strong> Try again and specify a .jar file'
};
}

doImport() {
this.importing = true;
if (!this.response || !this.response.id) {
// safety net
this.response = undefined;
return;
}
this.store.importExtension(this.response.id).toPromise().then( value => {
this.notificationService.message(
NotificationType.SUCCESS,
'Imported!',
'Your technical extension has been imported',
false,
null,
[]
);
this.router.navigate(['..', this.response.id], { relativeTo: this.route });
}).catch((reason: any) => {
this.error = {
level: 'alert alert-danger',
message: reason.userMsg || 'An unknown error has occurred'
};
});
}

ngOnInit() {
// WIP
this.uploader = new FileUploader({
url: this.store.getUploadUrl(),
disableMultipart: false,
autoUpload: true,
filters: [
{
name: 'filename filter',
fn: (item: FileLikeObject, options: FileUploaderOptions) => {
if (!item.name.endsWith('.jar')) {
return false;
}
return true;
}
}
]
});
this.uploader.onWhenAddingFileFailed = (item: FileLikeObject, filter: any, options: any): any => {
this.error = this.getGenericError();
this.fileSelect.nativeElement['value'] = '';
this.uploader.clearQueue();
};
this.uploader.onCompleteItem = (item: FileItem, response: string, status: number, headers: ParsedResponseHeaders) => {
this.error = undefined;
this.response = undefined;
let resp: any = {};
try {
resp = JSON.parse(response);
} catch (err) {
this.error = this.getGenericError();
return;
}
if (status === 200) {
this.response = <Extension> resp;
return;
}
this.error = {
level: 'alert alert-danger',
message: resp.userMsg || 'An unknown error has occurred'
};
};
}
}
Loading

0 comments on commit 88b82b4

Please sign in to comment.