Skip to content

Commit

Permalink
Merge pull request #498 from COS301-SE-2023/dev/rollback_hotfixes
Browse files Browse the repository at this point in the history
Dev/rollback hotfixes -> codecov
  • Loading branch information
JanSpies82 authored Sep 27, 2023
2 parents 787d4d8 + 760278f commit 087fe86
Show file tree
Hide file tree
Showing 16 changed files with 228 additions and 45 deletions.
23 changes: 23 additions & 0 deletions backend/src/diffs/diffs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,27 @@ export class DiffsService {
},
);
}

///===-----------------------------------------------------

async resetTrailingDiffs(
nextDiffIndex: number,
markdownID: string,
) {
for (
let j = nextDiffIndex + 1;
j <
nextDiffIndex +
parseInt(process.env.DIFFS_PER_SNAPSHOT);
j++
) {
await this.diffRepository.update(
{
MarkdownID: markdownID,
S3DiffIndex: j,
},
{ HasBeenUsed: false },
);
}
}
}
4 changes: 0 additions & 4 deletions backend/src/s3/s3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ export class S3Service {
) {
const filePath = `${diffDTO.UserID}/${diffDTO.MarkdownID}`;

console.log(
'diffDTO.Content: ',
diffDTO.Content,
);
try {
await this.s3Client.send(
new PutObjectCommand({
Expand Down
21 changes: 21 additions & 0 deletions backend/src/version_control/version_control.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ export class VersionControlService {
saveDiffInfoDTO.nextSnapshotIndex,
);

console.log(
'nextDiffIndex: ',
saveDiffInfoDTO.nextDiffIndex,
);

if (
saveDiffInfoDTO.totalNumDiffs >=
parseInt(process.env.MAX_DIFFS) &&
saveDiffInfoDTO.nextDiffIndex %
parseInt(
process.env.DIFFS_PER_SNAPSHOT,
) ===
0
) {
console.log('resetting trailing diffs');
await this.diffService.resetTrailingDiffs(
saveDiffInfoDTO.nextDiffIndex,
diffDTO.MarkdownID,
);
}

///===----------------------------------------------------
// 4. Create DB and S3 references if they do not yet exist
// 5. Create diff references if nextDiff does not exist
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/app/camera/camera.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@
</div>

<div class="footer" [ngClass]="{ 'notVisible': !captured }">
<p-checkbox class="checkbox" [(ngModel)]="isAsset" [binary]="true" label="Extract Text"
styleClass="p-button-rounded"></p-checkbox>
<div style="display:flex; margin:auto">
<p-checkbox class="checkbox" [(ngModel)]="isAsset" [binary]="true" label="Extract Text"
styleClass="p-button-rounded" [disabled]="isTable"></p-checkbox>
<div style="width:20px"></div>
<p-checkbox class="checkbox" [(ngModel)]="isTable" [binary]="true" label="Extract Table"
styleClass="p-button-rounded" (click)="isAsset=isTable"></p-checkbox>
</div>
<input class="assetName" pInputText type="text" label="hi" title="Enter Asset Name" [(ngModel)]="assetName"
placeholder="Enter Asset Name" />
<p-button class="uploadImage" title="Upload Image" (click)="uploadImage()" styleClass="p-button-rounded">Upload
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/app/camera/camera.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ $top-bottom-color: #202221;
}

.footer {
display: flex;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
align-items: center;
background-color: $top-bottom-color;
margin-top: 10px;
min-height: 60px;
width: 100%;
justify-content: space-around;
}

.capture {
Expand Down Expand Up @@ -120,14 +120,17 @@ $top-bottom-color: #202221;
}

.assetName {
margin: auto 0;
margin: auto;
color: black;
width: 20svw;
min-width: 150px;
max-width: 39svw;
}

.uploadImage {
margin: auto 0;
margin: auto;
color: white;
width:150px;
max-width: 30svw;
}

Expand Down Expand Up @@ -185,4 +188,5 @@ $top-bottom-color: #202221;

.loadingIcon {
width: 10%;
min-width: 100px;
}
6 changes: 5 additions & 1 deletion frontend/src/app/camera/camera.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export class CameraComponent {
parentFolderId: string = '';
path: string = '';
isAsset: boolean = false;
isTable: boolean = false;
captured: boolean = false;
flipCamera: boolean = false;
cameraAvailable: boolean = false;
Expand Down Expand Up @@ -159,6 +160,9 @@ export class CameraComponent {
if (this.isAsset) {
format = 'text';
}
if (this.isTable) {
format = 'table';
}
this.loading = true;
await this.assetService
.uploadImage(
Expand Down Expand Up @@ -292,7 +296,7 @@ export class CameraComponent {
loadImageFailed() {
// show message
}

async cropImage(base64Image: string, left: number, top: number, right: number, bottom: number): Promise<string> {
return new Promise<string>((resolve, reject) => {
const image = new Image();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/edit/edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
title="Save Document"
>
<!-- Save -->
<img src="assets/Spinner/loading2.gif" alt="" />
<img src="assets/Spinner/loading2alt.gif" alt="" />
</div>
<!-- <div class="tool" (click)="delete()">
<img src="assets/Icons/editIcons/delete.png" alt="" />
Expand Down Expand Up @@ -412,7 +412,7 @@ <h4 *ngIf="sideBarTab" class="sidebarHeaderText">History</h4>
<img
*ngIf="obj.loading"
class="snapshotIcon"
src="assets/Spinner/loading2.gif"
src="assets/Spinner/loading2alt.gif"
alt=""
/>
<!-- <p>{{ obj.LastModified }}</p> -->
Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/edit/edit.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -863,4 +863,5 @@ Preserve the relative scale, though. */

.loadingIcon {
width: 10%;
min-width: 100px;
}
29 changes: 26 additions & 3 deletions frontend/src/app/edit/edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class EditComponent implements AfterViewInit, OnInit {
this.loading = true;
console.log("Current Object:\n", this.currentContextMenuObject);
let diffIndex = this.currentContextMenuObject.S3DiffIndex;
if (!diffIndex)
if (diffIndex !== 0 && !diffIndex)
diffIndex = this.currentContextMenuObject.ChildDiffs[0].S3DiffIndex;
if (await this.versioningApiService.restoreVersion(this.editService.getMarkdownID() as string, diffIndex, this.currentContextMenuObject.Content)) {
this.messageService.add({
Expand All @@ -170,10 +170,12 @@ export class EditComponent implements AfterViewInit, OnInit {
return;
}

this.versionControlService.setLatestVersionContent(this.currentContextMenuObject.Content);
this.editor.setData(this.currentContextMenuObject.Content);
this.editService.setContent(this.currentContextMenuObject.Content);
this.currentEditorContent = undefined;
this.refreshSidebarHistory();
this.disableReadOnly();
this.loading = false;
},
});
Expand All @@ -182,8 +184,29 @@ export class EditComponent implements AfterViewInit, OnInit {
{
label: 'Create a copy of this version',
icon: 'pi pi-copy',
command: () => {
console.log('Create a copy of this version');
command: async () => {
this.loading = true;
if(await this.fileService.createDocument(this.editService.getName()+'(copy)', this.editService.getPath(), this.editService.getParentFolderID()))
{
await this.fileService.saveDocument(this.currentContextMenuObject.Content, this.editService.getMarkdownID(), this.editService.getPath(), this.editService.getSafeLock());
this.messageService.add({
severity: 'success',
summary: 'Success',
detail: 'Version copied',
});
this.refreshSidebarHistory();
this.editService.setContent(this.currentContextMenuObject.Content);
this.editor.setData(this.currentContextMenuObject.Content);
this.fileName = this.editService.getName();
}
else
this.messageService.add({
severity: 'error',
summary: 'Error',
detail: 'Version not copied',
});
this.loading = false;

},
}
]
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/home/home.component.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

<div *ngIf="loading" class="loading-overlay">
<img class="loadingIcon" src="assets/Spinner/loading2.gif" title="Loading..." alt="Loading..." />
<img class="loadingIcon" src="assets/Spinner/loading2.gif" title="Loading..." alt="Loading..."/>
</div>

<div class="container" data-testid="home-page" (click)="unselectAll()">
<p-toast [breakpoints]="{'600px': {width: '300px'}, '350px': {width: '90%'}}"></p-toast>
<div class="header" >
<div (click)="navigateToPage('home')" class="logoWrapper">
<img alt="Home Page" class="logo" src="assets/Logos/WriteToPdf_Logo_white.png" />
<img alt="Home Page" class="logo" id="logo" src="assets/Logos/WriteToPdf_Logo_white.png" (click)="addCssClass()"/>
</div>
<div class="headerNavigation">
<div class="p-menubar custom-menubar" (click)="$event.stopPropagation()">
Expand Down
Loading

0 comments on commit 087fe86

Please sign in to comment.