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 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<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="vifib.css" />
<!--<script src="js/utils/fake.js"></script>-->
<script src="vifib.js"></script>
<style>
.ui-content{
......
'use strict';
var getDevice = function (w) {
return 'mobile';
if (w < 500) {
return 'mobile';
}
......@@ -14,21 +15,19 @@ var body = $("body");
$.vifib.devices = {
"mobile": function (url) {
if ($.vifib.isauthenticated()) {
$('body')
.route('add', '')
.done($.vifib.mobile.dashboard);
} else {
$('body')
.route('add', '')
.done($.vifib.mobile.overview);
}
$('body')
.route('add', '')
.done($.vifib.mobile.overview);
$('body')
.route('add', '/login/facebook')
.done($.vifib.login.facebook);
$('body')
.route('add', '/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')
.route('add', '/overview')
.done($.vifib.mobile.overview);
......
......@@ -19,6 +19,16 @@ $.vifib.login = {
'&response_type=token';
$(document).slapos('store', 'token_type', 'Google');
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 = {
......@@ -53,24 +63,23 @@ $.vifib.softwareList = function (context) {
});
});
}
$.vifib.instanceList = function (context) {
var list;
var list,
countRequest = 0;
return context.each(function () {
list = $(this).find('ul');
$(this).slapos('instanceList', {
success: function (response) {
$.when(
$.vifib.fillRowInstance(list, $('<li></li>'), response.list[0])
).then(function () {
list.listview('refresh');
$(this).ajaxSend(function () { ++countRequest; });
$(this).ajaxComplete(function () {
if (countRequest-- == 0) {
console.log("the end")
list.listview('refresh');
} else {
console.log(countRequest)
}
});
//$.when.apply($(this), $.map(response.list, function (inst) {
//$.vifib.fillRowInstance(list, $('<li></li>'), inst);
//})).done(function (a, b, c) {
//console.log(arguments);
//list.listview('refresh');
//});
$.vifib.fillRowInstance(list, $('<li></li>'), '');
},
});
});
......@@ -82,6 +91,7 @@ $.vifib.fillRowInstance = function (list, row, instid) {
$(this).html(Mustache.render($.vifib.panel.rowinstance, response));
},
complete: function (jqxhr, textstatus) {
console.log("complete")
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