Skip to content

Commit

Permalink
Merge pull request #367 from EverythingMe/feature/offline
Browse files Browse the repository at this point in the history
Fix #242: handle the case there is no connection to the server
  • Loading branch information
arikfr committed Jan 29, 2015
2 parents 3dde578 + 3960005 commit b76906b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions rd_ui/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<link rel="stylesheet" href="/bower_components/angular-ui-select/dist/select.css">
<link rel="stylesheet" href="/bower_components/pace/themes/pace-theme-minimal.css">
<link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.css">
<link rel="stylesheet" href="/bower_components/offline/themes/offline-theme-default.css">
<link rel="stylesheet" href="/bower_components/offline/themes/offline-language-english.css">
<link rel="stylesheet" href="/styles/redash.css">
<!-- endbuild -->
</head>
Expand Down Expand Up @@ -127,6 +129,7 @@
<script src="/bower_components/bucky/bucky.js"></script>
<script src="/bower_components/pace/pace.js"></script>
<script src="/bower_components/mustache/mustache.js"></script>
<script src="/bower_components/offline/offline.min.js"></script>
<!-- endbuild -->

<!-- build:js({.tmp,app}) /scripts/scripts.js -->
Expand Down
16 changes: 16 additions & 0 deletions rd_ui/app/scripts/services/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,22 @@
refreshStatus(queryResult, query, ttl);
}, 3000);
}
}, function() {
var upHandler = function() {
Offline.off('up', upHandler);
console.log('trying again');
refreshStatus(queryResult, query, ttl);
};

var downHandler = function() {
console.log('2 handling down case');

Offline.on('up', upHandler);
Offline.off('down', downHandler);
};

Offline.on('down', downHandler);
Offline.check();
})
}

Expand Down
3 changes: 2 additions & 1 deletion rd_ui/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"pace": "~0.5.1",
"angular-ui-select": "0.8.2",
"font-awesome": "~4.2.0",
"mustache": "~1.0.0"
"mustache": "~1.0.0",
"offline": "~0.7.11"
},
"devDependencies": {
"angular-mocks": "1.2.18",
Expand Down

0 comments on commit b76906b

Please sign in to comment.