Commit 11f65d61 authored by Thomas Lechauve's avatar Thomas Lechauve

First stable demo version (Library)

Only authentication by facebook with mobile format works
parent c46e6e98
...@@ -10,12 +10,20 @@ JSDIR = js ...@@ -10,12 +10,20 @@ JSDIR = js
FINALJS = vifib.js FINALJS = vifib.js
FINALCSS = vifib.css FINALCSS = vifib.css
all: test release all: dev release
######################################### #########################################
# Dev environment # Dev environment
######################################### #########################################
# Emulate server responses with sinonjs
fake: dev ${DEVDIR}/js/fake.js
cat $(CATJSFILES) ${DEVDIR}/js/fake.js > ${DEVDIR}/$(FINALJS)
${DEVDIR}/js/fake.js: js/utils/fake.js
@mkdir -p $(@D)
cp $< $@
# Sort files for concatenation # Sort files for concatenation
CATJSFILES = ${DEVDIR}/lib/jquery.js ${DEVDIR}/lib/sinon.js ${DEVDIR}/lib/mustache.js ${DEVDIR}/lib/spin.js ${DEVDIR}/lib/modernizr.js ${DEVDIR}/lib/swipe.js ${DEVDIR}/js/jquery.slapos.js ${DEVDIR}/js/init.js ${DEVDIR}/lib/jquery-mobile.js ${DEVDIR}/js/url.js ${DEVDIR}/js/route.js ${DEVDIR}/js/main.js ${DEVDIR}/js/render.js ${DEVDIR}/js/panels.js ${DEVDIR}/js/pages.js ${DEVDIR}/js/pages.mobile.js ${DEVDIR}/js/pages.tablet.js ${DEVDIR}/js/pages.desktop.js CATJSFILES = ${DEVDIR}/lib/jquery.js ${DEVDIR}/lib/sinon.js ${DEVDIR}/lib/mustache.js ${DEVDIR}/lib/spin.js ${DEVDIR}/lib/modernizr.js ${DEVDIR}/lib/swipe.js ${DEVDIR}/js/jquery.slapos.js ${DEVDIR}/js/init.js ${DEVDIR}/lib/jquery-mobile.js ${DEVDIR}/js/url.js ${DEVDIR}/js/route.js ${DEVDIR}/js/main.js ${DEVDIR}/js/render.js ${DEVDIR}/js/panels.js ${DEVDIR}/js/pages.js ${DEVDIR}/js/pages.mobile.js ${DEVDIR}/js/pages.tablet.js ${DEVDIR}/js/pages.desktop.js
......
...@@ -121,17 +121,18 @@ ...@@ -121,17 +121,18 @@
return $(this).slapos('request', 'GET', '', args); return $(this).slapos('request', 'GET', '', args);
}, },
//softwareList: function (args) { softwareList: function (args) {
//return $(this).slapos('request', '', args); return $(this).slapos('request', 'GET', '/software', args);
//}, },
//softwareInfo: function (url, args) { softwareInfo: function (url, args) {
//return $(this).slapos('request', '', args); $.extend(args, {url: url});
//}, return $(this).slapos('request', 'GET', '', args);
},
//computerList: function (args) { computerList: function (args) {
//return $(this).slapos('request', '', args); return $(this).slapos('request', '', args);
//}, },
computerInfo: function (url, args) { computerInfo: function (url, args) {
$.extend(args, {url: url}); $.extend(args, {url: url});
......
'use strict'; 'use strict';
var getDevice = function (w) { var getDevice = function (w) {
return 'mobile'; if (w < 500) {
if (w < 600) {
return 'mobile'; return 'mobile';
} }
if (w < 1281) { if (w < 900) {
return 'tablet'; return 'tablet';
} }
return 'desktop'; return 'desktop';
...@@ -15,9 +14,15 @@ var body = $("body"); ...@@ -15,9 +14,15 @@ var body = $("body");
$.vifib.devices = { $.vifib.devices = {
"mobile": function (url) { "mobile": function (url) {
$('body') if ($.vifib.isauthenticated()) {
.route('add', '') $('body')
.done($.vifib.mobile.overview); .route('add', '')
.done($.vifib.mobile.dashboard);
} else {
$('body')
.route('add', '')
.done($.vifib.mobile.overview);
}
$('body') $('body')
.route('add', '/login/facebook') .route('add', '/login/facebook')
.done($.vifib.login.facebook); .done($.vifib.login.facebook);
...@@ -59,7 +64,16 @@ $.vifib.devices = { ...@@ -59,7 +64,16 @@ $.vifib.devices = {
} }
$.vifib.isauthenticated = function () { $.vifib.isauthenticated = function () {
return true; var token_type = $(document).slapos('store', 'token_type');
if ($(document).slapos('access_token') === undefined || token_type === undefined) {
return false;
}
if (token_type === 'Google') {
} else if (token_type === 'Facebook') {
}
return false;
} }
$.vifib.startrouter = function () { $.vifib.startrouter = function () {
......
...@@ -32,7 +32,7 @@ $.vifib.desktop = { ...@@ -32,7 +32,7 @@ $.vifib.desktop = {
}, },
overview: function (route) { overview: function (route) {
$.vifib.replacepanel($(this), $.vifib.panel.carousel); $.vifib.replacepanel($(this), $.vifib.panel.carousel);
if ( Modernizr.csstransforms ) { if (Modernizr.csstransforms) {
window.mySwipe = new Swipe(document.getElementById('slider'), { window.mySwipe = new Swipe(document.getElementById('slider'), {
speed: 800, speed: 800,
auto: 4000, auto: 4000,
...@@ -40,7 +40,6 @@ $.vifib.desktop = { ...@@ -40,7 +40,6 @@ $.vifib.desktop = {
}); });
} }
$.vifib.replacepanel($('#panel-2'), $.vifib.panel.login); $.vifib.replacepanel($('#panel-2'), $.vifib.panel.login);
window.mySwipe.begin();
}, },
library: { library: {
dispatch: function (route) { dispatch: function (route) {
...@@ -58,7 +57,7 @@ $.vifib.desktop = { ...@@ -58,7 +57,7 @@ $.vifib.desktop = {
.route('add', '/library/', 2) .route('add', '/library/', 2)
.done($.vifib.desktop.library.overview); .done($.vifib.desktop.library.overview);
$('#panel-2') $('#panel-2')
.route('add', '/library/software/<softid>', 2) .route('add', '/library/software/id<path:softid>', 2)
.done($.vifib.desktop.library.software); .done($.vifib.desktop.library.software);
$('#panel-2') $('#panel-2')
.route('add', '/library/all', 2) .route('add', '/library/all', 2)
...@@ -70,10 +69,10 @@ $.vifib.desktop = { ...@@ -70,10 +69,10 @@ $.vifib.desktop = {
overview: function (route) { overview: function (route) {
$.vifib.replacepanel($(this), $.vifib.panel.library, { $.vifib.replacepanel($(this), $.vifib.panel.library, {
most: [ most: [
{url: '#/library/software/kvm', name: 'Kvm'}, {url: '#/library/software/id/fake/software_info/kvm', name: 'Kvm'},
], ],
newest: [ newest: [
{url: '#/library/software/html5', name: 'html5 AS'} {url: '#/library/software/id/fake/software_info/html5', name: 'html5 AS'}
] ]
}); });
}, },
......
...@@ -17,7 +17,6 @@ $.vifib.login = { ...@@ -17,7 +17,6 @@ $.vifib.login = {
'&redirect_uri=' + encodeURIComponent(redirect) + '&redirect_uri=' + encodeURIComponent(redirect) +
'&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email++https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile' + '&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email++https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile' +
'&response_type=token'; '&response_type=token';
console.log(ggurl);
$(document).slapos('store', 'token_type', 'Google'); $(document).slapos('store', 'token_type', 'Google');
window.location.href = ggurl; window.location.href = ggurl;
} }
...@@ -54,21 +53,39 @@ $.vifib.softwareList = function (context) { ...@@ -54,21 +53,39 @@ $.vifib.softwareList = function (context) {
}); });
}); });
} }
$.vifib.instanceList = function (context) { $.vifib.instanceList = function (context) {
var list; var list;
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) {
$.each(response.list, function (index, inst) { $.when(
var row = $.vifib.fillRowInstance($('<li></li>'), inst); $.vifib.fillRowInstance(list, $('<li></li>'), response.list[0])
list.append(row); ).then(function () {
list.listview('refresh');
}); });
list.listview('refresh'); //$.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 = function (list, row, instid) {
return row.slapos('instanceInfo', instid, {
success: function (response) {
$.extend(response, {insturl: '#/dashboard/instance/id' + instid});
$(this).html(Mustache.render($.vifib.panel.rowinstance, response));
},
complete: function (jqxhr, textstatus) {
list.append($(this));
}
});
}
$.vifib.computerList = function (context) { $.vifib.computerList = function (context) {
var list; var list;
return context.each(function () { return context.each(function () {
...@@ -88,22 +105,12 @@ $.vifib.fillRowSoftware = function (context, softid) { ...@@ -88,22 +105,12 @@ $.vifib.fillRowSoftware = function (context, softid) {
return context.each(function () { return context.each(function () {
$(this).slapos('softwareInfo', softid, { $(this).slapos('softwareInfo', softid, {
success: function (response) { success: function (response) {
$.extend(response, {softurl: '#/library/software/' + softid}); $.extend(response, {softurl: '#/library/software/id' + softid});
$(this).html(Mustache.render($.vifib.panel.rowsoftware, response)); $(this).html(Mustache.render($.vifib.panel.rowsoftware, response));
} }
}); });
}) })
} }
$.vifib.fillRowInstance = function (context, instid) {
return context.each(function () {
$(this).slapos('instanceInfo', instid, {
success: function (response) {
$.extend(response, {insturl: '#/dashboard/instance/id' + instid});
$(this).html(Mustache.render($.vifib.panel.rowinstance, response));
}
});
})
}
$.vifib.fillRowComputer = function (context, compid) { $.vifib.fillRowComputer = function (context, compid) {
return context.each(function () { return context.each(function () {
$(this).slapos('computerInfo', compid, { $(this).slapos('computerInfo', compid, {
......
...@@ -21,7 +21,7 @@ $.vifib.mobile = { ...@@ -21,7 +21,7 @@ $.vifib.mobile = {
.route('add', '/library/', 1) .route('add', '/library/', 1)
.done($.vifib.mobile.library.overview); .done($.vifib.mobile.library.overview);
$('body') $('body')
.route('add', '/library/software/<softid>', 1) .route('add', '/library/software/id<path:softid>', 1)
.done($.vifib.mobile.library.software); .done($.vifib.mobile.library.software);
$('body') $('body')
.route('add', '/library/all', 1) .route('add', '/library/all', 1)
...@@ -33,10 +33,10 @@ $.vifib.mobile = { ...@@ -33,10 +33,10 @@ $.vifib.mobile = {
overview: function () { overview: function () {
page = $.vifib.onepanel($.vifib.panel.library, { page = $.vifib.onepanel($.vifib.panel.library, {
most: [ most: [
{url: '#/library/software/kvm', name: 'Kvm'}, {url: '#/library/software/id/fake/software_info/kvm', name: 'Kvm'},
], ],
newest: [ newest: [
{url: '#/library/software/html5', name: 'html5 AS'} {url: '#/library/software/id/fake/software_info/html5', name: 'html5 AS'}
] ]
}); });
// header // header
......
...@@ -36,7 +36,7 @@ $.vifib.tablet = { ...@@ -36,7 +36,7 @@ $.vifib.tablet = {
.route('add', '/library/', 1) .route('add', '/library/', 1)
.done($.vifib.tablet.library.overview); .done($.vifib.tablet.library.overview);
$('#panel-1') $('#panel-1')
.route('add', '/library/software/<softid>', 1) .route('add', '/library/software/id<path:softid>', 1)
.done($.vifib.tablet.library.software); .done($.vifib.tablet.library.software);
$('#panel-1') $('#panel-1')
.route('add', '/library/all', 1) .route('add', '/library/all', 1)
...@@ -47,8 +47,8 @@ $.vifib.tablet = { ...@@ -47,8 +47,8 @@ $.vifib.tablet = {
}, },
overview: function () { overview: function () {
$.vifib.replacepanel($(this), $.vifib.panel.library, { $.vifib.replacepanel($(this), $.vifib.panel.library, {
most: [{url: '#/library/software/kvm', name: 'Kvm'},], most: [{url: '#/library/software/id/fake/software_info/kvm', name: 'Kvm'},],
newest: [{url: '#/library/software/html5', name: 'html5 AS'}] newest: [{url: '#/library/software/id/fake/software_info/html5', name: 'html5 AS'}]
}); });
}, },
software: function (softid) { software: function (softid) {
......
...@@ -142,12 +142,7 @@ $.vifib.panel = { ...@@ -142,12 +142,7 @@ $.vifib.panel = {
'</ul>' + '</ul>' +
'</article>', '</article>',
rowinstance: rowinstance:
'<a href="{{ insturl }}">' + '<a href="{{ insturl }}">{{ title }}</a>',
'{{# thumb_url }}' +
'<img src="{{ thumb_url }}">'+
'{{/ thumb_url }}' +
'{{ instance_id }}' +
'</a>',
computer: computer:
'<article>' + '<article>' +
'<h2>{{ computer_id }}</h2>' + '<h2>{{ computer_id }}</h2>' +
......
...@@ -19,7 +19,8 @@ $.vifib.threepanel = function (panels, data) { ...@@ -19,7 +19,8 @@ $.vifib.threepanel = function (panels, data) {
} }
$.vifib.replacepanel = function (context, panel, data) { $.vifib.replacepanel = function (context, panel, data) {
context.html(Mustache.render(panel, data)).trigger('pagecreate'); context.html(Mustache.render(panel, data));
$(':jqmData(role=page)').trigger('pagecreate');
} }
$.vifib.makecontent = function (panels, data) { $.vifib.makecontent = function (panels, data) {
......
...@@ -14,24 +14,24 @@ var comp = { ...@@ -14,24 +14,24 @@ var comp = {
}; };
var inst ={ var inst ={
instance_id: "INST-1", title: "INST-1",
status: "stop_requested", status: "stop_requested",
software_release: "http://example.com/example.cfg", software_release: "http://example.com/example.cfg",
software_type: "type_provided_by_the_software", software_type: "type_provided_by_the_software",
slave: "False", slave: "False",
connection: [{ connection: [{
key: "foo", key: "foo",
key: "bar"}], key: "bar"}],
parameter: { parameter: {
Custom1: "one string", Custom1: "one string",
Custom2: "one float", Custom2: "one float",
Custom3: ["abc", "def"]}, Custom3: ["abc", "def"]},
sla: {computer_id: "COMP-0"}, sla: {computer_id: "COMP-0"},
children_id_list: ["subinstance1", "subinstance2"], children_id_list: ["subinstance1", "subinstance2"],
partition: { partition: {
public_ip: ["::1", "91.121.63.94"], public_ip: ["::1", "91.121.63.94"],
private_ip: ["127.0.0.1"], private_ip: ["127.0.0.1"],
tap_interface: "tap2"} tap_interface: "tap2"}
}; };
var soft = { var soft = {
...@@ -59,7 +59,8 @@ var software_list = { ...@@ -59,7 +59,8 @@ var software_list = {
var instance_list = { var instance_list = {
list: [ list: [
'/fake/instance_info/kvm' '/fake/instance_info/kvm',
'/fake/instance_info/kvm',
] ]
}; };
...@@ -110,3 +111,5 @@ $.ajax = function(url, options){ ...@@ -110,3 +111,5 @@ $.ajax = function(url, options){
fakeserver.respond(); fakeserver.respond();
return result; return result;
}; };
$(document).slapos('store', 'host', '/fake');
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