Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix load ipfs documents #4087

Merged
merged 22 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions api-gateway/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { IAuthUser, PinoLogger } from '@guardian/common';
import { IOwner, PolicyHelper, UserRole } from '@guardian/interfaces';
import { PolicyEngine } from './policy-engine.js';

interface MessageError extends Error {
code: number;
}

/**
* Find all field values in object by field name
* @param obj
Expand Down Expand Up @@ -91,14 +95,18 @@ export const ONLY_SR = ' Only users with the Standard Registry role are allowed
* @param error
* @param logger
*/
export async function InternalException(error: HttpException | Error | string, logger: PinoLogger) {
export async function InternalException(error: HttpException | string | MessageError, logger: PinoLogger) {
await logger.error(error, ['API_GATEWAY']);
if (error instanceof HttpException) {
throw error;
} else if (typeof error === 'string') {
throw new HttpException(error, HttpStatus.INTERNAL_SERVER_ERROR);
} else {
throw new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR);
if (error.code) {
throw new HttpException(error.message, error.code);
} else {
throw new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR);
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
}

.stepper-steps-container {
overflow: auto;
overflow: auto;
position: relative;
}

Expand All @@ -25,8 +25,8 @@
//}

.stepper-steps {
border-radius: 8px;
border: 1px solid var(--color-grey-3);
border-radius: 8px;
border: 1px solid var(--color-grey-3);
}

.stepper-view-container {
Expand All @@ -35,17 +35,17 @@
display: flex;
align-items: center;
flex-direction: column;
margin-left: 24px;
margin-left: 24px;
}

.stepper-view-content {
width: 100%;
overflow-y: scroll;
position: relative;
box-sizing: border-box;
padding: 24px;
border-radius: 8px;
border: 1px solid var(--color-grey-3);
padding: 24px;
border-radius: 8px;
border: 1px solid var(--color-grey-3);
}

.stepper-view-header {
Expand All @@ -68,12 +68,12 @@
}

.title-label {
color: var(--color-grey-black-1);
font-family: Merriweather Sans, sans-serif;
color: var(--color-grey-black-1);
font-family: Merriweather Sans, sans-serif;
font-size: 24px;
font-style: normal;
font-weight: 700;
line-height: 32px;
font-style: normal;
font-weight: 700;
line-height: 32px;
}

.step-action-buttons {
Expand All @@ -91,5 +91,5 @@
}

.step-action-prev-btn {
border: 1px solid rgba(0, 0, 0, 0.12);
}
border: 1px solid rgba(0, 0, 0, 0.12);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, Input, OnInit } from '@angular/core';
import { PolicyEngineService } from 'src/app/services/policy-engine.service';
import { PolicyHelper } from 'src/app/services/policy-helper.service';
Expand Down Expand Up @@ -67,18 +68,23 @@ export class ActionBlockComponent implements OnInit {
} else {
this.policyEngineService
.getBlockData(this.id, this.policyId)
.subscribe(
(data: any) => {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 1000);
},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(this._onSuccess.bind(this), this._onError.bind(this));
}
}

private _onSuccess(data: any) {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 500);
}

private _onError(e: HttpErrorResponse) {
console.error(e.error);
if (e.status === 503) {
this._onSuccess(null);
} else {
this.loading = false;
}
}

Expand Down Expand Up @@ -147,13 +153,12 @@ export class ActionBlockComponent implements OnInit {
this.visible = this.options.findIndex((o: any) => o.value == this.value) == -1;
this.policyEngineService
.setBlockData(this.id, this.policyId, this.data)
.subscribe(
() => {},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(() => {

}, (e) => {
console.error(e.error);
this.loading = false;
});
}

setStatus(row: any, status: string) {
Expand All @@ -162,32 +167,26 @@ export class ActionBlockComponent implements OnInit {
data.status = status;
this.policyEngineService
.setBlockData(this.id, this.policyId, data)
.subscribe(
() => {
this.loadData();
},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(() => {
this.loadData();
}, (e) => {
console.error(e.error);
this.loading = false;
});
}

onDownload() {
this.policyEngineService
.setBlockData(this.id, this.policyId, this.data)
.subscribe(
(data) => {
if (data) {
this.downloadObjectAsJson(data.body, data.fileName);
}
this.loading = false;
},
(e) => {
console.error(e.error);
this.loading = false;
.subscribe((data) => {
if (data) {
this.downloadObjectAsJson(data.body, data.fileName);
}
);
this.loading = false;
}, (e) => {
console.error(e.error);
this.loading = false;
});
}

downloadObjectAsJson(exportObj: any, exportName: string) {
Expand All @@ -207,12 +206,11 @@ export class ActionBlockComponent implements OnInit {
this.setObjectValue(this.data, this.field, this.currentValue);
this.policyEngineService
.setBlockData(this.id, this.policyId, this.data)
.subscribe(
() => {},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(() => {

}, (e) => {
console.error(e.error);
this.loading = false;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PolicyEngineService } from 'src/app/services/policy-engine.service';
import { WebSocketService } from 'src/app/services/web-socket.service';
import { ConfirmationDialog } from '../confirmation-dialog/confirmation-dialog.component';
import { DialogService } from 'primeng/dynamicdialog';
import { HttpErrorResponse } from '@angular/common/http';

/**
* Component for display block of 'buttonBlockAddon' type.
Expand Down Expand Up @@ -71,18 +72,23 @@ export class ButtonBlockAddonComponent implements OnInit {
} else {
this.policyEngineService
.getBlockData(this.id, this.policyId)
.subscribe(
(data: any) => {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 1000);
},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(this._onSuccess.bind(this), this._onError.bind(this));
}
}

private _onSuccess(data: any) {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 500);
}

private _onError(e: HttpErrorResponse) {
console.error(e.error);
if (e.status === 503) {
this._onSuccess(null);
} else {
this.loading = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PolicyHelper } from 'src/app/services/policy-helper.service';
import { WebSocketService } from 'src/app/services/web-socket.service';
import { ConfirmationDialog } from '../confirmation-dialog/confirmation-dialog.component';
import { DialogService } from 'primeng/dynamicdialog';
import { HttpErrorResponse } from '@angular/common/http';

/**
* Component for display block of 'Buttons' type.
Expand Down Expand Up @@ -92,18 +93,23 @@ export class ButtonBlockComponent implements OnInit, AfterContentChecked {
} else {
this.policyEngineService
.getBlockData(this.id, this.policyId)
.subscribe(
(data: any) => {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 1000);
},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(this._onSuccess.bind(this), this._onError.bind(this));
}
}

private _onSuccess(data: any) {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 500);
}

private _onError(e: HttpErrorResponse) {
console.error(e.error);
if (e.status === 503) {
this._onSuccess(null);
} else {
this.loading = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PolicyEngineService } from 'src/app/services/policy-engine.service';
import { PolicyHelper } from 'src/app/services/policy-helper.service';
import { WebSocketService } from 'src/app/services/web-socket.service';
import { PolicyProgressService } from '../../../services/policy-progress.service';
import { HttpErrorResponse } from '@angular/common/http';

/**
* Component for display block of 'interfaceContainerBlock' type.
Expand Down Expand Up @@ -88,18 +89,23 @@ export class ContainerBlockComponent implements OnInit, OnDestroy {
} else {
this.policyEngineService
.getBlockData(this.id, this.policyId)
.subscribe(
(data: any) => {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 500);
},
(e) => {
console.error(e.error);
this.loading = false;
}
);
.subscribe(this._onSuccess.bind(this), this._onError.bind(this));
}
}

private _onSuccess(data: any) {
this.setData(data);
setTimeout(() => {
this.loading = false;
}, 500);
}

private _onError(e: HttpErrorResponse) {
console.error(e.error);
if (e.status === 503) {
this._onSuccess(null);
} else {
this.loading = false;
}
}

Expand Down
Loading