Popular New Releases in Access Management
unleash
v4.7.5
flagr
1.1.12
flipt
v1.8.1
flagsmith
Version 2.21.2
ff4j
Popular Libraries in Access Management
by Unleash typescript
5459 Apache-2.0
Unleash is the open source feature toggle service.
by viljamis html
3131
Feature.js is a fast, simple and lightweight browser feature detection library in 1kb.
by jnunemaker ruby
2861 MIT
:dolphin: Beautiful, performant feature flags for Ruby.
by fetlife ruby
2723 MIT
Feature flippers.
by scambra ruby
2490 MIT
An invitation strategy for devise
by uber java
1856 Apache-2.0
A tool for refactoring code related to feature flag APIs
by checkr go
1852 Apache-2.0
Flagr is a feature flagging, A/B testing and dynamic configuration microservice
by markphelps go
1806 GPL-3.0
An open-source, on-prem feature flag solution
by Flagsmith python
1580 NOASSERTION
Open Source Feature Flagging and Remote Config Service. Host on-prem or use our hosted version at https://flagsmith.com/
Trending New libraries in Access Management
by feature-flags-co csharp
882 Apache-2.0
Feature management platform for faster and more secure software delivery and iteration
by happykit typescript
574 MIT
⛳️ Feature Flags for Next.js
by thomaspoignant go
414 MIT
A simple and complete feature flag solution, without any complex backend system to install, all you need is a file as your backend. 🎛️
by binbincivil shell
112 Apache-2.0
Git extensions to provide high-level repository operations for new git branching model.
by JustSteveKing php
112 MIT
A simple to use Feature Flag package for Laravel
by unsignedapps swift
82 MIT
Vexil (named for Vexillology) is a Swift package for managing feature flags (also called feature toggles) in a flexible, multi-provider way.
by codeOfRobin swift
81 MIT
A library that lets you setup feature flagging for your iOS app using CloudKit
by MiSikora kotlin
70 Apache-2.0
Feature flags for multi-module Kotlin Android projects
by tesfy typescript
49 MIT
A lightweight A/B Testing and Feature Flag JavaScript library focused on performance
Top Authors in Access Management
1
13 Libraries
174
2
13 Libraries
121
3
12 Libraries
6118
4
11 Libraries
2088
5
7 Libraries
177
6
4 Libraries
92
7
4 Libraries
91
8
3 Libraries
32
9
3 Libraries
62
10
3 Libraries
114
1
13 Libraries
174
2
13 Libraries
121
3
12 Libraries
6118
4
11 Libraries
2088
5
7 Libraries
177
6
4 Libraries
92
7
4 Libraries
91
8
3 Libraries
32
9
3 Libraries
62
10
3 Libraries
114
Trending Kits in Access Management
No Trending Kits are available at this moment for Access Management
Trending Discussions on Access Management
Keycloak implementing both user and app authentication in the same realm
(Terraform, GCP) Error 403: Permission denied to list services for consumer container [projects/335478934851]
google analytics reporting api permission
Rest API design: Managing access to sub-entities
"Kafka Timed out waiting for a node assignment." on MSK
Django - Inline formset - How to set current user
SailPoint IdentityIQ 8.2 - Return a list of users who have any entitlement(group) in a predetermined list of entitlements
How to change my css to make hyper link visible [ with minimum sample code ]?
Error: Invalid hook call how can i solve it?
how to make a global environment variable accessible for PODs in a kubernetes cluster
QUESTION
Keycloak implementing both user and app authentication in the same realm
Asked 2022-Apr-08 at 11:25I have a setup like this:
Back-end REST API application - Single Instance running in Cloud Server - Let's call it as A
Public Users` Mobile app & browser clients - Let's call them together as X
We already are using Keycloak for Identity and Access Management. As per the current setup,
- X to A uses Password grant flow, that is – a client is created in Keycloak with Client-Type as Public for user management and auth of X to A.
Now, we have to introduce new layer of back-end app, that is,
- Back-end REST API application - Multiple Instances running in On-prem Servers across different physical locations - Let's call them together as B.
Now, both B and X both are clients of A, [i.e. A serve both B and X].
Please clarify:
Should I create another type of client in the same realm for B, like below?
- B to A: Client credentials grant flow i.e. I have to create another Client-Type as Confidential for B to A, to configure a service-account for each of the instances of B.
- If yes, please guide me on how to configure both Auth flows in A i.e. A has to auth both B and X.
- B to A: Client credentials grant flow i.e. I have to create another Client-Type as Confidential for B to A, to configure a service-account for each of the instances of B.
I feel like this one as a bad idea - Using the existing setup as it is, which is explained below.
As per the new business logic,
X logs-in the app (mobile/web app) using username and password and calls an API of A to generate a QR Code, which will contain the hash of the user's (X's) access token and some other info.
A stores both hash and access token of X in the database
B gets the hash of the access token used by X to access A, from the QR Code scanned by the user. B uses the hash to validate the authenticity of the QRCode, by calling an API of A
As mentioned in the above business logic, if needed, A can expose an API, where the above said user access token can be retrieved through a get request, by sending the hash as a request header param or query. This token can be further used by B for further API calls to A.
I think that the above idea is bad, because, we are not supposed to send the user access token over the internet, even if there is a SSL/TLS connection between B and A.
- Can the Client-Type, Bearer-Only be used in this scenario between B and A? If yes, Please guide me on this.
ANSWER
Answered 2022-Apr-08 at 11:25As you are having both Public and On prem services as clients, I would suggest the following:
- As you said, X as public client shall use Password grant
- B should use Client Credentials mechanism to get itself authenticated with Keycloak. Keycloak will provide it the access token through ${kc.realm-url}/protocol/openid-connect/token endpoint. This access token can be sent to A.
- "A" should also be a registered client with its own credentials.
- When "A" receives request from X or B, it should use a mechanism called Token verification through Introspection endpoint where it will get the token verified by calling Keycloak. Introspection endpoint expects access token, client id and client secret.
This way, A can be sure that the token received by it is indeed issued by Keycloak.
QUESTION
(Terraform, GCP) Error 403: Permission denied to list services for consumer container [projects/335478934851]
Asked 2022-Mar-02 at 03:39On GCP, I'm trying to enable "Identity and Access Management (IAM) API" with this Terraform code below:
1provider "google" {
2 credentials = file("myCredentials.json")
3 project = "myproject-173831"
4 region = "asia-northeast1"
5}
6
7resource "google_project_service" "project" {
8 service = "iam.googleapis.com"
9}
10
But I got this error:
Error when reading or editing Project Service : Request
List Project Services myproject-173831
returned error: Failed to list enabled services for project myproject-173831: googleapi: Error 403: Permission denied to list services for consumer container [projects/335478934851]
Then, I couldn't enable it
So now, I'm trying to add a role to solve this error above but there are too many roles to choose:
What role do I need to choose?
ANSWER
Answered 2022-Mar-02 at 03:391provider "google" {
2 credentials = file("myCredentials.json")
3 project = "myproject-173831"
4 region = "asia-northeast1"
5}
6
7resource "google_project_service" "project" {
8 service = "iam.googleapis.com"
9}
10provider "google" {
11 credentials = file("myCredentials.json")
12 project = "myproject-173831"
13 region = "asia-northeast1"
14}
15
16resource "google_project_service" "project" {
17 service = "iam.googleapis.com"
18}
19
QUESTION
google analytics reporting api permission
Asked 2022-Feb-25 at 13:46I'm making this custom dashboard using google analytics reporting api and MERN stack which allow users to create an account or login and choose whatever analytics they want to see depending on the filters they pick. But I'm having a problem where users have to add my API email manually to their account access management list so I can fetch Data from their google analytics accounts.
My Question is how can I use the reporting API without users having to give me permission?
I've seen a tutorial where users login with their google accounts but I want to implement my own User authentication.
ANSWER
Answered 2022-Feb-25 at 13:46The first thing you need to understand is the diffrence bettween public and private user data.
Public data is data that is well public. Anyone can access it. Public videos upload to youtube for example is public data.
Private data on the other hand is data that is owned by user. In order to access private user data you need the consent of the owner of that data or someone that has access to it.
My Question is how can I use the reporting API without users having to give me permission?
The answer is that you cant. You can not access a users private google analytics data without the consent of that user. The user will need to authorize your application and consent to your application accessing their data.
I've seen a tutorial where users login with their google accounts but I want to implement my own User authentication.
You can do that you can have your own login server and authorize users. But you are still going to have to request their consent to access their private Google analytics data on top of that.
QUESTION
Rest API design: Managing access to sub-entities
Asked 2022-Feb-10 at 14:39Note: I realize that this is close to being off-topic for being opinion-based, but I am hoping that there is some accepted best practice to handle this that I just don't know about.
My problem is the following: I need to design a Rest API for a program where users can create their own projects, and each project contains files that can only be seen by users that have access. I am stuck with how to design the "List all files of a project" query.
Standard Rest API practice would suggest two endpoints, like:
1`GET /projects` # List all projects
2`POST /projects` # Create new project
3`GET /projects/id` # Get specific project
4etc.
5
and the same for the files of a project.
However, there should never be a reason to list all files - only the files of a single project. To make it more complicated, access management needs to be a thing, users should never see files that are in projects they don't have access to.
I can see multiple ways to handle that:
So the obvious way is to implement the GET function, optionally with a filter. However, this isn't optimal, since if the user doesn't set a filter, it would have to crawl through all projects, check for each project whether the user has access, and then list all files the user has access to:
GET /files?project=test1
I could also make the files command a subcommand of the projects command - e.g.
GET /projects/#id/files
However, I have the feeling this isn't too restful, since it doesn't expose entities directly?
Is there any concencus on which should usually be implemented? Is it okay to "force" users to set a parameter in the first one? Or is there a third alternative that solves what I am looking for? Happy about any literature recommendations on how to design this as well.
ANSWER
Answered 2022-Feb-10 at 12:27After looking further, I came across this document from Microsoft. Some quotes:
Also consider the relationships between different types of resources and how you might expose these associations. For example, the /customers/5/orders might represent all of the orders for customer 5. You could also go in the other direction, and represent the association from an order back to a customer with a URI such as /orders/99/customer. However, extending this model too far can become cumbersome to implement. A better solution is to provide navigable links to associated resources in the body of the HTTP response message. This mechanism is described in more detail in the section Use HATEOAS to enable navigation to related resources.
In more complex systems, it can be tempting to provide URIs that enable a client to navigate through several levels of relationships, such as /customers/1/orders/99/products. However, this level of complexity can be difficult to maintain and is inflexible if the relationships between resources change in the future. Instead, try to keep URIs relatively simple. Once an application has a reference to a resource, it should be possible to use this reference to find items related to that resource. The preceding query can be replaced with the URI /customers/1/orders to find all the orders for customer 1, and then /orders/99/products to find the products in this order.
This makes me think that using solution 2 is probably the best case for me, since each file will be associated with only a single project, and should be deleted when a project is deleted. Files cannot exist on their own, outside of projects.
QUESTION
"Kafka Timed out waiting for a node assignment." on MSK
Asked 2022-Jan-17 at 05:00Specs:
- The serverless Amazon MSK that's in preview.
- t2.xlarge EC2 instance with Amazon Linux 2
- Installed Kafka from https://dlcdn.apache.org/kafka/3.0.0/kafka_2.13-3.0.0.tgz
- openjdk version "11.0.13" 2021-10-19 LTS
- OpenJDK Runtime Environment 18.9 (build 11.0.13+8-LTS)
- OpenJDK 64-Bit Server VM 18.9 (build 11.0.13+8-LTS, mixed mode, sharing)
- Gradle 7.3.3
- https://github.com/aws/aws-msk-iam-auth, successfully built.
I also tried adding IAM authentication information, as recommended by the Amazon MSK Library for AWS Identity and Access Management. It says to add the following in config/client.properties:
1# Sets up TLS for encryption and SASL for authN.
2security.protocol = SASL_SSL
3
4# Identifies the SASL mechanism to use.
5sasl.mechanism = AWS_MSK_IAM
6
7# Binds SASL client implementation.
8# sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required;
9
10# Encapsulates constructing a SigV4 signature based on extracted credentials.
11# The SASL client bound by "sasl.jaas.config" invokes this class.
12sasl.client.callback.handler.class = software.amazon.msk.auth.iam.IAMClientCallbackHandler
13
14# Binds SASL client implementation. Uses the specified profile name to look for credentials.
15sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required awsProfileName="kafka-client";
16
And kafka-client
is the IAM role attached to the EC2 instance as an instance profile.
Networking: I used VPC Reachability Analyzer to confirm that the security groups are configured correctly and the EC2 instance I'm using as a Producer can reach the serverless MSK cluster.
What I'm trying to do: create a topic.
How I'm trying: bin/kafka-topics.sh --create --partitions 1 --replication-factor 1 --topic quickstart-events --bootstrap-server boot-zclcyva3.c2.kafka-serverless.us-east-2.amazonaws.com:9098
Result:
1# Sets up TLS for encryption and SASL for authN.
2security.protocol = SASL_SSL
3
4# Identifies the SASL mechanism to use.
5sasl.mechanism = AWS_MSK_IAM
6
7# Binds SASL client implementation.
8# sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required;
9
10# Encapsulates constructing a SigV4 signature based on extracted credentials.
11# The SASL client bound by "sasl.jaas.config" invokes this class.
12sasl.client.callback.handler.class = software.amazon.msk.auth.iam.IAMClientCallbackHandler
13
14# Binds SASL client implementation. Uses the specified profile name to look for credentials.
15sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required awsProfileName="kafka-client";
16Error while executing topic command : Timed out waiting for a node assignment. Call: createTopics
17[2022-01-17 01:46:59,753] ERROR org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: createTopics
18 (kafka.admin.TopicCommand$)
19
I'm also trying: with the plaintext port of 9092. (9098 is the IAM-authentication port in MSK, and serverless MSK uses IAM authentication by default.)
All the other posts I found on SO about this node assignment error didn't include MSK. I tried suggestions like uncommenting the listener setting in server.properties, but that didn't change anything.
Installing kcat
for troubleshooting didn't work for me, since there's no out-of-the box installation for the yum package manager, which Amazon Linux 2 uses, and since these instructions failed for me at checking for libcurl (by compile)... failed (fail)
.
The Question: Any other tips on solving this "node assignment" error?
ANSWER
Answered 2022-Jan-17 at 05:00The created properties file is not automatically used; your command needs to include --command-config client.properties
, where this properties file is documented at the MSK docs on the linked IAM page.
Extract...
1# Sets up TLS for encryption and SASL for authN.
2security.protocol = SASL_SSL
3
4# Identifies the SASL mechanism to use.
5sasl.mechanism = AWS_MSK_IAM
6
7# Binds SASL client implementation.
8# sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required;
9
10# Encapsulates constructing a SigV4 signature based on extracted credentials.
11# The SASL client bound by "sasl.jaas.config" invokes this class.
12sasl.client.callback.handler.class = software.amazon.msk.auth.iam.IAMClientCallbackHandler
13
14# Binds SASL client implementation. Uses the specified profile name to look for credentials.
15sasl.jaas.config = software.amazon.msk.auth.iam.IAMLoginModule required awsProfileName="kafka-client";
16Error while executing topic command : Timed out waiting for a node assignment. Call: createTopics
17[2022-01-17 01:46:59,753] ERROR org.apache.kafka.common.errors.TimeoutException: Timed out waiting for a node assignment. Call: createTopics
18 (kafka.admin.TopicCommand$)
19ssl.truststore.location=<PATH_TO_TRUST_STORE_FILE>
20security.protocol=SASL_SSL
21sasl.mechanism=AWS_MSK_IAM
22sasl.jaas.config=software.amazon.msk.auth.iam.IAMLoginModule required;
23sasl.client.callback.handler.class=software.amazon.msk.auth.iam.IAMClientCallbackHandler
24
Alternatively, if the plaintext port didn't work, then you have other networking issues
Beyond these steps, I suggest reaching out to MSK support, and telling them to update the "Create a Topic" page to no longer use Zookeeper, keeping in mind that Kafka 3.0 is not (yet) supported
QUESTION
Django - Inline formset - How to set current user
Asked 2021-Nov-24 at 08:04-Objective- I need to set, in a Inline Formset, the current user as automatic content of a field of the form. (Currently not working)
Version Python 3.9.2 - Django 3.2
Context: I've created a List, where I have some objects(Headers). From the list I can create new headers and access to the detail-page(Detailview)for each of these by using a foreign-key(called by PK-primarykey).
In this page I can see more informations about 1 specific header. Each header can have multiple lines of informations that need to be linked to it. The lines are created or updated with (max 4 different) specific Inline Formsets.
-Issue and Error- I created the forms that are correctly rendered, but I need to set for each line, a field that automatically gets "current user" as its content. I can't save and receive instead"User cannot be null".
I'm unable to find a solutions and tried many things but stuck with this error.
Would kindly appreciate any help on how to solve this problem. Thanks in advance,
Below some code:
URLS.PY
1from django.urls import path, re_path
2from fttlapp import views
3
4app_name= 'fttlapps'
5
6urlpatterns = [
7path('fttlapphome2/', views.Fttlapphome2View.as_view(), name='fttlapphome2'),
8path('fttlogheader/', views.HeadfttlogListView.as_view(), name='headfttlogs'),
9path('fttlogheader/add/', views.HeadfttlogCreateView.as_view(), name='headfttlogcreate'),
10path('fttlogheader/<int:pk>/', views.HeadfttlogDetailView.as_view(), name='headfttlogdetail'),
11path('fttlogheader/<int:pk>/flights/edit/', views.HeadfttlogDeafttlogEditView.as_view(), name='head_flight_edit'),
12]
13
FORMS.PY
1from django.urls import path, re_path
2from fttlapp import views
3
4app_name= 'fttlapps'
5
6urlpatterns = [
7path('fttlapphome2/', views.Fttlapphome2View.as_view(), name='fttlapphome2'),
8path('fttlogheader/', views.HeadfttlogListView.as_view(), name='headfttlogs'),
9path('fttlogheader/add/', views.HeadfttlogCreateView.as_view(), name='headfttlogcreate'),
10path('fttlogheader/<int:pk>/', views.HeadfttlogDetailView.as_view(), name='headfttlogdetail'),
11path('fttlogheader/<int:pk>/flights/edit/', views.HeadfttlogDeafttlogEditView.as_view(), name='head_flight_edit'),
12]
13from django import forms
14from django.contrib.auth.models import User
15from django.db.models.fields import CharField, DateField
16from django.forms import ModelForm, widgets
17from django.forms.fields import ChoiceField
18from django.forms.models import ModelChoiceField
19from django.utils import timezone
20
21# Load necessary to manage Form in Form
22from django.forms.models import inlineformset_factory
23
24# Load Tables
25from fttlapp.models import Headfttlog, Deafttlog, Debfttlog
26###############################################################################
27# Forms for Headfttlog #
28###############################################################################
29
30
31class HeadfttlogcreateForm(ModelForm):
32 class Meta:
33 model = Headfttlog
34 exclude = ['hea_creator', 'hea_modifier']
35
36 widgets = {
37 'hea_fttldate' : forms.TextInput(attrs={'type': 'date'}),
38 'hea_nxtcheckdate' : forms.TextInput(attrs={'type': 'date'}),
39 'hea_transfereddate' : forms.TextInput(attrs={'type': 'date'}),
40 }
41 ## Calendar widget to work both with Create and Update needs to be TextInput with type date
42 ## Calendar widget not compatible with localized_fields !
43
44
45###############################################################################
46# Forms for Headfttlog with Deafttlog details view Management #
47###############################################################################
48HeadfttlogDeafttlogFormset = inlineformset_factory(Headfttlog, Deafttlog,
49 fields=('dea_linetype', 'dea_fttlcode', 'dea_airportfrom', 'dea_airportto',
50 'dea_instrtimestart', 'dea_instrtimeend', 'dea_instrtimetot',
51 'dea_blocktimestart', 'dea_blocktimeend', 'dea_blocktimetot',
52 'dea_flighttimestart', 'dea_flighttimeend', 'dea_flighttimetot',
53 'dea_approach', 'dea_landing', 'dea_external', 'dea_fuel', 'dea_oil',
54 'dea_lessonnotes', 'dea_preflightsignature', 'dea_invoiceaccount',
55 'dea_transfered', 'dea_transfereddate',
56 'dea_reccanceled', 'dea_creator', 'dea_modifier'),
57 widgets={
58 'dea_instrtimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
59 'dea_instrtimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
60 'dea_instrtimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
61 'dea_blocktimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
62 'dea_blocktimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
63 'dea_blocktimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
64 'dea_flighttimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
65 'dea_flighttimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
66 'dea_flighttimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
67 'dea_reccanceled' : forms.HiddenInput,
68 'dea_creator' : forms.HiddenInput,
69 'dea_modifier' : forms.HiddenInput,
70 }, extra=1, max_num=8)
71
72
73
VIEWS.PY
1from django.urls import path, re_path
2from fttlapp import views
3
4app_name= 'fttlapps'
5
6urlpatterns = [
7path('fttlapphome2/', views.Fttlapphome2View.as_view(), name='fttlapphome2'),
8path('fttlogheader/', views.HeadfttlogListView.as_view(), name='headfttlogs'),
9path('fttlogheader/add/', views.HeadfttlogCreateView.as_view(), name='headfttlogcreate'),
10path('fttlogheader/<int:pk>/', views.HeadfttlogDetailView.as_view(), name='headfttlogdetail'),
11path('fttlogheader/<int:pk>/flights/edit/', views.HeadfttlogDeafttlogEditView.as_view(), name='head_flight_edit'),
12]
13from django import forms
14from django.contrib.auth.models import User
15from django.db.models.fields import CharField, DateField
16from django.forms import ModelForm, widgets
17from django.forms.fields import ChoiceField
18from django.forms.models import ModelChoiceField
19from django.utils import timezone
20
21# Load necessary to manage Form in Form
22from django.forms.models import inlineformset_factory
23
24# Load Tables
25from fttlapp.models import Headfttlog, Deafttlog, Debfttlog
26###############################################################################
27# Forms for Headfttlog #
28###############################################################################
29
30
31class HeadfttlogcreateForm(ModelForm):
32 class Meta:
33 model = Headfttlog
34 exclude = ['hea_creator', 'hea_modifier']
35
36 widgets = {
37 'hea_fttldate' : forms.TextInput(attrs={'type': 'date'}),
38 'hea_nxtcheckdate' : forms.TextInput(attrs={'type': 'date'}),
39 'hea_transfereddate' : forms.TextInput(attrs={'type': 'date'}),
40 }
41 ## Calendar widget to work both with Create and Update needs to be TextInput with type date
42 ## Calendar widget not compatible with localized_fields !
43
44
45###############################################################################
46# Forms for Headfttlog with Deafttlog details view Management #
47###############################################################################
48HeadfttlogDeafttlogFormset = inlineformset_factory(Headfttlog, Deafttlog,
49 fields=('dea_linetype', 'dea_fttlcode', 'dea_airportfrom', 'dea_airportto',
50 'dea_instrtimestart', 'dea_instrtimeend', 'dea_instrtimetot',
51 'dea_blocktimestart', 'dea_blocktimeend', 'dea_blocktimetot',
52 'dea_flighttimestart', 'dea_flighttimeend', 'dea_flighttimetot',
53 'dea_approach', 'dea_landing', 'dea_external', 'dea_fuel', 'dea_oil',
54 'dea_lessonnotes', 'dea_preflightsignature', 'dea_invoiceaccount',
55 'dea_transfered', 'dea_transfereddate',
56 'dea_reccanceled', 'dea_creator', 'dea_modifier'),
57 widgets={
58 'dea_instrtimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
59 'dea_instrtimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
60 'dea_instrtimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
61 'dea_blocktimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
62 'dea_blocktimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
63 'dea_blocktimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
64 'dea_flighttimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
65 'dea_flighttimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
66 'dea_flighttimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
67 'dea_reccanceled' : forms.HiddenInput,
68 'dea_creator' : forms.HiddenInput,
69 'dea_modifier' : forms.HiddenInput,
70 }, extra=1, max_num=8)
71
72
73from django.shortcuts import render
74from django.http import HttpResponseRedirect
75from django.urls import reverse
76# Load necessary view
77from django.views.generic import (
78 TemplateView, ListView, CreateView, DetailView, FormView)
79from django.views.generic.detail import SingleObjectMixin
80# Load for security and access management
81from django.contrib.auth.decorators import login_required
82from django.contrib.auth.mixins import LoginRequiredMixin
83from django.contrib.auth.mixins import PermissionRequiredMixin
84# Load functions and tools for search bar management
85from fttlapp.filters import HeadfttlogFilter
86import operator
87from functools import partial, reduce
88from django.db.models import Q
89# Load functions for messages management
90from django.contrib import messages
91# Load Tables & Forms
92from fttlapp.models import Headfttlog
93from fttlapp.forms import HeadfttlogcreateForm
94from fttlapp.forms import HeadfttlogDeafttlogFormset
95
96
97###############################################################################
98# FTTL home page management #
99###############################################################################
100
101
102@login_required
103def fttlapphome(request):
104 context = {}
105 return render(request, 'fttlapp/fttlapphome.html', context)
106
107
108###############################################################################
109# FTTL home page 2 management #
110###############################################################################
111
112class Fttlapphome2View(TemplateView, LoginRequiredMixin):
113 template_name = 'fttlapp/fttlapphome2.html'
114
115###############################################################################
116# Headfttlog - List view Management #
117###############################################################################
118
119
120class HeadfttlogListView(ListView, LoginRequiredMixin, PermissionRequiredMixin):
121 permission_required = 'fttlapp.view_headfttlog'
122
123 model = Headfttlog
124 template_name = 'fttlapp/headfttlog_list.html'
125 paginate_by = 10
126
127 def get_context_data(self, *args, **kwargs):
128 context = super().get_context_data(*args, **kwargs)
129 context['myFilter'] = HeadfttlogFilter(
130 self.request.GET, queryset=self.get_queryset())
131 return context
132
133 # Following redefintion necessary to obtain correct pagination after Filter plugin
134 def get_queryset(self):
135 queryset = super().get_queryset()
136 return HeadfttlogFilter(self.request.GET, queryset=queryset).qs
137
138
139###############################################################################
140# Headfttlog - Create view Management Headfttlog #
141###############################################################################
142
143
144class HeadfttlogCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
145 permission_required = 'fttlapp.add_headfttlog'
146
147 model = Headfttlog
148 template_name = 'fttlapp/headfttlogcreate_form.html'
149 form_class = HeadfttlogcreateForm
150
151 def form_valid(self, form):
152 form.instance.hea_creator = self.request.user
153 form.instance.hea_modifier = self.request.user
154 messages.add_message(
155 self.request,
156 messages.SUCCESS,
157 'The LOG has been created'
158 )
159 return super().form_valid(form)
160
161
162###############################################################################
163# Headfttlog - Detail view Management Headfttlog #
164###############################################################################
165
166class HeadfttlogDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
167 permission_required = 'fttlapp.view_headfttlog'
168
169 model = Headfttlog
170 template_name = 'fttlapp/headfttlogdetail.html'
171
172
173###############################################################################
174# Headfttlog with Deafttlog details view Management #
175###############################################################################
176
177class HeadfttlogDeafttlogEditView(LoginRequiredMixin, PermissionRequiredMixin, SingleObjectMixin, FormView):
178 permission_required = ('fttlapp.add_headfttlog','fttlapp.change_headfttlog',
179 'fttlapp.add_deafttlog', 'fttlapp.change_deafttlog')
180
181 model = Headfttlog
182 template_name = 'fttlapp/head_flight_edit.html'
183
184 ### 1. Identification of the single Headfttlog we will work with
185 def get(self, request, *args, **kwargs):
186 self.object = self.get_object(queryset=Headfttlog.objects.all())
187 return super().get(request, *args, **kwargs)
188
189 def post(self, request, *args, **kwargs):
190 self.object = self.get_object(queryset=Headfttlog.objects.all())
191 return super().post(request, *args, **kwargs)
192
193 ### 2. FormSet creation - instance is the link to the above data.
194 def get_form(self, form_class=None):
195 return HeadfttlogDeafttlogFormset(**self.get_form_kwargs(), instance=self.object)
196
197 def formset_valid(self, form):
198 form.dea_creator = self.request.user
199 form.dea_modifier = self.request.user
200
201 form.save()
202
203 messages.add_message(
204 self.request,
205 messages.SUCCESS,
206 'Changes were saved.'
207 )
208
209 return HttpResponseRedirect(self.get_success_url())
210
211 def get_success_url(self):
212 return reverse('fttlapps:headfttlogdetail', kwargs={'pk': self.object.pk})
213
214
215
216###############################################################################
217# End of view Management #
218###############################################################################
219
HTML
1from django.urls import path, re_path
2from fttlapp import views
3
4app_name= 'fttlapps'
5
6urlpatterns = [
7path('fttlapphome2/', views.Fttlapphome2View.as_view(), name='fttlapphome2'),
8path('fttlogheader/', views.HeadfttlogListView.as_view(), name='headfttlogs'),
9path('fttlogheader/add/', views.HeadfttlogCreateView.as_view(), name='headfttlogcreate'),
10path('fttlogheader/<int:pk>/', views.HeadfttlogDetailView.as_view(), name='headfttlogdetail'),
11path('fttlogheader/<int:pk>/flights/edit/', views.HeadfttlogDeafttlogEditView.as_view(), name='head_flight_edit'),
12]
13from django import forms
14from django.contrib.auth.models import User
15from django.db.models.fields import CharField, DateField
16from django.forms import ModelForm, widgets
17from django.forms.fields import ChoiceField
18from django.forms.models import ModelChoiceField
19from django.utils import timezone
20
21# Load necessary to manage Form in Form
22from django.forms.models import inlineformset_factory
23
24# Load Tables
25from fttlapp.models import Headfttlog, Deafttlog, Debfttlog
26###############################################################################
27# Forms for Headfttlog #
28###############################################################################
29
30
31class HeadfttlogcreateForm(ModelForm):
32 class Meta:
33 model = Headfttlog
34 exclude = ['hea_creator', 'hea_modifier']
35
36 widgets = {
37 'hea_fttldate' : forms.TextInput(attrs={'type': 'date'}),
38 'hea_nxtcheckdate' : forms.TextInput(attrs={'type': 'date'}),
39 'hea_transfereddate' : forms.TextInput(attrs={'type': 'date'}),
40 }
41 ## Calendar widget to work both with Create and Update needs to be TextInput with type date
42 ## Calendar widget not compatible with localized_fields !
43
44
45###############################################################################
46# Forms for Headfttlog with Deafttlog details view Management #
47###############################################################################
48HeadfttlogDeafttlogFormset = inlineformset_factory(Headfttlog, Deafttlog,
49 fields=('dea_linetype', 'dea_fttlcode', 'dea_airportfrom', 'dea_airportto',
50 'dea_instrtimestart', 'dea_instrtimeend', 'dea_instrtimetot',
51 'dea_blocktimestart', 'dea_blocktimeend', 'dea_blocktimetot',
52 'dea_flighttimestart', 'dea_flighttimeend', 'dea_flighttimetot',
53 'dea_approach', 'dea_landing', 'dea_external', 'dea_fuel', 'dea_oil',
54 'dea_lessonnotes', 'dea_preflightsignature', 'dea_invoiceaccount',
55 'dea_transfered', 'dea_transfereddate',
56 'dea_reccanceled', 'dea_creator', 'dea_modifier'),
57 widgets={
58 'dea_instrtimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
59 'dea_instrtimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
60 'dea_instrtimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
61 'dea_blocktimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
62 'dea_blocktimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
63 'dea_blocktimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
64 'dea_flighttimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
65 'dea_flighttimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
66 'dea_flighttimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
67 'dea_reccanceled' : forms.HiddenInput,
68 'dea_creator' : forms.HiddenInput,
69 'dea_modifier' : forms.HiddenInput,
70 }, extra=1, max_num=8)
71
72
73from django.shortcuts import render
74from django.http import HttpResponseRedirect
75from django.urls import reverse
76# Load necessary view
77from django.views.generic import (
78 TemplateView, ListView, CreateView, DetailView, FormView)
79from django.views.generic.detail import SingleObjectMixin
80# Load for security and access management
81from django.contrib.auth.decorators import login_required
82from django.contrib.auth.mixins import LoginRequiredMixin
83from django.contrib.auth.mixins import PermissionRequiredMixin
84# Load functions and tools for search bar management
85from fttlapp.filters import HeadfttlogFilter
86import operator
87from functools import partial, reduce
88from django.db.models import Q
89# Load functions for messages management
90from django.contrib import messages
91# Load Tables & Forms
92from fttlapp.models import Headfttlog
93from fttlapp.forms import HeadfttlogcreateForm
94from fttlapp.forms import HeadfttlogDeafttlogFormset
95
96
97###############################################################################
98# FTTL home page management #
99###############################################################################
100
101
102@login_required
103def fttlapphome(request):
104 context = {}
105 return render(request, 'fttlapp/fttlapphome.html', context)
106
107
108###############################################################################
109# FTTL home page 2 management #
110###############################################################################
111
112class Fttlapphome2View(TemplateView, LoginRequiredMixin):
113 template_name = 'fttlapp/fttlapphome2.html'
114
115###############################################################################
116# Headfttlog - List view Management #
117###############################################################################
118
119
120class HeadfttlogListView(ListView, LoginRequiredMixin, PermissionRequiredMixin):
121 permission_required = 'fttlapp.view_headfttlog'
122
123 model = Headfttlog
124 template_name = 'fttlapp/headfttlog_list.html'
125 paginate_by = 10
126
127 def get_context_data(self, *args, **kwargs):
128 context = super().get_context_data(*args, **kwargs)
129 context['myFilter'] = HeadfttlogFilter(
130 self.request.GET, queryset=self.get_queryset())
131 return context
132
133 # Following redefintion necessary to obtain correct pagination after Filter plugin
134 def get_queryset(self):
135 queryset = super().get_queryset()
136 return HeadfttlogFilter(self.request.GET, queryset=queryset).qs
137
138
139###############################################################################
140# Headfttlog - Create view Management Headfttlog #
141###############################################################################
142
143
144class HeadfttlogCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
145 permission_required = 'fttlapp.add_headfttlog'
146
147 model = Headfttlog
148 template_name = 'fttlapp/headfttlogcreate_form.html'
149 form_class = HeadfttlogcreateForm
150
151 def form_valid(self, form):
152 form.instance.hea_creator = self.request.user
153 form.instance.hea_modifier = self.request.user
154 messages.add_message(
155 self.request,
156 messages.SUCCESS,
157 'The LOG has been created'
158 )
159 return super().form_valid(form)
160
161
162###############################################################################
163# Headfttlog - Detail view Management Headfttlog #
164###############################################################################
165
166class HeadfttlogDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
167 permission_required = 'fttlapp.view_headfttlog'
168
169 model = Headfttlog
170 template_name = 'fttlapp/headfttlogdetail.html'
171
172
173###############################################################################
174# Headfttlog with Deafttlog details view Management #
175###############################################################################
176
177class HeadfttlogDeafttlogEditView(LoginRequiredMixin, PermissionRequiredMixin, SingleObjectMixin, FormView):
178 permission_required = ('fttlapp.add_headfttlog','fttlapp.change_headfttlog',
179 'fttlapp.add_deafttlog', 'fttlapp.change_deafttlog')
180
181 model = Headfttlog
182 template_name = 'fttlapp/head_flight_edit.html'
183
184 ### 1. Identification of the single Headfttlog we will work with
185 def get(self, request, *args, **kwargs):
186 self.object = self.get_object(queryset=Headfttlog.objects.all())
187 return super().get(request, *args, **kwargs)
188
189 def post(self, request, *args, **kwargs):
190 self.object = self.get_object(queryset=Headfttlog.objects.all())
191 return super().post(request, *args, **kwargs)
192
193 ### 2. FormSet creation - instance is the link to the above data.
194 def get_form(self, form_class=None):
195 return HeadfttlogDeafttlogFormset(**self.get_form_kwargs(), instance=self.object)
196
197 def formset_valid(self, form):
198 form.dea_creator = self.request.user
199 form.dea_modifier = self.request.user
200
201 form.save()
202
203 messages.add_message(
204 self.request,
205 messages.SUCCESS,
206 'Changes were saved.'
207 )
208
209 return HttpResponseRedirect(self.get_success_url())
210
211 def get_success_url(self):
212 return reverse('fttlapps:headfttlogdetail', kwargs={'pk': self.object.pk})
213
214
215
216###############################################################################
217# End of view Management #
218###############################################################################
219
220{% extends 'base/dibase3.html' %}
221{% load static %}
222
223{% load crispy_forms_tags %}
224{% crispy formset %}
225
226{% block title %}Editing Flights and Instructions for {{ headfttlog.fttlcode }}{% endblock %}
227
228{% block content %}
229
230
231<style>
232
233 .box{
234 max-width: fit-content;
235 margin: auto;
236
237 }
238</style>
239
240</div>
241
242<nav class="navbar navbar-expand-lg navbar-light bg-light">
243 <div class="container-fluid">
244
245 <div class="text-start">
246 <a class="btn btn-outline-info " href="{% url 'fttlapps:headfttlogdetail' pk=headfttlog.pk %}">Back to Detail</a>
247
248 </div>
249
250 </div>
251 </nav>
252<hr>
253
254<div class="container">
255
256 <form action="" method="post" enctype="multipart/form-data">
257
258 {% for hidden_field in form.hidden_fields %}
259 {{ hidden_field.errors }}
260 {{ hidden_field }}
261 {% endfor %}
262
263 {% csrf_token %}
264
265 {{ form.management_form }}
266 {{ form.non_form_errors }}
267
268 <h3>Update Collection</h3>
269 {% for deafttlog_form in form.forms %}
270 <hr>
271 <h5>
272 {% if deafttlog_form.instance.id %}
273 Deafttlog: {{ deafttlog_form.instance.dea_linetype }}
274 {% else %}
275 {% if form.forms|length > 1 %}
276 Add another deafttlog
277 {% else %}
278 Add a deafttlog
279 {% endif %}
280 {% endif %}
281 </h5>
282 {% for hidden_field in deafttlog_form.hidden_fields %}
283 {{ hidden_field.errors }}
284 {% endfor %}
285 <table>
286 {{ deafttlog_form }}
287 </table>
288 {% endfor %}
289 <hr>
290 <p>
291 <button type="submit" value="Update Flight" class="btn btn-primary w-100 mb-3">Update Flight</button>
292 <a href="{{ author.get_absolute_url }}" role="button" class="btn btn-secondary w-100">Return</a>
293 </p>
294 </form>
295
296{% endblock content %}
297
298
ANSWER
Answered 2021-Nov-24 at 08:04For audit fields like creator
and modifier
model fields I will usually set blank=True, null=True
in the model field definition. Just by doing that your code will work, because you are already handling setting of dea_creator
and dea_modifier
in your views.
If you want to enforce this in the database like you are doing now, you will have to pass the request.user
to your formset and set it as the initial value for the dea_creator
field when initializing the forms.
Edit:
The alternative way I mentioned above, in your HeadfttlogDeafttlogFormset
, instead of setting fields
and widgets
, create an actual form to use, for example DeafttlogForm
, and set the fields
and widgets
there. Then in your formset, you set form=DeafttlogForm
.
In the newly created DeafttlogForm
, initialize the dea_creator
field:
1from django.urls import path, re_path
2from fttlapp import views
3
4app_name= 'fttlapps'
5
6urlpatterns = [
7path('fttlapphome2/', views.Fttlapphome2View.as_view(), name='fttlapphome2'),
8path('fttlogheader/', views.HeadfttlogListView.as_view(), name='headfttlogs'),
9path('fttlogheader/add/', views.HeadfttlogCreateView.as_view(), name='headfttlogcreate'),
10path('fttlogheader/<int:pk>/', views.HeadfttlogDetailView.as_view(), name='headfttlogdetail'),
11path('fttlogheader/<int:pk>/flights/edit/', views.HeadfttlogDeafttlogEditView.as_view(), name='head_flight_edit'),
12]
13from django import forms
14from django.contrib.auth.models import User
15from django.db.models.fields import CharField, DateField
16from django.forms import ModelForm, widgets
17from django.forms.fields import ChoiceField
18from django.forms.models import ModelChoiceField
19from django.utils import timezone
20
21# Load necessary to manage Form in Form
22from django.forms.models import inlineformset_factory
23
24# Load Tables
25from fttlapp.models import Headfttlog, Deafttlog, Debfttlog
26###############################################################################
27# Forms for Headfttlog #
28###############################################################################
29
30
31class HeadfttlogcreateForm(ModelForm):
32 class Meta:
33 model = Headfttlog
34 exclude = ['hea_creator', 'hea_modifier']
35
36 widgets = {
37 'hea_fttldate' : forms.TextInput(attrs={'type': 'date'}),
38 'hea_nxtcheckdate' : forms.TextInput(attrs={'type': 'date'}),
39 'hea_transfereddate' : forms.TextInput(attrs={'type': 'date'}),
40 }
41 ## Calendar widget to work both with Create and Update needs to be TextInput with type date
42 ## Calendar widget not compatible with localized_fields !
43
44
45###############################################################################
46# Forms for Headfttlog with Deafttlog details view Management #
47###############################################################################
48HeadfttlogDeafttlogFormset = inlineformset_factory(Headfttlog, Deafttlog,
49 fields=('dea_linetype', 'dea_fttlcode', 'dea_airportfrom', 'dea_airportto',
50 'dea_instrtimestart', 'dea_instrtimeend', 'dea_instrtimetot',
51 'dea_blocktimestart', 'dea_blocktimeend', 'dea_blocktimetot',
52 'dea_flighttimestart', 'dea_flighttimeend', 'dea_flighttimetot',
53 'dea_approach', 'dea_landing', 'dea_external', 'dea_fuel', 'dea_oil',
54 'dea_lessonnotes', 'dea_preflightsignature', 'dea_invoiceaccount',
55 'dea_transfered', 'dea_transfereddate',
56 'dea_reccanceled', 'dea_creator', 'dea_modifier'),
57 widgets={
58 'dea_instrtimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
59 'dea_instrtimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
60 'dea_instrtimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
61 'dea_blocktimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
62 'dea_blocktimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
63 'dea_blocktimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
64 'dea_flighttimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
65 'dea_flighttimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
66 'dea_flighttimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
67 'dea_reccanceled' : forms.HiddenInput,
68 'dea_creator' : forms.HiddenInput,
69 'dea_modifier' : forms.HiddenInput,
70 }, extra=1, max_num=8)
71
72
73from django.shortcuts import render
74from django.http import HttpResponseRedirect
75from django.urls import reverse
76# Load necessary view
77from django.views.generic import (
78 TemplateView, ListView, CreateView, DetailView, FormView)
79from django.views.generic.detail import SingleObjectMixin
80# Load for security and access management
81from django.contrib.auth.decorators import login_required
82from django.contrib.auth.mixins import LoginRequiredMixin
83from django.contrib.auth.mixins import PermissionRequiredMixin
84# Load functions and tools for search bar management
85from fttlapp.filters import HeadfttlogFilter
86import operator
87from functools import partial, reduce
88from django.db.models import Q
89# Load functions for messages management
90from django.contrib import messages
91# Load Tables & Forms
92from fttlapp.models import Headfttlog
93from fttlapp.forms import HeadfttlogcreateForm
94from fttlapp.forms import HeadfttlogDeafttlogFormset
95
96
97###############################################################################
98# FTTL home page management #
99###############################################################################
100
101
102@login_required
103def fttlapphome(request):
104 context = {}
105 return render(request, 'fttlapp/fttlapphome.html', context)
106
107
108###############################################################################
109# FTTL home page 2 management #
110###############################################################################
111
112class Fttlapphome2View(TemplateView, LoginRequiredMixin):
113 template_name = 'fttlapp/fttlapphome2.html'
114
115###############################################################################
116# Headfttlog - List view Management #
117###############################################################################
118
119
120class HeadfttlogListView(ListView, LoginRequiredMixin, PermissionRequiredMixin):
121 permission_required = 'fttlapp.view_headfttlog'
122
123 model = Headfttlog
124 template_name = 'fttlapp/headfttlog_list.html'
125 paginate_by = 10
126
127 def get_context_data(self, *args, **kwargs):
128 context = super().get_context_data(*args, **kwargs)
129 context['myFilter'] = HeadfttlogFilter(
130 self.request.GET, queryset=self.get_queryset())
131 return context
132
133 # Following redefintion necessary to obtain correct pagination after Filter plugin
134 def get_queryset(self):
135 queryset = super().get_queryset()
136 return HeadfttlogFilter(self.request.GET, queryset=queryset).qs
137
138
139###############################################################################
140# Headfttlog - Create view Management Headfttlog #
141###############################################################################
142
143
144class HeadfttlogCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
145 permission_required = 'fttlapp.add_headfttlog'
146
147 model = Headfttlog
148 template_name = 'fttlapp/headfttlogcreate_form.html'
149 form_class = HeadfttlogcreateForm
150
151 def form_valid(self, form):
152 form.instance.hea_creator = self.request.user
153 form.instance.hea_modifier = self.request.user
154 messages.add_message(
155 self.request,
156 messages.SUCCESS,
157 'The LOG has been created'
158 )
159 return super().form_valid(form)
160
161
162###############################################################################
163# Headfttlog - Detail view Management Headfttlog #
164###############################################################################
165
166class HeadfttlogDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
167 permission_required = 'fttlapp.view_headfttlog'
168
169 model = Headfttlog
170 template_name = 'fttlapp/headfttlogdetail.html'
171
172
173###############################################################################
174# Headfttlog with Deafttlog details view Management #
175###############################################################################
176
177class HeadfttlogDeafttlogEditView(LoginRequiredMixin, PermissionRequiredMixin, SingleObjectMixin, FormView):
178 permission_required = ('fttlapp.add_headfttlog','fttlapp.change_headfttlog',
179 'fttlapp.add_deafttlog', 'fttlapp.change_deafttlog')
180
181 model = Headfttlog
182 template_name = 'fttlapp/head_flight_edit.html'
183
184 ### 1. Identification of the single Headfttlog we will work with
185 def get(self, request, *args, **kwargs):
186 self.object = self.get_object(queryset=Headfttlog.objects.all())
187 return super().get(request, *args, **kwargs)
188
189 def post(self, request, *args, **kwargs):
190 self.object = self.get_object(queryset=Headfttlog.objects.all())
191 return super().post(request, *args, **kwargs)
192
193 ### 2. FormSet creation - instance is the link to the above data.
194 def get_form(self, form_class=None):
195 return HeadfttlogDeafttlogFormset(**self.get_form_kwargs(), instance=self.object)
196
197 def formset_valid(self, form):
198 form.dea_creator = self.request.user
199 form.dea_modifier = self.request.user
200
201 form.save()
202
203 messages.add_message(
204 self.request,
205 messages.SUCCESS,
206 'Changes were saved.'
207 )
208
209 return HttpResponseRedirect(self.get_success_url())
210
211 def get_success_url(self):
212 return reverse('fttlapps:headfttlogdetail', kwargs={'pk': self.object.pk})
213
214
215
216###############################################################################
217# End of view Management #
218###############################################################################
219
220{% extends 'base/dibase3.html' %}
221{% load static %}
222
223{% load crispy_forms_tags %}
224{% crispy formset %}
225
226{% block title %}Editing Flights and Instructions for {{ headfttlog.fttlcode }}{% endblock %}
227
228{% block content %}
229
230
231<style>
232
233 .box{
234 max-width: fit-content;
235 margin: auto;
236
237 }
238</style>
239
240</div>
241
242<nav class="navbar navbar-expand-lg navbar-light bg-light">
243 <div class="container-fluid">
244
245 <div class="text-start">
246 <a class="btn btn-outline-info " href="{% url 'fttlapps:headfttlogdetail' pk=headfttlog.pk %}">Back to Detail</a>
247
248 </div>
249
250 </div>
251 </nav>
252<hr>
253
254<div class="container">
255
256 <form action="" method="post" enctype="multipart/form-data">
257
258 {% for hidden_field in form.hidden_fields %}
259 {{ hidden_field.errors }}
260 {{ hidden_field }}
261 {% endfor %}
262
263 {% csrf_token %}
264
265 {{ form.management_form }}
266 {{ form.non_form_errors }}
267
268 <h3>Update Collection</h3>
269 {% for deafttlog_form in form.forms %}
270 <hr>
271 <h5>
272 {% if deafttlog_form.instance.id %}
273 Deafttlog: {{ deafttlog_form.instance.dea_linetype }}
274 {% else %}
275 {% if form.forms|length > 1 %}
276 Add another deafttlog
277 {% else %}
278 Add a deafttlog
279 {% endif %}
280 {% endif %}
281 </h5>
282 {% for hidden_field in deafttlog_form.hidden_fields %}
283 {{ hidden_field.errors }}
284 {% endfor %}
285 <table>
286 {{ deafttlog_form }}
287 </table>
288 {% endfor %}
289 <hr>
290 <p>
291 <button type="submit" value="Update Flight" class="btn btn-primary w-100 mb-3">Update Flight</button>
292 <a href="{{ author.get_absolute_url }}" role="button" class="btn btn-secondary w-100">Return</a>
293 </p>
294 </form>
295
296{% endblock content %}
297
298def __init__(self, *args, **kwargs):
299 user = kwargs.pop('user', None)
300 super(DeafttlogForm, self).__init__(*args, **kwargs)
301 instance = getattr(self, 'instance', None)
302 if not instance.id and user:
303 self.initial['dea_creator'] = user
304
Then in HeadfttlogDeafttlogEditView
, add a get_form_kwargs
method:
1from django.urls import path, re_path
2from fttlapp import views
3
4app_name= 'fttlapps'
5
6urlpatterns = [
7path('fttlapphome2/', views.Fttlapphome2View.as_view(), name='fttlapphome2'),
8path('fttlogheader/', views.HeadfttlogListView.as_view(), name='headfttlogs'),
9path('fttlogheader/add/', views.HeadfttlogCreateView.as_view(), name='headfttlogcreate'),
10path('fttlogheader/<int:pk>/', views.HeadfttlogDetailView.as_view(), name='headfttlogdetail'),
11path('fttlogheader/<int:pk>/flights/edit/', views.HeadfttlogDeafttlogEditView.as_view(), name='head_flight_edit'),
12]
13from django import forms
14from django.contrib.auth.models import User
15from django.db.models.fields import CharField, DateField
16from django.forms import ModelForm, widgets
17from django.forms.fields import ChoiceField
18from django.forms.models import ModelChoiceField
19from django.utils import timezone
20
21# Load necessary to manage Form in Form
22from django.forms.models import inlineformset_factory
23
24# Load Tables
25from fttlapp.models import Headfttlog, Deafttlog, Debfttlog
26###############################################################################
27# Forms for Headfttlog #
28###############################################################################
29
30
31class HeadfttlogcreateForm(ModelForm):
32 class Meta:
33 model = Headfttlog
34 exclude = ['hea_creator', 'hea_modifier']
35
36 widgets = {
37 'hea_fttldate' : forms.TextInput(attrs={'type': 'date'}),
38 'hea_nxtcheckdate' : forms.TextInput(attrs={'type': 'date'}),
39 'hea_transfereddate' : forms.TextInput(attrs={'type': 'date'}),
40 }
41 ## Calendar widget to work both with Create and Update needs to be TextInput with type date
42 ## Calendar widget not compatible with localized_fields !
43
44
45###############################################################################
46# Forms for Headfttlog with Deafttlog details view Management #
47###############################################################################
48HeadfttlogDeafttlogFormset = inlineformset_factory(Headfttlog, Deafttlog,
49 fields=('dea_linetype', 'dea_fttlcode', 'dea_airportfrom', 'dea_airportto',
50 'dea_instrtimestart', 'dea_instrtimeend', 'dea_instrtimetot',
51 'dea_blocktimestart', 'dea_blocktimeend', 'dea_blocktimetot',
52 'dea_flighttimestart', 'dea_flighttimeend', 'dea_flighttimetot',
53 'dea_approach', 'dea_landing', 'dea_external', 'dea_fuel', 'dea_oil',
54 'dea_lessonnotes', 'dea_preflightsignature', 'dea_invoiceaccount',
55 'dea_transfered', 'dea_transfereddate',
56 'dea_reccanceled', 'dea_creator', 'dea_modifier'),
57 widgets={
58 'dea_instrtimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
59 'dea_instrtimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
60 'dea_instrtimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
61 'dea_blocktimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
62 'dea_blocktimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
63 'dea_blocktimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
64 'dea_flighttimestart' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
65 'dea_flighttimeend' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
66 'dea_flighttimetot' : forms.TimeInput(format= '%H:%M', attrs={'type': 'time'}),
67 'dea_reccanceled' : forms.HiddenInput,
68 'dea_creator' : forms.HiddenInput,
69 'dea_modifier' : forms.HiddenInput,
70 }, extra=1, max_num=8)
71
72
73from django.shortcuts import render
74from django.http import HttpResponseRedirect
75from django.urls import reverse
76# Load necessary view
77from django.views.generic import (
78 TemplateView, ListView, CreateView, DetailView, FormView)
79from django.views.generic.detail import SingleObjectMixin
80# Load for security and access management
81from django.contrib.auth.decorators import login_required
82from django.contrib.auth.mixins import LoginRequiredMixin
83from django.contrib.auth.mixins import PermissionRequiredMixin
84# Load functions and tools for search bar management
85from fttlapp.filters import HeadfttlogFilter
86import operator
87from functools import partial, reduce
88from django.db.models import Q
89# Load functions for messages management
90from django.contrib import messages
91# Load Tables & Forms
92from fttlapp.models import Headfttlog
93from fttlapp.forms import HeadfttlogcreateForm
94from fttlapp.forms import HeadfttlogDeafttlogFormset
95
96
97###############################################################################
98# FTTL home page management #
99###############################################################################
100
101
102@login_required
103def fttlapphome(request):
104 context = {}
105 return render(request, 'fttlapp/fttlapphome.html', context)
106
107
108###############################################################################
109# FTTL home page 2 management #
110###############################################################################
111
112class Fttlapphome2View(TemplateView, LoginRequiredMixin):
113 template_name = 'fttlapp/fttlapphome2.html'
114
115###############################################################################
116# Headfttlog - List view Management #
117###############################################################################
118
119
120class HeadfttlogListView(ListView, LoginRequiredMixin, PermissionRequiredMixin):
121 permission_required = 'fttlapp.view_headfttlog'
122
123 model = Headfttlog
124 template_name = 'fttlapp/headfttlog_list.html'
125 paginate_by = 10
126
127 def get_context_data(self, *args, **kwargs):
128 context = super().get_context_data(*args, **kwargs)
129 context['myFilter'] = HeadfttlogFilter(
130 self.request.GET, queryset=self.get_queryset())
131 return context
132
133 # Following redefintion necessary to obtain correct pagination after Filter plugin
134 def get_queryset(self):
135 queryset = super().get_queryset()
136 return HeadfttlogFilter(self.request.GET, queryset=queryset).qs
137
138
139###############################################################################
140# Headfttlog - Create view Management Headfttlog #
141###############################################################################
142
143
144class HeadfttlogCreateView(LoginRequiredMixin, PermissionRequiredMixin, CreateView):
145 permission_required = 'fttlapp.add_headfttlog'
146
147 model = Headfttlog
148 template_name = 'fttlapp/headfttlogcreate_form.html'
149 form_class = HeadfttlogcreateForm
150
151 def form_valid(self, form):
152 form.instance.hea_creator = self.request.user
153 form.instance.hea_modifier = self.request.user
154 messages.add_message(
155 self.request,
156 messages.SUCCESS,
157 'The LOG has been created'
158 )
159 return super().form_valid(form)
160
161
162###############################################################################
163# Headfttlog - Detail view Management Headfttlog #
164###############################################################################
165
166class HeadfttlogDetailView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
167 permission_required = 'fttlapp.view_headfttlog'
168
169 model = Headfttlog
170 template_name = 'fttlapp/headfttlogdetail.html'
171
172
173###############################################################################
174# Headfttlog with Deafttlog details view Management #
175###############################################################################
176
177class HeadfttlogDeafttlogEditView(LoginRequiredMixin, PermissionRequiredMixin, SingleObjectMixin, FormView):
178 permission_required = ('fttlapp.add_headfttlog','fttlapp.change_headfttlog',
179 'fttlapp.add_deafttlog', 'fttlapp.change_deafttlog')
180
181 model = Headfttlog
182 template_name = 'fttlapp/head_flight_edit.html'
183
184 ### 1. Identification of the single Headfttlog we will work with
185 def get(self, request, *args, **kwargs):
186 self.object = self.get_object(queryset=Headfttlog.objects.all())
187 return super().get(request, *args, **kwargs)
188
189 def post(self, request, *args, **kwargs):
190 self.object = self.get_object(queryset=Headfttlog.objects.all())
191 return super().post(request, *args, **kwargs)
192
193 ### 2. FormSet creation - instance is the link to the above data.
194 def get_form(self, form_class=None):
195 return HeadfttlogDeafttlogFormset(**self.get_form_kwargs(), instance=self.object)
196
197 def formset_valid(self, form):
198 form.dea_creator = self.request.user
199 form.dea_modifier = self.request.user
200
201 form.save()
202
203 messages.add_message(
204 self.request,
205 messages.SUCCESS,
206 'Changes were saved.'
207 )
208
209 return HttpResponseRedirect(self.get_success_url())
210
211 def get_success_url(self):
212 return reverse('fttlapps:headfttlogdetail', kwargs={'pk': self.object.pk})
213
214
215
216###############################################################################
217# End of view Management #
218###############################################################################
219
220{% extends 'base/dibase3.html' %}
221{% load static %}
222
223{% load crispy_forms_tags %}
224{% crispy formset %}
225
226{% block title %}Editing Flights and Instructions for {{ headfttlog.fttlcode }}{% endblock %}
227
228{% block content %}
229
230
231<style>
232
233 .box{
234 max-width: fit-content;
235 margin: auto;
236
237 }
238</style>
239
240</div>
241
242<nav class="navbar navbar-expand-lg navbar-light bg-light">
243 <div class="container-fluid">
244
245 <div class="text-start">
246 <a class="btn btn-outline-info " href="{% url 'fttlapps:headfttlogdetail' pk=headfttlog.pk %}">Back to Detail</a>
247
248 </div>
249
250 </div>
251 </nav>
252<hr>
253
254<div class="container">
255
256 <form action="" method="post" enctype="multipart/form-data">
257
258 {% for hidden_field in form.hidden_fields %}
259 {{ hidden_field.errors }}
260 {{ hidden_field }}
261 {% endfor %}
262
263 {% csrf_token %}
264
265 {{ form.management_form }}
266 {{ form.non_form_errors }}
267
268 <h3>Update Collection</h3>
269 {% for deafttlog_form in form.forms %}
270 <hr>
271 <h5>
272 {% if deafttlog_form.instance.id %}
273 Deafttlog: {{ deafttlog_form.instance.dea_linetype }}
274 {% else %}
275 {% if form.forms|length > 1 %}
276 Add another deafttlog
277 {% else %}
278 Add a deafttlog
279 {% endif %}
280 {% endif %}
281 </h5>
282 {% for hidden_field in deafttlog_form.hidden_fields %}
283 {{ hidden_field.errors }}
284 {% endfor %}
285 <table>
286 {{ deafttlog_form }}
287 </table>
288 {% endfor %}
289 <hr>
290 <p>
291 <button type="submit" value="Update Flight" class="btn btn-primary w-100 mb-3">Update Flight</button>
292 <a href="{{ author.get_absolute_url }}" role="button" class="btn btn-secondary w-100">Return</a>
293 </p>
294 </form>
295
296{% endblock content %}
297
298def __init__(self, *args, **kwargs):
299 user = kwargs.pop('user', None)
300 super(DeafttlogForm, self).__init__(*args, **kwargs)
301 instance = getattr(self, 'instance', None)
302 if not instance.id and user:
303 self.initial['dea_creator'] = user
304def get_form_kwargs(self):
305 kwargs = super(HeadfttlogDeafttlogEditView, self).get_form_kwargs()
306 kwargs['user'] = self.request.user
307 return kwargs
308
QUESTION
SailPoint IdentityIQ 8.2 - Return a list of users who have any entitlement(group) in a predetermined list of entitlements
Asked 2021-Nov-22 at 16:24I'm working in an environment where IdentityIQ 8.2 is deployed for access management.
I am attempting to return a list of users, based on if they have any one of the entitlements in the provided "whitelist". (i.e. "Show me any user who has entitlement1 or entitlement2 or entitlement3")
I tried to use the Advanced Analytics search function. This does allow you to search for identities based on entitlement, but it function in an "Exclusive AND" logic style where only users who have every single entitlement on your "whitelist" will be returned. I haven't found a way to change this. The Advanced Search type doesn't support searching by entitlement, from what I can tell.
Is there an out of the box way to accomplish this?
ANSWER
Answered 2021-Nov-22 at 16:24You can create the entitlement search with AND and save the result as a Population. You can then change operation="AND" to operation="OR" using the Debug pages.
Example how to search for users who have either of these two AD group memberships (this is a Population saved from Advanced Analytics):
1<GroupDefinition indexed="true" name="x" private="true">
2 <GroupFilter>
3 <CompositeFilter operation="AND">
4 <Filter operation="COLLECTION_CONDITION" property="identityEntitlements">
5 <CollectionCondition>
6 <CompositeFilter operation="OR">
7 <CompositeFilter operation="AND">
8 <Filter operation="EQ" property="application.name" value="AD"/>
9 <Filter operation="EQ" property="name" value="memberOf"/>
10 <Filter operation="EQ" property="value" value="{e4ca3ebf-543e-4f19-aa6d-60ebee9968a7}"/>
11 </CompositeFilter>
12 <CompositeFilter operation="AND">
13 <Filter operation="EQ" property="application.name" value="AD"/>
14 <Filter operation="EQ" property="name" value="memberOf"/>
15 <Filter operation="EQ" property="value" value="{b263fcce-26e5-4fc8-9ed3-012df6b4c262}"/>
16 </CompositeFilter>
17 </CompositeFilter>
18 </CollectionCondition>
19 </Filter>
20 </CompositeFilter>
21 </GroupFilter>
22 <Owner>
23 <Reference class="sailpoint.object.Identity" name="spadmin"/>
24 </Owner>
25</GroupDefinition>
26
QUESTION
How to change my css to make hyper link visible [ with minimum sample code ]?
Asked 2021-Oct-12 at 15:34I have a site with CSS, but the hyper links are not visible [ right side ], how to change my html/css so that the hyper links are visible [ like the left side on the follow image ] ?
I've simplified my site to show the problem and here is the minimum sample code :
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>GATE Cyber Technology : Award Winning Innovation For Identity And Access Management</title>
7 <meta name="description" content="GATE Cyber Technology LLC. INTERCEPTION-RESISTANT AUTHENTICATION AND ENCRYPTION SYSTEM AND METHOD. Introducing a breakthrough digital security innovation : Graphic Access Tabular Entry [ GATE ], an interception-resistant authentication and encryption system and method. With the GATE system you are not afraid that you are watched when you enter passwords, and you are not afraid that the password will be intercepted, the GATE innovative method is designed to be peek-resistant and interception-resistant. The GATE system and method will offer you better digital security. Identity and Access Management (IAM)">
8 <meta name="keywords" content="GATE Cyber Technology LLC. INTERCEPTION-resistant AUTHENTICATION AND ENCRYPTION SYSTEM AND METHOD, Graphic Access Tabular Entry [ GATE ], GATE security, GATE authentication, GATE login, GATE user authentication, GATE password, GATE passcode, peek-resistant, online security, digital security, passwords, password protection, strong password, strong cybersecurity, strong user authentication, prevent password loss, prevent user credential loss, passcode, cyber security, pin, login, logon, digital access, online access, access control, online protection, digital protection, online defence, digital defence, message encryption, message decryption, signal encryption, signal decryption, overcome weakness of traditional password, the GATE system, award winning, better than fingerprinting, better than iris scanning, safer than keyfob, better than password manager, safer password entry, Identity and Access Management (IAM), GATE defeats wiretapping, keylogging, peeking, phishing and dictionary attack, no restrictions of traditional password's lowercase, uppercase, numbers and special characters requirements, easy to use">
9 <meta name="google-site-verification" content="cXY5hsdt7XCjR_k96nha7Hn5uW4fw_1u6mc2LWDyAQ0" />
10 <link rel="shortcut icon" href="favicon.ico">
11
12 <link media="all" type="text/css" rel="stylesheet" href="https://cdn.ahrefs.com/assets/css/bootstrap.min.css">
13 <link media="all" type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,300,100italic,100,300italic,400italic,700,700italic,900,900italic">
14 <link media="screen" type="text/css" rel="stylesheet" href="https://cdn.ahrefs.com/assets/css/home-responsive.css?20180815-001">
15
16 <link media="all" type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
17 <link media="all" type="text/css" rel="stylesheet" href="css/css.css">
18 <link media="screen" type="text/css" rel="stylesheet" href="css/home-responsive.css">
19
20 <meta property="og:image" content="GATE_1.PNG">
21
22 <style>
23 div.Intro
24 {
25 font-size: 100%;
26 text-align: left;
27 }
28
29 div.Table
30 {
31 font-size: 218%;
32 text-align: center;
33 }
34
35 a:hover { color:#ddeeff; }
36 a:visited { color:#E8E8E8 }
37
38 tr a{ font-size: 18px;color:#aabbcc; }
39 tr a:hover { color:#ddeeff; }
40
41 .pic-container-1{display:block; position:relative; }
42 .pic-container-1 .pic-box{display:block;}
43 .pic-container-1 .pic-box img{display:block;}
44 .pic-container-1 .pic-hover{position:absolute; top:0px; left:104px; display:none;}
45 .pic-container-1:hover .pic-hover{display:block;}
46
47 .pic-container-2{display:block; position:relative; }
48 .pic-container-2 .pic-box{display:block;}
49 .pic-container-2 .pic-box img{display:block;}
50 .pic-container-2 .pic-hover{position:absolute; top:0px; left:18px; display:none;}
51 .pic-container-2:hover .pic-hover{display:block;}
52
53 .pic-container-3{display:block; position:relative; }
54 .pic-container-3 .pic-box{display:block;}
55 .pic-container-3 .pic-box img{display:block;}
56 .pic-container-3 .pic-hover{position:absolute; top:0px; left:20px; display:none;}
57 .pic-container-3:hover .pic-hover{display:block;}
58
59 .pic-container-4{display:block; position:relative; }
60 .pic-container-4 .pic-box{display:block;}
61 .pic-container-4 .pic-box img{display:block;}
62 .pic-container-4 .pic-hover{position:absolute; top:0px; left:18px; display:none;}
63 .pic-container-4:hover .pic-hover{display:block;}
64
65 #GATE_Frame_1 { width: 78%; height: auto; }
66 #GATE_Frame_2 { width: 98%; height: auto; }
67
68 #Balance { width: 80%; height: auto; }
69
70 #Ted_Murphree_img { width: 36vw; height: auto; }
71 #Scott_Schober_img { width: 36vw; height: auto; }
72 #Cary_Pool_img { width: 36vw; height: auto; }
73 #Eduard_B_img { width: 36vw; height: auto; }
74 #Jonathan_Rosenoer_img { width: 36vw; height: auto; }
75
76 #Traditional_vs_GATE_1 { width: 96%; height: auto; }
77 #Traditional_vs_GATE_2 { width: 99.5%; height: auto; }
78
79 #modal
80 {
81 display: none;
82 position: fixed;
83 width: 100vw;
84 height: 100vh;
85 max-height: 100vh;
86 top: 0;
87 left: 0;
88 background: rgba(24, 24, 24, .6);
89 z-index: 999;
90 }
91 #modal .content
92 {
93 position: relative;
94 width: 55%;
95 height: 65vh;
96 margin: auto; /* allows horyzontal and vertical alignment as .content is in flex container */
97 }
98 #modal .content .yt-video
99 {
100 display: block;
101 width: 100%;
102 height: calc(100% - 45px);
103 }
104 #modal .content .title
105 {
106 box-sizing: border-box;
107 height: 45px;
108 line-height: 23px;
109 padding: 12px 4px;
110 margin: 0;
111 background: #007bff;
112 color: #fff;
113 text-align: center;
114 font-size: 26px;
115 max-width: 100%;
116 white-space: nowrap;
117 overflow: hidden;
118 text-overflow: ellipsis;
119 }
120 #modal .close
121 {
122 position: absolute;
123 top: 0;
124 right: 0;
125 width: 45px;
126 height: 45px;
127 line-height: 36px;
128 text-align: center;
129 border: 0;
130 font-weight: bold;
131 font-size: 38px;
132 color: #fff;
133 background: #366;
134 cursor: pointer;
135 transition: background .2s;
136 }
137 #modal .content .close .a { font-size:38px;color: #ffffff; }
138 #modal .close:hover, #modal .close:active { background: #ff0000; }
139 #modal.is-visible { display: flex; }
140
141 html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li,
142 fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
143 {
144 margin: 0;
145 padding: 0;
146 border: 0;
147 font-size: 100%;
148 font: inherit;
149 vertical-align: middle;
150 }
151
152 /* HTML5 display-role reset for older browsers */
153 article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
154 body { line-height: 1; }
155 // ol, ul { list-style: none; }
156 blockquote, q { quotes: none; }
157 blockquote:before, blockquote:after,
158 q:before, q:after
159 {
160 content: '';
161 content: none;
162 }
163 table
164 {
165 border-collapse: collapse;
166 border-spacing: 0;
167 }
168 </style>
169 </head>
170
171 <body class="page__guest ahrefs page-home">
172 <div id="localizejs">
173 <div class="content">
174 <a id="Awards"></a>
175 <div class="datas">
176 <div class="container center">
177 <Table Cellpadding=6>
178 <Tr>
179 <Td Align=Center><Br>
180 <Font Color=white><A Href=http://bestech.ittn.com.cn/#/projectlist2021 target=_blank>GATE has been selected</A> to the <A Href="2021_ZGC_Top_100_List_1.PNG" target=_blank>top 100</A>,<Br> among more than 2800 technologies collected<Br> from all over the world at 2021 ZGC<Br><A Href=http://bestech.ittn.com.cn/#/home target=_blank>International Technology Trade Conference</A>.</Font>
181 </Td>
182 </Tr>
183 </Table>
184 </div>
185 </div>
186
187 <!-- the modal div that will open when an anchor link is clicked to show the related video in an iframe. -->
188
189 <div id="modal">
190 <div class="content">
191 <div class="close"><a onclick = "return close_iFrame();">&times;</a></div>
192 <h4 class="title">.</h4>
193 <iframe class="yt-video" allowfullscreen></iframe>
194 </div>
195 </div>
196
197 <script>
198 var modal = document.getElementById('modal'),
199 closeBtn = modal.querySelector('close'),
200 ytVideo = modal.querySelector('.content .yt-video'),
201 title = modal.querySelector('.content .title'),
202 anchors = document.querySelectorAll('a[data-target="modal"]'),
203 l = anchors.length;
204
205 for (var i = 0; i < l; i++)
206 {
207 anchors[i].addEventListener("click", function (e)
208 {
209 e.preventDefault();
210 title.textContent = this.dataset.videoTitle || 'No title';
211 ytVideo.src = this.href;
212 modal.classList.toggle('is-visible');
213 modal.focus();
214 });
215 }
216
217 modal.addEventListener("keydown", function (e)
218 {
219 if (e.keyCode == 27)
220 {
221 title.textContent = '';
222 ytVideo.src = '';
223 this.classList.toggle('is-visible');
224 }
225 });
226 </script>
227
228 <script type="text/javascript">
229
230 function close_iFrame()
231 {
232 var modal = document.getElementById('modal'),
233 ytVideo = modal.querySelector('.content .yt-video');
234
235 ytVideo.src = '';
236 modal.classList.toggle('is-visible');
237
238 // Opera 8.0+
239 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
240
241 // Firefox 1.0+
242 var isFirefox = typeof InstallTrigger !== 'undefined';
243
244 // Safari 3.0+ "[object HTMLElementConstructor]"
245 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
246
247 // Internet Explorer 6-11
248 var isIE = /*@cc_on!@*/false || !!document.documentMode;
249
250 // Edge 20+
251 var isEdge = !isIE && !!window.StyleMedia;
252
253 // Chrome 1+
254 var isChrome = !!window.chrome && !!window.chrome.webstore;
255
256 // Blink engine detection
257 var isBlink = (isChrome || isOpera) && !!window.CSS;
258
259 var output = 'Detecting browsers by ducktyping :\n===========================\n';
260 output+='isChrome: '+isChrome+'\n'; // 57.8 % Market Share
261 output+='isSafari: '+isSafari+'\n'; // 14.0 %
262 output+='isFirefox: '+isFirefox+'\n'; // 6.0 %
263 output+='isIE: '+isIE+'\n';
264 output+='isEdge: '+isEdge+'\n'; // 5.9 % IE + Edge
265 output+='isOpera: '+isOpera+'\n'; // 3.7 %
266 output+='isBlink: '+isBlink+'\n';
267
268// alert(output+'[ history.length = '+history.length+' ]');
269
270 if (isChrome) // 57.8 % [ Will work correctly only after 3rd+ time of going to the #Videos section ]
271 {
272/*
273[1] No code : after 1st play, "back" plays sound
274 after 2nd play, "back" also plays sound, remembers history
275 after play 2 videos, 1 "back" plays last vodeo, 2 "back" does nothing, 3 "back" plays 2nd last video
276 Seems to remember [ empty ] + [ video ]
277
278Memory pattern : Top [video_1] [ ] [video_2] ?
279*/
280
281 if (!sessionStorage.getItem("runOnce")) // 1st time : Remembers 1st video // 2nd time : back to top after closing iFrame // 3rd time+ : works correctly
282 {
283 // alert('runOnce');
284 window.history.replaceState({},"Videos","#Videos");
285// window.location.href='#Videos';
286// history.go(0);
287 sessionStorage.setItem("runOnce",true);
288 }
289 else
290 {
291 window.history.replaceState({},"Videos","#Videos");
292 history.go(-1);
293 }
294
295 }
296 else if (isSafari) // 14.0
297 {
298
299 }
300 else if (isFirefox) // 6.0 % [ Works correctly ]
301 {
302 history.go(-1);
303 }
304 else if (isIE)
305 {
306 window.history.replaceState({},"Videos","#Videos");
307 }
308 else if (isEdge) // 5.9 % IE + Edge
309 {
310 history.go(-1);
311 }
312 else if (isOpera) // 3.7 %
313 {
314 history.go(-1);
315 }
316 else if (isBlink)
317 {
318 history.go(-1);
319 }
320//alert( window.location.href );
321// history.go(-1);
322//window.location.href = '#Videos';
323//history.replaceState({}, "#Videos", "#Videos");
324//alert( window.location.href );
325 }
326
327 window.onload = function()
328 {
329 // Opera 8.0+
330 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
331
332 // Firefox 1.0+
333 var isFirefox = typeof InstallTrigger !== 'undefined';
334
335 // Safari 3.0+ "[object HTMLElementConstructor]"
336 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
337
338 // Internet Explorer 6-11
339 var isIE = /*@cc_on!@*/false || !!document.documentMode;
340
341 // Edge 20+
342 var isEdge = !isIE && !!window.StyleMedia;
343
344 // Chrome 1+
345 var isChrome = !!window.chrome && !!window.chrome.webstore;
346
347 // Blink engine detection
348 var isBlink = (isChrome || isOpera) && !!window.CSS;
349
350 var output = 'Detecting browsers by ducktyping :\n===========================\n';
351 output+='isChrome: '+isChrome+'\n'; // 57.8 % Market Share
352 output+='isSafari: '+isSafari+'\n'; // 14.0 %
353 output+='isFirefox: '+isFirefox+'\n'; // 6.0 %
354 output+='isIE: '+isIE+'\n';
355 output+='isEdge: '+isEdge+'\n'; // 5.9 % IE + Edge
356 output+='isOpera: '+isOpera+'\n'; // 3.7 %
357 output+='isBlink: '+isBlink+'\n';
358
359// alert(output);
360
361 if (isIE)
362 {
363// alert(output);
364 var pichover=document.getElementsByClassName("pic-hover");
365 pichover[0].style.left="107px";
366 pichover[1].style.left="24px";
367 pichover[2].style.left="23px";
368 pichover[3].style.left="21px";
369 }
370 }
371
372
373 </script>
374 </body>
375</html>
376
ANSWER
Answered 2021-Oct-11 at 16:04but this is bad
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>GATE Cyber Technology : Award Winning Innovation For Identity And Access Management</title>
7 <meta name="description" content="GATE Cyber Technology LLC. INTERCEPTION-RESISTANT AUTHENTICATION AND ENCRYPTION SYSTEM AND METHOD. Introducing a breakthrough digital security innovation : Graphic Access Tabular Entry [ GATE ], an interception-resistant authentication and encryption system and method. With the GATE system you are not afraid that you are watched when you enter passwords, and you are not afraid that the password will be intercepted, the GATE innovative method is designed to be peek-resistant and interception-resistant. The GATE system and method will offer you better digital security. Identity and Access Management (IAM)">
8 <meta name="keywords" content="GATE Cyber Technology LLC. INTERCEPTION-resistant AUTHENTICATION AND ENCRYPTION SYSTEM AND METHOD, Graphic Access Tabular Entry [ GATE ], GATE security, GATE authentication, GATE login, GATE user authentication, GATE password, GATE passcode, peek-resistant, online security, digital security, passwords, password protection, strong password, strong cybersecurity, strong user authentication, prevent password loss, prevent user credential loss, passcode, cyber security, pin, login, logon, digital access, online access, access control, online protection, digital protection, online defence, digital defence, message encryption, message decryption, signal encryption, signal decryption, overcome weakness of traditional password, the GATE system, award winning, better than fingerprinting, better than iris scanning, safer than keyfob, better than password manager, safer password entry, Identity and Access Management (IAM), GATE defeats wiretapping, keylogging, peeking, phishing and dictionary attack, no restrictions of traditional password's lowercase, uppercase, numbers and special characters requirements, easy to use">
9 <meta name="google-site-verification" content="cXY5hsdt7XCjR_k96nha7Hn5uW4fw_1u6mc2LWDyAQ0" />
10 <link rel="shortcut icon" href="favicon.ico">
11
12 <link media="all" type="text/css" rel="stylesheet" href="https://cdn.ahrefs.com/assets/css/bootstrap.min.css">
13 <link media="all" type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,300,100italic,100,300italic,400italic,700,700italic,900,900italic">
14 <link media="screen" type="text/css" rel="stylesheet" href="https://cdn.ahrefs.com/assets/css/home-responsive.css?20180815-001">
15
16 <link media="all" type="text/css" rel="stylesheet" href="css/bootstrap.min.css">
17 <link media="all" type="text/css" rel="stylesheet" href="css/css.css">
18 <link media="screen" type="text/css" rel="stylesheet" href="css/home-responsive.css">
19
20 <meta property="og:image" content="GATE_1.PNG">
21
22 <style>
23 div.Intro
24 {
25 font-size: 100%;
26 text-align: left;
27 }
28
29 div.Table
30 {
31 font-size: 218%;
32 text-align: center;
33 }
34
35 a:hover { color:#ddeeff; }
36 a:visited { color:#E8E8E8 }
37
38 tr a{ font-size: 18px;color:#aabbcc; }
39 tr a:hover { color:#ddeeff; }
40
41 .pic-container-1{display:block; position:relative; }
42 .pic-container-1 .pic-box{display:block;}
43 .pic-container-1 .pic-box img{display:block;}
44 .pic-container-1 .pic-hover{position:absolute; top:0px; left:104px; display:none;}
45 .pic-container-1:hover .pic-hover{display:block;}
46
47 .pic-container-2{display:block; position:relative; }
48 .pic-container-2 .pic-box{display:block;}
49 .pic-container-2 .pic-box img{display:block;}
50 .pic-container-2 .pic-hover{position:absolute; top:0px; left:18px; display:none;}
51 .pic-container-2:hover .pic-hover{display:block;}
52
53 .pic-container-3{display:block; position:relative; }
54 .pic-container-3 .pic-box{display:block;}
55 .pic-container-3 .pic-box img{display:block;}
56 .pic-container-3 .pic-hover{position:absolute; top:0px; left:20px; display:none;}
57 .pic-container-3:hover .pic-hover{display:block;}
58
59 .pic-container-4{display:block; position:relative; }
60 .pic-container-4 .pic-box{display:block;}
61 .pic-container-4 .pic-box img{display:block;}
62 .pic-container-4 .pic-hover{position:absolute; top:0px; left:18px; display:none;}
63 .pic-container-4:hover .pic-hover{display:block;}
64
65 #GATE_Frame_1 { width: 78%; height: auto; }
66 #GATE_Frame_2 { width: 98%; height: auto; }
67
68 #Balance { width: 80%; height: auto; }
69
70 #Ted_Murphree_img { width: 36vw; height: auto; }
71 #Scott_Schober_img { width: 36vw; height: auto; }
72 #Cary_Pool_img { width: 36vw; height: auto; }
73 #Eduard_B_img { width: 36vw; height: auto; }
74 #Jonathan_Rosenoer_img { width: 36vw; height: auto; }
75
76 #Traditional_vs_GATE_1 { width: 96%; height: auto; }
77 #Traditional_vs_GATE_2 { width: 99.5%; height: auto; }
78
79 #modal
80 {
81 display: none;
82 position: fixed;
83 width: 100vw;
84 height: 100vh;
85 max-height: 100vh;
86 top: 0;
87 left: 0;
88 background: rgba(24, 24, 24, .6);
89 z-index: 999;
90 }
91 #modal .content
92 {
93 position: relative;
94 width: 55%;
95 height: 65vh;
96 margin: auto; /* allows horyzontal and vertical alignment as .content is in flex container */
97 }
98 #modal .content .yt-video
99 {
100 display: block;
101 width: 100%;
102 height: calc(100% - 45px);
103 }
104 #modal .content .title
105 {
106 box-sizing: border-box;
107 height: 45px;
108 line-height: 23px;
109 padding: 12px 4px;
110 margin: 0;
111 background: #007bff;
112 color: #fff;
113 text-align: center;
114 font-size: 26px;
115 max-width: 100%;
116 white-space: nowrap;
117 overflow: hidden;
118 text-overflow: ellipsis;
119 }
120 #modal .close
121 {
122 position: absolute;
123 top: 0;
124 right: 0;
125 width: 45px;
126 height: 45px;
127 line-height: 36px;
128 text-align: center;
129 border: 0;
130 font-weight: bold;
131 font-size: 38px;
132 color: #fff;
133 background: #366;
134 cursor: pointer;
135 transition: background .2s;
136 }
137 #modal .content .close .a { font-size:38px;color: #ffffff; }
138 #modal .close:hover, #modal .close:active { background: #ff0000; }
139 #modal.is-visible { display: flex; }
140
141 html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li,
142 fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video
143 {
144 margin: 0;
145 padding: 0;
146 border: 0;
147 font-size: 100%;
148 font: inherit;
149 vertical-align: middle;
150 }
151
152 /* HTML5 display-role reset for older browsers */
153 article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
154 body { line-height: 1; }
155 // ol, ul { list-style: none; }
156 blockquote, q { quotes: none; }
157 blockquote:before, blockquote:after,
158 q:before, q:after
159 {
160 content: '';
161 content: none;
162 }
163 table
164 {
165 border-collapse: collapse;
166 border-spacing: 0;
167 }
168 </style>
169 </head>
170
171 <body class="page__guest ahrefs page-home">
172 <div id="localizejs">
173 <div class="content">
174 <a id="Awards"></a>
175 <div class="datas">
176 <div class="container center">
177 <Table Cellpadding=6>
178 <Tr>
179 <Td Align=Center><Br>
180 <Font Color=white><A Href=http://bestech.ittn.com.cn/#/projectlist2021 target=_blank>GATE has been selected</A> to the <A Href="2021_ZGC_Top_100_List_1.PNG" target=_blank>top 100</A>,<Br> among more than 2800 technologies collected<Br> from all over the world at 2021 ZGC<Br><A Href=http://bestech.ittn.com.cn/#/home target=_blank>International Technology Trade Conference</A>.</Font>
181 </Td>
182 </Tr>
183 </Table>
184 </div>
185 </div>
186
187 <!-- the modal div that will open when an anchor link is clicked to show the related video in an iframe. -->
188
189 <div id="modal">
190 <div class="content">
191 <div class="close"><a onclick = "return close_iFrame();">&times;</a></div>
192 <h4 class="title">.</h4>
193 <iframe class="yt-video" allowfullscreen></iframe>
194 </div>
195 </div>
196
197 <script>
198 var modal = document.getElementById('modal'),
199 closeBtn = modal.querySelector('close'),
200 ytVideo = modal.querySelector('.content .yt-video'),
201 title = modal.querySelector('.content .title'),
202 anchors = document.querySelectorAll('a[data-target="modal"]'),
203 l = anchors.length;
204
205 for (var i = 0; i < l; i++)
206 {
207 anchors[i].addEventListener("click", function (e)
208 {
209 e.preventDefault();
210 title.textContent = this.dataset.videoTitle || 'No title';
211 ytVideo.src = this.href;
212 modal.classList.toggle('is-visible');
213 modal.focus();
214 });
215 }
216
217 modal.addEventListener("keydown", function (e)
218 {
219 if (e.keyCode == 27)
220 {
221 title.textContent = '';
222 ytVideo.src = '';
223 this.classList.toggle('is-visible');
224 }
225 });
226 </script>
227
228 <script type="text/javascript">
229
230 function close_iFrame()
231 {
232 var modal = document.getElementById('modal'),
233 ytVideo = modal.querySelector('.content .yt-video');
234
235 ytVideo.src = '';
236 modal.classList.toggle('is-visible');
237
238 // Opera 8.0+
239 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
240
241 // Firefox 1.0+
242 var isFirefox = typeof InstallTrigger !== 'undefined';
243
244 // Safari 3.0+ "[object HTMLElementConstructor]"
245 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
246
247 // Internet Explorer 6-11
248 var isIE = /*@cc_on!@*/false || !!document.documentMode;
249
250 // Edge 20+
251 var isEdge = !isIE && !!window.StyleMedia;
252
253 // Chrome 1+
254 var isChrome = !!window.chrome && !!window.chrome.webstore;
255
256 // Blink engine detection
257 var isBlink = (isChrome || isOpera) && !!window.CSS;
258
259 var output = 'Detecting browsers by ducktyping :\n===========================\n';
260 output+='isChrome: '+isChrome+'\n'; // 57.8 % Market Share
261 output+='isSafari: '+isSafari+'\n'; // 14.0 %
262 output+='isFirefox: '+isFirefox+'\n'; // 6.0 %
263 output+='isIE: '+isIE+'\n';
264 output+='isEdge: '+isEdge+'\n'; // 5.9 % IE + Edge
265 output+='isOpera: '+isOpera+'\n'; // 3.7 %
266 output+='isBlink: '+isBlink+'\n';
267
268// alert(output+'[ history.length = '+history.length+' ]');
269
270 if (isChrome) // 57.8 % [ Will work correctly only after 3rd+ time of going to the #Videos section ]
271 {
272/*
273[1] No code : after 1st play, "back" plays sound
274 after 2nd play, "back" also plays sound, remembers history
275 after play 2 videos, 1 "back" plays last vodeo, 2 "back" does nothing, 3 "back" plays 2nd last video
276 Seems to remember [ empty ] + [ video ]
277
278Memory pattern : Top [video_1] [ ] [video_2] ?
279*/
280
281 if (!sessionStorage.getItem("runOnce")) // 1st time : Remembers 1st video // 2nd time : back to top after closing iFrame // 3rd time+ : works correctly
282 {
283 // alert('runOnce');
284 window.history.replaceState({},"Videos","#Videos");
285// window.location.href='#Videos';
286// history.go(0);
287 sessionStorage.setItem("runOnce",true);
288 }
289 else
290 {
291 window.history.replaceState({},"Videos","#Videos");
292 history.go(-1);
293 }
294
295 }
296 else if (isSafari) // 14.0
297 {
298
299 }
300 else if (isFirefox) // 6.0 % [ Works correctly ]
301 {
302 history.go(-1);
303 }
304 else if (isIE)
305 {
306 window.history.replaceState({},"Videos","#Videos");
307 }
308 else if (isEdge) // 5.9 % IE + Edge
309 {
310 history.go(-1);
311 }
312 else if (isOpera) // 3.7 %
313 {
314 history.go(-1);
315 }
316 else if (isBlink)
317 {
318 history.go(-1);
319 }
320//alert( window.location.href );
321// history.go(-1);
322//window.location.href = '#Videos';
323//history.replaceState({}, "#Videos", "#Videos");
324//alert( window.location.href );
325 }
326
327 window.onload = function()
328 {
329 // Opera 8.0+
330 var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
331
332 // Firefox 1.0+
333 var isFirefox = typeof InstallTrigger !== 'undefined';
334
335 // Safari 3.0+ "[object HTMLElementConstructor]"
336 var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
337
338 // Internet Explorer 6-11
339 var isIE = /*@cc_on!@*/false || !!document.documentMode;
340
341 // Edge 20+
342 var isEdge = !isIE && !!window.StyleMedia;
343
344 // Chrome 1+
345 var isChrome = !!window.chrome && !!window.chrome.webstore;
346
347 // Blink engine detection
348 var isBlink = (isChrome || isOpera) && !!window.CSS;
349
350 var output = 'Detecting browsers by ducktyping :\n===========================\n';
351 output+='isChrome: '+isChrome+'\n'; // 57.8 % Market Share
352 output+='isSafari: '+isSafari+'\n'; // 14.0 %
353 output+='isFirefox: '+isFirefox+'\n'; // 6.0 %
354 output+='isIE: '+isIE+'\n';
355 output+='isEdge: '+isEdge+'\n'; // 5.9 % IE + Edge
356 output+='isOpera: '+isOpera+'\n'; // 3.7 %
357 output+='isBlink: '+isBlink+'\n';
358
359// alert(output);
360
361 if (isIE)
362 {
363// alert(output);
364 var pichover=document.getElementsByClassName("pic-hover");
365 pichover[0].style.left="107px";
366 pichover[1].style.left="24px";
367 pichover[2].style.left="23px";
368 pichover[3].style.left="21px";
369 }
370 }
371
372
373 </script>
374 </body>
375</html>
376a[href] {color: blue !important, text-decoration: underline !important}
377
QUESTION
Error: Invalid hook call how can i solve it?
Asked 2021-Sep-21 at 11:54this is the error i received
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
- You might have mismatching versions of React and the renderer (such as React DOM)
- You might be breaking the Rules of Hooks
- You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
This is my code:
1const HandleAdd = () => {
2 const [reRender, setRerender] = useState(false);
3 Swal.fire({
4 title: 'Add Department',
5 text: "Input department name below.",
6 showCancelButton: true,
7 confirmButtonColor: '#3085d6',
8 cancelButtonColor: '#d33',
9 confirmButtonText: 'Save',
10 html: generateInputForms({
11 strname: '',
12 intsequence: ''
13 }),
14
15 preConfirm: () => {
16 let strname = document.getElementById('strname').value;
17 let intsequence = document.getElementById('intsequence').value;
18
19 if (!strname) {
20 Swal.showValidationMessage('The Department field is required.')
21 }
22 if (!intsequence) {
23 Swal.showValidationMessage('The Sequence field is required.')
24 }
25 return {
26 strname: document.getElementById('strname').value,
27 intsequence: document.getElementById('intsequence').value
28 }
29 }
30 }).then((result) => {
31 if (result.isConfirmed) {
32 let request = {
33 strresourcename: "Richard",
34 strapplicationcode: "SchoolApp",
35 strmodulename: "Department",
36 strtablename: "fmDepartments",
37 strfieldid: "fmDepartmentsId",
38 strname:document.getElementById('strname').value,
39 intsequence:document.getElementById('intsequence').value
40 }
41 addDepartment(request).then(function(res){
42 if (res.status == 200){
43 Swal.fire({
44 icon: 'success',
45 title: 'Department',
46 text: 'New Department has been added successfully.',
47 }).then((res) => {
48 setRerender(!reRender);
49 })
50 }else{
51 Swal.fire({
52 icon: 'error',
53 title: 'Oops',
54 text: 'Something went wrong.',
55 })
56 }
57 })
58
59 }
60 })
61}
62class CustomToolbar extends React.Component {
63
64 handleClick = () => {
65 console.log("Add User Initiated...");
66 }
67
68 render() {
69 const { classes } = this.props;
70
71 return (
72 <React.Fragment>
73 <Tooltip title={"Add"}>
74 <Button
75 variant="contained"
76 color="primary"
77 size="small"
78 style={{
79 textTransform: 'unset',
80 outline: 'none',
81 marginLeft: 20,
82 backgroundColor: '#00B029',
83 }}
84 onClick={HandleAdd}
85 className={classes.button}
86 startIcon={<AddIcon className={classes.addIcon} style={{color: '#fff',}} />}
87 >
88 Add
89 </Button>
90 </Tooltip>
91 </React.Fragment>
92 );
93 }
94
95}
96
97export default withStyles(defaultToolbarStyles, { name: "CustomToolbar" })(CustomToolbar);
98
dependency
1const HandleAdd = () => {
2 const [reRender, setRerender] = useState(false);
3 Swal.fire({
4 title: 'Add Department',
5 text: "Input department name below.",
6 showCancelButton: true,
7 confirmButtonColor: '#3085d6',
8 cancelButtonColor: '#d33',
9 confirmButtonText: 'Save',
10 html: generateInputForms({
11 strname: '',
12 intsequence: ''
13 }),
14
15 preConfirm: () => {
16 let strname = document.getElementById('strname').value;
17 let intsequence = document.getElementById('intsequence').value;
18
19 if (!strname) {
20 Swal.showValidationMessage('The Department field is required.')
21 }
22 if (!intsequence) {
23 Swal.showValidationMessage('The Sequence field is required.')
24 }
25 return {
26 strname: document.getElementById('strname').value,
27 intsequence: document.getElementById('intsequence').value
28 }
29 }
30 }).then((result) => {
31 if (result.isConfirmed) {
32 let request = {
33 strresourcename: "Richard",
34 strapplicationcode: "SchoolApp",
35 strmodulename: "Department",
36 strtablename: "fmDepartments",
37 strfieldid: "fmDepartmentsId",
38 strname:document.getElementById('strname').value,
39 intsequence:document.getElementById('intsequence').value
40 }
41 addDepartment(request).then(function(res){
42 if (res.status == 200){
43 Swal.fire({
44 icon: 'success',
45 title: 'Department',
46 text: 'New Department has been added successfully.',
47 }).then((res) => {
48 setRerender(!reRender);
49 })
50 }else{
51 Swal.fire({
52 icon: 'error',
53 title: 'Oops',
54 text: 'Something went wrong.',
55 })
56 }
57 })
58
59 }
60 })
61}
62class CustomToolbar extends React.Component {
63
64 handleClick = () => {
65 console.log("Add User Initiated...");
66 }
67
68 render() {
69 const { classes } = this.props;
70
71 return (
72 <React.Fragment>
73 <Tooltip title={"Add"}>
74 <Button
75 variant="contained"
76 color="primary"
77 size="small"
78 style={{
79 textTransform: 'unset',
80 outline: 'none',
81 marginLeft: 20,
82 backgroundColor: '#00B029',
83 }}
84 onClick={HandleAdd}
85 className={classes.button}
86 startIcon={<AddIcon className={classes.addIcon} style={{color: '#fff',}} />}
87 >
88 Add
89 </Button>
90 </Tooltip>
91 </React.Fragment>
92 );
93 }
94
95}
96
97export default withStyles(defaultToolbarStyles, { name: "CustomToolbar" })(CustomToolbar);
98{
99 "name": "@group1/school-template",
100 "version": "3.2.1",
101 "description": "School Access Management System",
102 "author": {
103 "github": "https://github.com",
104 "twitter": "https://twitter.com"
105 },
106 "contributors": [
107 {
108 "name": "Group1 Team",
109 "url": "https://github.com"
110 }
111 ],
112 "homepage": ".",
113 "copyright": "Copyright Richard M.",
114 "license": "MIT",
115 "private": true,
116 "repository": {
117 "type": "git",
118 "url": "git@github.com"
119 },
120 "dependencies": {
121 "@coreui/chartjs": "^2.0.0",
122 "@coreui/coreui": "^3.4.0",
123 "@coreui/icons": "^2.0.0",
124 "@coreui/icons-react": "^1.1.0",
125 "@coreui/react": "^3.4.6",
126 "@coreui/react-chartjs": "^1.1.0",
127 "@coreui/utils": "^1.3.1",
128 "@date-io/date-fns": "^1.3.13",
129 "@date-io/moment": "^1.3.13",
130 "@material-ui/core": "^4.11.4",
131 "@material-ui/icons": "^4.11.2",
132 "@material-ui/lab": "^4.0.0-alpha.58",
133 "@material-ui/pickers": "^3.3.10",
134 "@syncfusion/ej2-react-calendars": "^19.2.47",
135 "@wojtekmaj/enzyme-adapter-react-17": "^0.6.0",
136 "axios": "^0.21.1",
137 "classnames": "^2.2.6",
138 "core-js": "^3.9.1",
139 "date-fns": "^2.22.1",
140 "downshift": "^3.4.8",
141 "enzyme": "^3.11.0",
142 "filter-material-ui": "^2.7.0",
143 "formik": "^2.2.9",
144 "lodash": "^4.17.21",
145 "match-sorter": "^4.2.1",
146 "material-ui-filter": "^3.1.3",
147 "moment": "^2.29.1",
148 "mui-datatables": "^3.7.7",
149 "nanoid": "^3.0.0",
150 "prop-types": "^15.7.2",
151 "react": "^17.0.2",
152 "react-app-polyfill": "^2.0.0",
153 "react-bootstrap-sweetalert": "^5.2.0",
154 "react-date-range": "^1.3.0",
155 "react-dom": "^17.0.2",
156 "react-dual-listbox": "^2.1.2",
157 "react-multi-select-component": "^4.0.3",
158 "react-multiselect-checkboxes": "^0.1.1",
159 "react-redux": "^7.2.3",
160 "react-router": "^5.2.0",
161 "react-router-dom": "^5.2.0",
162 "react-virtualized": "^9.22.3",
163 "redux": "^4.0.5",
164 "sass": "^1.32.8",
165 "sweetalert2": "^11.0.20",
166 "sweetalert2-react-content": "^4.1.1",
167 "yup": "^0.32.9"
168 },
169 "devDependencies": {
170 "@babel/core": "^7.13.14",
171 "auto-changelog": "~2.2.1",
172 "react-scripts": "^4.0.3"
173 },
174 "scripts": {
175 "start": "react-scripts start",
176 "build": "react-scripts build",
177 "test": "react-scripts test",
178 "test:cov": "npm test -- --coverage --watchAll=false",
179 "test:debug": "react-scripts --inspect-brk test --runInBand",
180 "eject": "react-scripts eject",
181 "changelog": "auto-changelog --starting-version 3.0.0 --commit-limit false --hide-credit"
182 },
183 "bugs": {
184 "url": "https://ncfsolutionsinc.com"
185 },
186 "eslintConfig": {
187 "extends": "react-app"
188 },
189 "browserslist": [
190 ">0.2%",
191 "not dead",
192 "not ie <= 10",
193 "not op_mini all"
194 ],
195 "jest": {
196 "collectCoverageFrom": [
197 "src/**/*.{js,jsx}",
198 "!**/*index.js",
199 "!src/serviceWorker.js",
200 "!src/polyfill.js"
201 ]
202 },
203 "engines": {
204 "node": ">=10",
205 "npm": ">=6"
206 }
207}
208
ANSWER
Answered 2021-Sep-21 at 11:54You cannot use useState
in non functional component. You're using it in a method called HandleAdd
. HandleAdd
is not a component! You're using classify component. You need to move the HandleAdd
into your component and use the class component's own state
and setState
:
1const HandleAdd = () => {
2 const [reRender, setRerender] = useState(false);
3 Swal.fire({
4 title: 'Add Department',
5 text: "Input department name below.",
6 showCancelButton: true,
7 confirmButtonColor: '#3085d6',
8 cancelButtonColor: '#d33',
9 confirmButtonText: 'Save',
10 html: generateInputForms({
11 strname: '',
12 intsequence: ''
13 }),
14
15 preConfirm: () => {
16 let strname = document.getElementById('strname').value;
17 let intsequence = document.getElementById('intsequence').value;
18
19 if (!strname) {
20 Swal.showValidationMessage('The Department field is required.')
21 }
22 if (!intsequence) {
23 Swal.showValidationMessage('The Sequence field is required.')
24 }
25 return {
26 strname: document.getElementById('strname').value,
27 intsequence: document.getElementById('intsequence').value
28 }
29 }
30 }).then((result) => {
31 if (result.isConfirmed) {
32 let request = {
33 strresourcename: "Richard",
34 strapplicationcode: "SchoolApp",
35 strmodulename: "Department",
36 strtablename: "fmDepartments",
37 strfieldid: "fmDepartmentsId",
38 strname:document.getElementById('strname').value,
39 intsequence:document.getElementById('intsequence').value
40 }
41 addDepartment(request).then(function(res){
42 if (res.status == 200){
43 Swal.fire({
44 icon: 'success',
45 title: 'Department',
46 text: 'New Department has been added successfully.',
47 }).then((res) => {
48 setRerender(!reRender);
49 })
50 }else{
51 Swal.fire({
52 icon: 'error',
53 title: 'Oops',
54 text: 'Something went wrong.',
55 })
56 }
57 })
58
59 }
60 })
61}
62class CustomToolbar extends React.Component {
63
64 handleClick = () => {
65 console.log("Add User Initiated...");
66 }
67
68 render() {
69 const { classes } = this.props;
70
71 return (
72 <React.Fragment>
73 <Tooltip title={"Add"}>
74 <Button
75 variant="contained"
76 color="primary"
77 size="small"
78 style={{
79 textTransform: 'unset',
80 outline: 'none',
81 marginLeft: 20,
82 backgroundColor: '#00B029',
83 }}
84 onClick={HandleAdd}
85 className={classes.button}
86 startIcon={<AddIcon className={classes.addIcon} style={{color: '#fff',}} />}
87 >
88 Add
89 </Button>
90 </Tooltip>
91 </React.Fragment>
92 );
93 }
94
95}
96
97export default withStyles(defaultToolbarStyles, { name: "CustomToolbar" })(CustomToolbar);
98{
99 "name": "@group1/school-template",
100 "version": "3.2.1",
101 "description": "School Access Management System",
102 "author": {
103 "github": "https://github.com",
104 "twitter": "https://twitter.com"
105 },
106 "contributors": [
107 {
108 "name": "Group1 Team",
109 "url": "https://github.com"
110 }
111 ],
112 "homepage": ".",
113 "copyright": "Copyright Richard M.",
114 "license": "MIT",
115 "private": true,
116 "repository": {
117 "type": "git",
118 "url": "git@github.com"
119 },
120 "dependencies": {
121 "@coreui/chartjs": "^2.0.0",
122 "@coreui/coreui": "^3.4.0",
123 "@coreui/icons": "^2.0.0",
124 "@coreui/icons-react": "^1.1.0",
125 "@coreui/react": "^3.4.6",
126 "@coreui/react-chartjs": "^1.1.0",
127 "@coreui/utils": "^1.3.1",
128 "@date-io/date-fns": "^1.3.13",
129 "@date-io/moment": "^1.3.13",
130 "@material-ui/core": "^4.11.4",
131 "@material-ui/icons": "^4.11.2",
132 "@material-ui/lab": "^4.0.0-alpha.58",
133 "@material-ui/pickers": "^3.3.10",
134 "@syncfusion/ej2-react-calendars": "^19.2.47",
135 "@wojtekmaj/enzyme-adapter-react-17": "^0.6.0",
136 "axios": "^0.21.1",
137 "classnames": "^2.2.6",
138 "core-js": "^3.9.1",
139 "date-fns": "^2.22.1",
140 "downshift": "^3.4.8",
141 "enzyme": "^3.11.0",
142 "filter-material-ui": "^2.7.0",
143 "formik": "^2.2.9",
144 "lodash": "^4.17.21",
145 "match-sorter": "^4.2.1",
146 "material-ui-filter": "^3.1.3",
147 "moment": "^2.29.1",
148 "mui-datatables": "^3.7.7",
149 "nanoid": "^3.0.0",
150 "prop-types": "^15.7.2",
151 "react": "^17.0.2",
152 "react-app-polyfill": "^2.0.0",
153 "react-bootstrap-sweetalert": "^5.2.0",
154 "react-date-range": "^1.3.0",
155 "react-dom": "^17.0.2",
156 "react-dual-listbox": "^2.1.2",
157 "react-multi-select-component": "^4.0.3",
158 "react-multiselect-checkboxes": "^0.1.1",
159 "react-redux": "^7.2.3",
160 "react-router": "^5.2.0",
161 "react-router-dom": "^5.2.0",
162 "react-virtualized": "^9.22.3",
163 "redux": "^4.0.5",
164 "sass": "^1.32.8",
165 "sweetalert2": "^11.0.20",
166 "sweetalert2-react-content": "^4.1.1",
167 "yup": "^0.32.9"
168 },
169 "devDependencies": {
170 "@babel/core": "^7.13.14",
171 "auto-changelog": "~2.2.1",
172 "react-scripts": "^4.0.3"
173 },
174 "scripts": {
175 "start": "react-scripts start",
176 "build": "react-scripts build",
177 "test": "react-scripts test",
178 "test:cov": "npm test -- --coverage --watchAll=false",
179 "test:debug": "react-scripts --inspect-brk test --runInBand",
180 "eject": "react-scripts eject",
181 "changelog": "auto-changelog --starting-version 3.0.0 --commit-limit false --hide-credit"
182 },
183 "bugs": {
184 "url": "https://ncfsolutionsinc.com"
185 },
186 "eslintConfig": {
187 "extends": "react-app"
188 },
189 "browserslist": [
190 ">0.2%",
191 "not dead",
192 "not ie <= 10",
193 "not op_mini all"
194 ],
195 "jest": {
196 "collectCoverageFrom": [
197 "src/**/*.{js,jsx}",
198 "!**/*index.js",
199 "!src/serviceWorker.js",
200 "!src/polyfill.js"
201 ]
202 },
203 "engines": {
204 "node": ">=10",
205 "npm": ">=6"
206 }
207}
208class CustomToolbar extends React.Component {
209 state = false;
210 constructor(props) {
211 super(props)
212 this.HandleAdd = this.HandleAdd.bind(this);
213 }
214 HandleAdd = () => {
215 Swal.fire({
216 title: 'Add Department',
217 text: "Input department name below.",
218 showCancelButton: true,
219 confirmButtonColor: '#3085d6',
220 cancelButtonColor: '#d33',
221 confirmButtonText: 'Save',
222 html: generateInputForms({
223 strname: '',
224 intsequence: ''
225 }),
226
227 preConfirm: () => {
228 let strname = document.getElementById('strname').value;
229 let intsequence = document.getElementById('intsequence').value;
230
231 if (!strname) {
232 Swal.showValidationMessage('The Department field is required.')
233 }
234 if (!intsequence) {
235 Swal.showValidationMessage('The Sequence field is required.')
236 }
237 return {
238 strname: document.getElementById('strname').value,
239 intsequence: document.getElementById('intsequence').value
240 }
241 }
242 }).then((result) => {
243 if (result.isConfirmed) {
244 let request = {
245 strresourcename: "Richard",
246 strapplicationcode: "SchoolApp",
247 strmodulename: "Department",
248 strtablename: "fmDepartments",
249 strfieldid: "fmDepartmentsId",
250 strname:document.getElementById('strname').value,
251 intsequence:document.getElementById('intsequence').value
252 }
253 addDepartment(request).then(function(res){
254 if (res.status == 200){
255 Swal.fire({
256 icon: 'success',
257 title: 'Department',
258 text: 'New Department has been added successfully.',
259 }).then((res) => {
260 this.setState(!this.state);
261 })
262 }else{
263 Swal.fire({
264 icon: 'error',
265 title: 'Oops',
266 text: 'Something went wrong.',
267 })
268 }
269 })
270
271 }
272 })
273}
274
275
276 handleClick = () => {
277 console.log("Add User Initiated...");
278 }
279
280 render() {
281 const { classes } = this.props;
282
283 return (
284 <React.Fragment>
285 <Tooltip title={"Add"}>
286 <Button
287 variant="contained"
288 color="primary"
289 size="small"
290 style={{
291 textTransform: 'unset',
292 outline: 'none',
293 marginLeft: 20,
294 backgroundColor: '#00B029',
295 }}
296 onClick={this.HandleAdd}
297 className={classes.button}
298 startIcon={<AddIcon className={classes.addIcon} style={{color: '#fff',}} />}
299 >
300 Add
301 </Button>
302 </Tooltip>
303 </React.Fragment>
304 );
305 }
306
307}
308
QUESTION
how to make a global environment variable accessible for PODs in a kubernetes cluster
Asked 2021-Aug-20 at 21:28In my company, we have an internal Security Token Service consumed by all web apps to validate the STS token issued by the company central access management server (e.g BigIP/APM). Therefore the same endpoint for token validation REST API has to be repeatedly set as an environment variable in Deployment Configuration for each individual web app (Openshift project). So is an ES256 public key used by each web app for validating JWT token.
I'm wondering if there exists a way to set up a global Environment variable or ConfigMap or anything else in Openshift for these kind of common, shared settings per cluster such that they can be by default accessible for all web apps running in all PODs in the cluster? of coz, each individual Deployment Config should override these default values from the global settings at will.
ANSWER
Answered 2021-Aug-20 at 10:02Nothing built in. You could built that yourself with some webhooks and custom code. Otherwise you need to add the envFrom
pointing at a Secret and/or ConfigMap to each pod template and copy that Secret/ConfigMap to all namespaces that needed it (kubed can help with that part at least).
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Access Management
Tutorials and Learning Resources are not available at this moment for Access Management