diff --git a/src/api/index.py b/src/api/index.py index 11c1464..6aca7df 100644 --- a/src/api/index.py +++ b/src/api/index.py @@ -8,6 +8,9 @@ 'monitoring-type': 'class':'' 'config':' + @TODO: + - In order to make this Saas we need to have the configuration be session driven + - Add socketio, so that each section of the dashboard updates independently """ from flask import Flask, session, request, redirect, Response @@ -45,7 +48,29 @@ class_write= CONFIG['store']['class']['write'] factory = DataSourceFactory() # gReader = factory.instance(type=class_read,args=p) -atexit.register(ThreadManager.stop) +@app.route('/1/get/apps') +def get_apps(): + r = [] + try: + gReader = factory.instance(type=class_read,args=p) + r = gReader.view('summary/app_names',key=p['uid']) + except Exception,e: + print (e) + return json.dumps(r) +@app.route('/1/get/summary/') +def get_summary(id): + r = [] + try: + gReader = factory.instance(type=class_read,args=p) + #if id == 'apps_resources' : + # r = gReader.view('summary/app_resources',key=p['uid']) + #else: + # r = gReader.view('summary/folder_size',key=p['uid']) + r = r = gReader.view('summary/'+id.strip(),key=p['uid']) + + except Exception,e: + print (e) + return json.dumps(r) @app.route('/get/') def procs(id): try: @@ -157,7 +182,13 @@ def dashboard(): title = PARAMS['title'] else: title = 'Dashboard' - return render_template('dashboard.html',context=context,title=title) + apps = [] + try: + gReader = factory.instance(type=class_read,args=p) + apps = gReader.view('summary/app_names',key=p['uid']) + except Exception, e: + print (e) + return render_template('dashboard.html',context=context,title=title,app_names=apps) @app.route('/upgrade') def upgrade(): diff --git a/src/api/static/css/dashboard.css b/src/api/static/css/dashboard.css index 4513ca2..c19bd9c 100644 --- a/src/api/static/css/dashboard.css +++ b/src/api/static/css/dashboard.css @@ -1,3 +1,7 @@ +.small { + font-size:11px; font-family:sans-serif; font-weight:lighter; + color:gray; +} .ct-blue { stroke: #7A9E9F !important; } diff --git a/src/api/static/js/dashboard.js b/src/api/static/js/dashboard.js index 1de9768..1cce947 100755 --- a/src/api/static/js/dashboard.js +++ b/src/api/static/js/dashboard.js @@ -21,7 +21,7 @@ dashboard = { getData.done(function(results) { var data = JSON.parse(results) - console.log(data) + var app = data['apps@lab']; function getCpuUsage (app){ @@ -240,3 +240,39 @@ dashboard = { }, } + + +/** + * Global information about the dashboard + * @TODO: Add socket handling ... it would make non-blocking updating information + */ + +var g = {} +g.summary = {} +/** + * Initializing the top section of the dashboard (apps and folders) + */ +g.summary.factory = function (url,pointer) { + var object = {} + object.url = url + var observer = null + + object.callback = function (r) { + r = JSON.parse(r.responseText) + pointer(r) + //observer.notify() + + } + object.init = function (observer) { + observer = observer + + var httpclient = HttpClient.instance() + httpclient.setAsync(false) + httpclient.get(this.url, this.callback) + + observer.notify() + } + + return object + +} \ No newline at end of file diff --git a/src/api/templates/dashboard.html b/src/api/templates/dashboard.html index ab6ffaf..7daac92 100644 --- a/src/api/templates/dashboard.html +++ b/src/api/templates/dashboard.html @@ -21,10 +21,73 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + +
@@ -93,11 +156,10 @@
  • @@ -123,13 +185,17 @@
    +
    Total CPU
    +
    -

    Total CPU

    - + +
    00
    +
    Percent
    +