Commit 2b12f3d5 authored by Vitali Stupin's avatar Vitali Stupin
Browse files

Bugfixes, cleanups

parent a87cfb8b
......@@ -25,7 +25,6 @@ export class MethodsService {
private lastMessage: string = '';
@Output() subsystemsUpdated: EventEmitter<any> = new EventEmitter();
@Output() hideDetails: EventEmitter<boolean> = new EventEmitter();
@Output() newMessage: EventEmitter<string> = new EventEmitter();
constructor(private http: HttpClient) {
......@@ -44,14 +43,13 @@ export class MethodsService {
this.subsystemsUpdated.emit(null);
}
private signalHideDetails(signal: boolean) {
this.hideDetails.emit(signal);
}
private filteredSubsystems(): Subsystem[] {
let filtered: Subsystem[] = []
let limit: number = this.limit
for (let subsystem of this.subsystems) {
for (let x of this.subsystems) {
// Copy object to avoid overwriting methods array
// TODO: Is there a better way???
let subsystem = Object.assign(Object.create(x), x);
if (this.nonEmpty && !subsystem.methods.length) {
// Filtering out empty subsystems
continue
......@@ -77,6 +75,7 @@ export class MethodsService {
// No matching method names found
continue
}
// Leaving only matcing methods
subsystem.methods = filteredMethods
}
......@@ -105,6 +104,10 @@ export class MethodsService {
}
}
getApiUrlBase(): string {
return this.apiUrlBase
}
getLimit(): string {
if (this.limit == MAX_LIMIT) {
return 'All'
......@@ -152,13 +155,6 @@ export class MethodsService {
setFilter(filter: string) {
if (this.filter != filter.trim()) {
if (filter.trim() == '') {
// Always close methods when filter is deleted
this.signalHideDetails(true)
} else {
// Always open methods when filter is inserted
this.signalHideDetails(false)
}
this.filter = filter.trim();
this.signalRefresh();
}
......
......@@ -14,7 +14,7 @@
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'OK' && subsystem.methods.length">
<p *ngFor="let method of getMethodsPreview()">
{{method.fullMethodName}}
<a href="{{methodsService.apiUrlBase}}{{method.wsdl}}" class="badge badge-success"
<a href="{{getApiUrlBase()}}{{method.wsdl}}" class="badge badge-success"
*ngIf="method.wsdl" [target]="'_blank'">WSDL</a>
<span class="badge badge-danger" *ngIf="!method.wsdl">Error while downloading or parsing of WSDL</span>
</p>
......
......@@ -22,6 +22,10 @@ export class SubsystemItemComponent implements OnInit {
ngOnInit() {
}
getApiUrlBase(): string {
return this.methodsService.getApiUrlBase()
}
getMethodsPreview(): Method[] {
return this.subsystem.methods.length ? this.subsystem.methods.slice(0, this.previewSize) : []
}
......
......@@ -21,7 +21,7 @@
<div class="card-body" *ngIf="subsystem.subsystemStatus == 'OK' && subsystem.methods.length">
<p *ngFor="let method of subsystem.methods">
{{method.fullMethodName}}
<a href="{{methodsService.apiUrlBase}}{{method.wsdl}}" class="badge badge-success"
<a href="{{getApiUrlBase()}}{{method.wsdl}}" class="badge badge-success"
*ngIf="method.wsdl" [target]="'_blank'">WSDL</a>
<span class="badge badge-danger" *ngIf="!method.wsdl">Error while downloading or parsing of WSDL</span>
</p>
......
......@@ -30,13 +30,20 @@ export class SubsystemComponent implements OnInit {
getSubsystem() {
this.subsystemId = this.route.snapshot.paramMap.get('id')
// Show data if already available
this.subsystem = this.methodsService.getSubsystem(this.subsystemId)
// Service will tell when updated data is available!
//console.log(this.subsystem)
// Service will tell when data has finished loading
this.methodsService.subsystemsUpdated.subscribe(signal => {
this.subsystem = this.methodsService.getSubsystem(this.subsystemId)
//console.log(this.subsystem)
});
}
getApiUrlBase(): string {
return this.methodsService.getApiUrlBase()
}
goToList(): void {
//this.location.back();
this.router.navigateByUrl('/list')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment