Disclosure of Invention
The application aims to provide a button authority control method, which can realize control on button authority and is not in conflict with menu level authority control. Another object of the present application is to provide a button authority control device, an apparatus and a computer readable storage medium, all having the above technical effects.
In order to solve the technical problem, the present application provides a button authority control method, including:
configuring service authority of various user roles;
configuring the use authority of the button;
judging whether the button in the page is available according to the service authority corresponding to the user role of the login user and the use authority of the button in the page;
and if the button in the page is available, setting the button in the page to be in an available state.
Optionally, the usage right of the configuration button includes:
configuring the button to be available when a user has a preset service right; or configuring the button to be available when the user has a preset service authority and the row in the page is selected; or the button is configured to be available when the user has a preset service authority and meets a preset condition; or the button is configured to be available when the user has a preset service authority, and the row in the page is selected and meets a preset condition.
Optionally, the determining, according to the service right corresponding to the user role of the login user and the usage right of the button in the page, whether the button in the page is available includes:
if the use authority of the button is configured to that the user has a preset service authority, and the button is available, judging whether the login user has the preset service authority;
if the use permission of the button is configured that a user has a preset service permission and the row in the page is selected, the button is available, and whether the login user has the preset service permission and the row in the page is selected is judged;
if the use permission of the button is configured that the user has a preset service permission and meets a preset condition, the button is available, and whether the login user has the preset service permission and meets the preset condition is judged;
if the use permission of the button is configured to be that a user has a preset service permission, the row in the page is selected and meets a preset condition, the button is available, and whether the login user has the preset service permission and the row in the page is selected and meets the preset condition is judged.
Optionally, the determining whether the login user has the preset service right includes:
matching the user role of the login user with the user role with the preset service authority;
and if the matching is successful, the login user has the preset service authority.
Optionally, the setting the button in the page to an available state includes:
illuminating the button in the page.
In order to solve the above technical problem, the present application further provides a button authority control device, including:
the first configuration module is used for configuring the service authority of various user roles;
the second configuration module is used for configuring the use permission of the button;
the judging module is used for judging whether the button in the page is available according to the service authority corresponding to the user role of the login user and the use authority of the button in the page;
and the setting module is used for setting the button in the page to be in an available state if the button in the page is available.
Optionally, the second configuration module is specifically configured to:
configuring the button to be available when a user has a preset service right; or configuring the button to be available when the user has a preset service authority and the row in the page is selected; or the button is configured to be available when the user has a preset service authority and meets a preset condition; or the button is configured to be available when the user has a preset service authority, and the row in the page is selected and meets a preset condition.
Optionally, the determining module includes:
the first judging unit is used for judging whether the login user has the preset service authority or not if the use authority of the button is configured that the user has the preset service authority and the button is available;
the second judgment unit is used for judging whether the login user has the preset service authority and the row in the page is selected if the use authority of the button is configured that the user has the preset service authority and the row in the page is selected and the button is available;
a third judging unit, configured to judge whether the login user has the preset service authority and meets the preset condition if the use authority of the button is configured that the user has the preset service authority and meets the preset condition, and the button is available;
and the fourth judgment unit is used for judging whether the login user has the preset service authority and the row in the page is selected and meets the preset condition if the use authority of the button is configured to that the user has the preset service authority and the row in the page is selected and meets the preset condition if the button is available.
In order to solve the above technical problem, the present application further provides a button authority control device, including:
a memory for storing a computer program;
a processor for implementing the steps of the button authorization control method according to any one of the above when executing the computer program.
In order to solve the above technical problem, the present application further provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of the button authority control method according to any one of the above items.
The button authority control method provided by the application comprises the following steps: configuring service authority of various user roles; configuring the use authority of the button; judging whether the button in the page is available according to the service authority corresponding to the user role of the login user and the use authority of the button in the page; and if the button in the page is available, setting the button in the page to be in an available state.
Therefore, the button authority control method provided by the application configures service authorities for various user roles and configures use authorities for buttons, on the basis, judges whether the buttons in the page are available according to the service authorities corresponding to the user roles of the login users and the use authorities of the buttons in the page, and sets the buttons to be in an available state when the buttons are available, so that the control of the button-level authorities is realized, and the control of the button-level authorities is not in conflict with the control of the menu-level authorities. Meanwhile, the authority control of the button authority control method provided by the application can not be influenced by module coding, and the button authority control method has low coupling. The artificial neural network is easy to transplant and use in various angularjs systems, and has better universality.
The button authority control device, the equipment and the computer readable storage medium provided by the application have the technical effects.
Detailed Description
The key point of the application is to provide a button authority control method, which can realize the control of the button authority and has no conflict with the menu level authority control. Another core of the present application is to provide a button authority control device, an apparatus and a computer readable storage medium, all having the above technical effects.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Referring to fig. 1, fig. 1 is a schematic flow chart of a button permission control method provided in an embodiment of the present application, and referring to fig. 1, the method is implemented based on angularjs and mainly includes:
s101: configuring service authority of various user roles;
specifically, each login user has a unique user role, for example, super-user (super administrator), admin _ user (common administrator), resource _ user (resource administrator), readonly _ user (read-only administrator), device _ user (device administrator), and the like. And configuring corresponding service authority for each user role to form an authority control table. Wherein, the same user role can have multiple service authorities. User roles with certain service authority, which allow access and operate corresponding pages. For example, the user role super corresponds to the admin _ user and the cluster, and the cluster represents the cluster setting, that is, the user role super and the admin _ user have the access and operation authority of the cluster setting page. The user roles super, admin _ user, resource _ user and readonly _ user correspond to a directory, and the directory represents directory management, that is, the user roles super, admin _ user, resource _ user and readonly _ user have the access and operation authority of a directory management page.
S102: configuring the use authority of the button;
specifically, this step is intended to configure the usage right corresponding to each button in the page.
In a specific embodiment, configuring the usage right of the button includes:
configuring the button to be available when the user has the preset service right; or, configuring the button to be available when the user has the preset service authority and the row in the page is selected; or, configuring the button to be available when the user has the preset service authority and meets the preset condition; or the button is configured to be available when the user has the preset service authority and the row in the page is selected and meets the preset condition.
Specifically, the use authority of the button can be configured in the form of value | action | state. When the user has the preset service right, the button is available; when a user has a preset service authority and a row in a page is selected, a button is available; when the user has a preset service authority and meets a preset condition, the button is available; and when the user has a preset service authority and the row in the page is selected and meets the preset condition, the buttons can be used for four.
Taking the preset service authority as an example of cluster setting, four configurations in the form of value | action | state can be expressed as follows:
cluster | create, cluster | edge, cluster | create | state and cluster | edge | state.
cluster | create represents available with cluster rights; cluster | edit stands for having cluster authority and selecting a row for use; the cluster | create | state represents that it has cluster authority and it is available to satisfy the condition state. cluster | edge | state represents having cluster authority, selecting the row, and satisfying the condition state is available.
Different buttons, suitably arranged in one of the four configurations described above. In addition, the conditions set by the different buttons may be different. For example, the use authority of the start button is configured as cluster | create | state1, and the state1 indicates that the node is not usable in the on state. The traffic limit of state1 is expressed as:
Scope.$broadcast(”state1”,{
value, Cluster setting/whether or not a Cluster setting function is owned
"Disabled" …// row selected or not, and is in an enabled state
});
At this time, the use authority of the start button is that the user has a cluster authority, and the start button is available when state1 transmits disabled _ false.
For example, the use authority of the close button in the cluster setting page is configured as cluster | create | state2, and state2 indicates that the node is usable in the open state. The traffic limit of State2 is expressed as:
Scope.$broadcast(”state2”,{
value, Cluster setting/whether or not a Cluster setting function is owned
"Disabled" …// row selected or not, and is in an enabled state
});
At this time, the use authority of the close button is that the user has a cluster authority, and the close button is available when state2 transmits disabled _ future.
S103: judging whether the button in the page is available according to the service authority corresponding to the user role of the login user and the use authority of the button in the page;
on the basis that the use permission of the button comprises the four configuration forms, correspondingly, judging whether the button in the page is available according to the service permission corresponding to the user role of the login user and the use permission of the button in the page comprises the following steps:
if the use authority of the button is configured to that the user has the preset service authority, the button is available, and whether the login user has the preset service authority is judged;
if the login user has the preset service authority, a button in the page is available. If the login user does not have the preset service authority, the button in the page is unavailable.
If the use permission of the button is configured that the user has the preset service permission and the row in the page is selected, the button is available, and whether the login user has the preset service permission and the row in the page is selected is judged;
if the login user has the preset service authority and a certain line in the page is selected, the button in the page is available; if the login user does not have the preset service authority or no line in the page is selected, namely, any one of the preset service authority of the login user and the selected line in the page is not satisfied, the button in the page is unavailable.
If the use permission of the button is configured that the user has the preset service permission and meets the preset condition, the button is available, and whether the login user has the preset service permission and meets the preset condition is judged;
if the login user has the preset service authority and meets the preset conditions, the button in the page is available; if the login user does not have the preset service authority or does not meet the preset condition, namely, any one of the two factors of the login user having the preset service authority and meeting the preset condition is not met, the button in the page is unavailable.
If the use permission of the button is configured that the user has the preset service permission, the row in the page is selected and meets the preset condition, the button is available, and whether the login user has the preset service permission or not is judged, and the row in the page is selected and meets the preset condition.
If the login user has a preset service authority and a certain line in the page is selected and meets a preset condition, the button in the page is available; if the login user does not have the preset service authority, or no row in the page is selected, or the preset condition is not met, namely the login user has the preset service authority, the row in the page is selected, and any one of the three factors meeting the preset condition is not met, the button in the page is unavailable.
Further, in a specific implementation manner, the determining whether the login user has the preset service right includes:
matching the user role of the login user with the user role with the preset service authority; and if the matching is successful, the login user has a preset service authority.
Specifically, an include method can be used to determine whether the login user needs to have a preset service authority. If yes, the representation is successfully matched, and the current login user has the preset service authority. Wherein, a is a user role with factors and service authority, and role is a user role of the current login user. On the contrary, if _. include (a, role) is false, the token matching is not successful, and the current login user does not have the preset service authority.
S104: if the button in the page is available, setting the button in the page to be in an available state;
s105: and if the button in the page is unavailable, setting the button in the page to be in an unavailable state.
Specifically, when it is determined that a button in the page is available, the available button is set to the available state. In contrast, when it is judged that the button in the page is not available, it is set to the unavailable state.
In a specific embodiment, the setting of the button in the page to the available state includes:
the button in the page is illuminated.
Specifically, when a button in the page is not available, the button may be grayed out, and when html is judged to be available, the button is brightened.
It will be appreciated that in addition to the above embodiments, other ways of characterizing the availability or unavailability of a button may be used, and the present application is not limited thereto.
Referring to fig. 2, an embodiment provided by the present application is described below by taking a button above a node list page as an example:
and entering a node list, wherein buttons above pages of the node list are all gray. And finishing default loading of the configuration data of the use authority of each button above the node list page.
After a certain line in the node list page is selected, the watch method of the system detects that the line in the node list page is selected, and assigns values to preset conditions in the use permission of a button above the node list page. state1 represents node on status unavailable; state2 represents a node that is available in the on state. And further broadcasts state1 and state 2.
Once broadcast, the logic associated with the control button state is captured (via the on function) and the execution of the toggle disabled dBased OnState is initiated to draw the page (with the button grayed out or lit).
And the tokleDisabledBasedOnState internally calls the hasPermission method to match the user roles. And the set use authority cluster | edge | state1 of the start button is fetched for use.
Through role matching, the result of matching to HasParmission is true, which represents that the current login user has the use right of the start button above the node list page.
Then, the user returns to toggle disabledBasedOnState, after HasParission is judged to pass, the value of state1 is removed, and if state1 is false (button authority is judged to pass), the button is represented to be available. At the moment, the button can be lightened to become available through double-layer judgment.
As can be seen from fig. 3, after selecting one of the rows, the node is on according to the state shown in the third column, so the start button is grey (state1 is active) and the shutdown and restart buttons are bright (state2 is active).
In summary, the button permission control method provided by the present application configures service permissions for various user roles and configures use permissions for buttons, and on this basis, based on the service permissions corresponding to the user roles of the login user and the use permissions of the buttons in the page, determines whether the buttons in the page are available, and sets the buttons to be in an available state when the buttons are available, thereby implementing control of button-level permissions without conflict with menu-level permission control. Meanwhile, the authority control of the button authority control method provided by the application can not be influenced by module coding, and the button authority control method has low coupling. The method is easy to transplant and use in various angularjs systems, and has better universality.
The application also provides a button authority control device, and the device described below can be mutually and correspondingly referred to with the method described above. Referring to fig. 4, fig. 4 is a schematic diagram of a button authority control device according to an embodiment of the present application, and referring to fig. 4, the device includes:
the first configuration module 10 is used for configuring service permissions of various user roles;
a second configuration module 20 for configuring the usage right of the button;
the judging module 30 is configured to judge whether the button in the page is available according to the service permission corresponding to the user role of the login user and the usage permission of the button in the page;
a setting module 40, configured to set the button in the page to an available state if the button in the page is available.
On the basis of the foregoing embodiment, as a specific implementation manner, the second configuration module 20 is specifically configured to:
configuring the button to be available when a user has a preset service right; or configuring the button to be available when the user has a preset service authority and the row in the page is selected; or the button is configured to be available when the user has a preset service authority and meets a preset condition; or the button is configured to be available when the user has a preset service authority, and the row in the page is selected and meets a preset condition.
On the basis of the foregoing embodiment, as a specific implementation manner, the determining module 30 includes:
the first judging unit is used for judging whether the login user has the preset service authority or not if the use authority of the button is configured that the user has the preset service authority and the button is available;
the second judgment unit is used for judging whether the login user has the preset service authority and the row in the page is selected if the use authority of the button is configured that the user has the preset service authority and the row in the page is selected and the button is available;
a third judging unit, configured to judge whether the login user has the preset service authority and meets the preset condition if the use authority of the button is configured that the user has the preset service authority and meets the preset condition, and the button is available;
and the fourth judgment unit is used for judging whether the login user has the preset service authority and the row in the page is selected and meets the preset condition if the use authority of the button is configured to that the user has the preset service authority and the row in the page is selected and meets the preset condition if the button is available.
On the basis of the above embodiment, as a specific implementation manner, each judgment unit includes:
the matching subunit is used for matching the user role of the login user with the user role with the preset service authority; and if the matching is successful, the login user has the preset service authority.
On the basis of the foregoing embodiment, as a specific implementation manner, the setting module 40 is specifically configured to:
illuminating the button in the page.
The button authority control device provided by the application configures service authorities for various user roles and configures use authorities for buttons, on the basis, judges whether the buttons in the pages are available according to the service authorities corresponding to the user roles of login users and the use authorities of the buttons in the pages, and sets the buttons to be in an available state when the buttons are available, so that control of button-level authorities is realized, and the control of the button-level authorities is not in conflict with control of menu-level authorities. Meanwhile, the authority control of the button authority control method provided by the application can not be influenced by module coding, and the button authority control method has low coupling. The method is easy to transplant and use in various angularjs systems, and has better universality.
The present application also provides a button authority control device, as shown with reference to fig. 5, which includes a memory 1 and a processor 2.
A memory 1 for storing a computer program;
a processor 2 for executing a computer program to implement the steps of:
configuring service authority of various user roles; configuring the use authority of the button; judging whether the button in the page is available according to the service authority corresponding to the user role of the login user and the use authority of the button in the page; and if the button in the page is available, setting the button in the page to be in an available state.
For the introduction of the device provided in the present application, please refer to the above method embodiment, which is not described herein again.
The present application further provides a computer readable storage medium having a computer program stored thereon, which when executed by a processor, performs the steps of:
configuring service authority of various user roles; configuring the use authority of the button; judging whether the button in the page is available according to the service authority corresponding to the user role of the login user and the use authority of the button in the page; and if the button in the page is available, setting the button in the page to be in an available state.
The computer-readable storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
For the introduction of the computer-readable storage medium provided in the present application, please refer to the above method embodiments, which are not described herein again.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device, the apparatus and the computer-readable storage medium disclosed by the embodiments correspond to the method disclosed by the embodiments, so that the description is simple, and the relevant points can be referred to the description of the method.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The technical solutions provided by the present application are described in detail above. The principles and embodiments of the present application are explained herein using specific examples, which are provided only to help understand the method and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.