-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: job id advanced parameter type #1383
Changes from 3 commits
d615857
3797ff8
ddbee42
a2c3bf4
9a489f0
83e395c
b426109
6d74e2a
78172d7
2620511
677d3e7
3c662da
2ca5bef
2cb5a62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,15 +9,20 @@ import { FileGroupPickerComponent } from "./file-group-picker"; | |
import { FileGroupSasComponent } from "./file-group-sas"; | ||
import { FileGroupsPickerComponent } from "./file-groups-picker"; | ||
import { FileOrDirectoryPickerComponent } from "./file-or-directory-picker"; | ||
import { JobIdComponent } from "./job-id/job-id.component"; | ||
import { StorageAccountPickerComponent } from "./storage-account-picker"; | ||
|
||
const components = [ | ||
FileGroupPickerComponent, FileGroupSasComponent, FileGroupsPickerComponent, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make those 1 per line instead |
||
CloudFilePickerComponent, CloudFilePickerDialogComponent, | ||
StorageErrorDisplayComponent, | ||
BlobContainerPickerComponent, | ||
StorageAccountPickerComponent, | ||
CloudFilePickerComponent, | ||
CloudFilePickerDialogComponent, | ||
FileGroupPickerComponent, | ||
FileGroupSasComponent, | ||
FileGroupsPickerComponent, | ||
FileOrDirectoryPickerComponent, | ||
JobIdComponent, | ||
StorageAccountPickerComponent, | ||
StorageErrorDisplayComponent, | ||
]; | ||
|
||
@NgModule({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<bl-form-field> | ||
<input type="text" blInput [formControl]="value" [placeholder]="label"> | ||
<bl-button type="round" [action]="generateSasToken" [disabled]="!containerId" title="Generate SAS"><i class="fa fa-refresh"></i></bl-button> | ||
<bl-hint *ngIf="hint" align="end"> | ||
{{hint}} | ||
</bl-hint> | ||
</bl-form-field> | ||
<bl-button type="round" [action]="generateSasToken" [disabled]="!containerId" title="Generate SAS"><i class="fa fa-refresh"></i></bl-button> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./job-id.component"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { ChangeDetectionStrategy, Component, Input, OnDestroy, forwardRef } from "@angular/core"; | ||
import { ControlValueAccessor, FormControl, NG_VALIDATORS, NG_VALUE_ACCESSOR } from "@angular/forms"; | ||
import { Subscription } from "rxjs"; | ||
|
||
import { JobService } from "app/services"; | ||
|
||
import "./job-id.scss"; | ||
|
||
@Component({ | ||
selector: "bl-job-id", | ||
templateUrl: "job-id.html", | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
providers: [ | ||
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => JobIdComponent), multi: true }, | ||
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => JobIdComponent), multi: true }, | ||
], | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you add changeDetection There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, will make sure to add this whenever i am pottering about in the code. |
||
export class JobIdComponent implements ControlValueAccessor, OnDestroy { | ||
@Input() public label: string; | ||
@Input() public hint: string; | ||
|
||
public value = new FormControl(); | ||
public warning = false; | ||
|
||
private _propagateChange: (value: any) => void = null; | ||
private _subscriptions: Subscription[] = []; | ||
|
||
constructor(private jobService: JobService) { | ||
this._subscriptions.push(this.value.valueChanges.debounceTime(400).distinctUntilChanged().subscribe((value) => { | ||
this._checkValid(value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that should probably be a validator so it prevent the form from being submitted There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah i noticed this just before i left last night. Seems that none of the advanced components use validators, so file-in-file-group also passes validation if you add a rubbish filename. |
||
if (this._propagateChange) { | ||
this._propagateChange(value); | ||
} | ||
})); | ||
} | ||
|
||
public ngOnDestroy() { | ||
this._subscriptions.forEach(x => x.unsubscribe()); | ||
} | ||
|
||
public writeValue(value: string) { | ||
this.value.setValue(value); | ||
} | ||
|
||
public registerOnChange(fn) { | ||
this._propagateChange = fn; | ||
} | ||
|
||
public registerOnTouched() { | ||
// Do nothing | ||
} | ||
|
||
public validate(c: FormControl) { | ||
return null; | ||
} | ||
|
||
private _checkValid(value: string) { | ||
this.jobService.get(value).subscribe({ | ||
next: (job: any) => { | ||
this.warning = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might want to add changeDetector.markForCheck() here now that it is OnPush or it might not get detected There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, cheers. This will probably change somewhat when i look to use the validator. |
||
this.value.setErrors({ | ||
notUnique: true, | ||
}); | ||
}, | ||
error: () => { | ||
this.warning = false; | ||
this.value.setErrors({}); | ||
}, | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<bl-form-field> | ||
<input type="text" blInput [formControl]="value" [placeholder]="label"> | ||
<bl-hint class="warning" *ngIf="warning"> | ||
The job ID has already been used, please choose a unique job ID | ||
</bl-hint> | ||
<bl-hint *ngIf="hint" align="end"> | ||
{{hint}} | ||
</bl-hint> | ||
</bl-form-field> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@import "app/styles/variables"; | ||
|
||
bl-job-id { | ||
bl-form-field { | ||
flex: 1; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm saw at the bottom