class MetricEdit(View): template_name = 'templates/admin/metric/edit.html' __context = Context() __metric = MetricModule() __correlation_id = None @login_if_not_authenticated def get(self, request, metric_id): self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" metric = self.__metric.get_one_by_id(metric_id) if not metric: raise Http404("Metric not found.") self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.push({ "page_title": _("Edit Metric · %s") % self.__context.get( "app_name", os.getenv("APP_NAME", "Silverback")), "metric": metric }) metric["data"] = json.loads(metric["data"]) return render(request, self.template_name, self.__context.get())
def __init__(self): self.__request = Request() self.__response = Response() self.__helpers = Helpers() self.__form = Form() self.__metric = MetricModule() self.__logger = self.__helpers.get_logger(__name__) self.__form.add_validator(ExtraRules())
def __init__(self): self.__request = Request() self.__response = Response() self.__helpers = Helpers() self.__settings = Settings() self.__metric = MetricModule() self.__form = Form() self.__logger = self.__helpers.get_logger(__name__) self.__user_id = None self.__correlation_id = "" self.__form.add_validator(ExtraRules())
def get(self, request): self.__metric = MetricModule() self.autoload_options() self.autoload_user( request.user.id if request.user.is_authenticated else None) self.context_push({ "page_title": _("Add a Metric · %s") % self.context_get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, self.template_name, self.context_get())
def get(self, request): self.__context = Context() self.__metric = MetricModule() self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.push({ "page_title": _("Add a Metric · %s") % self.__context.get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, self.template_name, self.__context.get())
def get(self, request): self.__context = Context() self.__metric = MetricModule() self.__component = ComponentModule() self.__component_group = ComponentGroupModule() self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.load_options({ "builder_headline": "", "builder_favicon_url": "", "builder_logo_url": "", "builder_about": "", "builder_components": json.dumps([]), "builder_metrics": json.dumps([]) }) self.__context.push({ "page_title": _("Status Page Builder · %s") % self.__context.get( "app_name", os.getenv("APP_NAME", "Silverback")), "groups": self.__format_groups(self.__component.get_all_groups()), "components": self.__format_components(self.__component.get_all()), "metrics": self.__format_metrics(self.__metric.get_all()) }) self.__context.push({ "builder_components": json.loads(str(self.__context.get("builder_components"))), "builder_metrics": json.loads(str(self.__context.get("builder_metrics"))) }) return render(request, self.template_name, self.__context.get())
class MetricList(View): template_name = 'templates/admin/metric/list.html' __context = Context() __metric = MetricModule() __correlation_id = None @login_if_not_authenticated def get(self, request): self.__correlation_id = request.META[ "X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" self.__context.autoload_options() self.__context.autoload_user( request.user.id if request.user.is_authenticated else None) self.__context.push({ "page_title": _("Metrics · %s") % self.__context.get("app_name", os.getenv("APP_NAME", "Silverback")) }) return render(request, self.template_name, self.__context.get())
def get(self, request, metric_id): self.__metric = MetricModule() metric = self.__metric.get_one_by_id(metric_id) if not metric: raise Http404("Metric not found.") self.autoload_options() self.autoload_user( request.user.id if request.user.is_authenticated else None) self.context_push({ "page_title": _("Edit Metric · %s") % self.context_get("app_name", os.getenv("APP_NAME", "Silverback")), "metric": metric }) metric["data"] = json.loads(metric["data"]) return render(request, self.template_name, self.context_get())
def __init__(self): self.__settings = Settings() self.__metric = MetricModule()
def __init__(self): self.__metric = MetricModule()
class Builder(View): template_name = 'templates/admin/builder.html' __context = Context() __metric = MetricModule() __component = ComponentModule() __component_group = ComponentGroupModule() __correlation_id = None @login_if_not_authenticated_or_no_permission("manage_settings") def get(self, request): self.__correlation_id = request.META["X-Correlation-ID"] if "X-Correlation-ID" in request.META else "" self.__context.autoload_options() self.__context.autoload_user(request.user.id if request.user.is_authenticated else None) self.__context.load_options({ "builder_headline": "", "builder_favicon_url": "", "builder_logo_url": "", "builder_about": "", "builder_components": json.dumps([]), "builder_metrics": json.dumps([]) }) self.__context.push({ "page_title": _("Status Page Builder · %s") % self.__context.get("app_name", os.getenv("APP_NAME", "Silverback")), "groups": self.__format_groups(self.__component.get_all_groups()), "components": self.__format_components(self.__component.get_all()), "metrics": self.__format_metrics(self.__metric.get_all()) }) self.__context.push({ "builder_components": json.loads(str(self.__context.get("builder_components"))), "builder_metrics": json.loads(str(self.__context.get("builder_metrics"))) }) return render(request, self.template_name, self.__context.get()) def __format_components(self, components): components_list = [] for component in components: components_list.append({ "id": "c-%d" % component.id, "name": component.name }) return components_list def __format_groups(self, groups): groups_list = [] for group in groups: groups_list.append({ "id": "g-%d" % group.id, "name": group.name }) return groups_list def __format_metrics(self, metrics): metrics_list = [] for metric in metrics: metrics_list.append({ "id": "m-%d" % metric.id, "title": metric.title }) return metrics_list