Skip to content

Commit

Permalink
Challenge descriptions
Browse files Browse the repository at this point in the history
Fixes #55

Signed-off-by: Mirko Mollik <[email protected]>
  • Loading branch information
cre8 committed Aug 16, 2023
2 parents 2906a4c + 4443ef4 commit 5113347
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
11 changes: 11 additions & 0 deletions viewer/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,15 @@ export class AppService {
}
return '';
}

getType(value: any) {
if (value.type) {
return value.type;
} else {
const ref = value.allOf ? value.allOf[0].$ref : value.$ref;
const res = JSON.parse(JSON.stringify(def));
const id = ref.split('/')[2];
return res.definitions[id].type;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { CredentialProfileAddDialogComponent } from '../credential-profile-add-dialog/credential-profile-add-dialog.component';
import { AppService, Resource } from '../app.service';
import { Format, Property, Resources } from '../resources';
import { Format, Resources } from '../resources';
import { Filter, FilterComponent } from '../filter/filter.component';
import { MatPaginator } from '@angular/material/paginator';

Expand Down Expand Up @@ -45,8 +45,9 @@ export class CredentialProfileComponent implements OnInit, AfterViewInit {
if (value === '$schema') return;
this.allColumns.push({
key: value,
tooltip: (this.data.structure.properties[value] as Property)
.description,
tooltip: this.appService.getTooltip(
this.data.structure.properties[value]
),
});
});
for (const key of this.appService.extraValues) {
Expand Down Expand Up @@ -101,11 +102,14 @@ export class CredentialProfileComponent implements OnInit, AfterViewInit {
})
// filter out the columns that do not match with the filter
.filter((value) => {
if (Object.keys(this.filter).length === 0) return true;
for (const category in this.filter) {
for (const key in this.filter[category]) {
if (this.filter[category][key]) {
const res = value[`${category} - ${key}`];
return typeof res === 'object' ? res.Value : res;
if (typeof res === 'object' ? res.Value : res === false) {
return false;
}
}
}
}
Expand Down
21 changes: 11 additions & 10 deletions viewer/src/app/filter/filter.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ export class FilterComponent implements OnInit {
.structure.properties;
Object.keys(subValues).forEach((value: string) => {
if (value === '$schema') return;
elements.push({
value: `${key} - ${value}`,
show: value,
type: subValues[value].type ?? 'boolean',
tooltip:
subValues[value].description ??
subValues[value].allOf[1].description,
});
if (this.isCheckbox(elements[elements.length - 1])) {
group.addControl(value, new FormControl());
const type = this.appService.getType(subValues[value]);
if (type === 'boolean' || type.includes('boolean')) {
elements.push({
value: `${key} - ${value}`,
show: value,
type: subValues[value].type ?? 'boolean',
tooltip: this.appService.getTooltip(subValues[value]),
});
if (this.isCheckbox(elements[elements.length - 1])) {
group.addControl(value, new FormControl());
}
}
});
this.selectionColumns.push({
Expand Down
4 changes: 2 additions & 2 deletions viewer/src/app/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute, Router } from '@angular/router';
import { AppService } from '../app.service';
import { Format, Property, Resources } from '../resources';
import { Format, Resources } from '../resources';
import { MatPaginator } from '@angular/material/paginator';
import { MatChipInputEvent } from '@angular/material/chips';
import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
Expand Down Expand Up @@ -66,7 +66,7 @@ export class TableComponent implements OnInit, AfterViewInit {
this.allColumns = this.getNames();
this.columns = this.getNames().map((key) => ({
header: key,
tooltip: (this.data.structure.properties[key] as Property).description,
tooltip: this.appService.getTooltip(this.data.structure.properties[key]),
}));
this.dataSource.data = Object.keys(this.data.values)
.filter((key) => key !== 'structure')
Expand Down

0 comments on commit 5113347

Please sign in to comment.