Prototype OAuth3 Web App
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

60 lines
2.4 KiB

app.factory('websitesService',[
'$q', 'Auth', 'azp@oauth3.org', '$timeout', '$sce', '$stateParams',
function($q, Auth, Oauth3, $timeout, $sce, $stateParams){
// var shows = [];
// var shows = [{
// id: 1,
// name: 'Walking Dead',
// description: 'The Walking Dead is an American post-apocalyptic horror drama television series developed by Frank Darabont. It is based on the comic book series of the same name by Robert Kirkman, Tony Moore, and Charlie Adlard. It stars Andrew Lincoln as sheriff\'s deputy Rick Grimes, who awakens from a coma to find a post-apocalyptic world dominated by flesh-eating zombies.'
// },
// {
// id: 2,
// name: 'Breaking Bad',
// description: 'Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. The show originally aired on the AMC network for five seasons, from January 20, 2008 to September 29, 2013. The main character is Walter White (Bryan Cranston), a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series.'
// },
// {
// id: 3,
// name: '7D',
// description: 'The 7D is an American animated television series produced by Disney Television Animation, and broadcast on Disney XD starting in July 7, 2014. It is a re-imagining of the titular characters from the 1937 film Snow White and the Seven Dwarfs by Walt Disney Productions'
// }];
var sites = [];
listSites = function () {
var sites = [];
return $q.all(Auth.sessions.map(function (session) {
return Auth.get(session).then(function (oauth3) {
var pkg = oauth3.pkg('www@daplie.com');
return pkg.list().then(function (result) {
var _sites = result.data;
if (Array.isArray(_sites)) {
sites = _sites.concat(sites);
return;
}
// console.error('_sites is not an array');
// console.error(_sites);
}, function (err) {
console.error('_sites had an error');
console.error(err);
});
});
})).then(function () {
var sitez;
sitez = sites;
return sitez;
console.log('[listSites] sites:');
console.log(sites);
});
};
return {
list: function(){
console.log('asdf');
// return sites;
},
find: function(id){
return _.find(sites, function(site){
return site.id == id;
});
}
};
}]);