Skip to content

Commit

Permalink
Lint typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
NHAS committed Nov 21, 2024
1 parent 5aa4e2c commit f7a28ec
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 168 deletions.
2 changes: 0 additions & 2 deletions adminui2/src/api/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export function getClusterEvents(): Promise<ClusterEvents> {
return client.get('/api/cluster/events').then(res => res.data)
}


export function getClusterMembers(): Promise<ClusterMember[]> {
return client.get('/api/cluster/members').then(res => res.data)
}

4 changes: 2 additions & 2 deletions adminui2/src/api/groups.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GroupDTO,GenericResponseDTO } from './types'
import type { GroupDTO, GenericResponseDTO } from './types'

import { client } from '.'

Expand All @@ -12,4 +12,4 @@ export function editGroup(updatedGroup: GroupDTO): Promise<GenericResponseDTO> {

export function createGroup(group: GroupDTO): Promise<GenericResponseDTO> {
return client.post('/api/policy/groups', group).then(res => res.data)
}
}
2 changes: 1 addition & 1 deletion adminui2/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ client.interceptors.request.use(config => {
})

export function setCSRFHeader(csrfToken: string, csrfHeaderName: string) {
console.log("setting: ", csrfHeaderName, csrfToken)
console.log('setting: ', csrfHeaderName, csrfToken)
client.defaults.headers.common[csrfHeaderName] = csrfToken
}

Expand Down
2 changes: 1 addition & 1 deletion adminui2/src/api/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export function editRule(updatedRule: RuleDTO): Promise<GenericResponseDTO> {

export function createRule(rule: RuleDTO): Promise<GenericResponseDTO> {
return client.post('/api/policy/rules', rule).then(res => res.data)
}
}
3 changes: 0 additions & 3 deletions adminui2/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ export interface ClusterMember {
peer_urls: string[]
}




export interface GenericResponseDTO {
message: string
success: boolean
Expand Down
8 changes: 2 additions & 6 deletions adminui2/src/components/RulesInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const props = defineProps<{
const emit = defineEmits(['update:modelValue'])
const rows = props.rows ?? "3"
const rows = props.rows ?? '3'
const rules = computed({
get: () => props.modelValue,
Expand All @@ -17,11 +17,7 @@ const rules = computed({
</script>

<template>
<textarea
class="rules-input textarea textarea-bordered w-full font-mono"
:rows="rows"
v-model="rules"
></textarea>
<textarea class="rules-input textarea textarea-bordered w-full font-mono" :rows="rows" v-model="rules"></textarea>
</template>

<style scoped>
Expand Down
8 changes: 1 addition & 7 deletions adminui2/src/composables/useTextareaInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ import { ref, computed } from 'vue'
export function useTextareaInput() {
const Input = ref('')
const Arr = computed(() => {

console.log(Input)
if(Input === null) {
return []
}

return Input.value
.trim()
.split(/\n+/)
.filter(x => !!x)
.map(x => x.trim())
})
return { Input, Arr }
}
}
2 changes: 1 addition & 1 deletion adminui2/src/composables/useToastError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function useToastError() {
errorString = e.message
}

console.log(e, typeof(e))
console.log(e, typeof e)

const paddedPrefixString = prefixString.endsWith(' ') ? prefixString : prefixString + ' '

Expand Down
10 changes: 3 additions & 7 deletions adminui2/src/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const adminPageLinks = [
{ name: 'Manage Users', icon: Icons.User, to: '/admin/users' }
]
async function logout() {
await authStore.logout()
router.push('/login')
Expand All @@ -51,13 +50,11 @@ async function logout() {
<div class="drawer lg:drawer-open h-max bg-slate-100">
<input id="my-drawer" type="checkbox" class="drawer-toggle" />
<div class="drawer-content">

<router-view />

<label for="my-drawer-2" class="fixed btn text-neutral-content bg-neutral lg:hidden">
<span class="w-6 text-center"><font-awesome-icon :icon=Icons.Open /></span>
<span class="w-6 text-center"><font-awesome-icon :icon="Icons.Open" /></span>
</label>

</div>
<div class="drawer-side">
<label for="my-drawer" aria-label="close sidebar" class="drawer-overlay"></label>
Expand Down Expand Up @@ -117,7 +114,6 @@ async function logout() {

<div class="flex flex-grow"></div>


<ul class="menu justify-self-end">
<li class="hover-bordered" :class="route.path.startsWith('/admin') ? 'bordered' : 'hover-bordered'">
<div class="text-content-neutral dropdown dropdown-top">
Expand All @@ -141,7 +137,7 @@ async function logout() {
<div class="text-content-neutral dropdown dropdown-top">
<label tabindex="0" class="col-span-2 w-full cursor-pointer">
<span class="w-6 text-center"><font-awesome-icon :icon="Icons.User" /></span>
<span
<span
>Welcome, <strong>{{ loggedInUser?.username }}</strong></span
>
</label>
Expand Down Expand Up @@ -225,4 +221,4 @@ async function logout() {
.tooltip-white-bg::after {
--tooltip-color: white;
}
</style>
</style>
20 changes: 14 additions & 6 deletions adminui2/src/pages/ClusterEvents.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ const {
<EmptyTable v-if="allEvents.length == 0" text="No events yet" />
</div>
<div class="mt-2 w-full text-center mb-3">
<PaginationControls @next="() => nextEventsPage()" @prev="() => prevEventsPage()"
:current-page="activeEventsPage" :total-pages="totalEventsPages" />
<PaginationControls
@next="() => nextEventsPage()"
@prev="() => prevEventsPage()"
:current-page="activeEventsPage"
:total-pages="totalEventsPages"
/>
</div>
</div>
<div class="card w-1/2 bg-base-100 shadow-xl">
Expand All @@ -86,8 +90,12 @@ const {
<EmptyTable v-if="errors.length == 0" text="No errors!" />
</div>
<div class="mt-2 w-full text-center mb-3">
<PaginationControls @next="() => nextErrorsPage()" @prev="() => prevErrorsPage()"
:current-page="activeErrorsPage" :total-pages="totalErrorsPages" />
<PaginationControls
@next="() => nextErrorsPage()"
@prev="() => prevErrorsPage()"
:current-page="activeErrorsPage"
:total-pages="totalErrorsPages"
/>
</div>
</div>
</div>
Expand All @@ -96,11 +104,11 @@ const {
</template>

<style scoped>
thead>tr>th {
thead > tr > th {
background: none !important;
}
.first-col-bold>tr td:first-of-type {
.first-col-bold > tr td:first-of-type {
font-weight: bold;
}
</style>
36 changes: 17 additions & 19 deletions adminui2/src/pages/ClusterMembers.vue
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
<script setup lang="ts">
import { useToast } from 'vue-toastification'
import { useApi } from '@/composables/useApi';
import { getClusterMembers } from '@/api/cluster';
import type { ClusterMember } from '@/api';
import { useAuthStore } from '@/stores/auth'
import { getClusterMembers } from '@/api/cluster'
import { useApi } from '@/composables/useApi'
import { useAuthStore } from '@/stores/auth'
import { Icons } from '@/util/icons'
import type { ClusterMember } from '@/api'
const { data: members } = useApi(() => getClusterMembers())
const authStore = useAuthStore()
const toast = useToast()
function nodeName(member: ClusterMember): string {
let result = member.name
if (member.name === "") {
result = "Connecting..."
if (member.name === '') {
result = 'Connecting...'
}
if (member.current_node) {
result += " (current node)"
result += ' (current node)'
}
return result
}
</script>


<template>
<main class="w-full p-4">
<h1 class="text-4xl font-bold">Cluster Members</h1>
<div class="mt-6 flex flex-wrap gap-6">
<div class="grid w-full grid-cols-4 gap-4">

<div v-for="member in members" class="card-compact bg-base-100 shadow-xl min-w-96 max-w-96">
<div class="card-body">
<h5 class="card-title overflow-hidden text-ellipsis whitespace-nowrap">{{ nodeName(member) }}</h5>
Expand All @@ -50,34 +48,34 @@ function nodeName(member: ClusterMember): string {
<div class="overflow-hidden text-ellipsis whitespace-nowrap">{{ member.version }}</div>

<div>Role:</div>
<div class="overflow-hidden text-ellipsis whitespace-nowrap">{{ member.leader ? "Leader" : member.learner ? "Learner" : member.witness ? "Witness" : "Member" }}</div>
<div class="overflow-hidden text-ellipsis whitespace-nowrap">
{{ member.leader ? 'Leader' : member.learner ? 'Learner' : member.witness ? 'Witness' : 'Member' }}
</div>

<div>Status:</div>
<div class="overflow-hidden text-ellipsis whitespace-nowrap" >{{ member.status }}</div>
<div class="overflow-hidden text-ellipsis whitespace-nowrap">{{ member.status }}</div>

<div>Last Ping:</div>
<div class="overflow-hidden text-ellipsis whitespace-nowrap">{{ member.last_ping }}</div>

<div>{{ member.peer_urls?.length > 1 ? "Addresses" : "Address" }}:</div>
<div>{{ member.peer_urls?.length > 1 ? 'Addresses' : 'Address' }}:</div>
<div class="grid grid-rows-subgrid grid-cols-1">
<div class="overflow-hidden text-ellipsis whitespace-nowrap" v-for="address in member.peer_urls">{{ address }}</div>
</div>
</div>
</div>
</div>


</div>
</div>
</main>
</template>

<style scoped>
thead>tr>th {
thead > tr > th {
background: none !important;
}

.first-col-bold>tr td:first-of-type {
.first-col-bold > tr td:first-of-type {
font-weight: bold;
}
</style>
2 changes: 1 addition & 1 deletion adminui2/src/pages/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const toast = useToast()
<h1 class="text-4xl font-bold">Dashboard</h1>
<div class="mt-6 flex flex-wrap gap-6">
<div class="flex w-full gap-4">
<div class="flex grid w-1/2 grid-cols-2 gap-4 min-w-[405px]" >
<div class="flex grid w-1/2 grid-cols-2 gap-4 min-w-[405px]">
<router-link to="/users" class="card-compact bg-base-100 shadow-xl">
<div class="card-body">
<h5 class="card-title">Manage MFA</h5>
Expand Down
Loading

0 comments on commit f7a28ec

Please sign in to comment.