Merge remote-tracking branch 'origin/dev' into gruppPP
This commit is contained in:
commit
99eb5f17b5
9 changed files with 333 additions and 5 deletions
|
|
@ -269,7 +269,32 @@ interface API {
|
|||
getStatistics(
|
||||
projectName: string,
|
||||
token: string,
|
||||
userName?: string,
|
||||
): Promise<APIResponse<Statistics>>;
|
||||
|
||||
/**
|
||||
* Changes the name of a project
|
||||
* @param {string} projectName The name of the project
|
||||
* @param {string} newProjectName The new name of the project
|
||||
* @param {string} token The authentication token
|
||||
*/
|
||||
changeProjectName(
|
||||
projectName: string,
|
||||
newProjectName: string,
|
||||
token: string,
|
||||
): Promise<APIResponse<string>>;
|
||||
|
||||
/**
|
||||
* Changes the password of a user
|
||||
* @param {string} username The username of the user
|
||||
* @param {string} newPassword The new password
|
||||
* @param {string} token The authentication token
|
||||
*/
|
||||
changeUserPassword(
|
||||
username: string,
|
||||
newPassword: string,
|
||||
token: string,
|
||||
): Promise<APIResponse<string>>;
|
||||
}
|
||||
|
||||
/** An instance of the API */
|
||||
|
|
@ -981,10 +1006,11 @@ export const api: API = {
|
|||
async getStatistics(
|
||||
token: string,
|
||||
projectName: string,
|
||||
userName?: string,
|
||||
): Promise<APIResponse<Statistics>> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/getStatistics/?projectName=${projectName}`,
|
||||
`/api/getStatistics/?projectName=${projectName}&userName=${userName ?? ""}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
|
@ -1004,4 +1030,58 @@ export const api: API = {
|
|||
return { success: false, message: "Failed to get statistics" };
|
||||
}
|
||||
},
|
||||
|
||||
async changeProjectName(
|
||||
projectName: string,
|
||||
newProjectName: string,
|
||||
token: string,
|
||||
): Promise<APIResponse<string>> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/changeProjectName/${projectName}?newProjectName=${newProjectName}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + token,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
return { success: false, message: "Failed to change project name" };
|
||||
} else {
|
||||
return { success: true, message: "Project name changed" };
|
||||
}
|
||||
} catch (e) {
|
||||
return { success: false, message: "Failed to change project name" };
|
||||
}
|
||||
},
|
||||
|
||||
async changeUserPassword(
|
||||
username: string,
|
||||
newPassword: string,
|
||||
token: string,
|
||||
): Promise<APIResponse<string>> {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/api/changePassword/${username}?newPassword=${newPassword}`,
|
||||
{
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: "Bearer " + token,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
return { success: false, message: "Failed to change password" };
|
||||
} else {
|
||||
return { success: true, message: "Password changed" };
|
||||
}
|
||||
} catch (e) {
|
||||
return { success: false, message: "Failed to change password" };
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue