Skip to content
This repository was archived by the owner on Aug 5, 2021. It is now read-only.

Commit bf3741d

Browse files
Merge pull request #597 from GSA/594
display additional metadata on desktop and mobile
2 parents 15e3671 + 9011d75 commit bf3741d

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/app/components/explore-code/repo/repo.component.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ <h2>{{ repo.name }}</h2>
6060
</ul>
6161
<p>{{repo.description}}</p>
6262
<br>
63+
<div *ngIf="repo.additional_data">
64+
<div class="metadata-entry" *ngFor="let key of getKeys(repo.additional_data)">
65+
<div class="metadata-key" [textContent]="clean(key)"></div>
66+
<div class="metadata-value" *ngIf="isArray(repo.additional_data[key])">
67+
<div *ngFor="let value of repo.additional_data[key]" [textContent]="value"></div>
68+
</div>
69+
<div class="metadata-value" *ngIf="!isArray(repo.additional_data[key])">
70+
<div [textContent]="repo.additional_data[key]"></div>
71+
</div>
72+
</div>
73+
</div>
74+
<br>
6375
<a *ngIf="getRepositoryUrl() | isdefined" href="{{ getRepositoryUrl() }}">
6476
<button class="button">Visit Repo</button>
6577
</a>

src/app/components/explore-code/repo/repo.component.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,28 @@
104104
display: none;
105105
}
106106
}
107+
108+
.metadata-entry {
109+
margin-top: 15px;
110+
margin-bottom: 15px;
111+
112+
.metadata-key {
113+
display: block;
114+
font-weight: bold;
115+
116+
@media screen and (min-width: $medium-screen) {
117+
display: inline-block;
118+
width: 200px;
119+
vertical-align: top;
120+
}
121+
}
122+
123+
.metadata-value {
124+
display: block;
125+
126+
@media screen and (min-width: $medium-screen) {
127+
display: inline-block;
128+
max-width: calc(100% - 300px);
129+
}
130+
}
131+
}

src/app/components/explore-code/repo/repo.component.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export class RepoComponent implements OnInit, OnDestroy {
3838
if (this.repoSub) this.repoSub.unsubscribe();
3939
}
4040

41+
getKeys(object) {
42+
return Object.keys(object);
43+
}
44+
4145
getRepo(agencyId, releaseId) {
4246
this.clientService.getRepoByID(releaseId).subscribe(repo => {
4347
this.repo = repo;
@@ -60,5 +64,18 @@ export class RepoComponent implements OnInit, OnDestroy {
6064
return this.repo.repositoryURL;
6165
}
6266

67+
isArray(input) {
68+
return Array.isArray(input);
69+
}
70+
71+
clean(input) {
72+
if (typeof input === "number") {
73+
return input.toString();
74+
} else if (typeof input === "string") {
75+
return input.replace(/[_-]/g, " ");
76+
} else {
77+
return JSON.stringify(input);
78+
}
79+
}
6380

6481
}

0 commit comments

Comments
 (0)