Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Merge 02729fb into 48646cf
Browse files Browse the repository at this point in the history
  • Loading branch information
renanrodrigo committed Mar 30, 2017
2 parents 48646cf + 02729fb commit ff4c0da
Show file tree
Hide file tree
Showing 189 changed files with 19,147 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Expand Up @@ -95,3 +95,9 @@ ENV/
# Auxilary files to test the controller
aux_*.py
aux_*.sh

# Web-Ui stuff
.sass-cache
node_modules
include
kytos/web-ui/source/static/css/*
1 change: 1 addition & 0 deletions MANIFEST.in
@@ -1,3 +1,4 @@
include etc/kytos.conf
include etc/logging.ini
include *.txt
recursive-include kytos *
19 changes: 16 additions & 3 deletions kytos/core/api_server.py
@@ -1,11 +1,12 @@
"""Module used to handle a API Server."""
import os

from http.client import RemoteDisconnected
from urllib.request import urlopen

from flask import Flask, request
from flask import Flask, request, send_from_directory
from flask_socketio import SocketIO


class APIServer:
"""Api server used to provide Kytos Controller routes."""

Expand All @@ -17,7 +18,10 @@ def __init__(self, app_name):
Parameters:
app_name(string): String representing a App Name
"""
self.app = Flask(app_name)
dirname = os.path.dirname(os.path.abspath(__file__))
self.flask_dir = os.path.join(dirname, '../web-ui/source')

self.app = Flask(app_name, root_path=self.flask_dir)
self.server = SocketIO(self.app)

def run(self, *args, **kwargs ):
Expand Down Expand Up @@ -51,6 +55,11 @@ def register_websocket(self, name, function, namespace='/'):
"""Method used to register websocket channel."""
self.server.on_event(name, function, namespace)

def register_web_ui(self):
"""Method used to register routes to the admin-ui homepage."""
self.app.add_url_rule('/', self.web_ui.__name__, self.web_ui)
self.app.add_url_rule('/index.html', self.web_ui.__name__, self.web_ui)

@property
def rest_endpoints(self):
"""Return string with routes registered by Api Server."""
Expand Down Expand Up @@ -94,3 +103,7 @@ def shutdown_api(self):
self.server.stop()

return 'Server shutting down...', 200

def web_ui(self):
"""Method userd to serve the index.html page for the admin-ui."""
return send_from_directory(self.flask_dir, 'index.html')
1 change: 1 addition & 0 deletions kytos/core/controller.py
Expand Up @@ -118,6 +118,7 @@ def start(self):
Load the installed apps.
"""
self.api_server.register_kytos_routes()
self.api_server.register_web_ui()
self.register_websockets()
self.log.info("Starting Kytos - Kytos Controller")
self.server = KytosServer((self.options.listen,
Expand Down
39 changes: 39 additions & 0 deletions kytos/web-ui/Gruntfile.js
@@ -0,0 +1,39 @@
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
express: {
all: {
options: {
bases: ['./source'],
port: 8080,
hostname: "0.0.0.0",
livereload: true
}
}
},
sass: {
dist: {
files: {
'source/static/css/style.css': 'source/sass/main.scss'
}
}
},
watch: {
sass: {
files: ['source/sass/**/*.scss', 'source/*.html'],
tasks: ['sass']
},
all: {
files: '**/*.html',
options: {
livereload: true
}
}
}
});

grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('server', ['express', 'sass', 'watch']);
}
38 changes: 38 additions & 0 deletions kytos/web-ui/package.json
@@ -0,0 +1,38 @@
{
"name": "kytos-admin-ui",
"version": "v1.1.0b0",
"description": "Kytos admin page",
"main": "Gruntfile.js",
"repository": {
"type": "git",
"url": "git+https://github.com/kytos/admin-ui.git"
},
"keywords": [
"kytos",
"admin",
"openflow",
"network",
"interface"
],
"author": "Kytos Team",
"license": "MIT",
"bugs": {
"url": "https://github.com/kytos/admin-ui/issues"
},
"homepage": "https://github.com/kytos/admin-ui",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-sass": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-express": "^1.4.1",
"grunt-parallel": "^0.5.1",
"grunt-sass": "^1.2.1",
"load-grunt-tasks": "^3.5.2"
},
"dependencies": {
"grunt": "^1.0.1",
"grunt-sass": "^1.2.1",
"grunt-contrib-sass": "^1.0.0",
"load-grunt-tasks": "^3.5.2"
}
}

0 comments on commit ff4c0da

Please sign in to comment.