Skip to content

Commit

Permalink
fixing dynamic pipe field, UI: Renewing Study page #1802
Browse files Browse the repository at this point in the history
  • Loading branch information
shral committed Mar 11, 2019
1 parent 2a506a7 commit 1250dbd
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 13 deletions.
1 change: 1 addition & 0 deletions dcm4chee-arc-ui2/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ import { DynamicPipePipe } from './pipes/dynamic-pipe.pipe';
RangePickerService,
StorageVerificationService,
StudyService,
ContentDescriptionPipe,
{provide: LOCALE_ID, useValue: 'en-US' }
],
bootstrap: [AppComponent]
Expand Down
3 changes: 2 additions & 1 deletion dcm4chee-arc-ui2/src/app/constants/globalvar.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {FilterSchema, SelectDropdown} from "../interfaces";
import {DicomTableSchema, DynamicPipe} from "../helpers/dicom-studies-table/dicom-studies-table.interfaces";
import {ContentDescriptionPipe} from "../pipes/content-description.pipe";

export class Globalvar {
public static get MODALITIES(): any {
Expand Down Expand Up @@ -1419,7 +1420,7 @@ export class Globalvar {
headerDescription:"Content Description",
widthWeight:1.5,
calculatedWidth:"20%",
pipe:new DynamicPipe("contentDescription",undefined)
pipe:new DynamicPipe(ContentDescriptionPipe,undefined)
},{
type:"value",
header:"#F",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3 *ngIf="title">{{title}}</h3>
<i *ngIf="action.icon.tag === 'i' && (!action.icon.showIf || action.icon.showIf(patient))" class="{{action.icon.cssClass||''}}">{{action.icon.text||''}}</i>
</a>
</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{patient_table.pipe | dynamicPipe}}</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{patient.attrs | dynamicPipe:patient_table.pipe}}</ng-container>
<ng-container *ngSwitchCase="'value'">{{_.get(patient.attrs,patient_table.pathToValue) || '&nbsp;'}}</ng-container>
</div>
<attribute-list *ngIf="patient.showAttributes" [attrs]="patient.attrs"></attribute-list>
Expand All @@ -38,7 +38,7 @@ <h3 *ngIf="title">{{title}}</h3>
<i *ngIf="action.icon.tag === 'i' && (!action.icon.showIf || action.icon.showIf(study))" class="{{action.icon.cssClass||''}}">{{action.icon.text||''}}</i>
</a>
</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{studies_table.pipe | dynamicPipe}}</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{study.attrs | dynamicPipe:studies_table.pipe}}</ng-container>
<ng-container *ngSwitchCase="'value'">{{_.get(study.attrs,studies_table.pathToValue) || '&nbsp;'}}</ng-container>
</div>
<attribute-list *ngIf="study.showAttributes" [attrs]="study.attrs"></attribute-list>
Expand All @@ -55,7 +55,7 @@ <h3 *ngIf="title">{{title}}</h3>
<i *ngIf="action.icon.tag === 'i' && (!action.icon.showIf || action.icon.showIf(serie))" class="{{action.icon.cssClass||''}}">{{action.icon.text||''}}</i>
</a>
</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{serie_table.pipe | dynamicPipe}}</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{serie.attrs | dynamicPipe:serie_table.pipe}}</ng-container>
<ng-container *ngSwitchCase="'value'">{{_.get(serie.attrs,serie_table.pathToValue) || '&nbsp;'}}</ng-container>
</div>
<attribute-list *ngIf="serie.showAttributes" [attrs]="serie.attrs"></attribute-list>
Expand All @@ -73,7 +73,7 @@ <h3 *ngIf="title">{{title}}</h3>
<i *ngIf="action.icon.tag === 'i' && (!action.icon.showIf || action.icon.showIf(instance))" class="{{action.icon.cssClass||''}}">{{action.icon.text||''}}</i>
</a>
</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{instance_table.pipe | dynamicPipe}}</ng-container>
<ng-container *ngSwitchCase="'pipe'">{{instance.attrs | dynamicPipe:instance_table.pipe}}</ng-container>
<ng-container *ngSwitchCase="'value'">{{_.get(instance.attrs,instance_table.pathToValue) || '&nbsp;'}}</ng-container>
</div>
<attribute-list *ngIf="instance.showAttributes" [attrs]="instance.attrs"></attribute-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ export interface TableSchemaConfig {

export class DynamicPipe{

private _pipeToken:string;
private _pipeToken:any;
private _pipeArgs:any[];

constructor(pipeToken:string, pipeArgs:any[]){
constructor(pipeToken:any, pipeArgs:any[]){
this._pipeToken = pipeToken;
this._pipeArgs = pipeArgs;
}


get pipeToken(): string {
get pipeToken(): any {
return this._pipeToken;
}

set pipeToken(value: string) {
set pipeToken(value: any) {
this._pipeToken = value;
}

Expand Down
72 changes: 72 additions & 0 deletions dcm4chee-arc-ui2/src/app/pipes/dynamic-pipe.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,82 @@
import { DynamicPipePipe } from './dynamic-pipe.pipe';
import {Injector} from "@angular/core";
import {DynamicPipe} from "../helpers/dicom-studies-table/dicom-studies-table.interfaces";

const attr = {
"00080016": {
"vr": "UI",
"Value": [
"1.2.840.10008.5.1.4.1.1.2"
]
},
"00080018": {
"vr": "UI",
"Value": [
"1.2.840.113704.7.7.1.1762134868.1376.807379226.78"
]
},
"00080054": {
"vr": "AE",
"Value": [
"DCM4CHEE"
]
},
"00080056": {
"vr": "CS",
"Value": [
"ONLINE"
]
},
"00081190": {
"vr": "UR",
"Value": [
"http://shefki-lifebook:8080/dcm4chee-arc/aets/DCM4CHEE/rs/studies/2.16.376.1.1.511752826.1.2.21313.5230164/series/2.16.376.1.1.511752826.1.2.21459.3526228/instances/1.2.840.113704.7.7.1.1762134868.1376.807379226.78"
]
},
"0020000D": {
"vr": "UI",
"Value": [
"2.16.376.1.1.511752826.1.2.21313.5230164"
]
},
"0020000E": {
"vr": "UI",
"Value": [
"2.16.376.1.1.511752826.1.2.21459.3526228"
]
},
"00200013": {
"vr": "IS",
"Value": [
0
]
},
"00280010": {
"vr": "US",
"Value": [
340
]
},
"00280011": {
"vr": "US",
"Value": [
340
]
},
"00280100": {
"vr": "US",
"Value": [
16
]
}
};

describe('DynamicPipePipe', () => {
it('create an instance', () => {
let injector:Injector;
const pipe = new DynamicPipePipe(injector);
expect(pipe).toBeTruthy();

expect(pipe.transform(attr, new DynamicPipe("ContentDescriptionPipe",undefined))).toBe("");
});
});
11 changes: 7 additions & 4 deletions dcm4chee-arc-ui2/src/app/pipes/dynamic-pipe.pipe.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {Injector, Pipe, PipeTransform} from '@angular/core';
import * as _ from 'lodash';
import {DynamicPipe} from "../helpers/dicom-studies-table/dicom-studies-table.interfaces";

@Pipe({
name: 'dynamicPipe'
Expand All @@ -8,13 +10,14 @@ export class DynamicPipePipe implements PipeTransform {
public constructor(private injector: Injector) {
}

transform(value: any, pipeToken: any, pipeArgs: any[]): any {
if (!pipeToken) {
transform(value: any, dynamicPipe:DynamicPipe): any {
console.log("value",value);
if (!value) {
return value;
}
else {
let pipe = this.injector.get(pipeToken);
return pipe.transform(value, ...pipeArgs);
let pipe = this.injector.get(dynamicPipe.pipeToken);
return pipe.transform(value, ...value.pipeArgs);
}
}
}

0 comments on commit 1250dbd

Please sign in to comment.