cp
This commit is contained in:
parent
98b6bd9313
commit
d193f05974
@ -11,7 +11,9 @@ async function loadApiKeys() {
|
|||||||
container.innerHTML = '<div class="text-center"><div class="loading-spinner"></div> Loading API keys...</div>';
|
container.innerHTML = '<div class="text-center"><div class="loading-spinner"></div> Loading API keys...</div>';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const apiKeys = await apiClient.getApiKeys();
|
const response = await apiClient.getApiKeys();
|
||||||
|
// Handle structured response - extract api_keys array from response object
|
||||||
|
const apiKeys = response.api_keys || response;
|
||||||
displayApiKeys(apiKeys);
|
displayApiKeys(apiKeys);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleApiError(error, 'loading API keys');
|
handleApiError(error, 'loading API keys');
|
||||||
@ -252,7 +254,9 @@ async function copyApiKey(key) {
|
|||||||
// View API key details
|
// View API key details
|
||||||
async function viewApiKey(keyId) {
|
async function viewApiKey(keyId) {
|
||||||
try {
|
try {
|
||||||
const apiKeys = await apiClient.getApiKeys();
|
const response = await apiClient.getApiKeys();
|
||||||
|
// Handle structured response - extract api_keys array from response object
|
||||||
|
const apiKeys = response.api_keys || response;
|
||||||
const apiKey = apiKeys.find(k => k.id === keyId);
|
const apiKey = apiKeys.find(k => k.id === keyId);
|
||||||
|
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
|
|||||||
@ -16,9 +16,11 @@ async function loadImages(page = 1, tags = null) {
|
|||||||
try {
|
try {
|
||||||
const response = await apiClient.getImages(page, 20, tags);
|
const response = await apiClient.getImages(page, 20, tags);
|
||||||
currentPage = page;
|
currentPage = page;
|
||||||
totalPages = Math.ceil(response.total / response.limit);
|
totalPages = Math.ceil(response.total / (response.limit || 20));
|
||||||
|
|
||||||
displayImages(response.images);
|
// Handle structured response - extract images array from response object
|
||||||
|
const images = response.images || response;
|
||||||
|
displayImages(images);
|
||||||
displayPagination(response);
|
displayPagination(response);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleApiError(error, 'loading images');
|
handleApiError(error, 'loading images');
|
||||||
|
|||||||
@ -11,7 +11,9 @@ async function loadTeams() {
|
|||||||
container.innerHTML = '<div class="text-center"><div class="loading-spinner"></div> Loading teams...</div>';
|
container.innerHTML = '<div class="text-center"><div class="loading-spinner"></div> Loading teams...</div>';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const teams = await apiClient.getTeams();
|
const response = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = response.teams || response;
|
||||||
displayTeams(teams);
|
displayTeams(teams);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleApiError(error, 'loading teams');
|
handleApiError(error, 'loading teams');
|
||||||
@ -147,7 +149,9 @@ async function createTeam() {
|
|||||||
// View team details
|
// View team details
|
||||||
async function viewTeam(teamId) {
|
async function viewTeam(teamId) {
|
||||||
try {
|
try {
|
||||||
const teams = await apiClient.getTeams();
|
const response = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = response.teams || response;
|
||||||
const team = teams.find(t => t.id === teamId);
|
const team = teams.find(t => t.id === teamId);
|
||||||
|
|
||||||
if (!team) {
|
if (!team) {
|
||||||
@ -198,7 +202,9 @@ async function viewTeam(teamId) {
|
|||||||
// Load team member count
|
// Load team member count
|
||||||
async function loadTeamMemberCount(teamId) {
|
async function loadTeamMemberCount(teamId) {
|
||||||
try {
|
try {
|
||||||
const users = await apiClient.getUsers();
|
const response = await apiClient.getUsers();
|
||||||
|
// Handle structured response - extract users array from response object
|
||||||
|
const users = response.users || response;
|
||||||
const teamMembers = users.filter(user => user.team_id === teamId);
|
const teamMembers = users.filter(user => user.team_id === teamId);
|
||||||
document.getElementById('teamMemberCount').textContent = teamMembers.length;
|
document.getElementById('teamMemberCount').textContent = teamMembers.length;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -209,7 +215,9 @@ async function loadTeamMemberCount(teamId) {
|
|||||||
// Edit team
|
// Edit team
|
||||||
async function editTeam(teamId) {
|
async function editTeam(teamId) {
|
||||||
try {
|
try {
|
||||||
const teams = await apiClient.getTeams();
|
const response = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = response.teams || response;
|
||||||
const team = teams.find(t => t.id === teamId);
|
const team = teams.find(t => t.id === teamId);
|
||||||
|
|
||||||
if (!team) {
|
if (!team) {
|
||||||
|
|||||||
@ -11,7 +11,9 @@ async function loadUsers() {
|
|||||||
container.innerHTML = '<div class="text-center"><div class="loading-spinner"></div> Loading users...</div>';
|
container.innerHTML = '<div class="text-center"><div class="loading-spinner"></div> Loading users...</div>';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const users = await apiClient.getUsers();
|
const response = await apiClient.getUsers();
|
||||||
|
// Handle structured response - extract users array from response object
|
||||||
|
const users = response.users || response;
|
||||||
displayUsers(users);
|
displayUsers(users);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleApiError(error, 'loading users');
|
handleApiError(error, 'loading users');
|
||||||
@ -102,7 +104,9 @@ function displayUsers(users) {
|
|||||||
// Load team names for display
|
// Load team names for display
|
||||||
async function loadTeamNames() {
|
async function loadTeamNames() {
|
||||||
try {
|
try {
|
||||||
const teams = await apiClient.getTeams();
|
const response = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = response.teams || response;
|
||||||
teams.forEach(team => {
|
teams.forEach(team => {
|
||||||
const teamBadges = document.querySelectorAll(`#team-${team.id}`);
|
const teamBadges = document.querySelectorAll(`#team-${team.id}`);
|
||||||
teamBadges.forEach(badge => {
|
teamBadges.forEach(badge => {
|
||||||
@ -117,7 +121,9 @@ async function loadTeamNames() {
|
|||||||
// Show create user modal
|
// Show create user modal
|
||||||
async function showCreateUserModal() {
|
async function showCreateUserModal() {
|
||||||
try {
|
try {
|
||||||
const teams = await apiClient.getTeams();
|
const response = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = response.teams || response;
|
||||||
|
|
||||||
const modalBody = `
|
const modalBody = `
|
||||||
<form id="createUserForm">
|
<form id="createUserForm">
|
||||||
@ -227,7 +233,9 @@ async function createUser() {
|
|||||||
// View user details
|
// View user details
|
||||||
async function viewUser(userId) {
|
async function viewUser(userId) {
|
||||||
try {
|
try {
|
||||||
const users = await apiClient.getUsers();
|
const usersResponse = await apiClient.getUsers();
|
||||||
|
// Handle structured response - extract users array from response object
|
||||||
|
const users = usersResponse.users || usersResponse;
|
||||||
const user = users.find(u => u.id === userId);
|
const user = users.find(u => u.id === userId);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -235,7 +243,9 @@ async function viewUser(userId) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const teams = await apiClient.getTeams();
|
const teamsResponse = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = teamsResponse.teams || teamsResponse;
|
||||||
const userTeam = teams.find(t => t.id === user.team_id);
|
const userTeam = teams.find(t => t.id === user.team_id);
|
||||||
|
|
||||||
const modalBody = `
|
const modalBody = `
|
||||||
@ -287,7 +297,9 @@ async function viewUser(userId) {
|
|||||||
// Edit user
|
// Edit user
|
||||||
async function editUser(userId) {
|
async function editUser(userId) {
|
||||||
try {
|
try {
|
||||||
const users = await apiClient.getUsers();
|
const usersResponse = await apiClient.getUsers();
|
||||||
|
// Handle structured response - extract users array from response object
|
||||||
|
const users = usersResponse.users || usersResponse;
|
||||||
const user = users.find(u => u.id === userId);
|
const user = users.find(u => u.id === userId);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@ -295,7 +307,9 @@ async function editUser(userId) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const teams = await apiClient.getTeams();
|
const teamsResponse = await apiClient.getTeams();
|
||||||
|
// Handle structured response - extract teams array from response object
|
||||||
|
const teams = teamsResponse.teams || teamsResponse;
|
||||||
|
|
||||||
const modalBody = `
|
const modalBody = `
|
||||||
<form id="editUserForm">
|
<form id="editUserForm">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user