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

Alec 114 #36

Merged
merged 2 commits into from
Jun 29, 2022
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
2 changes: 1 addition & 1 deletion features/ui/src/main/resources/ui-ext/style.css

Large diffs are not rendered by default.

791 changes: 539 additions & 252 deletions features/ui/src/main/resources/ui-ext/uiextension.es.js

Large diffs are not rendered by default.

75 changes: 38 additions & 37 deletions features/ui/src/main/resources/ui-ext/uiextension.umd.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"dev": "vite --config vite.config.dev.ts",
"build": "vue-tsc --noEmit && vite build",
"preview": "vite preview --port 5002"
"build": "vue-tsc --noEmit && vite build && cp dist/* ../features/ui/src/main/resources/ui-ext/ ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI, this won't work for most windows terminals, but I guess we can force them to build in wsl or git bash

"preview": "vite build --mode development && vite preview --port 5002"
},
"dependencies": {
"axios": "^0.26.1",
Expand Down
7 changes: 4 additions & 3 deletions ui/src/components/AlarmsCountBySeverity.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { groupBy } from 'lodash'
import { SEVERITY_COLOR } from '@/helpers/constants'
import { TRelatedAlarm } from '@/types/TSituation'

const props = defineProps<{
Expand All @@ -12,7 +11,7 @@ const props = defineProps<{
<div class="alarms-list">
<div
class="alarm-count"
:style="{ color: SEVERITY_COLOR[key.toString().toLowerCase()] }"
:class="[`${key.toString().toLowerCase()}-color`]"
v-for="(list, key) in groupBy(props?.relatedAlarms, 'severity')"
:key="key"
>
Expand All @@ -21,7 +20,9 @@ const props = defineProps<{
</div>
</template>

<style scoped>
<style scoped lang="scss">
@import '@/styles/variables.scss';

.alarms-list {
display: flex;
flex-direction: row;
Expand Down
8 changes: 4 additions & 4 deletions ui/src/components/SituationCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script setup lang="ts">
import { SEVERITY_COLOR } from '@/helpers/constants'
import SeverityStatus from '@/elements/SeverityStatus.vue'
import AlarmsCountBySeverity from '@/components/AlarmsCountBySeverity.vue'
import { TSituation } from '@/types/TSituation'
Expand All @@ -8,7 +7,6 @@ const props = defineProps<{
alarmInfo: TSituation
}>()

const severity = SEVERITY_COLOR[props.alarmInfo?.severity?.toLowerCase()]
const emit = defineEmits(['situation-selected'])
const handleSituationSelected = () => {
emit('situation-selected', props.alarmInfo?.id)
Expand All @@ -17,7 +15,10 @@ const handleSituationSelected = () => {

<template>
<div v-on:click="handleSituationSelected" class="card">
<div class="severity-line"></div>
<div
class="severity-line"
:class="[`${props.alarmInfo?.severity?.toLowerCase()}-bg dark`]"
></div>
<div class="content">
<div class="title-row">
<span class="title">Situation {{ props.alarmInfo?.id }} </span>
Expand Down Expand Up @@ -57,7 +58,6 @@ const handleSituationSelected = () => {

.severity-line {
width: 8px;
background-color: v-bind('severity');
}

.content {
Expand Down
51 changes: 48 additions & 3 deletions ui/src/components/SituationDetail.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<script setup lang="ts">
import SeverityStatus from '@/elements/SeverityStatus.vue'
import AlarmsCountBySeverity from '@/components/AlarmsCountBySeverity.vue'
import {
FeatherTab,
FeatherTabContainer,
FeatherTabPanel
} from '@featherds/tabs'
import { FeatherSortHeader, SORT } from '@featherds/table'
import { TSituation } from '@/types/TSituation'

const props = defineProps<{
Expand All @@ -23,7 +23,7 @@ const props = defineProps<{
</template>
<FeatherTabPanel class="panel">
<div class="id">
Situation - {{ props.alarmInfo?.id }}
<span>Situation - {{ props.alarmInfo?.id }}</span>
<SeverityStatus :severity="props.alarmInfo?.severity" />
</div>

Expand All @@ -39,7 +39,36 @@ const props = defineProps<{
<p>
<strong>Reduction key: </strong>{{ props.alarmInfo.reductionKey }}
</p>
<AlarmsCountBySeverity :relatedAlarms="props.alarmInfo.relatedAlarms" />
<div>
<table class="tc1 tr2 tc4 tr6" :class="{ condensed: true }">
<thead>
<tr>
<FeatherSortHeader
scope="col"
property="Id"
:sort="SORT.ASCENDING"
>
ID
</FeatherSortHeader>
<th scope="col">Severity</th>
<th scope="col">Node</th>
<th scope="col">Log msg</th>
</tr>
</thead>
<tbody>
<tr
:class="[`${alarm.severity.toLowerCase()}-bg`]"
v-for="alarm in props?.alarmInfo?.relatedAlarms"
:key="alarm.id"
>
<td>{{ alarm.id }}</td>
<td>{{ alarm.severity }}</td>
<td>{{ alarm.nodeLabel }}</td>
<td>{{ alarm.logMessage }}</td>
</tr>
</tbody>
</table>
</div>
</FeatherTabPanel>
<FeatherTabPanel class="panel">Topology</FeatherTabPanel>
<FeatherTabPanel class="panel">Metrics</FeatherTabPanel>
Expand All @@ -49,6 +78,7 @@ const props = defineProps<{

<style scoped lang="scss">
@import '@/styles/variables.scss';
@import '@featherds/table/scss/table';

.detail {
width: 100%;
Expand All @@ -64,5 +94,20 @@ const props = defineProps<{
font-weight: 600;
font-size: 22px;
margin-bottom: 20px;
display: flex;
flex-direction: row;
justify-content: space-between;
}

table {
width: 100%;
@include table();
@include row-select();
&.hover {
@include row-hover();
}
&.condensed {
@include table-condensed();
}
}
</style>
7 changes: 1 addition & 6 deletions ui/src/elements/SeverityStatus.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { SEVERITY_COLOR } from '@/helpers/constants'

const props = defineProps({
severity: {
required: false,
Expand All @@ -13,10 +11,7 @@ const props = defineProps({
<span
v-if="props?.severity"
class="severity-status"
:style="{
color: SEVERITY_COLOR[props?.severity?.toLowerCase()],
borderColor: SEVERITY_COLOR[props?.severity?.toLowerCase()]
}"
:class="[`${props.severity.toLowerCase()}-color`]"
>{{ props.severity }}</span
>
</template>
Expand Down
7 changes: 0 additions & 7 deletions ui/src/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
export const SEVERITY_COLOR: Record<string, string> = {
critical: 'red',
major: 'orange',
warning: 'orange',
minor: '#dae830',
normal: 'green'
}
4 changes: 2 additions & 2 deletions ui/src/services/AlarmService.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ApiResponse } from '@/types/TSituation'
import { v2 } from './axiosInstances'

const endpoint = '/alarms'
const situationEndpoint = '/alarms?_s=isSituation==true'

export const getSituations = async (): Promise<ApiResponse | false> => {
try {
const resp = await v2.get(endpoint)
const resp = await v2.get(situationEndpoint)
if (resp.status === 204) {
return { alarm: [], totalCount: 0, count: 0, offset: 0 }
}
Expand Down
105 changes: 100 additions & 5 deletions ui/src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,103 @@
@import '@featherds/styles/themes/variables';

$border-grey: #dfdfdf;
$severity-normal: $success;
$severity-warning: $warning;
$severity-minor: $warning;
$severity-major: $warning;
$severity-critical: $error;

$severity-alarm-critical-text: black;
$severity-alarm-critical-bg: #f5cdcd;
$severity-alarm-critical-border: #cc0000;

$severity-alarm-major-text: black;
$severity-alarm-major-bg: #ffd7cd;
$severity-alarm-major-border: #ff3300;

$severity-alarm-minor-text: black;
$severity-alarm-minor-bg: #ffebcd;
$severity-alarm-minor-border: #ff9900;

$severity-alarm-warning-text: black;
$severity-alarm-warning-bg: #fff5cd;
$severity-alarm-warning-border: #ffcc00;

$severity-alarm-indeterminate-text: black;
$severity-alarm-indeterminate-bg: #ebebcd;
$severity-alarm-indeterminate-border: #999000;

$severity-alarm-normal-text: black;
$severity-alarm-normal-bg: #d7e1cd;
$severity-alarm-normal-border: #336600;

$severity-alarm-cleared-text: black;
$severity-alarm-cleared-bg: #eeeeee;
$severity-alarm-cleared-border: #999999;

.critical-bg {
background-color: $severity-alarm-critical-bg;
&.dark {
background-color: $severity-alarm-critical-border;
}
}

.major-bg {
background-color: $severity-alarm-major-bg;
&.dark {
background-color: $severity-alarm-major-border;
}
}

.minor-bg {
background-color: $severity-alarm-minor-bg;
&.dark {
background-color: $severity-alarm-minor-border;
}
}

.indeterminate-bg {
background-color: $severity-alarm-indeterminate-bg;
&.dark {
background-color: $severity-alarm-indeterminate-border;
}
}

.normal-bg {
background-color: $severity-alarm-normal-bg;
&.dark {
background-color: $severity-alarm-normal-border;
}
}

.cleared-bg {
background-color: $severity-alarm-cleared-bg;
&.dark {
background-color: $severity-alarm-cleared-border;
}
}

.critical-color {
border-color: $severity-alarm-critical-border;
color: $severity-alarm-critical-border;
}

.major-color {
border-color: $severity-alarm-major-border;
color: $severity-alarm-major-border;
}

.minor-color {
border-color: $severity-alarm-minor-border;
color: $severity-alarm-minor-border;
}

.indeterminate-color {
border-color: $severity-alarm-indeterminate-border;
color: $severity-alarm-indeterminate-border;
}

.normal-color {
border-color: $severity-alarm-normal-border;
color: $severity-alarm-normal-border;
}

.cleared-color {
border-color: $severity-alarm-cleared-border;
color: $severity-alarm-cleared-border;
}
1 change: 1 addition & 0 deletions ui/src/types/TSituation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export type TRelatedAlarm = {
reductionKey: string
description: string
logMessage: string
nodeLabel: string
}

export type TAlarm = {
Expand Down