Loading capif_backend/backoffice_service/controllers/default_controller.py +18 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ from flask import Blueprint, jsonify from ..core.operations import Operations from flask_jwt_extended import jwt_required, get_jwt_identity from flask_cors import cross_origin import requests GRAFANA_URL = 'http://grafana.mon.svc.cluster.local:3000' # create blueprint backoffice_routes backoffice_routes = Blueprint("backoffice_routes", __name__) Loading Loading @@ -145,3 +148,18 @@ def get_apis(): @jwt_required() def get_num_apis(): return operations.get_num_apis() @cross_origin() @backoffice_routes.route('/grafana', methods=['GET']) @jwt_required() def get_grafana_data(): return jsonify("todo guya mi nigga"), 200 @cross_origin() @backoffice_routes.route('/refreshgrafana', methods=['GET']) @jwt_required() def refresh_grafana_data(): return jsonify("todo guya mi nigga"), 200 capif_backend/backoffice_service/controllers/login.py +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ def login(): print("username: ", username) print("password: ", password) if username != "superadmin" or password != "1234": if username != "superadmin" or password != "LzVgyRxi": print("Bad username or password") return jsonify({"msg": "Bad username or password"}), 401 Loading capif_backend/backoffice_service/core/operations.py +36 −5 Original line number Diff line number Diff line Loading @@ -80,6 +80,21 @@ class Operations: return "Error when retrieving number of providers: ", e def retrieve_providers(self): mycol = self.db.get_col_by_name(self.db.providers) providers = mycol.find({}, {"_id": 0}) users = self.retrieve_users() json_providers = [] for provider in providers: provider_aux = copy.deepcopy(provider) for user in users: if provider["api_prov_dom_id"] in user["list_providers"]: provider_aux["username"] = user["username"] json_providers.append(provider_aux) return json_providers def retrieve_providers2(self): mycol = self.db.get_col_by_name(self.db.providers) #user_col = self.db.get_col_by_name_register(self.db.user) #users = user_col.find({}, {"_id": 0}) Loading @@ -89,10 +104,11 @@ class Operations: json_providers = [] for provider in providers: provider_aux = copy.deepcopy(provider) for user in users: if provider["api_prov_dom_id"] in user["list_providers"]: provider["username"] = user["username"] json_providers.append(provider) provider_aux["username"] = user["username"] json_providers.append(provider_aux) return json_providers def get_provider_services(self, id): Loading Loading @@ -260,6 +276,21 @@ class Operations: return jsonify(message=f"Error deleting user: {str(e)}"), 500 def get_apis(self): try: mycol = self.db.get_col_by_name(self.db.services) apis = mycol.find({}, {"_id": 0}) json_apis = [] for api in apis: json_apis.append(api) return jsonify(message="Services retrieved succesfully", object=json_apis), 200 except Exception as e: return "Error when retrieving apis list: ", e def get_apis_cont(self): mycol = self.db.get_col_by_name(self.db.services) apis = mycol.find({}, {"_id": 0}) Loading @@ -272,7 +303,7 @@ class Operations: def get_num_apis(self): try: # Carga la cadena JSON de las APIs y conviértela a un objeto Python json_apis = self.get_apis() json_apis = self.get_apis_cont() num_apis = len(json_apis) return jsonify(num_apis), 200 Loading Loading
capif_backend/backoffice_service/controllers/default_controller.py +18 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,9 @@ from flask import Blueprint, jsonify from ..core.operations import Operations from flask_jwt_extended import jwt_required, get_jwt_identity from flask_cors import cross_origin import requests GRAFANA_URL = 'http://grafana.mon.svc.cluster.local:3000' # create blueprint backoffice_routes backoffice_routes = Blueprint("backoffice_routes", __name__) Loading Loading @@ -145,3 +148,18 @@ def get_apis(): @jwt_required() def get_num_apis(): return operations.get_num_apis() @cross_origin() @backoffice_routes.route('/grafana', methods=['GET']) @jwt_required() def get_grafana_data(): return jsonify("todo guya mi nigga"), 200 @cross_origin() @backoffice_routes.route('/refreshgrafana', methods=['GET']) @jwt_required() def refresh_grafana_data(): return jsonify("todo guya mi nigga"), 200
capif_backend/backoffice_service/controllers/login.py +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ def login(): print("username: ", username) print("password: ", password) if username != "superadmin" or password != "1234": if username != "superadmin" or password != "LzVgyRxi": print("Bad username or password") return jsonify({"msg": "Bad username or password"}), 401 Loading
capif_backend/backoffice_service/core/operations.py +36 −5 Original line number Diff line number Diff line Loading @@ -80,6 +80,21 @@ class Operations: return "Error when retrieving number of providers: ", e def retrieve_providers(self): mycol = self.db.get_col_by_name(self.db.providers) providers = mycol.find({}, {"_id": 0}) users = self.retrieve_users() json_providers = [] for provider in providers: provider_aux = copy.deepcopy(provider) for user in users: if provider["api_prov_dom_id"] in user["list_providers"]: provider_aux["username"] = user["username"] json_providers.append(provider_aux) return json_providers def retrieve_providers2(self): mycol = self.db.get_col_by_name(self.db.providers) #user_col = self.db.get_col_by_name_register(self.db.user) #users = user_col.find({}, {"_id": 0}) Loading @@ -89,10 +104,11 @@ class Operations: json_providers = [] for provider in providers: provider_aux = copy.deepcopy(provider) for user in users: if provider["api_prov_dom_id"] in user["list_providers"]: provider["username"] = user["username"] json_providers.append(provider) provider_aux["username"] = user["username"] json_providers.append(provider_aux) return json_providers def get_provider_services(self, id): Loading Loading @@ -260,6 +276,21 @@ class Operations: return jsonify(message=f"Error deleting user: {str(e)}"), 500 def get_apis(self): try: mycol = self.db.get_col_by_name(self.db.services) apis = mycol.find({}, {"_id": 0}) json_apis = [] for api in apis: json_apis.append(api) return jsonify(message="Services retrieved succesfully", object=json_apis), 200 except Exception as e: return "Error when retrieving apis list: ", e def get_apis_cont(self): mycol = self.db.get_col_by_name(self.db.services) apis = mycol.find({}, {"_id": 0}) Loading @@ -272,7 +303,7 @@ class Operations: def get_num_apis(self): try: # Carga la cadena JSON de las APIs y conviértela a un objeto Python json_apis = self.get_apis() json_apis = self.get_apis_cont() num_apis = len(json_apis) return jsonify(num_apis), 200 Loading