Added file disable feature
- Redesigned login page
This commit is contained in:
parent
1462e141ad
commit
5f3304674f
@ -100,7 +100,16 @@
|
|||||||
<td>{{ file.fileName }}</td>
|
<td>{{ file.fileName }}</td>
|
||||||
<td>{{ file.fileSize | formatFileSizePipe }}</td>
|
<td>{{ file.fileSize | formatFileSizePipe }}</td>
|
||||||
<td>{{ file.singleDownload ? 'true' : 'false' }}</td>
|
<td>{{ file.singleDownload ? 'true' : 'false' }}</td>
|
||||||
<td>{{ file.disabled ? 'true' : 'false' }}</td>
|
<td>
|
||||||
|
<div class="flex flex-row justify-center">
|
||||||
|
{{ file.disabled ? 'true' : 'false' }}
|
||||||
|
<button class="ms-2 btn btn-xs" (click)="disableFile(file.fileId)">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-ban" viewBox="0 0 16 16">
|
||||||
|
<path d="M15 8a6.97 6.97 0 0 0-1.71-4.584l-9.874 9.875A7 7 0 0 0 15 8M2.71 12.584l9.874-9.875a7 7 0 0 0-9.874 9.874ZM16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
<td>{{ file.uploadDate | date: 'medium' }}</td>
|
<td>{{ file.uploadDate | date: 'medium' }}</td>
|
||||||
<td>{{ file.uploadedByIpAddress }}</td>
|
<td>{{ file.uploadedByIpAddress }}</td>
|
||||||
<td>{{ file.downloadCount }}</td>
|
<td>{{ file.downloadCount }}</td>
|
||||||
|
@ -137,7 +137,7 @@ export class AdminuiComponent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.statistics = response.data;
|
this.statistics = response.data;
|
||||||
console.log(this.statistics)
|
//console.log(this.statistics)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
@ -152,7 +152,26 @@ export class AdminuiComponent {
|
|||||||
'Authorization': 'Bearer ' + await firstValueFrom(this.authStore.token$)
|
'Authorization': 'Bearer ' + await firstValueFrom(this.authStore.token$)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log(this.statistics)
|
console.log(response.data)
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async disableFile(fileId: string) {
|
||||||
|
try {
|
||||||
|
const response = await axios({
|
||||||
|
method: 'put',
|
||||||
|
url: this.developmentStore.getBaseUrl() + 'api/v1/secure/files/disable',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer ' + await firstValueFrom(this.authStore.token$)
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
fileId: fileId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.log(response.data)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="container mx-auto p-4 mt-20">
|
<div class="container mx-auto p-4 mt-20">
|
||||||
<div class="bg-white shadow-lg rounded-lg p-10 w-full max-w-xl mx-auto">
|
<div class="bg-white shadow-lg rounded-lg p-10 w-full max-w-xl mx-auto">
|
||||||
<h2 class="text-3xl font-bold text-gray-800 mb-6 text-center">Login to SharePulse</h2>
|
<h2 class="text-3xl font-bold text-gray-800 mb-10 text-center">Login to SharePulse</h2>
|
||||||
<form>
|
<form class="mb-10">
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<label class="block text-gray-700 text-sm font-bold mb-2 text-center" for="username">
|
<label class="block text-gray-700 text-sm font-bold mb-2 text-center" for="username">
|
||||||
Username
|
Username
|
||||||
@ -19,7 +19,7 @@
|
|||||||
[ngClass]="{'input-error': loginFailed}"
|
[ngClass]="{'input-error': loginFailed}"
|
||||||
(keydown.enter)="tryToLogin()">
|
(keydown.enter)="tryToLogin()">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-5">
|
<div class="mb-10">
|
||||||
<label class="flex items-center justify-center tooltip" data-tip="Storing login sessions is not functional yet">
|
<label class="flex items-center justify-center tooltip" data-tip="Storing login sessions is not functional yet">
|
||||||
<input type="checkbox" class="toggle" checked name="keepSignedIn"/>
|
<input type="checkbox" class="toggle" checked name="keepSignedIn"/>
|
||||||
<span class="ml-2 text-gray-700">Keep me signed in</span>
|
<span class="ml-2 text-gray-700">Keep me signed in</span>
|
||||||
|
@ -49,14 +49,10 @@ export class LoginComponent {
|
|||||||
this.authStore.setToken(response.data.token);
|
this.authStore.setToken(response.data.token);
|
||||||
this.authStore.setUsername(this.inputUsername);
|
this.authStore.setUsername(this.inputUsername);
|
||||||
|
|
||||||
console.log("Login successful");
|
|
||||||
console.log("Token: " + await firstValueFrom(this.authStore.token$));
|
|
||||||
console.log("Username: " + await firstValueFrom(this.authStore.username$));
|
|
||||||
|
|
||||||
//timeout
|
//timeout
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.router.navigate(['/secure/administration']);
|
this.router.navigate(['/secure/administration']);
|
||||||
}, 1000);
|
}, 500);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package de.w665.sharepulse.rest.mappings;
|
package de.w665.sharepulse.rest.mappings;
|
||||||
|
|
||||||
import de.w665.sharepulse.SharepulseApplication;
|
import de.w665.sharepulse.SharepulseApplication;
|
||||||
|
import de.w665.sharepulse.db.repo.FileUploadRepository;
|
||||||
import de.w665.sharepulse.db.repo.UserLoginRepository;
|
import de.w665.sharepulse.db.repo.UserLoginRepository;
|
||||||
import de.w665.sharepulse.db.repo.UserRepository;
|
import de.w665.sharepulse.db.repo.UserRepository;
|
||||||
import de.w665.sharepulse.model.FileUpload;
|
import de.w665.sharepulse.model.FileUpload;
|
||||||
import de.w665.sharepulse.model.User;
|
import de.w665.sharepulse.model.User;
|
||||||
import de.w665.sharepulse.rest.SecureApiRestController;
|
import de.w665.sharepulse.rest.SecureApiRestController;
|
||||||
|
import de.w665.sharepulse.rest.ro.FileDeleteRequest;
|
||||||
import de.w665.sharepulse.rest.ro.UserEditRequest;
|
import de.w665.sharepulse.rest.ro.UserEditRequest;
|
||||||
import de.w665.sharepulse.service.AuthenticationService;
|
import de.w665.sharepulse.service.AuthenticationService;
|
||||||
import de.w665.sharepulse.service.FileCleanupService;
|
import de.w665.sharepulse.service.FileCleanupService;
|
||||||
@ -27,12 +29,14 @@ public class Administration extends SecureApiRestController {
|
|||||||
private final AuthenticationService authenticationService;
|
private final AuthenticationService authenticationService;
|
||||||
private final FileCleanupService fileCleanupService;
|
private final FileCleanupService fileCleanupService;
|
||||||
private final UserLoginRepository userLoginRepository;
|
private final UserLoginRepository userLoginRepository;
|
||||||
|
private final FileUploadRepository fileUploadRepository;
|
||||||
|
|
||||||
public Administration(UserRepository userRepository, AuthenticationService authenticationService, FileCleanupService fileCleanupService, UserLoginRepository userLoginRepository) {
|
public Administration(UserRepository userRepository, AuthenticationService authenticationService, FileCleanupService fileCleanupService, UserLoginRepository userLoginRepository, FileUploadRepository fileUploadRepository) {
|
||||||
this.userRepository = userRepository;
|
this.userRepository = userRepository;
|
||||||
this.authenticationService = authenticationService;
|
this.authenticationService = authenticationService;
|
||||||
this.fileCleanupService = fileCleanupService;
|
this.fileCleanupService = fileCleanupService;
|
||||||
this.userLoginRepository = userLoginRepository;
|
this.userLoginRepository = userLoginRepository;
|
||||||
|
this.fileUploadRepository = fileUploadRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/statistics")
|
@GetMapping("/statistics")
|
||||||
@ -107,4 +111,16 @@ public class Administration extends SecureApiRestController {
|
|||||||
List<FileUpload> files = fileCleanupService.deleteFiles();
|
List<FileUpload> files = fileCleanupService.deleteFiles();
|
||||||
return ResponseEntity.ok(files);
|
return ResponseEntity.ok(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PutMapping("/files/disable")
|
||||||
|
public ResponseEntity<Object> disableFileUploads(@RequestBody FileDeleteRequest fdr, HttpServletRequest request) {
|
||||||
|
Optional<FileUpload> optionalFileUpload = fileUploadRepository.retrieveFileUploadByFileId(fdr.getFileId());
|
||||||
|
if(optionalFileUpload.isEmpty()) {
|
||||||
|
return ResponseEntity.badRequest().body("File not found");
|
||||||
|
}
|
||||||
|
FileUpload fileUpload = optionalFileUpload.get();
|
||||||
|
fileUpload.setDisabled(true);
|
||||||
|
fileUploadRepository.updateFileUpload(fileUpload);
|
||||||
|
return ResponseEntity.ok("File " + fdr.getFileId() + " disabled successfully.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package de.w665.sharepulse.rest.ro;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class FileDeleteRequest {
|
||||||
|
private String fileId;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user