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

Initial version of discovery graph #61

Merged
merged 18 commits into from
Nov 1, 2023
134 changes: 134 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@
"@sveltejs/adapter-node": "^1.3.1",
"@sveltejs/kit": "^1.27.0",
"@tailwindcss/forms": "^0.5.3",
"@types/cytoscape": "^3.19.13",
"@types/cytoscape-dagre": "^2.3.2",
"@types/cytoscape-euler": "^1.2.2",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"autoprefixer": "^10.4.14",
"chart.js": "^4.4.0",
"cytoscape": "^3.26.0",
"cytoscape-cola": "^2.5.1",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte": "^2.34.0",
"flat": "^6.0.1",
"inter-ui": "^3.19.3",
"oidc-client-ts": "^2.4.0",
"postcss": "^8.4.31",
Expand All @@ -39,4 +45,4 @@
"vite": "^4.5.0"
},
"type": "module"
}
}
30 changes: 28 additions & 2 deletions src/lib/api/discovery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { throwError } from './errors';
import { clouditorize } from './util';

export interface GraphEdge {
id: string
source: string
target: string
}

export interface StartDiscoveryResponse {
successful: boolean
}
Expand All @@ -8,6 +15,10 @@ export interface QueryResponse {
results: Resource[]
}

export interface ListGraphEdgesResponse {
edges: GraphEdge[]
}

export interface ListResourcesRequest {
filter?: Filter
orderBy?: string
Expand Down Expand Up @@ -35,6 +46,7 @@ export interface ResourceProperties {
type: string[]
serviceId: string
id: string
labels: object
}

export interface Resource {
Expand Down Expand Up @@ -70,8 +82,6 @@ export async function listResources(
apiUrl += `&filter.type=${type}`
}

const emptyResource: Resource[] = [];

return fetch(apiUrl, {
method: 'GET',
headers: {
Expand All @@ -82,4 +92,20 @@ export async function listResources(
.then((response: QueryResponse) => {
return response.results;
});
}


export async function listGraphEdges(fetch = window.fetch): Promise<GraphEdge[]> {
const apiUrl = clouditorize(`/v1experimental/discovery/graph/edges?&pageSize=1500`);

return fetch(apiUrl, {
method: 'GET',
headers: {
'Authorization': `Bearer ${localStorage.token}`,
}
}).then(throwError)
.then((res) => res.json())
.then((response: ListGraphEdgesResponse) => {
return response.edges;
});
}
4 changes: 2 additions & 2 deletions src/lib/api/orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ export async function getRuntimeInfo(fetch = window.fetch): Promise<Runtime> {
*
* @returns an array of {@link AssessmentResult}s.
*/
export async function listAssessmentResults(fetch = window.fetch): Promise<AssessmentResult[]> {
const apiUrl = clouditorize(`/v1/orchestrator/assessment_results?pageSize=1500&orderBy=timestamp&asc=false`);
export async function listAssessmentResults(fetch = window.fetch, latestByResourceId = false): Promise<AssessmentResult[]> {
const apiUrl = clouditorize(`/v1/orchestrator/assessment_results?pageSize=1500&latestByResourceId=${latestByResourceId}&orderBy=timestamp&asc=false`);

return fetch(apiUrl, {
method: 'GET',
Expand Down
13 changes: 13 additions & 0 deletions src/lib/components/AssessmentIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script lang="ts">
import type { AssessmentResult } from '$lib/api/assessment';
import { CheckCircle, XCircle } from '@steeze-ui/heroicons';
import { Icon } from '@steeze-ui/svelte-icon';

export let result: AssessmentResult;
</script>

{#if result.compliant}
<Icon src={CheckCircle} theme="solid" class="h-5 w-5 mr-2 text-green-800" />
{:else}
<Icon src={XCircle} theme="solid" class="h-5 w-5 mr-2 text-red-800" />
{/if}
Loading
Loading