User Manager expects a backend server to fetch data. You can provide a link to it by the url setting:
webix.ui({
view: "usermanager",
url: "https://docs.webix.com/usermanager-backend/"
});
User Manager will load and save data using the next URLs:
Sample backend for User Manager is available for downloading.
If you do not have a backend server, you can customize the methods of the Backend service and provide client-side data as a promise.
Backend service is a server-side model that contains methods for sending requests. They are called by the Operations service when data needs to be loaded or saved.
Check out the full list of methods below.
To change data requests, get and process the responses you can:
class MyBackend extends userManager.services.Backend {
// define and override methods here
}
webix.ui({
view: "usermanager",
url:"http://localhost:3200/",
override: new Map([
[userManager.services.Backend, MyBackend]
])
});
You can send AJAX requests to your server by using the needed URLs, e.g.:
Adding a user
class MyBackend extends userManager.services.Backend {
addUser(data) {
return webix.ajax().post("//localhost:3200/users", data)
.then(data => data.json());
}
}
If you need to fill User Manager with client-side data, you can return it as a promise like the following:
Client-side data
class MyBackend extends userManager.services.Backend {
users() {
return webix.promise.resolve(users);
}
roles() {
return webix.promise.resolve(roles);
}
rules() {
return webix.promise.resolve(rules);
}
}
Related sample: User Manager: Local Data
See the required format of the incoming data.
Below you can find descriptions of the following methods:
Is called for all data fetching operations. It issues a GET request for the defined path.
Parameters:
Returns: a promise that resolves with the data.
Is called for all data saving operations. It issues a POST/DELETE/PUT request with an application/json content type depending on user action.
Parameters:
Returns: a promise that resolves with a response data.
Is called upon widget initialization.
Returns: a promise that resolves with an array of user objects.
Request:
GET http://localhost:3200/users
Response:
The server returns an array of user objects.
[
{"id":87,"name":"Berni Mayour","email":"","details":"",
"visited":"2020-05-21T10:02:06Z","registered":"2020-05-21T10:02:06Z",
"avatar":"http://localhost:3200/users/87/avatar/503723673.jpg",
"status":1},
{"id":95,"name":"John Doe","email":"","details":"",
"visited":"2020-05-31T17:21:12Z","registered":"2020-05-31T17:21:12Z",
"avatar":"","status":0}
]
Adds new user.
Parameters:
Returns: a promise that resolves with the user object ID.
Request:
POST http://localhost:3200/users
Request Payload
name: "Walter Scott"
Response:
The server returns the user object ID.
{"id":99}
Deletes a specified user.
Parameters:
Returns: a promise that resolves with a user object ID.
Request:
DELETE http://localhost:3200/users/98
Response:
The server returns the user object ID.
{"id":98}
Updates a specified user.
Parameters:
Returns: a promise that resolves with the user object ID.
Request:
PUT http://localhost:3200/users/99
Request Payload
avatar: ""
details: ""
email: "elly.soyer@example.com"
id: 98
name: "Elly Soyer"
registered: "2020-05-31T17:42:34Z"
status: 1
visited: "2020-05-31T17:42:34Z"
Response:
The server returns the user object ID.
{"id":98}
Is called when user opens the roles list.
Returns: a promise that resolves with an array of role objects.
Request:
GET http://localhost:3200/roles
Response:
The server returns an array of role objects.
[
{"id":1,"name":"The Creator","color":"#00a037","details":""},
{"id":2,"name":"Sales","color":"#e7a90b","details":""},
{"id":3,"name":"Admin","color":"#038cd9","details":""}
]
Adds new role.
Parameters:
Returns: a promise that resolves with the role object ID.
Request:
POST http://localhost:3200/roles
Request Payload
name: "Manager"
Response:
The server returns the role object ID.
{"id":5}
Deletes a specified role.
Parameters:
Returns: a promise that resolves with the role object ID.
Request:
DELETE http://localhost:3200/roles/3
Response:
The server returns the role object ID.
{"id":3}
Updates a specified role.
Parameters:
Returns: a promise that resolves with the role object ID.
Request:
PUT http://localhost:3200/roles/7
Request Payload
color: "#006EDD"
details: ""
id: 7
name: "Designer"
rules: [7, 1]
Response:
The server returns the role object ID.
{"id":7}
Is called when user opens rules list.
Returns: a promise that resolves with an array of the rule objects.
Request:
GET http://localhost:3200/rules
Response:
The server returns an array of rule objects.
[
{"id":1,"short":"CanSeeUsers","long":"Can see user details and access levels"},
{"id":2,"short":"CanEditUsers","long":"Can modify user details and access levels"},
{"id":3,"short":"CanAdminProjects","long":"Can create projects"}
]
Is called when user opens the audit tab.
Returns: a promise that resolves with an object of the category relations.
Request:
GET http://localhost:3200/meta
Response:
The server returns an object containing information on how the categories are related to one another. The structure is as follows:
{
"RoleRule":[[3,1]],
"UserRole":[[4,3]], // a user with ID 4 has a role with ID 3
"UserRule":[[2,6]]
}
Is called when user uploads a new avatar.
Parameters:
Returns: an object with the avatar data.
Request:
POST http://localhost:3200/users/95/avatar
Response:
The server returns an object with information about uploaded avatar.
{
"status":"server",
"value":"http://localhost:3200/users/95/avatar/photo.jpg"
}
Is called when user goes to the edit area.
Parameters:
Returns: a promise that resolves with an array of user credentials.
Request:
GET http://localhost:3200/user/87/credentials
Adds a credential to the user.
Parameters:
Returns: a promise that resolves with the user object ID.
Request:
POST http://localhost:3200/user/100/credentials
Request Payload
record: "test"
source: 1
user_id: 100
Response:
The server returns the user object ID.
{"id":100}
Is called upon resetting user password.
Parameters:
Returns: a promise that resolves with the user object ID.
Request:
PUT http://localhost:3200/user/100/credentials
Request Payload
id: 23
record: "qwerty123"
Response:
The server returns the user object ID.
{"id":100}
Is called when user deletes credentials.
Parameters:
Returns: a promise that resolves with the credential object ID.
Request:
DELETE http://localhost:3200/user/100/credentials/23
Contains the URL segments, the ID of the user and the ID of the credential.
Response:
The server returns the credential object ID.
{"id":23}
Is called when user go to the audit area and triggers one of the records (logins, changes to or changes by).
Parameters:
Returns: a promise that resolves with an array of audit objects.
Request:
GET http://localhost:3200/logs/by-user/100
Contains the URL segment, type of the record and the user's ID.
Response:
The server returns an array of audit objects. Below it is audit for the changes to record.
[
{"id":506,"user_id":1,"target_id":87,"type":5,
"details":"Berni Mayour","date":"2020-05-21T10:02:06Z"},
{"id":524,"user_id":1,"target_id":87,"type":6,
"details":"role Guest added","date":"2020-05-21T14:36:56Z"}
]
Is called when user goes to the audit area.
Returns: a promise that resolves with an array of the actions performed in User Manager.
Request:
GET http://localhost:3200/logs/meta
Response:
The server returns an object containing the audit of the actions performed in User Manager.
{
"1":{"name":"User login","target":"user"},
"2":{"name":"Role added","target":"role"},
"3":{"name":"Role data changed","target":"role"},
}
Back to top