-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* devel: (78 commits) Bump to version 0.3.0 Update paths to FA and .htaccess Copy FA fonts to assets folder Add steps to build production Update to @angular/cli@1.1.2 Rename getConfig function to main FTAS: remove ftas from environment FTAS: add initial config setup NERD: add configuration to module FTAS: refactoring of modal triggering Config: all needed methods in service Config: do not force absence of name FTAS: add configuration Configuration API full implementation ng couldn't find entry module Base for configuration API Add source for app.module bootstraping WIP: Configuration service for modules Configurable HTTP interceptor via config.json file Config: Add sample config file and update gitignore ...
- Loading branch information
Showing
107 changed files
with
3,772 additions
and
830 deletions.
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
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,148 @@ | ||
""" | ||
Configuration REST API | ||
Configuration is separated into documents where each document is identified by | ||
name of the module, where 'liberoutergui' module is reserved for future use | ||
in case we need something globally configurable in the Liberouter GUI. | ||
When inserting a configuration 'name' must be unique. | ||
""" | ||
|
||
from flask import request | ||
|
||
from liberouterapi import auth, dbConnector | ||
from liberouterapi.error import ApiException | ||
from .module import Module | ||
from bson import json_util as json | ||
from pymongo import ReturnDocument | ||
|
||
class ConfError(ApiException): | ||
status_code = 400 | ||
|
||
# Initialize connector to the configuration collection | ||
connector = dbConnector() | ||
conf_db = connector.db["configuration"] | ||
|
||
conf = Module('configuration', __name__, url_prefix='/configuration', no_version = True) | ||
|
||
@conf.route('', methods=['GET']) | ||
#@auth.required() | ||
def get_conf(): | ||
res = list(conf_db.find()) | ||
return (json.dumps(res)) | ||
|
||
def unprotected_get_module_conf(module): | ||
""" | ||
Get module's configuration specified by the module's name | ||
Prevent from storing module liberoutergui (reserved for future use). | ||
Each module name is converted to lowercase | ||
""" | ||
if module == 'liberoutergui': | ||
raise ConfError("'liberoutergui' module name is reserved", status_code=409) | ||
|
||
res = conf_db.find_one({ | ||
'name' : module.lower() | ||
}) | ||
|
||
if not res: | ||
raise ConfError("Module '%s' not found" % module, status_code=404) | ||
|
||
return(res) | ||
|
||
|
||
@conf.route('/<string:module>', methods=['GET']) | ||
def get_module_conf(module): | ||
""" | ||
Get module by its name using the unprotected function | ||
""" | ||
return (json.dumps(unprotected_get_module_conf(module))) | ||
|
||
@conf.route('/<string:module>', methods=['PUT']) | ||
def update_conf(module): | ||
""" | ||
Update a module's configuration specified by its name | ||
'name' mustn't be specified in data and data must be non-empty | ||
""" | ||
|
||
data = request.get_json() | ||
|
||
if not data: | ||
raise ConfError("Nothing to update") | ||
|
||
if "name" in data: | ||
del data["name"] | ||
|
||
if "_id" in data: | ||
del data["_id"] | ||
|
||
res = conf_db.find_one_and_update({ | ||
"name" : str(module).lower() | ||
}, | ||
{ | ||
"$set" : data | ||
}, | ||
return_document=ReturnDocument.AFTER) | ||
|
||
if not res: | ||
raise ConfError("Can't update module '%s'" % str(module).lower()) | ||
|
||
return(json.dumps(res)) | ||
|
||
@conf.route('', methods=['POST']) | ||
def insert_conf(): | ||
""" | ||
Insert module's configuration, the configuration name mustn't be present in | ||
the collection | ||
'name' is a mandatory key | ||
""" | ||
|
||
conf = request.get_json() | ||
res = {} | ||
|
||
if 'name' not in conf: | ||
raise ConfError("'name' must be specified in configuration") | ||
|
||
try: | ||
# We expect it to raise ConfError (config not found) | ||
res = unprotected_get_module_conf(conf['name']) | ||
except ConfError: | ||
# Name must be lowercase | ||
conf['name'] = conf['name'].lower() | ||
|
||
res = conf_db.insert_one(conf) | ||
|
||
try: | ||
res = conf_db.find_one({ | ||
"_id" : res.inserted_id | ||
}) | ||
except Exception as e: | ||
raise ConfError(str(e)) | ||
else: | ||
raise ConfError("Configuration with name '%s' already exists" % conf['name']) | ||
|
||
return(json.dumps(res)) | ||
|
||
@conf.route('/<string:module>', methods=['DELETE']) | ||
def remove_conf(module): | ||
""" | ||
Remove specified module from db | ||
Module is identified by its name in lowercase | ||
""" | ||
|
||
# Get the original document | ||
orig_config = unprotected_get_module_conf(module) | ||
|
||
res = conf_db.delete_one({ | ||
'name' : str(module).lower() | ||
}) | ||
|
||
if res.deleted_count != 1: | ||
raise ConfError("Module '%s' wasn't deleted" % module, status_code=404) | ||
|
||
return(json.dumps(orig_config)) | ||
|
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 @@ | ||
../../../modules/Nemea-Dashboard/api/modules/nemea/reporter-rest |
Submodule Nemea-Dashboard
updated
6 files
+106 −0 | api/modules/nemea/Query.py | |
+174 −0 | api/modules/nemea/Stats.py | |
+19 −1 | api/modules/nemea/__init__.py | |
+1 −243 | api/modules/nemea/events.py | |
+10 −0 | api/modules/nemea/reporter-rest/__init__.py | |
+34 −0 | api/modules/nemea/reporter-rest/base.py |
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,68 @@ | ||
{ | ||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json", | ||
"project": { | ||
"version": "0.2.0", | ||
"name": "liberouter-gui" | ||
}, | ||
"apps": [ | ||
{ | ||
"root": "src", | ||
"outDir": "dist", | ||
"assets": [ | ||
"assets", | ||
"favicon.ico", | ||
".htaccess", | ||
"../node_modules/font-awesome/fonts/*.+(otf|eot|svg|ttf|woff|woff2)" | ||
], | ||
"index": "index.html", | ||
"main": "main.ts", | ||
"polyfills": "polyfills.ts", | ||
"test": "test.ts", | ||
"tsconfig": "tsconfig.app.json", | ||
"testTsconfig": "tsconfig.spec.json", | ||
"prefix": "app", | ||
"styles": [ | ||
"styles/main.scss", | ||
"../node_modules/bootstrap/dist/css/bootstrap.min.css", | ||
"../node_modules/codemirror/lib/codemirror.css" | ||
], | ||
"scripts": [], | ||
"environmentSource": "environments/environment.ts", | ||
"environments": { | ||
"dev": "environments/environment.ts", | ||
"prod": "environments/environment.prod.ts" | ||
} | ||
} | ||
], | ||
"sassCompiler" : { | ||
"includePaths": ["src/styles"] | ||
}, | ||
"e2e": { | ||
"protractor": { | ||
"config": "./protractor.conf.js" | ||
} | ||
}, | ||
"lint": [ | ||
{ | ||
"project": "src/tsconfig.app.json" | ||
}, | ||
{ | ||
"project": "src/tsconfig.spec.json" | ||
}, | ||
{ | ||
"project": "e2e/tsconfig.e2e.json" | ||
} | ||
], | ||
"test": { | ||
"karma": { | ||
"config": "./karma.conf.js" | ||
} | ||
}, | ||
"defaults": { | ||
"styleExt": "scss", | ||
"component": { | ||
"inlineTemplate": false, | ||
"spec": true | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -38,3 +38,5 @@ testem.log | |
#System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
config.json |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<IfModule mod_rewrite.c> | ||
RewriteEngine On | ||
RewriteRule ^$ /liberouter-gui/www/dist [L] | ||
RewriteRule ^$ / [L] | ||
RewriteBase /dist | ||
RewriteRule ^index\.html$ - [L] | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule . /liberouter-gui/www/dist/index.html [L] | ||
RewriteRule . /index.html [L] | ||
</IfModule> |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.