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
FINALJS = vifib.js
FINALCSS = vifib.css
all: test release
all: dev release
#########################################
# 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
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 @@
return $(this).slapos('request', 'GET', '', args);
},
//softwareList: function (args) {
//return $(this).slapos('request', '', args);
//},
softwareList: function (args) {
return $(this).slapos('request', 'GET', '/software', args);
},
//softwareInfo: function (url, args) {
//return $(this).slapos('request', '', args);
//},
softwareInfo: function (url, args) {
$.extend(args, {url: url});
return $(this).slapos('request', 'GET', '', args);
},
//computerList: function (args) {
//return $(this).slapos('request', '', args);
//},
computerList: function (args) {
return $(this).slapos('request', '', args);
},
computerInfo: function (url, args) {
$.extend(args, {url: url});
......
'use strict';
var getDevice = function (w) {
return 'mobile';
if (w < 600) {
if (w < 500) {
return 'mobile';
}
if (w < 1281) {
if (w < 900) {
return 'tablet';
}
return 'desktop';
......@@ -15,9 +14,15 @@ var body = $("body");
$.vifib.devices = {
"mobile": function (url) {
$('body')
.route('add', '')
.done($.vifib.mobile.overview);
if ($.vifib.isauthenticated()) {
$('body')
.route('add', '')
.done($.vifib.mobile.dashboard);
} else {
$('body')
.route('add', '')
.done($.vifib.mobile.overview);
}
$('body')
.route('add', '/login/facebook')
.done($.vifib.login.facebook);
......@@ -59,7 +64,16 @@ $.vifib.devices = {
}
$.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 () {
......
......@@ -32,7 +32,7 @@ $.vifib.desktop = {
},
overview: function (route) {
$.vifib.replacepanel($(this), $.vifib.panel.carousel);
if ( Modernizr.csstransforms ) {
if (Modernizr.csstransforms) {
window.mySwipe = new Swipe(document.getElementById('slider'), {
speed: 800,
auto: 4000,
......@@ -40,7 +40,6 @@ $.vifib.desktop = {
});
}
$.vifib.replacepanel($('#panel-2'), $.vifib.panel.login);
window.mySwipe.begin();
},
library: {
dispatch: function (route) {
......@@ -58,7 +57,7 @@ $.vifib.desktop = {
.route('add', '/library/', 2)
.done($.vifib.desktop.library.overview);
$('#panel-2')
.route('add', '/library/software/<softid>', 2)
.route('add', '/library/software/id<path:softid>', 2)
.done($.vifib.desktop.library.software);
$('#panel-2')
.route('add', '/library/all', 2)
......@@ -70,10 +69,10 @@ $.vifib.desktop = {
overview: function (route) {
$.vifib.replacepanel($(this), $.vifib.panel.library, {
most: [
{url: '#/library/software/kvm', name: 'Kvm'},
{url: '#/library/software/id/fake/software_info/kvm', name: 'Kvm'},
],
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 = {
'&redirect_uri=' + encodeURIComponent(redirect) +
'&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email++https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile' +
'&response_type=token';
console.log(ggurl);
$(document).slapos('store', 'token_type', 'Google');
window.location.href = ggurl;
}
......@@ -54,21 +53,39 @@ $.vifib.softwareList = function (context) {
});
});
}
$.vifib.instanceList = function (context) {
var list;
return context.each(function () {
list = $(this).find('ul');
$(this).slapos('instanceList', {
success: function (response) {
$.each(response.list, function (index, inst) {
var row = $.vifib.fillRowInstance($('<li></li>'), inst);
list.append(row);
$.when(
$.vifib.fillRowInstance(list, $('<li></li>'), response.list[0])
).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) {
var list;
return context.each(function () {
......@@ -88,22 +105,12 @@ $.vifib.fillRowSoftware = function (context, softid) {
return context.each(function () {
$(this).slapos('softwareInfo', softid, {
success: function (response) {
$.extend(response, {softurl: '#/library/software/' + softid});
$.extend(response, {softurl: '#/library/software/id' + softid});
$(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) {
return context.each(function () {
$(this).slapos('computerInfo', compid, {
......
......@@ -21,7 +21,7 @@ $.vifib.mobile = {
.route('add', '/library/', 1)
.done($.vifib.mobile.library.overview);
$('body')
.route('add', '/library/software/<softid>', 1)
.route('add', '/library/software/id<path:softid>', 1)
.done($.vifib.mobile.library.software);
$('body')
.route('add', '/library/all', 1)
......@@ -33,10 +33,10 @@ $.vifib.mobile = {
overview: function () {
page = $.vifib.onepanel($.vifib.panel.library, {
most: [
{url: '#/library/software/kvm', name: 'Kvm'},
{url: '#/library/software/id/fake/software_info/kvm', name: 'Kvm'},
],
newest: [
{url: '#/library/software/html5', name: 'html5 AS'}
{url: '#/library/software/id/fake/software_info/html5', name: 'html5 AS'}
]
});
// header
......
......@@ -36,7 +36,7 @@ $.vifib.tablet = {
.route('add', '/library/', 1)
.done($.vifib.tablet.library.overview);
$('#panel-1')
.route('add', '/library/software/<softid>', 1)
.route('add', '/library/software/id<path:softid>', 1)
.done($.vifib.tablet.library.software);
$('#panel-1')
.route('add', '/library/all', 1)
......@@ -47,8 +47,8 @@ $.vifib.tablet = {
},
overview: function () {
$.vifib.replacepanel($(this), $.vifib.panel.library, {
most: [{url: '#/library/software/kvm', name: 'Kvm'},],
newest: [{url: '#/library/software/html5', name: 'html5 AS'}]
most: [{url: '#/library/software/id/fake/software_info/kvm', name: 'Kvm'},],
newest: [{url: '#/library/software/id/fake/software_info/html5', name: 'html5 AS'}]
});
},
software: function (softid) {
......
......@@ -142,12 +142,7 @@ $.vifib.panel = {
'</ul>' +
'</article>',
rowinstance:
'<a href="{{ insturl }}">' +
'{{# thumb_url }}' +
'<img src="{{ thumb_url }}">'+
'{{/ thumb_url }}' +
'{{ instance_id }}' +
'</a>',
'<a href="{{ insturl }}">{{ title }}</a>',
computer:
'<article>' +
'<h2>{{ computer_id }}</h2>' +
......
......@@ -19,7 +19,8 @@ $.vifib.threepanel = function (panels, 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) {
......
......@@ -14,24 +14,24 @@ var comp = {
};
var inst ={
instance_id: "INST-1",
title: "INST-1",
status: "stop_requested",
software_release: "http://example.com/example.cfg",
software_type: "type_provided_by_the_software",
slave: "False",
connection: [{
key: "foo",
key: "bar"}],
parameter: {
Custom1: "one string",
Custom2: "one float",
Custom3: ["abc", "def"]},
sla: {computer_id: "COMP-0"},
children_id_list: ["subinstance1", "subinstance2"],
partition: {
public_ip: ["::1", "91.121.63.94"],
private_ip: ["127.0.0.1"],
tap_interface: "tap2"}
software_release: "http://example.com/example.cfg",
software_type: "type_provided_by_the_software",
slave: "False",
connection: [{
key: "foo",
key: "bar"}],
parameter: {
Custom1: "one string",
Custom2: "one float",
Custom3: ["abc", "def"]},
sla: {computer_id: "COMP-0"},
children_id_list: ["subinstance1", "subinstance2"],
partition: {
public_ip: ["::1", "91.121.63.94"],
private_ip: ["127.0.0.1"],
tap_interface: "tap2"}
};
var soft = {
......@@ -59,7 +59,8 @@ var software_list = {
var instance_list = {
list: [
'/fake/instance_info/kvm'
'/fake/instance_info/kvm',
'/fake/instance_info/kvm',
]
};
......@@ -110,3 +111,5 @@ $.ajax = function(url, options){
fakeserver.respond();
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