Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Commit

Permalink
feat(api): add warning for wrong version
Browse files Browse the repository at this point in the history
displays a warning if api version is wrong
Closes #251
  • Loading branch information
Daniel Stern committed Feb 6, 2015
1 parent 3ebab0d commit 9585248
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ angular.module("ngApp.config", [])
"version": "__VERSION__",
"commitLink": "https://github.com/NCI-GDC/portal-ui/commit/__COMMIT__",
"commitHash": "__COMMIT__",
"api": "__API__",
"api": "__API__", "supportedAPI":"1",
"tag":"https://github.com/NCI-GDC/portal-ui/releases/tag/__VERSION__"
});
6 changes: 6 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
</head>

<body>
<div class="alert alert-warning m-margin-bottom-0" ng-if="config.apiIsMismatched">
<a onclick="window.location.reload()">
A newer version of this software is available. Click here to refresh the page. <i class="fa fa-lg fa-refresh"></i>
</a>
</div>
<div id="notification"></div>
<a href="#skip" tabindex="1" class="skip-to-content" data-translate>Skip to Main Content</a>

Expand Down Expand Up @@ -97,6 +102,7 @@

<div id="skip" class="gdc-body" data-ui-view role="main" tabindex="0"></div>


<!-- NCI Footer -->
<footer id="footer">
<div class="container" role="contentinfo">
Expand Down
10 changes: 9 additions & 1 deletion app/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare module ngApp {
apiCommitHash: string;
apiCommitLink: string;
apiTag: string;
supportedAPI: string;
}

export interface IRootScope extends ng.IScope {
Expand Down Expand Up @@ -43,6 +44,8 @@ function appRun(gettextCatalog: any, Restangular: restangular.IProvider,
$rootScope: IRootScope, config: IGDCConfig, notify: INotifyService) {
gettextCatalog.debug = true;

//debugger;

$rootScope.config = config;
Restangular.setErrorInterceptor((response) => {
CoreService.xhrDone();
Expand All @@ -61,10 +64,15 @@ function appRun(gettextCatalog: any, Restangular: restangular.IProvider,
});

Restangular.all('status').get('').then(function(data){
config.apiVersion = data['version'];

config.apiVersion = data['tag'];
config.apiCommitHash = data['commit'];
config.apiTag = "https://github.com/NCI-GDC/gdcapi/releases/tag/" + config.apiVersion;
config.apiCommitLink ="https://github.com/NCI-GDC/gdcapi/commit/" + config.apiCommitHash;

if (+data.version !== +config.supportedAPI) {
config.apiIsMismatched = true;
};
});

$rootScope.$on("$stateChangeStart", () => {
Expand Down
3 changes: 3 additions & 0 deletions app/styles/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,6 @@ table .btn {
color: @link-blue;
}

.m-margin-bottom-0 {
margin-bottom: 0px;
}

0 comments on commit 9585248

Please sign in to comment.