Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(async () => {
var get = async(url, prop, dataless) => {
var data = (await (await fetch(url)).json());
if (!dataless) data = data.data;
var result = {};
data.forEach(element => {
result[element[prop]] = element;
});
return result;
}
let teams = await get('/rest/team', 'id')
let users = await get('/rest/user', 'id')
let roles = await get('/rest/role', 'id')
let permissions = await get('/rest/role/available-permissions', 'name', true)
var result = '';
var append = function(indent, text) {
result += ' '.repeat(indent) + text + '\n';
};
Object.values(teams).forEach(team => {
append(0, 'Equipe: ' + team.name);
append(1, 'Perspectivas:');
Object.values(team.perspectives).forEach(perspective => {
append(2, 'Pespectiva: ' + perspective.name);
});
append(1, 'Papéis:');
Object.values(team.roles).forEach(role => {
role = roles[role.id];
append(2, 'Papel: ' + role.name);
role.permissions.forEach(permission => {
var fullPermission = permissions[permission.toLowerCase()];
append(3, fullPermission && fullPermission.descriptions['pt_br'] || "unknown: " + permission);
});
});
append(1, 'Usuários:');
Object.values(team.users).forEach(user => {
user = users[user.id];
append(2, 'Usuário: ' + (user.name && user.name + ' (' +user.username + ')' || user.username));
append(3, 'Criado em: ' + (user.dateCreated && new Date(user.dateCreated).toLocaleString() || 'nunca'));
append(3, 'Último login: ' + (user.lastLogin && new Date(user.lastLogin).toLocaleString() || 'nunca'));
});
});
console.log(result);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.