Skip to content
This repository has been archived by the owner on Apr 17, 2024. It is now read-only.

Commit

Permalink
feat: display troubleshoot report in text field
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <galexrt@googlemail.com>
  • Loading branch information
galexrt committed Nov 6, 2023
1 parent cf8fed3 commit a287799
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
6 changes: 4 additions & 2 deletions pkg/server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ import (
"go.uber.org/fx"
"go.uber.org/zap"

// Services
// Connect Services - Need to be added here
serverauth "github.com/koor-tech/data-control-center/server/auth"
servercluster "github.com/koor-tech/data-control-center/server/cluster"
serverstats "github.com/koor-tech/data-control-center/server/stats"
)

Expand Down Expand Up @@ -184,9 +185,10 @@ func StartHTTPServer() {
ceph.Module,
cephcache.Module,

// Connect Services
// Connect Services - Need to be added here
fx.Provide(
AsService(serverauth.New),
AsService(servercluster.New),
AsService(serverstats.New),
),

Expand Down
10 changes: 9 additions & 1 deletion server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

"connectrpc.com/connect"
"github.com/gin-gonic/gin"
clusterpb "github.com/koor-tech/data-control-center/gen/go/api/services/cluster/v1"
"github.com/koor-tech/data-control-center/gen/go/api/services/cluster/v1/clusterv1connect"
"github.com/koor-tech/data-control-center/pkg/config"
Expand Down Expand Up @@ -42,6 +43,13 @@ func New(p Params) (*Server, error) {
}, nil
}

func (s *Server) RegisterService(g *gin.RouterGroup) {
path, handler := clusterv1connect.NewClusterServiceHandler(s, connect.WithInterceptors(
s.auth.NewAuthInterceptor(),
))
g.Any(path+"/*path", gin.WrapH(handler))
}

func (s *Server) GetKoorCluster(ctx context.Context, req *connect.Request[clusterpb.GetKoorClusterRequest]) (*connect.Response[clusterpb.GetKoorClusterResponse], error) {
kc, _ := s.k.GetKoorCluster(s.Namespace)

Expand All @@ -57,7 +65,7 @@ func (s *Server) GetTroubleshootReport(ctx context.Context, req *connect.Request
Content string
}{}

// TODO
// TODO get k8s, rook pod versions, ceph version and the custom resource infos

report := ""
if len(reportContent) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/components/partials/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const sidebarNavigation = ref<
},
{
name: 'Troubleshooting',
href: { name: 'troubleshooting' },
href: { name: 'troubleshoot' },
icon: markRaw(HelpBoxMultipleIcon),
position: 'top',
current: false,
Expand Down
30 changes: 24 additions & 6 deletions src/pages/troubleshooting.vue → src/pages/troubleshoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@
import { ConnectError } from '@connectrpc/connect';
import { useThrottleFn } from '@vueuse/core';
import GenericDivider from '~/components/partials/GenericDivider.vue';
import DataErrorBlock from '~/components/partials/data/DataErrorBlock.vue';
import DataNoDataBlock from '~/components/partials/data/DataNoDataBlock.vue';
import DataPendingBlock from '~/components/partials/data/DataPendingBlock.vue';
import { useClusterStore } from '~/store/cluster';
useHead({
title: 'Troubleshooting',
title: 'Troubleshoot',
});
definePageMeta({
title: 'Troubleshooting',
title: 'Troubleshoot',
requiresAuth: true,
});
const { $grpc } = useNuxtApp();
const clusterStore = useClusterStore();
const { data: report, refresh } = useLazyAsyncData(
const {
data: report,
error,
pending,
refresh,
} = useLazyAsyncData(
'cluster-troubleshoot_report',
async () => {
try {
Expand Down Expand Up @@ -53,9 +61,19 @@ const onSubmitThrottle = useThrottleFn(async (_) => {
Generate Troubleshoot Report
</button>
</div>
<div v-if="report" class="flex">
<GenericDivider />
<textarea :value="report.report" />
<div v-if="report" class="mt-4 flex flex-col">
<GenericDivider label="Report" />

<DataErrorBlock v-if="error" :retry="refresh" :message="error.value?.message" />
<DataPendingBlock v-else-if="pending" message="Loading Troubleshoot report" />
<DataNoDataBlock v-else-if="!report || !report.report" />
<textarea
v-else
:value="report.report"
rows="10"
name="comment"
class="mt-2 block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
/>
</div>
</div>
</template>

0 comments on commit a287799

Please sign in to comment.