Popular New Releases in Dashboard
grafana
8.5.0 (2022-04-21)
AdminLTE
AdminLTE v3.2.0
ngx-admin
v6.0.0
kibana
Kibana 8.1.3
appsmith
Release v1.6.20 🌈
Popular Libraries in Dashboard
by grafana typescript
48159 AGPL-3.0
The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
by ColorlibHQ javascript
40777 MIT
AdminLTE - Free admin dashboard template based on Bootstrap 4
by akveo typescript
22994 MIT
Customizable admin dashboard template based on Angular 10+
by elastic typescript
17328 NOASSERTION
Your window into the Elastic Stack
by appsmithorg typescript
15181 Apache-2.0
Low code project to build admin panels, internal tools, and dashboards. Integrates with 15+ databases and any API.
by FormidableLabs javascript
13873 MIT
A CLI dashboard for webpack dev server
by akveo javascript
11220 NOASSERTION
AngularJS Bootstrap Admin Panel Framework
by coreui html
11139 MIT
Free Bootstrap 5 admin & dashboard template
by Shopify javascript
11116 MIT
The exceptionally handsome dashboard framework in Ruby and Coffeescript.
Trending New libraries in Dashboard
by appsmithorg typescript
15181 Apache-2.0
Low code project to build admin panels, internal tools, and dashboards. Integrates with 15+ databases and any API.
by h2oai python
2885 Apache-2.0
Realtime Web Apps and Dashboards for Python and R
by grafana go
1958 AGPL-3.0
Grafana Tempo is a high volume, minimal dependency distributed tracing backend.
by dunky11 javascript
1480 MIT
🌊 Template for building an SaaS / admin website using React + Material-UI
by motor-admin ruby
1172 AGPL-3.0
Deploy a no-code admin panel for any application in less than a minute. Search, create, update, and delete data entries, create custom actions, and build reports.
by pinterest typescript
1139 Apache-2.0
Querybook is a Big Data Querying UI, combining collocated table metadata and a simple notebook interface.
by farridav html
983 MIT
Jazzy theme for Django
by KubeOperator go
944 Apache-2.0
KubePi 是一款简单易用的开源 Kubernetes 可视化管理面板
by rmountjoy92 python
884 GPL-3.0
Another web application bookmark dashboard, with fun features.
Top Authors in Dashboard
1
50 Libraries
1943
2
35 Libraries
53005
3
19 Libraries
15843
4
18 Libraries
4290
5
18 Libraries
4151
6
14 Libraries
2292
7
13 Libraries
57
8
11 Libraries
446
9
11 Libraries
477
10
11 Libraries
10062
1
50 Libraries
1943
2
35 Libraries
53005
3
19 Libraries
15843
4
18 Libraries
4290
5
18 Libraries
4151
6
14 Libraries
2292
7
13 Libraries
57
8
11 Libraries
446
9
11 Libraries
477
10
11 Libraries
10062
Trending Kits in Dashboard
Python Dashboard library offers graphs, maps, charts, and tables. Dashboards can be interactive by adding sliders, drop-down lists and buttons.
It can update the visualizations dynamically. These libraries often offer options for customizing the dashboard's layout, styles, and colors to match specific design requirements. Dashboards can be deployed locally or on the web using a cloud-based platform or a built-in server. These dashboards can integrate with different data sources like APIs, spreadsheets, and databases, making it easier to update the data in real-time. Different users can share and access it through password-protected logins or public URLs. These libraries can come with extensive documentation and community support making it easier to get started and troubleshoot any issues.
Here is the list of the top 17 Python Dashboard libraries that are handpicked to help developers:
redash:
- Is an open source visualization and dashboard platform which will allow users to connect and visualize the data from different sources, like APIs, third-party services, and databases.
- Is a web-based platform that can be accessed through a browser and is built using JavaScript and Python.
- Offers a simple and intuitive interface to create and share data visualization, which can be customized to be suitable for individual requirements.
plotly.py:
- Is a Python Data visualization that can be used for creating interactive, publication-quality graphs and charts.
- Allows the creation of interactive visualizations with hover, zoom, and click events, making it easy to explore and analyze data in real time.
- Allows customization of each aspect of a chart, like fonts, titles, colors, and axis labels.
flask_jsondash:
- Is a flask extension to create dashboards and visualizations in Python designed to be customizable, allowing developers to create their own dashboard layouts and widgets.
- Create custom widgets that interact with the data in real-time, like drop-down lists, buttons, and sliders.
- Is a good choice for developers creating simple, lightweight dashboards, and visualizations in Python, without learning a more complex framework.
wave:
- Is a Python library to build and deploy interactive, web-based dashboards for data exploration and visualization.
- Integrates seamlessly with H2O.ai's machine learning platform, allowing users to visualize and explore machine learning models.
- Offers features for sharing and collaboration, like the ability to share dashboards with others and collaborate on projects.
psdash:
- Is a Python-based web dashboard for real-time monitoring of process statistics, system resource utilization, and other system-related information.
- Can be used for identifying and troubleshooting issues, optimizing system performance, and performance bottlenecks.
- Offers real-time updates of process and system statistics with the ability to refresh data at a customizable interval.
panel:
- Is a Python library to create interactive web dashboards and applications and offers a high-level API.
- Supports different backends like Matplotlib, Holoviews, Bokeh, and Plotly, allowing developers to use their preferred plotting library.
- Offers reactive widgets that can update in real-time based on user input, allowing interactive and dynamic applications to be created.
stashboard:
- Offers a user-friendly interface to monitor system health, uptime, and other key metrics, which can be used to notify users of system issues in real-time.
- Can be used for monitoring APIs, web services, and other software systems with support for SOAP, REST, and other protocols.
- Offers custom metrics support, allowing users to monitor system performance using their analytics tools and metrics.
pygraphistry:
- Is a Python-based library to visualize large and complex datasets in interactive and visually appealing methods.
- Offers a graph-based visualization of data which is useful for visualizing connections and relationships between data points.
- Can be deployed to the cloud, allowing users to access their visualizations from anywhere.
grafanalib:
- Is a Python library for programmatically creating dashboards in Grafana, an open source platform for monitoring and analytics.
- Allows developers to create and manage dashboards using Python code which can be version-controlled and automated.
- Supports macros and templates, allowing developers to create reusable components for their dashboards.
flow-dashboard:
- Is designed to be used with the Flow framework, a web-based platform to build and deploy machine learning models.
- Can display data from various sources like APIs, streaming services, and databases.
- Offers built-in user management features allowing administrators to control access to data and dashboards.
horizon:
- Is a Python library to build real-time monitoring systems and scalable dashboards.
- Offers real-time data processing capabilities, allowing users to filter, collect, and process data in real-time.
- Is designed to be highly scalable with support for distributed processing and horizontal scaling.
graph-explorer:
- Is a Python-based library to build a dashboard to display data from different sources, like Prometheus, Elasticsearch, and Graphite.
- Allows users to create customizable dashboards with the support of various data sources and visualizations.
- Offers advanced querying capabilities, allowing users to filter and search data.
django-controlcenter:
- Is a Python-based library to build reusable and customizable dashboards in Django-based web applications.
- Allows developers to create dashboards that display data from different sources like APIs, Django models, and other data sources.
- Offers integration with Django models, allowing developers to display data from their database in their dashboards.
changes:
- Is a Python library that offers an easy-to-use interface to monitor file system events like creation, editing, and deletion.
- Allows developers to create applications that monitor directories and respond to real-time changes.
- Is a useful tool for creating applications that can monitor file system events in real-time with various integrations and features, making it suited for various use cases.
bowtie:
- Is a bioinformatics software tool to align short DNA sequences to large reference genomes.
- Allows developers to easily create dashboards that display data from different sources like SQL databases, APIs, and CSV files.
- Offers support for interactive visualizations, like graphs, maps, and charts.
socialsentiment:
- Is designed for sentiment analysis of social media data like comments or tweets on online platforms.
- Uses machine learning algorithms for classifying text as negative, positive, and neutral based on the sentiment expressed in the text.
- Offers a pre-trained sentiment analysis model which can be trained on a larger corpus of social media data.
dashboard-api-python:
- Is a Python library for the Google Analytics Dashboard API which will allow developers to access and retrieve Google Analytics data programmatically using Python.
- Is designed to make it easier for developers to question and manipulate data in Google Analytics without requiring the API details or how to construct API calls.
- Includes creating and updating dashboards, managing data sources, and functions for querying data.
Trending Discussions on Dashboard
Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind "Ingress" in version "extensions/v1beta1"`)
Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
You cannot render a <Router> inside another <Router>. You should never have more than one in your app
Add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes
Using GitHub Actions to create a .env file in the workflow
How to use Private route in react-router-dom@v6
Field 'recordName' is not marked queryable - cloudkit dashboard
Custom Page Permission using Angular 11
Error while generating report in apache-jmeter-5.4.1.tgz
404 error while adding lambda trigger in cognito user pool
QUESTION
Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind "Ingress" in version "extensions/v1beta1"`)
Asked 2022-Apr-01 at 07:26I have microk8s v1.22.2 running on Ubuntu 20.04.3 LTS.
Output from /etc/hosts
:
1127.0.0.1 localhost
2127.0.1.1 main
3
Excerpt from microk8s status
:
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9
I checked for the running dashboard (kubectl get all --all-namespaces
):
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39
I want to expose the microk8s dashboard within my local network to access it through http://main/dashboard/
To do so, I did the following nano ingress.yaml
:
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56
Enabling the ingress-config through kubectl apply -f ingress.yaml
gave the following error:
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57
Help would be much appreciated, thanks!
Update: @harsh-manvar pointed out a mismatch in the config version. I have rewritten ingress.yaml to a very stripped down version:
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60 name: dashboard
61 namespace: kube-system
62spec:
63 rules:
64 - http:
65 paths:
66 - path: /dashboard
67 pathType: Prefix
68 backend:
69 service:
70 name: kubernetes-dashboard
71 port:
72 number: 443
73
Applying this works. Also, the ingress rule gets created.
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60 name: dashboard
61 namespace: kube-system
62spec:
63 rules:
64 - http:
65 paths:
66 - path: /dashboard
67 pathType: Prefix
68 backend:
69 service:
70 name: kubernetes-dashboard
71 port:
72 number: 443
73NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
74kube-system dashboard public * 127.0.0.1 80 11m
75
However, when I access the dashboard through http://<ip-of-kubernetes-master>/dashboard
, I get a 400
error.
Log from the ingress controller:
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60 name: dashboard
61 namespace: kube-system
62spec:
63 rules:
64 - http:
65 paths:
66 - path: /dashboard
67 pathType: Prefix
68 backend:
69 service:
70 name: kubernetes-dashboard
71 port:
72 number: 443
73NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
74kube-system dashboard public * 127.0.0.1 80 11m
75192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] "GET /dashboard HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36" 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
76
Does the dashboard also need to be exposed using the microk8s proxy
? I thought the ingress controller would take care of this, or did I misunderstand this?
ANSWER
Answered 2021-Oct-10 at 18:291127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60 name: dashboard
61 namespace: kube-system
62spec:
63 rules:
64 - http:
65 paths:
66 - path: /dashboard
67 pathType: Prefix
68 backend:
69 service:
70 name: kubernetes-dashboard
71 port:
72 number: 443
73NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
74kube-system dashboard public * 127.0.0.1 80 11m
75192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] "GET /dashboard HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36" 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
76error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
77
it' due to the mismatch in the ingress API version.
You are running the v1.22.2 while API version in YAML is old.
Good example : https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
you are using the older ingress API version in your YAML which is extensions/v1beta1
.
You need to change this based on ingress version and K8s version you are running.
This is for version 1.19 in K8s and will work in 1.22 also
Example :
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4 enabled:
5 dashboard # The Kubernetes dashboard
6 ha-cluster # Configure high availability on the current node
7 ingress # Ingress controller for external access
8 metrics-server # K8s Metrics Server for API access to service metrics
9NAMESPACE NAME READY STATUS RESTARTS AGE
10kube-system pod/calico-node-2jltr 1/1 Running 0 23m
11kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
12kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
13kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
14kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
15ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
16
17NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
18default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
19kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
20kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
21kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
22
23NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
24kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
25ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
26
27NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
28kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
29kube-system deployment.apps/metrics-server 1/1 1 1 22m
30kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
31kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
32
33NAMESPACE NAME DESIRED CURRENT READY AGE
34kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
35kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
36kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
37kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
38kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42 annotations:
43 kubernetes.io/ingress.class: public
44 nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45 name: dashboard
46 namespace: kube-system
47spec:
48 rules:
49 - host: main
50 http:
51 paths:
52 - backend:
53 serviceName: kubernetes-dashboard
54 servicePort: 443
55 path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60 name: dashboard
61 namespace: kube-system
62spec:
63 rules:
64 - http:
65 paths:
66 - path: /dashboard
67 pathType: Prefix
68 backend:
69 service:
70 name: kubernetes-dashboard
71 port:
72 number: 443
73NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
74kube-system dashboard public * 127.0.0.1 80 11m
75192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] "GET /dashboard HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36" 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
76error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
77apiVersion: networking.k8s.io/v1
78kind: Ingress
79metadata:
80 name: minimal-ingress
81 annotations:
82 nginx.ingress.kubernetes.io/rewrite-target: /
83spec:
84 rules:
85 - http:
86 paths:
87 - path: /testpath
88 pathType: Prefix
89 backend:
90 service:
91 name: test
92 port:
93 number: 80
94
QUESTION
Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>
Asked 2022-Mar-24 at 16:08I'm using React Router v6 and am creating private routes for my application.
In file PrivateRoute.js, I've the code
1import React from 'react';
2import {Route,Navigate} from "react-router-dom";
3import {isauth} from 'auth'
4
5function PrivateRoute({ element, path }) {
6 const authed = isauth() // isauth() returns true or false based on localStorage
7 const ele = authed === true ? element : <Navigate to="/Home" />;
8 return <Route path={path} element={ele} />;
9}
10
11export default PrivateRoute
12
And in file route.js I've written as:
1import React from 'react';
2import {Route,Navigate} from "react-router-dom";
3import {isauth} from 'auth'
4
5function PrivateRoute({ element, path }) {
6 const authed = isauth() // isauth() returns true or false based on localStorage
7 const ele = authed === true ? element : <Navigate to="/Home" />;
8 return <Route path={path} element={ele} />;
9}
10
11export default PrivateRoute
12 ...
13<PrivateRoute exact path="/" element={<Dashboard/>}/>
14<Route exact path="/home" element={<Home/>}/>
15
I've gone through the same example React-router Auth Example - StackBlitz, file App.tsx
Is there something I'm missing?
ANSWER
Answered 2021-Nov-12 at 21:20I ran into the same issue today and came up with the following solution based on this very helpful article by Andrew Luca
In PrivateRoute.js:
1import React from 'react';
2import {Route,Navigate} from "react-router-dom";
3import {isauth} from 'auth'
4
5function PrivateRoute({ element, path }) {
6 const authed = isauth() // isauth() returns true or false based on localStorage
7 const ele = authed === true ? element : <Navigate to="/Home" />;
8 return <Route path={path} element={ele} />;
9}
10
11export default PrivateRoute
12 ...
13<PrivateRoute exact path="/" element={<Dashboard/>}/>
14<Route exact path="/home" element={<Home/>}/>
15import React from 'react';
16import { Navigate, Outlet } from 'react-router-dom';
17
18const PrivateRoute = () => {
19 const auth = null; // determine if authorized, from context or however you're doing it
20
21 // If authorized, return an outlet that will render child elements
22 // If not, return element that will navigate to login page
23 return auth ? <Outlet /> : <Navigate to="/login" />;
24}
25
In App.js (I've left in some other pages as examples):
1import React from 'react';
2import {Route,Navigate} from "react-router-dom";
3import {isauth} from 'auth'
4
5function PrivateRoute({ element, path }) {
6 const authed = isauth() // isauth() returns true or false based on localStorage
7 const ele = authed === true ? element : <Navigate to="/Home" />;
8 return <Route path={path} element={ele} />;
9}
10
11export default PrivateRoute
12 ...
13<PrivateRoute exact path="/" element={<Dashboard/>}/>
14<Route exact path="/home" element={<Home/>}/>
15import React from 'react';
16import { Navigate, Outlet } from 'react-router-dom';
17
18const PrivateRoute = () => {
19 const auth = null; // determine if authorized, from context or however you're doing it
20
21 // If authorized, return an outlet that will render child elements
22 // If not, return element that will navigate to login page
23 return auth ? <Outlet /> : <Navigate to="/login" />;
24}
25import './App.css';
26import React, {Fragment} from 'react';
27import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
28import Navbar from './components/layout/Navbar';
29import Home from './components/pages/Home';
30import Register from './components/auth/Register'
31import Login from './components/auth/Login';
32import PrivateRoute from './components/routing/PrivateRoute';
33
34const App = () => {
35 return (
36 <Router>
37 <Fragment>
38 <Navbar/>
39 <Routes>
40 <Route exact path='/' element={<PrivateRoute/>}>
41 <Route exact path='/' element={<Home/>}/>
42 </Route>
43 <Route exact path='/register' element={<Register/>}/>
44 <Route exact path='/login' element={<Login/>}/>
45 </Routes>
46 </Fragment>
47 </Router>
48
49 );
50}
51
In the above routing, this is the private route:
1import React from 'react';
2import {Route,Navigate} from "react-router-dom";
3import {isauth} from 'auth'
4
5function PrivateRoute({ element, path }) {
6 const authed = isauth() // isauth() returns true or false based on localStorage
7 const ele = authed === true ? element : <Navigate to="/Home" />;
8 return <Route path={path} element={ele} />;
9}
10
11export default PrivateRoute
12 ...
13<PrivateRoute exact path="/" element={<Dashboard/>}/>
14<Route exact path="/home" element={<Home/>}/>
15import React from 'react';
16import { Navigate, Outlet } from 'react-router-dom';
17
18const PrivateRoute = () => {
19 const auth = null; // determine if authorized, from context or however you're doing it
20
21 // If authorized, return an outlet that will render child elements
22 // If not, return element that will navigate to login page
23 return auth ? <Outlet /> : <Navigate to="/login" />;
24}
25import './App.css';
26import React, {Fragment} from 'react';
27import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
28import Navbar from './components/layout/Navbar';
29import Home from './components/pages/Home';
30import Register from './components/auth/Register'
31import Login from './components/auth/Login';
32import PrivateRoute from './components/routing/PrivateRoute';
33
34const App = () => {
35 return (
36 <Router>
37 <Fragment>
38 <Navbar/>
39 <Routes>
40 <Route exact path='/' element={<PrivateRoute/>}>
41 <Route exact path='/' element={<Home/>}/>
42 </Route>
43 <Route exact path='/register' element={<Register/>}/>
44 <Route exact path='/login' element={<Login/>}/>
45 </Routes>
46 </Fragment>
47 </Router>
48
49 );
50}
51<Route exact path='/' element={<PrivateRoute/>}>
52 <Route exact path='/' element={<Home/>}/>
53</Route>
54
If authorization is successful, the element will show. Otherwise, it will navigate to the login page.
QUESTION
You cannot render a <Router> inside another <Router>. You should never have more than one in your app
Asked 2022-Mar-21 at 07:091import { BrowserRouter, Routes, Route } from "react-router-dom";
2
3//Layouts
4import HomeLayoutRoute from "./components/layouts/HomeLayout";
5
6//components
7import Home from './components/Home';
8//import Dashboard from './components/Dash';
9
10// Routing
11import PrivateRoute from "./components/routing/PrivateRoute";
12
13// Screens
14import PrivateScreen from "./components/loginscreens/PrivateScreen";
15import LoginScreen from "./components/loginscreens/LoginScreen";
16import RegisterScreen from "./components/loginscreens/RegisterScreen";
17import ForgotPasswordScreen from "./components/loginscreens/ForgotPasswordScreen";
18import ResetPasswordScreen from "./components/loginscreens/ResetPasswordScreen";
19
20const App = () => {
21 return (
22 <BrowserRouter>
23 <div className="app">
24 <Routes>
25 <HomeLayoutRoute path="/" element={<Home />} />
26 <PrivateRoute path="/" element={<PrivateScreen/>} />
27 <Route path="/login" element={<LoginScreen/>} />
28 <Route path="/register" element={<RegisterScreen/>} />
29 <Route path="/forgotpassword" element={<ForgotPasswordScreen/>}/>
30 <Route path="/passwordreset/:resetToken" element={<ResetPasswordScreen/>}/>
31 </Routes>
32 </div>
33 </BrowserRouter>
34 );
35};
36
37export default App;
38
This is my App.js file This is the Error : Error: You cannot render a inside another . You should never have more than one in your app.
This code works with React-Router-Dom Version 5, But When I move to React-Router-Dom version 6 this error came.
ANSWER
Answered 2021-Nov-03 at 16:481import { BrowserRouter, Routes, Route } from "react-router-dom";
2
3//Layouts
4import HomeLayoutRoute from "./components/layouts/HomeLayout";
5
6//components
7import Home from './components/Home';
8//import Dashboard from './components/Dash';
9
10// Routing
11import PrivateRoute from "./components/routing/PrivateRoute";
12
13// Screens
14import PrivateScreen from "./components/loginscreens/PrivateScreen";
15import LoginScreen from "./components/loginscreens/LoginScreen";
16import RegisterScreen from "./components/loginscreens/RegisterScreen";
17import ForgotPasswordScreen from "./components/loginscreens/ForgotPasswordScreen";
18import ResetPasswordScreen from "./components/loginscreens/ResetPasswordScreen";
19
20const App = () => {
21 return (
22 <BrowserRouter>
23 <div className="app">
24 <Routes>
25 <HomeLayoutRoute path="/" element={<Home />} />
26 <PrivateRoute path="/" element={<PrivateScreen/>} />
27 <Route path="/login" element={<LoginScreen/>} />
28 <Route path="/register" element={<RegisterScreen/>} />
29 <Route path="/forgotpassword" element={<ForgotPasswordScreen/>}/>
30 <Route path="/passwordreset/:resetToken" element={<ResetPasswordScreen/>}/>
31 </Routes>
32 </div>
33 </BrowserRouter>
34 );
35};
36
37export default App;
38import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
39
40//Layouts
41import HomeLayoutRoute from "./components/layouts/HomeLayout";
42
43//components
44import Home from './components/Home';
45//import Dash from './components/DashBoard';
46
47// Routing
48import PrivateRoute from "./components/routing/PrivateRoute";
49
50// Screens
51import PrivateScreen from "./components/loginscreens/PrivateScreen";
52import LoginScreen from "./components/loginscreens/LoginScreen";
53import RegisterScreen from "./components/loginscreens/RegisterScreen";
54import ForgotPasswordScreen from "./components/loginscreens/ForgotPasswordScreen";
55import ResetPasswordScreen from "./components/loginscreens/ResetPasswordScreen";
56
57
58const App = () => {
59 return (
60 <Router>
61 <div className="app">
62 <Routes>
63 <HomeLayoutRoute exact path="/" component={Home} />
64 <PrivateRoute exact path="/" component={PrivateScreen} />
65 <Route exact path="/login" component={LoginScreen} />
66 <Route exact path="/register" component={RegisterScreen} />
67 <Route
68 exact
69 path="/forgotpassword"
70 component={ForgotPasswordScreen}
71 />
72 <Route
73 exact
74 path="/passwordreset/:resetToken"
75 component={ResetPasswordScreen}
76 />
77 </Routes>
78 </div>
79 </Router>
80 );
81};
82
83export default App;
84
This is the Code I have used with React-Router-Dom Version 5 I think problem with the Version 6
QUESTION
Add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes
Asked 2022-Feb-13 at 20:24I run prometheus locally as http://localhost:9090/targets with
1docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus
2
and want to connect it to several Kubernetes (cluster) instances we have. See that scraping works, try Grafana dashboards etc.
And then I'll do the same on dedicated server that will be specially for monitoring. However all googling gives me all different ways to configure prometheus that is already within one Kubernetes instance, and no way to read metrics from external Kubernetes.
How to add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes?
I have read Where Kubernetes metrics come from and checked that my (first) Kubernetes cluster has the Metrics Server.
1docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus
2kubectl get pods --all-namespaces | grep metrics-server
3
There is definitely no sense to add Prometheus instance into every Kubernetes (cluster) instance. One Prometheus must be able to read metrics from many Kubernetes clusters and every node within them.
P.S. Some old question has answer to install Prometheus in every Kubernetes and then use federation, that is just opposite from what I am looking for.
P.P.S. It is also strange for me, why Kubernetes and Prometheus that are #1 and #2 projects from Cloud Native Foundation don't have simple "add Kubernetes target in Prometheus" button or simple step.
ANSWER
Answered 2021-Dec-28 at 08:33There are many agents capable of saving metrics collected in k8s to remote Prometheus server outside the cluster, example Prometheus itself now support agent mode, exporter from Opentelemetry, or using managed Prometheus etc.
QUESTION
Using GitHub Actions to create a .env file in the workflow
Asked 2022-Jan-28 at 15:36I recently created this post trying to figure out how to reference GitHub Secrets in a GitHub action. I believe I got that solved & figured out and I'm onto a different issue.
Below is a sample of the workflow code as of right now, the issue I need help with is the Create and populate .Renviron file
part.
1on: [push, pull_request]
2name: CI-CD
3jobs:
4 CI-CD:
5 runs-on: ${{ matrix.config.os }}
6
7 name: ${{ matrix.config.os }} (${{ matrix.config.r }})
8
9 strategy:
10 # we keep a matrix for convenience, but we would typically just run on one
11 # single OS and R version, aligned with the target deployment environment
12 matrix:
13 config:
14 - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
15
16 env:
17 # Enable RStudio Package Manager to speed up package installation
18 RSPM: ${{ matrix.config.rspm }}
19 # Access token for GitHub
20 GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21
22 steps:
23
24 - name: Checkout repo
25 uses: actions/checkout@v2
26
27 - name: Setup R
28 uses: r-lib/actions/setup-r@v1
29 with:
30 r-version: ${{ matrix.config.r }}
31
32 - name: Install system dependencies
33 run: |
34 while read -r cmd
35 do
36 eval sudo $cmd
37 done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
38 - name: Install R dependencies
39 run: |
40 remotes::install_deps(dependencies = TRUE)
41 remotes::install_cran("rcmdcheck")
42 shell: Rscript {0}
43
44 - name: Create and populate .Renviron file
45 env:
46 AWS_HOST: ${{ secrets.AWS_HOST }}
47 AWS_PORT: ${{ secrets.AWS_PORT }}
48 AWS_PW: ${{ secrets.AWS_PW }}
49 AWS_USER: ${{ secrets.AWS_USER }}
50 DBNAME: ${{ secrets.DBNAME }}
51 run: |
52 touch .Renviron
53 echo aws_host="$AWS_HOST" >> .Renviron
54 echo aws_port="$AWS_PORT" >> .Renviron
55 echo aws_pw="$AWS_PW" >> .Renviron
56 echo aws_user="$AWS_USER" >> .Renviron
57 echo dbname="$DBNAME" >> .Renviron
58 ls ${{ github.workspace }}
59 shell: bash
60
61 - name: Deploy to shinyapps.io
62 # continuous deployment only for pushes to the main / master branch
63 if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
64 env:
65 SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
66 SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
67 SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
68 run: Rscript deploy/deploy-shinyapps.R
69
70
I believe this .Renviron file is getting created, but I don't know where, and it certainly doesn't look like it's where the rest of the files are. I've tried a number of file path destinations, .Renviron
, ~/.Renviron
, $github.workspace/.Renviron
, /home/runner/work/NBA-Dashboard/NBA-Dashboard/.Renviron
, none of them work. After I create the file I list all of the contents of the workspace directory (which is where I want the file to be) and it's never listed there.
I need that .Renvrion file to be created & listed in that specific directory along with all of these other files so when I continue to the next step and use the rsconnect package to build & deploy my Shiny app it's able to include that file to retrieve environment variables correctly when someone uses the app.
I thought maybe there was some issue with .gitignore so I deleted .Renviron off of that ? But it didn't fix the issue. But ya if anyone has any ideas I'd appreciate it!
ANSWER
Answered 2021-Sep-01 at 09:23The file is there where you expect to be
1on: [push, pull_request]
2name: CI-CD
3jobs:
4 CI-CD:
5 runs-on: ${{ matrix.config.os }}
6
7 name: ${{ matrix.config.os }} (${{ matrix.config.r }})
8
9 strategy:
10 # we keep a matrix for convenience, but we would typically just run on one
11 # single OS and R version, aligned with the target deployment environment
12 matrix:
13 config:
14 - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
15
16 env:
17 # Enable RStudio Package Manager to speed up package installation
18 RSPM: ${{ matrix.config.rspm }}
19 # Access token for GitHub
20 GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21
22 steps:
23
24 - name: Checkout repo
25 uses: actions/checkout@v2
26
27 - name: Setup R
28 uses: r-lib/actions/setup-r@v1
29 with:
30 r-version: ${{ matrix.config.r }}
31
32 - name: Install system dependencies
33 run: |
34 while read -r cmd
35 do
36 eval sudo $cmd
37 done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
38 - name: Install R dependencies
39 run: |
40 remotes::install_deps(dependencies = TRUE)
41 remotes::install_cran("rcmdcheck")
42 shell: Rscript {0}
43
44 - name: Create and populate .Renviron file
45 env:
46 AWS_HOST: ${{ secrets.AWS_HOST }}
47 AWS_PORT: ${{ secrets.AWS_PORT }}
48 AWS_PW: ${{ secrets.AWS_PW }}
49 AWS_USER: ${{ secrets.AWS_USER }}
50 DBNAME: ${{ secrets.DBNAME }}
51 run: |
52 touch .Renviron
53 echo aws_host="$AWS_HOST" >> .Renviron
54 echo aws_port="$AWS_PORT" >> .Renviron
55 echo aws_pw="$AWS_PW" >> .Renviron
56 echo aws_user="$AWS_USER" >> .Renviron
57 echo dbname="$DBNAME" >> .Renviron
58 ls ${{ github.workspace }}
59 shell: bash
60
61 - name: Deploy to shinyapps.io
62 # continuous deployment only for pushes to the main / master branch
63 if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
64 env:
65 SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
66 SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
67 SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
68 run: Rscript deploy/deploy-shinyapps.R
69
70 - name: Create and populate .Renviron file
71 env:
72 AWS_HOST: ${{ secrets.AWS_HOST }}
73 AWS_PORT: ${{ secrets.AWS_PORT }}
74 AWS_PW: ${{ secrets.AWS_PW }}
75 AWS_USER: ${{ secrets.AWS_USER }}
76 DBNAME: ${{ secrets.DBNAME }}
77 run: |
78 touch .Renviron
79 echo aws_host="$AWS_HOST" >> .Renviron
80 echo aws_port="$AWS_PORT" >> .Renviron
81 echo aws_pw="$AWS_PW" >> .Renviron
82 echo aws_user="$AWS_USER" >> .Renviron
83 echo dbname="$DBNAME" >> .Renviron
84
85 echo "cat .Renviron"
86 cat .Renviron
87
88 echo "ls -a ."
89 ls -a .
90
91 echo "ls -a ${{ github.workspace }}"
92 ls -a ${{ github.workspace }}
93 shell: bash
94
you need to run ls -a
to show hidden files.
1on: [push, pull_request]
2name: CI-CD
3jobs:
4 CI-CD:
5 runs-on: ${{ matrix.config.os }}
6
7 name: ${{ matrix.config.os }} (${{ matrix.config.r }})
8
9 strategy:
10 # we keep a matrix for convenience, but we would typically just run on one
11 # single OS and R version, aligned with the target deployment environment
12 matrix:
13 config:
14 - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
15
16 env:
17 # Enable RStudio Package Manager to speed up package installation
18 RSPM: ${{ matrix.config.rspm }}
19 # Access token for GitHub
20 GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21
22 steps:
23
24 - name: Checkout repo
25 uses: actions/checkout@v2
26
27 - name: Setup R
28 uses: r-lib/actions/setup-r@v1
29 with:
30 r-version: ${{ matrix.config.r }}
31
32 - name: Install system dependencies
33 run: |
34 while read -r cmd
35 do
36 eval sudo $cmd
37 done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
38 - name: Install R dependencies
39 run: |
40 remotes::install_deps(dependencies = TRUE)
41 remotes::install_cran("rcmdcheck")
42 shell: Rscript {0}
43
44 - name: Create and populate .Renviron file
45 env:
46 AWS_HOST: ${{ secrets.AWS_HOST }}
47 AWS_PORT: ${{ secrets.AWS_PORT }}
48 AWS_PW: ${{ secrets.AWS_PW }}
49 AWS_USER: ${{ secrets.AWS_USER }}
50 DBNAME: ${{ secrets.DBNAME }}
51 run: |
52 touch .Renviron
53 echo aws_host="$AWS_HOST" >> .Renviron
54 echo aws_port="$AWS_PORT" >> .Renviron
55 echo aws_pw="$AWS_PW" >> .Renviron
56 echo aws_user="$AWS_USER" >> .Renviron
57 echo dbname="$DBNAME" >> .Renviron
58 ls ${{ github.workspace }}
59 shell: bash
60
61 - name: Deploy to shinyapps.io
62 # continuous deployment only for pushes to the main / master branch
63 if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
64 env:
65 SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
66 SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
67 SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
68 run: Rscript deploy/deploy-shinyapps.R
69
70 - name: Create and populate .Renviron file
71 env:
72 AWS_HOST: ${{ secrets.AWS_HOST }}
73 AWS_PORT: ${{ secrets.AWS_PORT }}
74 AWS_PW: ${{ secrets.AWS_PW }}
75 AWS_USER: ${{ secrets.AWS_USER }}
76 DBNAME: ${{ secrets.DBNAME }}
77 run: |
78 touch .Renviron
79 echo aws_host="$AWS_HOST" >> .Renviron
80 echo aws_port="$AWS_PORT" >> .Renviron
81 echo aws_pw="$AWS_PW" >> .Renviron
82 echo aws_user="$AWS_USER" >> .Renviron
83 echo dbname="$DBNAME" >> .Renviron
84
85 echo "cat .Renviron"
86 cat .Renviron
87
88 echo "ls -a ."
89 ls -a .
90
91 echo "ls -a ${{ github.workspace }}"
92 ls -a ${{ github.workspace }}
93 shell: bash
94Run touch .Renviron
95 touch .Renviron
96 echo aws_host="$AWS_HOST" >> .Renviron
97 echo aws_port="$AWS_PORT" >> .Renviron
98 echo aws_pw="$AWS_PW" >> .Renviron
99 echo aws_user="$AWS_USER" >> .Renviron
100 echo dbname="$DBNAME" >> .Renviron
101
102 echo "cat .Renviron"
103 cat .Renviron
104
105 echo "ls -a ."
106 ls -a .
107
108 echo "ls -a /home/runner/work/github-actions-manual/github-actions-manual"
109 ls -a /home/runner/work/github-actions-manual/github-actions-manual
110 shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
111 env:
112 AWS_HOST:
113 AWS_PORT:
114 AWS_PW:
115 AWS_USER:
116 DBNAME:
117cat .Renviron
118aws_host=
119aws_port=
120aws_pw=
121aws_user=
122dbname=
123ls -a .
124.
125..
126.Renviron
127.git
128.github
129.gitignore
130LICENSE
131README.md
132change-workflow.ps1
133commit-new-workflow.ps1
134dist
135public
136test.ps1
137test2.ps1
138ls -a /home/runner/work/github-actions-manual/github-actions-manual
139.
140..
141.Renviron
142.git
143.github
144.gitignore
145LICENSE
146README.md
147change-workflow.ps1
148commit-new-workflow.ps1
149dist
150public
151test.ps1
152test2.ps1
153
QUESTION
How to use Private route in react-router-dom@v6
Asked 2022-Jan-21 at 16:10I want to use private route with react-router-dom v6, while i am trying to apply a condition for auth.
In App.js
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2
In a component .js
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3
- When the Route is not inside <Routes> it gives an error:
Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your in a <Routes>
- When it is inside <Routes> it give an error as:
Error: [Abc] is not a <Route> component. All component children of must be a <Route> or <React.Fragment>
Pls help me to resolve this situation ? Or any suggestion.
Tried this but one of the above error in both cases
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3<Route path='/dashboard' element= {<PrivateRoute> <Dashboard />
4 </PrivateRoute>}/>
5
Also
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3<Route path='/dashboard' element= {<PrivateRoute> <Dashboard />
4 </PrivateRoute>}/>
5`<PrivateRoute path='/dashboard' element= { <Dashboard />}/>`
6
PICCode full
ANSWER
Answered 2021-Nov-11 at 07:22In react-router-dom
version 6 there is no render
prop for the Route
component. You can also simplify your PrivateRoute
wrapper component a bit, it doesn't need to render more Routes
and Route
components.
Conditionally render the component's children or navigate to log in.
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3<Route path='/dashboard' element= {<PrivateRoute> <Dashboard />
4 </PrivateRoute>}/>
5`<PrivateRoute path='/dashboard' element= { <Dashboard />}/>`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) => {
7 return isAuthenticated ? children : <Navigate to="/login" />;
8};
9
Usage:
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3<Route path='/dashboard' element= {<PrivateRoute> <Dashboard />
4 </PrivateRoute>}/>
5`<PrivateRoute path='/dashboard' element= { <Dashboard />}/>`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) => {
7 return isAuthenticated ? children : <Navigate to="/login" />;
8};
9<Route
10 path="/dashboard"
11 element={
12 <PrivateRoute>
13 <Dashboard />
14 </PrivateRoute>
15 }
16/>
17
A slightly improved version to allow nesting more private route components utilizes an outlet to handle rendering out nested routes.
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3<Route path='/dashboard' element= {<PrivateRoute> <Dashboard />
4 </PrivateRoute>}/>
5`<PrivateRoute path='/dashboard' element= { <Dashboard />}/>`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) => {
7 return isAuthenticated ? children : <Navigate to="/login" />;
8};
9<Route
10 path="/dashboard"
11 element={
12 <PrivateRoute>
13 <Dashboard />
14 </PrivateRoute>
15 }
16/>
17const PrivateWrapper = ({ auth: { isAuthenticated } }) => {
18 return isAuthenticated ? <Outlet /> : <Navigate to="/login" />;
19};
20
Usage:
1<Route path='/dashboard' element= { <PrivateRoute><Abc /></PrivateRoute>}/>
2<Routes> <Route {...rest} render={props => !isAuthenticated && !loading ? (<Navigate to='/login' />) : (<Component {...props} />)} /></Routes>
3<Route path='/dashboard' element= {<PrivateRoute> <Dashboard />
4 </PrivateRoute>}/>
5`<PrivateRoute path='/dashboard' element= { <Dashboard />}/>`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) => {
7 return isAuthenticated ? children : <Navigate to="/login" />;
8};
9<Route
10 path="/dashboard"
11 element={
12 <PrivateRoute>
13 <Dashboard />
14 </PrivateRoute>
15 }
16/>
17const PrivateWrapper = ({ auth: { isAuthenticated } }) => {
18 return isAuthenticated ? <Outlet /> : <Navigate to="/login" />;
19};
20<Route element={<PrivateWrapper />}>
21 <Route path="/dashboard" element={<Dashboard />} />
22</Route>
23
QUESTION
Field 'recordName' is not marked queryable - cloudkit dashboard
Asked 2022-Jan-07 at 03:51In Cloudkit Dashboard, I select Record Type, Edit Indexes, then I select Add Basic Index. I see in the dropdown createTime, createdBy, eTag, modTime, modifiedBy, recordID and the record fields. I do not see recordName in the dropdown( Attached screenshot). Without creating index on recordName, I cannot query the record in cloudKit Dashboard. I get error: Field 'recordName' is not marked queryable How to create index on recordName?
ANSWER
Answered 2021-Oct-25 at 17:18I ran into this same issue and solved it by adding ___recordID
as a queryable index. When it is added to the list of indexes, the field changes to recordName
.
To add this as a queryable index, go to the Schema Section -> Indexes, and click Add Basic Index.
QUESTION
Custom Page Permission using Angular 11
Asked 2021-Dec-31 at 09:25I am working on an application in which I am implementing custom permission. There is subscription-based permission that I can't check in auth guard which will be static and I have implemented helper for permission which checks for route and then check it in user subscription for that route and then redirected to any of the pages on role permission. It is working fine but I need a better approach to implement it with clean code. Here is my implementation
Home Component
1import { Component, OnInit } from "@angular/core";
2import { Location } from '@angular/common';
3import { AuthService } from "src/app/services/apiServices/auth.service";
4
5@Component({
6 selector: "app-home",
7 templateUrl: "./home.component.html"
8})
9export class HomeComponent implements OnInit {
10 constructor(private readonly location: Location, private readonly authService : AuthService ) {
11 }
12 ngOnInit() {
13 this.authService.getPermission(this.location.path());
14 }
15}
16
Auth Service Code
1import { Component, OnInit } from "@angular/core";
2import { Location } from '@angular/common';
3import { AuthService } from "src/app/services/apiServices/auth.service";
4
5@Component({
6 selector: "app-home",
7 templateUrl: "./home.component.html"
8})
9export class HomeComponent implements OnInit {
10 constructor(private readonly location: Location, private readonly authService : AuthService ) {
11 }
12 ngOnInit() {
13 this.authService.getPermission(this.location.path());
14 }
15}
16getPermission(currentRoute: string) {
17 this.userPermissions = this.loggedInUserSubscriptionDetails$.subscribe(sub => {
18 if (sub) {
19 if (sub.MenuPermissioList.map(x => x.url).indexOf(currentRoute) === -1) {
20 this.router.navigate(["/finance-analysis/not-authorized"]);
21 return;
22 }else{
23 console.log('exists');
24 }
25 }
26 });
27
28 }
29
This code is basically getting a current location path and then checking that path in subscription MenuPermissioList if it exists then it allows to open up the page otherwise it redirected to unauthorized.
I don't want to use this code data : {roles: [ApplicationRolesEnum.CompanyAdmin]} because I have to add or remove roles from data to allow that user for a specific page and it is basically static binding. Here I have added this check and it is working fine but my permission may vary from user to user. Which makes it difficult to maintain.
1import { Component, OnInit } from "@angular/core";
2import { Location } from '@angular/common';
3import { AuthService } from "src/app/services/apiServices/auth.service";
4
5@Component({
6 selector: "app-home",
7 templateUrl: "./home.component.html"
8})
9export class HomeComponent implements OnInit {
10 constructor(private readonly location: Location, private readonly authService : AuthService ) {
11 }
12 ngOnInit() {
13 this.authService.getPermission(this.location.path());
14 }
15}
16getPermission(currentRoute: string) {
17 this.userPermissions = this.loggedInUserSubscriptionDetails$.subscribe(sub => {
18 if (sub) {
19 if (sub.MenuPermissioList.map(x => x.url).indexOf(currentRoute) === -1) {
20 this.router.navigate(["/finance-analysis/not-authorized"]);
21 return;
22 }else{
23 console.log('exists');
24 }
25 }
26 });
27
28 }
29 {
30 path: "home",
31 canActivate: [AuthGuard, SubscriptionGuard],data : {roles: [ApplicationRolesEnum.CompanyAdmin, ApplicationRolesEnum.ExternalUser]},
32 loadChildren: () => import("src/app/pages/dashboard/dashboard.module").then(m => m.DashboardModule)
33 },
34
ANSWER
Answered 2021-Dec-31 at 09:25You could try following approach. I did not test it now and have written it off the top of my head but it is based on an approach I used in one project.
Basically you would still use a Guard for this but load the permissions from your service dynamically and based on them either let the user activate the page or redirect to the Unauthorized page. CanActivate subscribes to the Observable for you so you don't have to manage any subscription manually.
1import { Component, OnInit } from "@angular/core";
2import { Location } from '@angular/common';
3import { AuthService } from "src/app/services/apiServices/auth.service";
4
5@Component({
6 selector: "app-home",
7 templateUrl: "./home.component.html"
8})
9export class HomeComponent implements OnInit {
10 constructor(private readonly location: Location, private readonly authService : AuthService ) {
11 }
12 ngOnInit() {
13 this.authService.getPermission(this.location.path());
14 }
15}
16getPermission(currentRoute: string) {
17 this.userPermissions = this.loggedInUserSubscriptionDetails$.subscribe(sub => {
18 if (sub) {
19 if (sub.MenuPermissioList.map(x => x.url).indexOf(currentRoute) === -1) {
20 this.router.navigate(["/finance-analysis/not-authorized"]);
21 return;
22 }else{
23 console.log('exists');
24 }
25 }
26 });
27
28 }
29 {
30 path: "home",
31 canActivate: [AuthGuard, SubscriptionGuard],data : {roles: [ApplicationRolesEnum.CompanyAdmin, ApplicationRolesEnum.ExternalUser]},
32 loadChildren: () => import("src/app/pages/dashboard/dashboard.module").then(m => m.DashboardModule)
33 },
34import { AuthService } from "src/app/services/apiServices/auth.service";
35
36
37@Injectable()
38export class SubscriptionGuard implements CanActivate {
39
40 constructor(
41 private readonly router: Router,
42 private readonly authService: AuthService,
43 ) { }
44
45 canActivate(activatedRoute: ActivatedRouteSnapshot, routerState: RouterStateSnapshot): Observable<boolean> {
46 return this.authService.loggedInUserSubscriptionDetails$.pipe(
47 take(1),
48 map((sub) => {
49 if (!sub) {
50 return false;
51 }
52 return sub.MenuPermissioList.map(x => x.url).includes(routerState.url);
53 }),
54 tap(hasPermission => hasPermission ? undefined : this.router.navigate(['/finance-analysis/not-authorized']))
55 );
56 }
57}
58
Edit: changed the way of extracting current url after discussion in comments.
QUESTION
Error while generating report in apache-jmeter-5.4.1.tgz
Asked 2021-Dec-31 at 08:56sh jmeter.sh -n -t filePath.jmx -l outFilePath.jtl -e -o folderPath
1Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5
2
In resume
1Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5
2Consumer failed with message :Begin size 0 is not equal to fixed size 5
3
- currently using Java version "17" 2021-09-14 LTS
- MacOS big SUR version 11.4
- the properties files are fresh and values are equal to the default ones
- Jmeter 5.4.1
- outFile.jtl
1Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5
2Consumer failed with message :Begin size 0 is not equal to fixed size 5
3timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
41632430450882,1117,HTTP Request,200,OK,FIRST_Jmeter_Test 1-3,text,true,,3824,557,3,3,Url_hidden,1111,0,256
51632430450448,1755,HTTP Request,200,OK,FIRST_Jmeter_Test 1-2,text,true,,3836,557,3,3,Url_hidden,1755,0,690
61632430450448,1755,HTTP Request,200,OK,FIRST_Jmeter_Test 1-1,text,true,,3828,557,3,3,Url_hidden,1755,0,690
71632430452312,585,HTTP Request,200,OK,FIRST_Jmeter_Test 1-2,text,true,,3836,557,3,3,Url_hidden,585,0,144
81632430452238,758,HTTP Request,200,OK,FIRST_Jmeter_Test 1-3,text,true,,3832,557,3,3,Url_hidden,757,0,137
91632430452301,806,HTTP Request,200,OK,FIRST_Jmeter_Test 1-1,text,true,,3828,557,3,3,Url_hidden,805,0,136
101632430452962,550,HTTP Request,200,OK,FIRST_Jmeter_Test 1-2,text,true,,3824,557,3,3,Url_hidden,550,0,152
111632430453328,593,HTTP Request,200,OK,FIRST_Jmeter_Test 1-1,text,true,,3828,557,2,2,Url_hidden,592,0,135
121632430453276,815,HTTP Request,200,OK,FIRST_Jmeter_Test 1-3,text,true,,3840,557,1,1,Url_hidden,814,0,142
13
The thread run successfully and the jtl file is created as well.
I quite new on Jmeter and tried to see where that "size" attribute is currently locate to see how change it, but could not find it on any *.properties file
any though how can be this fixed, what the message is referring to?
thanks
ANSWER
Answered 2021-Sep-23 at 07:18I cannot reproduce your issue using:
openjdk:8-jre-alpine
docker image- JMeter 5.4.1
- Test plan
Test.jmx
from extras folder of JMeter
Demo:
If you cannot reproduce the above behaviour I think you made some changes either to Results File Configuration or to Reporting Configuration or both so you need to inspect all the JMeter Properties which differ from the defaults and restore their values to the original ones.
If you need further support you need to share at least first 2 lines of your outFilePath.jtl results file. Better if possible the full file and all the .properties files from JMeter's "bin" folder.
QUESTION
404 error while adding lambda trigger in cognito user pool
Asked 2021-Dec-24 at 11:44I have created a SAM template with a function in it. After deploying SAM the lambda function gets added and are also displayed while adding lambda function trigger in cognito but when I save it gives a 404 error.
SAM template
1AWSTemplateFormatVersion: '2010-09-09'
2Transform: AWS::Serverless-2016-10-31
3Description: >-
4 description
5
6Globals:
7 Function:
8 CodeUri: .
9 Runtime: nodejs14.x
10
11Resources:
12 function1:
13 Type: 'AWS::Serverless::Function'
14 Properties:
15 FunctionName: function1
16 Handler: dist/handlers/fun1.handler
17
error in cognito while adding trigger
1AWSTemplateFormatVersion: '2010-09-09'
2Transform: AWS::Serverless-2016-10-31
3Description: >-
4 description
5
6Globals:
7 Function:
8 CodeUri: .
9 Runtime: nodejs14.x
10
11Resources:
12 function1:
13 Type: 'AWS::Serverless::Function'
14 Properties:
15 FunctionName: function1
16 Handler: dist/handlers/fun1.handler
17[404 Not Found] Allowing Cognito to invoke lambda function cannot be completed.
18ResourceNotFoundException (Request ID: e963254b-8d2a-49fa-b012-xxxxxxxx)
19
Note - if I add a Cognito Sync trigger
in the lambda config dashboard and then try to configure a trigger in the user pool it works.
ANSWER
Answered 2021-Dec-24 at 11:44You can change to old console, set lambda trigger, it's worked. Then you can change to new console again.
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Dashboard
Tutorials and Learning Resources are not available at this moment for Dashboard