Created
February 16, 2022 17:02
-
-
Save hoadh/a2e49f91964aed2de581117869155f3c to your computer and use it in GitHub Desktop.
nothing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<script> | |
let menu = { | |
"success": true, | |
"data": [ | |
{ | |
"id": 1, | |
"title": "Super Admin", | |
"key": "*", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Super Admin", | |
"group_id": 0, | |
"ability_key": "*" | |
}, | |
{ | |
"id": 2, | |
"title": "Tạo tài khoản mới", | |
"key": "user-create", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Tài khoản", | |
"group_id": 1, | |
"ability_key": "user-create" | |
}, | |
{ | |
"id": 3, | |
"title": "Reset mật khẩu", | |
"key": "password-reset", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Tài khoản", | |
"group_id": 1, | |
"ability_key": "password-reset" | |
}, | |
{ | |
"id": 4, | |
"title": "Sửa tài khoản", | |
"key": "user-update", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Tài khoản", | |
"group_id": 1, | |
"ability_key": "user-update" | |
}, | |
{ | |
"id": 5, | |
"title": "Tạo nhóm người dùng", | |
"key": "role-create", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Tài khoản", | |
"group_id": 1, | |
"ability_key": "role-create" | |
}, | |
{ | |
"id": 6, | |
"title": "Sửa nhóm người dùng", | |
"key": "role-update", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Tài khoản", | |
"group_id": 1, | |
"ability_key": "role-update" | |
}, | |
{ | |
"id": 7, | |
"title": "Tạo dịch vụ mới", | |
"key": "service-create", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Quản trị dịch vụ", | |
"group_id": 2, | |
"ability_key": "service-create" | |
}, | |
{ | |
"id": 8, | |
"title": "Sửa dịch vụ", | |
"key": "service-update", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Quản trị dịch vụ", | |
"group_id": 2, | |
"ability_key": "service-update" | |
}, | |
{ | |
"id": 9, | |
"title": "Tạo công trình", | |
"key": "construction-create", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Công trình", | |
"group_id": 3, | |
"ability_key": "construction-create" | |
}, | |
{ | |
"id": 10, | |
"title": "Sửa công trình", | |
"key": "construction-update", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Công trình", | |
"group_id": 3, | |
"ability_key": "construction-update" | |
}, | |
{ | |
"id": 11, | |
"title": "Thêm lịch sử dịch vụ", | |
"key": "service-history-add", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Công trình", | |
"group_id": 3, | |
"ability_key": "service-history-add" | |
}, | |
{ | |
"id": 12, | |
"title": "Cập nhật trạng thái", | |
"key": "status-update", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Công trình", | |
"group_id": 3, | |
"ability_key": "status-update" | |
}, | |
{ | |
"id": 13, | |
"title": "Báo cáo công trình", | |
"key": "construction-report", | |
"created_at": "2022-02-16T12:33:55.000000Z", | |
"updated_at": null, | |
"group_name": "Công trình", | |
"group_id": 3, | |
"ability_key": "construction-report" | |
} | |
] | |
}; | |
let view = {}; | |
menu.data.forEach((item) => { | |
if (!(item.group_name in view)) { | |
view[item.group_name] = []; | |
} | |
view[item.group_name].push(item); | |
}); | |
console.log(view); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment