-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI service MVP #95
Closed
Closed
UI service MVP #95
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
96ec18a
initial commit ui feature
41a431c
updated ui-service.py
9f36a86
added rest api call
ca08293
support for CORS
842e845
simple ui
97f2329
mvp
fd7470d
fixed requirements.txt
1767dcf
requirments.txt
197f020
Merge remote-tracking branch 'upstream/dev' into dev
08d09bc
set pythonpath in script
9a61f3b
removed dependency on flask CORS module
916e481
updated requirements
db1cbac
Merge branch 'dev' into dev
damienkilgannon d65a4d2
updated rest service tests to work with response object
735401e
Merge branch 'dev' of https://github.com/damienkilgannon/scrapy-clust…
3df267e
changed scutils version
a3427de
Merge branch 'dev' into dev
damienkilgannon 9891770
bumped scutils version back to 1.2.0dev7
71e790a
fix merge conflicts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,7 @@ docker-compose.prod.yml | |
docker-compose.override.yml | ||
|
||
# backup files | ||
*.bak | ||
*.bak | ||
|
||
# IDE stuff | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
appdirs==1.4.0 | ||
click==6.7 | ||
ConcurrentLogHandler==0.9.1 | ||
Flask==0.11 | ||
Flask-Triangle==0.5.4 | ||
funcsigs==1.0.2 | ||
functools32==3.2.3.post2 | ||
future==0.15.2 | ||
itsdangerous==0.24 | ||
Jinja2==2.9.5 | ||
jsonschema==2.5.1 | ||
kazoo==2.2.1 | ||
MarkupSafe==0.23 | ||
mock==2.0.0 | ||
packaging==16.8 | ||
pbr==1.10.0 | ||
pyparsing==2.1.10 | ||
python-json-logger==0.1.4 | ||
redis==2.10.5 | ||
scutils==1.2.0.dev6 | ||
six==1.10.0 | ||
testfixtures==4.10.0 | ||
ujson==1.35 | ||
Werkzeug==0.11.15 | ||
Flask-Cors==3.0.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Flask configuration | ||
FLASK_LOGGING_ENABLED = True | ||
FLASK_PORT = 5000 | ||
|
||
# logging setup | ||
LOGGER_NAME = 'ui_service' | ||
LOG_DIR = 'logs' | ||
LOG_FILE = 'ui_service.log' | ||
LOG_MAX_BYTES = 10 * 1024 * 1024 | ||
LOG_BACKUPS = 5 | ||
LOG_STDOUT = True | ||
LOG_JSON = False | ||
LOG_LEVEL = 'INFO' | ||
|
||
# internal configuration | ||
SLEEP_TIME = 5 | ||
WAIT_FOR_RESPONSE_TIME = 5 | ||
|
||
# Angular settings are dir /static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
uiApp.constant('REST_CONFIG', { | ||
url: 'http://localhost:5343/', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.navbar-brand | ||
{ | ||
font-family: 'Lato', sans-serif; | ||
color:black; | ||
font-size: 30px; | ||
margin: 20px; | ||
} | ||
.btn | ||
{ | ||
margin: 60px; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
'use strict'; | ||
|
||
var uiApp = angular.module('uiApp', [ | ||
'ngRoute', | ||
]); | ||
|
||
uiApp.config(['$routeProvider', | ||
function($routeProvider) { | ||
$routeProvider. | ||
when('/', { | ||
templateUrl: '/static/partials/overview.html', | ||
controller: 'mainController' | ||
}). | ||
when('/kafka', { | ||
templateUrl: '/static/partials/kafka.html', | ||
controller: 'kafkaController' | ||
}). | ||
when('/crawlers', { | ||
templateUrl: '/static/partials/crawlers.html', | ||
controller: 'crawlersController' | ||
}). | ||
when('/redis', { | ||
templateUrl: '/static/partials/redis.html', | ||
controller: 'redisController' | ||
}). | ||
otherwise({ | ||
redirectTo: '/' | ||
}); | ||
}]); | ||
|
||
uiApp.controller('tabsController', ['$scope', function($scope) { | ||
$scope.tabs = [ | ||
{ link : '#/', label : 'Overview' }, | ||
{ link : '#/kafka', label : 'Kafka' }, | ||
{ link : '#/redis', label : 'Redis' }, | ||
{ link : '#/crawlers', label : 'Crawlers' } | ||
]; | ||
|
||
$scope.selectedTab = $scope.tabs[0]; | ||
$scope.setSelectedTab = function(tab) { | ||
$scope.selectedTab = tab; | ||
} | ||
|
||
$scope.tabClass = function(tab) { | ||
if ($scope.selectedTab == tab) { | ||
return "active"; | ||
} else { | ||
return ""; | ||
} | ||
} | ||
}]).controller('mainController', function($scope, $http, REST_CONFIG) { | ||
$scope.loadstatus=function(){ | ||
$http.get(REST_CONFIG.url) | ||
.success(function(response){ | ||
$scope.data=response; | ||
}) | ||
.error(function(){ | ||
alert("An unexpected error occurred!"); | ||
}); | ||
} | ||
|
||
// create a blank object to handle form data. | ||
$scope.request = {}; | ||
|
||
// calling our submit function. | ||
$scope.submitForm = function() { | ||
var reqObj = { | ||
url : $scope.request.url, | ||
appid : "uiservice", | ||
crawlid : $scope.request.crawlid, | ||
maxdepth : $scope.request.maxdepth, | ||
priority : $scope.request.priority, | ||
}; | ||
|
||
// Posting data to php file | ||
$http({ | ||
method : 'POST', | ||
url : REST_CONFIG.url + '/feed', | ||
data : angular.toJson(reqObj), //forms user object | ||
headers : {'Content-Type': 'application/json'} | ||
}) | ||
.success(function(data) { | ||
if (data.errors) { | ||
$scope.error = data.errors; | ||
} else { | ||
$scope.message = data.message; | ||
} | ||
}); | ||
}; | ||
|
||
}).controller('kafkaController', function($scope) { | ||
$scope.message = 'Kafka...'; | ||
}).controller('redisController', function($scope) { | ||
$scope.message = 'Redis...'; | ||
}).controller('crawlersController', function($scope) { | ||
$scope.message = 'Crawler...'; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>About</h1> | ||
|
||
<p>Hmm, not much here.</p> | ||
<p>Best get back to the <a href="/#/">home page</a>.</p> | ||
|
||
<p>Tip: going to an incorrect URL will take you to the homepage, <a href="/#/404">Try it!</a></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="jumbotron text-center"> | ||
<h1>Crawlers Page</h1> | ||
|
||
<p>{{ message }}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="jumbotron text-center"> | ||
<h1>Kafka Page</h1> | ||
|
||
<p>{{ message }}</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<div class="col-xs-12" style="height:20px;"></div> | ||
<div class="panel-group"> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Scrapy Cluster status</div> | ||
<div class="panel-body"> | ||
<div class="row" ng-controller="mainController" ng-init="loadstatus()"> | ||
<div class="col-md-4"> | ||
<div ng-attr-class="{{ data.redis_connected && 'panel panel-success' || 'panel panel-danger' }}"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Crawl Queue</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p style="font-size:70%;">Status: {{ data.redis_connected == true ? 'OK' : 'FAULT' }} <br/></p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<div ng-attr-class="{{ data.kafka_connected && 'panel panel-success' || 'panel panel-danger' }}"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Kafka</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p style="font-size:70%;">Status: {{ data.kafka_connected == true ? 'OK' : 'FAULT' }} <br/></p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-md-4"> | ||
<div ng-attr-class="{{ data.kafka_connected + data.redis_connected ? 'panel panel-success' : 'panel panel-danger' }}"> | ||
<div class="panel-heading"> | ||
<h3 class="panel-title">Spiders</h3> | ||
</div> | ||
<div class="panel-body"> | ||
<p style="font-size:70%;">Total number of spiders: <br/></p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-xs-12" style="height:20px;"></div> | ||
<div class="panel panel-default"> | ||
<div class="panel-heading">Feed a crawl request to Scrapy Cluster</div> | ||
<div class="panel-body"> | ||
<div class="container" ng-controller="mainController"> | ||
<div class="col-md-10"> | ||
<!--<div class="page-header"><h2></h2></div>--> | ||
<!-- FORM --> | ||
<form name="userForm" ng-submit="submitForm()"> | ||
<div class="form-group"> | ||
<label>URL:</label> | ||
<input type="text" name="url" class="form-control" ng-model="request.url"> | ||
</div> | ||
<div class="form-group"> | ||
<label>CrawlID:</label> | ||
<input type="text" name="crawlid" class="form-control" ng-model="request.crawlid"> | ||
</div> | ||
<div class="form-group"> | ||
<label>Depth:</label> | ||
<input type="text" name="depth" class="form-control" ng-model="request.depth"> | ||
</div> | ||
<div class="form-group"> | ||
<label>Priority:</label> | ||
<input type="text" name="priority" class="form-control" ng-model="request.priority"> | ||
</div> | ||
<button type="submit" class="btn btn-primary">Submit</button> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="jumbotron text-center"> | ||
<h1>Redis Page</h1> | ||
|
||
<p>{{ message }}</p> | ||
</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@madisonb the CORS module adds support for cross origin requests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 'No 'Access-Control-Allow-Origin'' should be not be an issue as the CORS modules adds the required HTTP headers to the HTTP messages to allow cross origin requests.
Following your second EDIT .... are you still getting that error?