def load_graph(graphname): try: return jsondump(loadstate(graphname).generate_full_data()) except GraphTypeError: abort(404) except DependencyError: abort(501)
def get_units(): """ Return units list """ return jsondump({ row.name : { 'symbol': row.symbol, 'factor': row.factor, 'magnitudes': row.magnitudes } for row in Unit.query.all()})
def dashboard_part_save(): """ Save a new part """ pid = int(request.form['id']) oldid = pid savedata = {'id': pid} if 'width' in request.form: savedata['width'] = int(float(request.form['width'])) if 'height' in request.form: savedata['height'] = int(float(request.form['height'])) if 'col' in request.form: savedata['col'] = int(request.form['col']) if 'row' in request.form: savedata['row'] = int(request.form['row']) if pid <= 0: # New part savedata['widget'] = request.form['widget'] savedata['dashboard'] = request.form['dashboard'] savedata['title'] = request.form['title'] pid = create_part(**savedata) else: # Existing part if 'title' in request.form: savedata['title'] = request.form['title'] del savedata['id'] if len(savedata): update_part(pid, **savedata) if 'conf' in request.form: update_part_conf(pid, json.loads(request.form['conf'])) return jsondump({'original_id': oldid, 'saved_id': pid})
def get_units(): """ Return units list """ return jsondump( { row.name: {"symbol": row.symbol, "factor": row.factor, "magnitudes": row.magnitudes} for row in Unit.query.all() } )
def get_units(): """ Return units list """ return jsondump({ row.name: { 'symbol': row.symbol, 'factor': row.factor, 'magnitudes': row.magnitudes } for row in Unit.query.all() })
def get_widgets_list(): """ This action method sends a JSON array containing a list of all available widget names """ # Note : These member names will be used as-is from all the scripts on client side. Change with care. return jsondump([{'id':w.name, 'name':w.humanname, 'minWidth':w.min_width, 'maxWidth':w.max_width, 'minHeight':w.min_height, 'maxHeight':w.max_height, 'hasCss':w.hascss()} for w in load_widgets_list(True)], True)
def get_widgets_list(): """ This action method sends a JSON array containing a list of all available widget names """ # Note : These member names will be used as-is from all the scripts on client side. Change with care. return jsondump([{ 'id': w.name, 'name': w.humanname, 'minWidth': w.min_width, 'maxWidth': w.max_width, 'minHeight': w.min_height, 'maxHeight': w.max_height, 'hasCss': w.hascss() } for w in load_widgets_list(True)], True)
def reset_graph(): """ Resets the specified graph positions, and re-runs an entire layout for it using the specified layout algorithm """ layout_type = request.args.get('layout') graph_name = request.args.get('graph') if layout_type not in _layout_types: return abort(403) try: return jsondump(loadstate(graph_name, layout_type).generate_state_data()) except GraphTypeError: abort(404) except DependencyError: abort(501)
def reset_graph(): """ Resets the specified graph positions, and re-runs an entire layout for it using the specified layout algorithm """ layout_type = request.args.get('layout') graph_name = request.args.get('graph') if layout_type not in _layout_types: return abort(403) try: return jsondump( loadstate(graph_name, layout_type).generate_state_data()) except GraphTypeError: abort(404) except DependencyError: abort(501)
def hostsservice(): return jsondump(get_all_hosts(), True)
def graph_saves(graphtype): """ A service that returns the list of existing saves existing for the specified graph type """ list = get_list_saves(graphtype) return jsondump(list)
def dashboards_checkname(): """ Returns a JSON boolean indicating if the specified name exists """ name = request.args['name'] if not name: return abort(404) return jsondump(not dashboard_name_exists(name))
def dashboards_list(): """ Returns a list of user's dashboards """ return jsondump(get_list_dashboards(), True)
def dashboards_details(dashboardName): """ Gets the details (that is, a list of all installed parts) for a specific dashboard """ data = get_dashboard_parts(dashboardName) if data is None or len(data) == 0: abort(404) return jsondump(data)
def dashboards_checkname(): """ Returns a JSON boolean indicating if the specified name exists """ name = request.args['name'] if not name: return abort(404) return jsondump(not dashboard_name_exists(name));