Commit 0c3a069a authored by Thomas Lechauve's avatar Thomas Lechauve

Add route for google token response

When google send back access token it reset hashtag
so we have to handle this with a new route especially for google
authentication
parent 11f65d61
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" /> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<link rel="stylesheet" href="vifib.css" />
<!--<script src="js/utils/fake.js"></script>-->
<script src="vifib.js"></script> <script src="vifib.js"></script>
<style> <style>
.ui-content{ .ui-content{
......
'use strict'; 'use strict';
var getDevice = function (w) { var getDevice = function (w) {
return 'mobile';
if (w < 500) { if (w < 500) {
return 'mobile'; return 'mobile';
} }
...@@ -14,21 +15,19 @@ var body = $("body"); ...@@ -14,21 +15,19 @@ var body = $("body");
$.vifib.devices = { $.vifib.devices = {
"mobile": function (url) { "mobile": function (url) {
if ($.vifib.isauthenticated()) {
$('body')
.route('add', '')
.done($.vifib.mobile.dashboard);
} else {
$('body') $('body')
.route('add', '') .route('add', '')
.done($.vifib.mobile.overview); .done($.vifib.mobile.overview);
}
$('body') $('body')
.route('add', '/login/facebook') .route('add', '/login/facebook')
.done($.vifib.login.facebook); .done($.vifib.login.facebook);
$('body') $('body')
.route('add', '/login/google') .route('add', '/login/google')
.done($.vifib.login.google); .done($.vifib.login.google);
// when oogle send back the token, it reset hashtag from url
$('body')
.route('add', 'access_token=<path:path>')
.done($.vifib.login.googleRedirect);
$('body') $('body')
.route('add', '/overview') .route('add', '/overview')
.done($.vifib.mobile.overview); .done($.vifib.mobile.overview);
......
...@@ -19,6 +19,16 @@ $.vifib.login = { ...@@ -19,6 +19,16 @@ $.vifib.login = {
'&response_type=token'; '&response_type=token';
$(document).slapos('store', 'token_type', 'Google'); $(document).slapos('store', 'token_type', 'Google');
window.location.href = ggurl; window.location.href = ggurl;
},
googleRedirect: function (response) {
var options = {},
option;
response = 'access_token=' + response;
$.each(response.split('&'), function (i, e) {
option = e.split('=');
options[option[0]] = option[1];
});
$.url.redirect('/dashboard/', options);
} }
} }
$.vifib.statuscode = { $.vifib.statuscode = {
...@@ -53,24 +63,23 @@ $.vifib.softwareList = function (context) { ...@@ -53,24 +63,23 @@ $.vifib.softwareList = function (context) {
}); });
}); });
} }
$.vifib.instanceList = function (context) { $.vifib.instanceList = function (context) {
var list; var list,
countRequest = 0;
return context.each(function () { return context.each(function () {
list = $(this).find('ul'); list = $(this).find('ul');
$(this).slapos('instanceList', { $(this).slapos('instanceList', {
success: function (response) { success: function (response) {
$.when( $(this).ajaxSend(function () { ++countRequest; });
$.vifib.fillRowInstance(list, $('<li></li>'), response.list[0]) $(this).ajaxComplete(function () {
).then(function () { if (countRequest-- == 0) {
console.log("the end")
list.listview('refresh'); list.listview('refresh');
} else {
console.log(countRequest)
}
}); });
//$.when.apply($(this), $.map(response.list, function (inst) { $.vifib.fillRowInstance(list, $('<li></li>'), '');
//$.vifib.fillRowInstance(list, $('<li></li>'), inst);
//})).done(function (a, b, c) {
//console.log(arguments);
//list.listview('refresh');
//});
}, },
}); });
}); });
...@@ -82,6 +91,7 @@ $.vifib.fillRowInstance = function (list, row, instid) { ...@@ -82,6 +91,7 @@ $.vifib.fillRowInstance = function (list, row, instid) {
$(this).html(Mustache.render($.vifib.panel.rowinstance, response)); $(this).html(Mustache.render($.vifib.panel.rowinstance, response));
}, },
complete: function (jqxhr, textstatus) { complete: function (jqxhr, textstatus) {
console.log("complete")
list.append($(this)); list.append($(this));
} }
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment