2014-06-21 21:22:38 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-10-28 15:16:50 +00:00
|
|
|
angular.module('app').controller("HomeController", function($scope, $http, $location, feed) {
|
2014-06-21 21:22:38 +00:00
|
|
|
|
2014-06-22 10:02:22 +00:00
|
|
|
feed.subscribe(function(item) {
|
2014-07-13 23:46:49 +00:00
|
|
|
// todo toast notification
|
2014-06-22 00:41:40 +00:00
|
|
|
});
|
|
|
|
|
2014-09-30 07:43:50 +00:00
|
|
|
$http({method: 'GET', url: '/api/user/feed'}).
|
2014-06-21 21:22:38 +00:00
|
|
|
success(function(data, status, headers, config) {
|
2014-07-10 05:24:06 +00:00
|
|
|
$scope.feed = (typeof data==='string')?[]:data;
|
2014-07-09 07:46:15 +00:00
|
|
|
}).
|
|
|
|
error(function(data, status, headers, config) {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
|
2014-10-28 15:16:50 +00:00
|
|
|
$scope.syncUser = function() {
|
|
|
|
$http({method: 'POST', url: '/api/user/sync' }).success(function(data){
|
|
|
|
$location.search('return_to', $location.$$path).path('/sync')
|
|
|
|
}).error(function(data, status){
|
|
|
|
if (status == 409) {
|
|
|
|
$scope.msg = 'already'
|
|
|
|
} else {
|
|
|
|
$scope.msg = 'bad'
|
|
|
|
}
|
|
|
|
$scope.$apply();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-09-30 07:43:50 +00:00
|
|
|
$http({method: 'GET', url: '/api/user/repos'}).
|
2014-07-09 07:46:15 +00:00
|
|
|
success(function(data, status, headers, config) {
|
|
|
|
$scope.repos = (typeof data==='string')?[]:data;
|
2014-06-21 21:22:38 +00:00
|
|
|
}).
|
|
|
|
error(function(data, status, headers, config) {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
});
|