This document provides an overview of the Admin functionality in the application, covering various components such as Users, Articles, Dashboard, Rss, and Settings. Each component is documented with details about its features, state, functions, and render.
The Users component is a React.js User Management component that allows you to view, add, edit, promote/demote, and delete users. The component includes features like searching for users, filtering users by permission type, and pagination.
- View Users: Displays a list of users with their username, email, and permission type (Admin/User).
- Search Users: Allows you to search for users by username or email.
- Filter Users: Filters the displayed users by permission type (All/Admin).
- Add Users: A modal dialog allows you to input a new user's username, email, password, and permission type.
- Edit Users: Edit an existing user's username, email, and permission type.
- Promote/Demote Users: Change a user's permission type between Admin and User.
- Delete Users: Remove a user from the list after confirming the action through a modal dialog.
- Pagination: Displays a limited number of users per page, with pagination controls for navigation.
- React.js
- Bootstrap
- react-bootstrap
- react-toastify
GET http://127.0.0.1:4444/api/getUsers
: Fetches a list of all users.POST http://127.0.0.1:4444/api/addUser
: Adds a new user.PUT http://127.0.0.1:4444/api/updateUser/:id
: Updates an existing user.DELETE http://127.0.0.1:4444/api/deleteUser/:id
: Deletes a user.
To use this User Management component, include it in your desired React.js application and ensure all dependencies are installed.
The Articles
component is a React component that displays a list of articles. It allows the user to filter the articles by title or description, add a new article, and edit an existing article. The component uses the useState and useEffect hooks from React to manage the state of the component.
articles
: an array of objects that represent the articles. Each article object has the following properties:id
: a unique identifier for the article.title
: the title of the article.description
: a brief description of the article.image
: the URL of the image associated with the article.
showForm
: a boolean that indicates whether the form for adding a new article is visible or not.newArticle
: an object that represents the new article being added. It has the following properties:title
: the title of the article.description
: a brief description of the article.image
: the URL of the image associated with the article.
filterText
: a string that represents the text used to filter the articles.
handleFormChange
: a function that handles changes in the input fields of the form for adding a new article. It updates thenewArticle
state object with the new values entered by the user.handleFormSubmit
: a function that handles the submission of the form for adding a new article. It adds the new article to thearticles
array and resets thenewArticle
state object to its default values.handleEdit
: a function that handles the editing of an existing article. It is a placeholder function that logs a message to the console with the ID of the article being edited.handleFilterChange
: a function that handles changes in the input field used for filtering the articles. It updates thefilterText
state object with the new value entered by the user.
The Articles
component renders a container div that holds the following elements:
- A form group that contains an input field for filtering the articles by title or description.
- A button for adding a new article. Clicking this button shows a form that allows the user to enter the details of the new article.
- A div that contains the filtered articles as a list of cards. Each card displays the image, title, and description of an article. Clicking the "Read More" button opens the article in a new page. Clicking the "Edit" button logs a message to the console with the ID of the article being edited.
The Dashboard
component is a React component that displays a simple dashboard. It renders a container div with a single row that contains a single column. The column displays a heading with the text "Dashboard".
None.
None.
The Dashboard
component renders a container div that holds a single row with a single column that displays the heading "Dashboard". The component uses the Bootstrap CSS framework for styling.
The Rss
component is a React component that allows users to manage RSS feeds. It provides a form for adding new feeds and a table for listing existing feeds. Each row of the table displays the feed URL and three buttons: "Edit", "Delete", and "Refresh". The component also uses the react-toastify
library to display success and error messages when adding, editing, deleting, or refreshing feeds.
feeds
: an array of strings representing the list of RSS feeds.newFeed
: a string representing the value of the input field in the form for adding new feeds.feedStatus
: an object with the same keys asfeeds
and values that represent the status of each feed (e.g.,{http://example.com/rss.xml: {loading: true, status: "loading"}}
)
handleAddFeed
: a function that handles the submission of the form for adding new feeds. It adds the new feed to thefeeds
array and sets its initial status in thefeedStatus
object.handleDeleteFeed
: a function that handles the deletion of a feed. It removes the feed from thefeeds
array and its status from thefeedStatus
object.handleEditFeed
: a function that handles the editing of a feed. It prompts the user to enter a new URL for the feed and updates thefeeds
array and thefeedStatus
object accordingly.handleRefreshFeed
: a function that handles the refreshing of a feed. It sends an HTTP request to the feed URL and updates the status of the feed in thefeedStatus
object based on the response.
The Rss
component renders a container div that holds a form for adding new feeds and a table for displaying the existing feeds. The form includes an input field for entering the URL of the new feed and a button for submitting the form. The table includes two columns: one for the feed URL and one for the buttons. The buttons include "Edit", "Delete", and "Refresh". The component also includes a ToastContainer
component from the react-toastify
library for displaying success and error messages.