|
@@ -20,13 +20,28 @@ app.config(function($routeProvider, $locationProvider) {
|
|
|
|
|
|
|
|
app.controller('sources', function($scope,$http) {
|
|
app.controller('sources', function($scope,$http) {
|
|
|
$scope.sources=[];
|
|
$scope.sources=[];
|
|
|
- $http.get("/pymnts/sources").then(
|
|
|
|
|
- function(data){
|
|
|
|
|
- $scope.sources=data.data.sources;
|
|
|
|
|
|
|
+ $scope.parsed_articles=[];
|
|
|
|
|
+ $http.get("/pymnts/sources").then(
|
|
|
|
|
+ function(data){
|
|
|
|
|
+ $scope.sources=data.data.sources;
|
|
|
|
|
+ },
|
|
|
|
|
+ function(data){
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
+ $scope.parseSource = function(source,name,sel,rss,add) {
|
|
|
|
|
+ url="/pymnts/source/test/";
|
|
|
|
|
+ if(add==1)
|
|
|
|
|
+ url="/pymnts/source/add/";
|
|
|
|
|
+
|
|
|
|
|
+ $http.post(url, { "source": source, "selector":sel, "rss":rss, "name":name }).then(
|
|
|
|
|
+ function(data) {
|
|
|
|
|
+ if(!add)
|
|
|
|
|
+ $scope.parsed_articles=data.data.links;
|
|
|
},
|
|
},
|
|
|
function(data){
|
|
function(data){
|
|
|
}
|
|
}
|
|
|
);
|
|
);
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
app.controller('main', function($scope,$http,$sce) {
|
|
app.controller('main', function($scope,$http,$sce) {
|
|
@@ -77,6 +92,7 @@ app.controller('main', function($scope,$http,$sce) {
|
|
|
function(data) {
|
|
function(data) {
|
|
|
if(page==undefined)
|
|
if(page==undefined)
|
|
|
$scope.curPage=1;
|
|
$scope.curPage=1;
|
|
|
|
|
+ //$scope.news=#data.data.articles.map(function(el) { el.scrap_date=Date(el.scrap_date); return el; });
|
|
|
$scope.news=data.data.articles;
|
|
$scope.news=data.data.articles;
|
|
|
$scope.totPages=Math.ceil(data.data.count/itemsPerPage);
|
|
$scope.totPages=Math.ceil(data.data.count/itemsPerPage);
|
|
|
},
|
|
},
|
|
@@ -86,19 +102,6 @@ app.controller('main', function($scope,$http,$sce) {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
$scope.filter();
|
|
$scope.filter();
|
|
|
- $scope.parseSource = function(source,name,sel,rss,add) {
|
|
|
|
|
- url="/pymnts/source/test/";
|
|
|
|
|
- if(add==1)
|
|
|
|
|
- url="/pymnts/source/add/";
|
|
|
|
|
-
|
|
|
|
|
- $http.post(url, { "source": source, "selector":sel, "rss":rss, "name":name }).then(
|
|
|
|
|
- function(data) {
|
|
|
|
|
- console.log(data.data);
|
|
|
|
|
- },
|
|
|
|
|
- function(data){
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
- };
|
|
|
|
|
$scope.changePage = function(newPage) {
|
|
$scope.changePage = function(newPage) {
|
|
|
if (newPage > $scope.totPages)
|
|
if (newPage > $scope.totPages)
|
|
|
newPage=$scope.totPages;
|
|
newPage=$scope.totPages;
|