-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SHIBUI-1269 Implemented configuration xml component
- Loading branch information
Showing
18 changed files
with
372 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ui/src/app/metadata/configuration/component/metadata-configuration.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
import { Routes } from '@angular/router'; | ||
import { ConfigurationComponent } from './container/configuration.component'; | ||
import { MetadataOptionsComponent } from './container/metadata-options.component'; | ||
import { MetadataXmlComponent } from './container/metadata-xml.component'; | ||
|
||
export const ConfigurationRoutes: Routes = [ | ||
{ | ||
path: ':type/:id/configuration', | ||
component: ConfigurationComponent | ||
component: ConfigurationComponent, | ||
children: [ | ||
{ | ||
path: '', | ||
redirectTo: 'options' | ||
}, | ||
{ | ||
path: 'options', | ||
component: MetadataOptionsComponent | ||
}, | ||
{ | ||
path: 'xml', | ||
component: MetadataXmlComponent | ||
} | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
ui/src/app/metadata/configuration/container/metadata-options.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="container"> | ||
<metadata-configuration [configuration]="configuration$ | async"></metadata-configuration> | ||
</div> |
70 changes: 70 additions & 0 deletions
70
ui/src/app/metadata/configuration/container/metadata-options.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { Component, ViewChild, Input } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, combineReducers, Store } from '@ngrx/store'; | ||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { MetadataConfiguration } from '../model/metadata-configuration'; | ||
import * as fromConfiguration from '../reducer'; | ||
import { MockI18nModule } from '../../../../testing/i18n.stub'; | ||
import { MetadataOptionsComponent } from './metadata-options.component'; | ||
|
||
@Component({ | ||
selector: 'metadata-configuration', | ||
template: `` | ||
}) | ||
class MetadataConfigurationComponent { | ||
@Input() configuration: MetadataConfiguration; | ||
} | ||
|
||
@Component({ | ||
template: ` | ||
<metadata-options-page></metadata-options-page> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(MetadataOptionsComponent) | ||
public componentUnderTest: MetadataOptionsComponent; | ||
|
||
configuration: MetadataConfiguration = { sections: [] }; | ||
} | ||
|
||
describe('Metadata Options Page Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: MetadataOptionsComponent; | ||
let store: Store<fromConfiguration.State>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule, | ||
StoreModule.forRoot({ | ||
'metadata-configuration': combineReducers(fromConfiguration.reducers), | ||
}), | ||
MockI18nModule, | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
MetadataOptionsComponent, | ||
MetadataConfigurationComponent, | ||
TestHostComponent | ||
], | ||
}).compileComponents(); | ||
|
||
store = TestBed.get(Store); | ||
spyOn(store, 'dispatch'); | ||
spyOn(store, 'select'); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should load metadata objects', async(() => { | ||
expect(app).toBeTruthy(); | ||
expect(store.select).toHaveBeenCalled(); | ||
})); | ||
}); |
23 changes: 23 additions & 0 deletions
23
ui/src/app/metadata/configuration/container/metadata-options.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Store } from '@ngrx/store'; | ||
import { Component, ChangeDetectionStrategy } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import * as fromConfiguration from '../reducer'; | ||
import { MetadataConfiguration } from '../model/metadata-configuration'; | ||
|
||
@Component({ | ||
selector: 'metadata-options-page', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
templateUrl: './metadata-options.component.html', | ||
styleUrls: [] | ||
}) | ||
export class MetadataOptionsComponent { | ||
|
||
configuration$: Observable<MetadataConfiguration>; | ||
|
||
constructor( | ||
private store: Store<fromConfiguration.ConfigurationState> | ||
) { | ||
this.configuration$ = this.store.select(fromConfiguration.getConfigurationSections); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
ui/src/app/metadata/configuration/container/metadata-xml.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="container-fluid"> | ||
<pre class="border p-2 bg-light rounded"><code>{{ xml$ | async }}</code></pre> | ||
<button type="button" class="btn btn-primary" (click)="preview(xml)"> | ||
<i class="fa fa-fw fa-save"></i> | ||
<translate-i18n key="action.download-file">Download File</translate-i18n> | ||
</button> | ||
</div> |
61 changes: 61 additions & 0 deletions
61
ui/src/app/metadata/configuration/container/metadata-xml.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Component, ViewChild, Input } from '@angular/core'; | ||
import { TestBed, async, ComponentFixture } from '@angular/core/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { StoreModule, combineReducers, Store } from '@ngrx/store'; | ||
import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; | ||
|
||
import { MetadataConfiguration } from '../model/metadata-configuration'; | ||
import * as fromConfiguration from '../reducer'; | ||
import { MockI18nModule } from '../../../../testing/i18n.stub'; | ||
import { MetadataXmlComponent } from './metadata-xml.component'; | ||
|
||
@Component({ | ||
template: ` | ||
<metadata-xml-page></metadata-xml-page> | ||
` | ||
}) | ||
class TestHostComponent { | ||
@ViewChild(MetadataXmlComponent) | ||
public componentUnderTest: MetadataXmlComponent; | ||
|
||
configuration: MetadataConfiguration = { sections: [] }; | ||
} | ||
|
||
describe('Metadata Xml Page Component', () => { | ||
|
||
let fixture: ComponentFixture<TestHostComponent>; | ||
let instance: TestHostComponent; | ||
let app: MetadataXmlComponent; | ||
let store: Store<fromConfiguration.State>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NgbDropdownModule, | ||
StoreModule.forRoot({ | ||
'metadata-configuration': combineReducers(fromConfiguration.reducers), | ||
}), | ||
MockI18nModule, | ||
RouterTestingModule | ||
], | ||
declarations: [ | ||
MetadataXmlComponent, | ||
TestHostComponent | ||
], | ||
}).compileComponents(); | ||
|
||
store = TestBed.get(Store); | ||
spyOn(store, 'dispatch'); | ||
spyOn(store, 'select'); | ||
|
||
fixture = TestBed.createComponent(TestHostComponent); | ||
instance = fixture.componentInstance; | ||
app = instance.componentUnderTest; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should load metadata objects', async(() => { | ||
expect(app).toBeTruthy(); | ||
expect(store.select).toHaveBeenCalledTimes(2); | ||
})); | ||
}); |
33 changes: 33 additions & 0 deletions
33
ui/src/app/metadata/configuration/container/metadata-xml.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Store } from '@ngrx/store'; | ||
import { Component } from '@angular/core'; | ||
import { Observable, Subject } from 'rxjs'; | ||
|
||
import * as fromConfiguration from '../reducer'; | ||
import { Metadata } from '../../domain/domain.type'; | ||
import { DownloadXml } from '../action/configuration.action'; | ||
|
||
@Component({ | ||
selector: 'metadata-xml-page', | ||
templateUrl: './metadata-xml.component.html', | ||
styleUrls: [] | ||
}) | ||
export class MetadataXmlComponent { | ||
|
||
private ngUnsubscribe: Subject<void> = new Subject<void>(); | ||
|
||
entity: Metadata; | ||
entity$: Observable<Metadata>; | ||
xml: string; | ||
xml$: Observable<string>; | ||
|
||
constructor( | ||
private store: Store<fromConfiguration.ConfigurationState> | ||
) { | ||
this.xml$ = this.store.select(fromConfiguration.getConfigurationXml); | ||
this.entity$ = this.store.select(fromConfiguration.getConfigurationModel); | ||
} | ||
|
||
preview(): void { | ||
this.store.dispatch(new DownloadXml()); | ||
} | ||
} |
Oops, something went wrong.