Skip to content

Commit

Permalink
Implements Atlas version display from package.json (#2134)
Browse files Browse the repository at this point in the history
* Implements Atlas version display from package.json

* update requirejs version

* fixes r.js crossplatform run

* added loading for release issues pane
  • Loading branch information
wivern authored Feb 21, 2020
1 parent 22f88ca commit b909515
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
/js/assets/fonts
/js/assets/images
js/config-local.js
js/version.js
package-lock.json
21 changes: 12 additions & 9 deletions js/pages/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,23 @@
<div class="heading">Release Notes</div>
<div class="release-notes">
<div class="paddedWrapper">
<a data-bind="attr: { href: atlasReleaseUrl }" target="_new">ATLAS Version <span data-bind="text: version"></span> Release Notes</a>
<a data-bind="attr: { href: atlasReleaseUrl }" target="_new">ATLAS Version <span data-bind="text: atlasVersion"></span> Release Notes</a>
<br/>
<a data-bind="attr: { href: webapiReleaseUrl }" target="_new">WebAPI Version <span data-bind="text: version"></span> Release Notes</a>
<a data-bind="attr: { href: webapiReleaseUrl }" target="_new">WebAPI Version <span data-bind="text: webapiVersion"></span> Release Notes</a>
</div>

<div class="paddedWrapper">
<br/>This latest release contains <strong data-bind="text:github_status().length"></strong> feature enhancements and issue resolutions:
</div>
<div data-bind="hidden: loading">
<div class="paddedWrapper">
<br/>This latest release contains <strong data-bind="text:github_status().length"></strong> feature enhancements and issue resolutions:
</div>

<div class="paddedWrapper github-issue-container" data-bind="foreach:github_status">
<div class="github-issue">
<a target="_blank" data-bind="attr:{href: html_url, title: title}, text:title"></a>
<img class="github-avatar" data-bind="attr:{src: user.avatar_url}" />
<div class="paddedWrapper github-issue-container" data-bind="foreach:github_status">
<div class="github-issue">
<a target="_blank" data-bind="attr:{href: html_url, title: title}, text:title"></a>
<img class="github-avatar" data-bind="attr:{src: user.avatar_url}" />
</div>
</div>
</div>
</div>
<loading data-bind="visible: loading" params="status: 'Loading release info'"></loading>
</div>
31 changes: 22 additions & 9 deletions js/pages/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ define([
'services/BuildInfoService',
'atlas-state',
'lodash',
'version',
'components/heading',
], function (
ko,
Expand All @@ -20,7 +21,8 @@ define([
authApi,
buildInfoService,
sharedState,
lodash
lodash,
version,
) {
class Home extends Page {
constructor(params) {
Expand All @@ -34,9 +36,11 @@ define([
this.canSearch = ko.computed(() => {
return authApi.isAuthenticated();
});
this.version = ko.observable();
this.atlasVersion = ko.observable(this.formatVersion(version));
this.webapiVersion = ko.observable();
this.atlasReleaseTag = ko.observable();
this.webapiReleaseTag = ko.observable();
this.loading = ko.observable();
this.atlasReleaseUrl = ko.computed(() => consts.releaseNotesUrl('Atlas', this.atlasReleaseTag()));
this.webapiReleaseUrl = ko.computed(() => consts.releaseNotesUrl('WebAPI', this.webapiReleaseTag()));
}
Expand All @@ -49,7 +53,7 @@ define([
const webapiReleaseTag = lodash.get(info, 'buildInfo.webapiRepositoryInfo.releaseTag');
this.atlasReleaseTag(atlasReleaseTag);
this.webapiReleaseTag(webapiReleaseTag);
this.version(this.getVersion(info));
this.webapiVersion(this.getWebapiVersion(info));
const atlasIssues = await this.getIssuesFromAllPages('OHDSI/Atlas', atlasMilestoneId);
const webapiIssues = await this.getIssuesFromAllPages('OHDSI/WebAPI', webapiMilestoneId);
let issues = lodash.orderBy([...atlasIssues, ...webapiIssues], ['closed_at'], ['desc']);
Expand All @@ -60,15 +64,24 @@ define([

async getIssuesFromAllPages(repo, milestone, page = 1, list = []) {

const { data } = await buildInfoService.getIssues(repo, milestone, page);
if (data.length === buildInfoService.ISSUES_PAGE_SIZE) {
return this.getIssuesFromAllPages(repo, milestone, page + 1, list.concat(data));
} else {
return list.concat(data);
this.loading(true);
try {
const {data} = await buildInfoService.getIssues(repo, milestone, page);
if (data.length === buildInfoService.ISSUES_PAGE_SIZE) {
return this.getIssuesFromAllPages(repo, milestone, page + 1, list.concat(data));
} else {
return list.concat(data);
}
} finally {
this.loading(false);
}
}

getVersion(info) {
formatVersion(ver) {
return ver.replace(/(\d+\.\d+\.\d+)-(.*)/, "$1 $2");
}

getWebapiVersion(info) {
let qualifier = false;
const artifactVersion = (info.buildInfo && info.buildInfo.artifactVersion) || '';
if (artifactVersion.match(/.*-SNAPSHOT/)) {
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "atlas",
"version": "2.8.0",
"version": "2.8.0-DEV",
"description": "is an open source software tool for researchers to conduct scientific analyses on standardized observational data converted to the OMOP Common Data Model V5",
"main": "js/main.js",
"scripts": {
"prep": "npm i && npm run clean",
"prep": "npm i && npm run clean && npm run genversion",
"clean": "rimraf ./js/assets/bundle && rimraf ./js/assets/fonts && rimraf ./js/assets/images",
"build": "npm run prep && npm run build:dev",
"build:dev": "node build/optimize.js && npm run compress",
"compress": "terser ./js/assets/bundle/bundle.js -o ./js/assets/bundle/bundle.js -c --source-map"
"compress": "terser ./js/assets/bundle/bundle.js -o ./js/assets/bundle/bundle.js -c --source-map",
"genversion": "genversion -s js/version/version.js && r_js -convert js/version js/ && rimraf js/version"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -38,7 +39,8 @@
"@babel/preset-env": "^7.1.5",
"esprima": "^4.0.1",
"html-document": "^0.8.1",
"requirejs": "^2.3.4",
"genversion": "^2.2.0",
"requirejs": "^2.3.6",
"rimraf": "^2.6.2",
"terser": "3.17.0"
},
Expand Down

0 comments on commit b909515

Please sign in to comment.