Skip to content

Commit

Permalink
selects for cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech committed Aug 24, 2023
1 parent 482bcd7 commit 1b6a10a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 3 deletions.
25 changes: 24 additions & 1 deletion frontend/src/pages/Backups/ScheduledBackups.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import React, { useEffect, useState } from 'react'
import { usePollingEffect } from '../../utils/usePollingEffect'
import { ColumnType } from 'antd/es/table'
import { Switch, Table, Button, Form, Input, Modal, Tag, Col, Progress, Row, Tooltip, notification } from 'antd'
import { Switch, Select, Table, Button, Form, Input, Modal, Tag, Col, Progress, Row, Tooltip, notification } from 'antd'
import { Clusters } from '../Clusters/Clusters'

interface ScheduleRow {
id: string
created_at: string
enabled: boolean
last_run_time: string
cluster: string
schedule: string
table: string
database: string
Expand All @@ -21,6 +23,7 @@ interface Backups {
}

type FieldType = {
cluster?: string
schedule?: string
database?: string
table?: string
Expand All @@ -35,6 +38,9 @@ export default function ScheduledBackups() {
const [loadingBackups, setLoadingBackups] = useState(false)
const [open, setOpen] = useState(false)
const [confirmLoading, setConfirmLoading] = useState(false)
const [clusters, setClusters] = useState<Clusters>({
clusters: [],
})

const [form] = Form.useForm() // Hook to get form API

Expand Down Expand Up @@ -79,6 +85,15 @@ export default function ScheduledBackups() {
} catch (err) {
notification.error({ message: 'Failed to load data' })
}

try {
const res = await fetch('/api/clusters')
const resJson = await res.json()
const clusters = { clusters: resJson }
setClusters(clusters)
} catch (err) {
notification.error({ message: 'Failed to load data' })
}
}

useEffect(() => {
Expand Down Expand Up @@ -111,6 +126,7 @@ export default function ScheduledBackups() {
},
},
{ title: 'Enabled', dataIndex: 'enabled' },
{ title: 'Cluster', dataIndex: 'cluster' },
{ title: 'Schedule', dataIndex: 'schedule' },
{ title: 'Last Run Time', dataIndex: 'last_run_time' },
{ title: 'Database', dataIndex: 'database' },
Expand Down Expand Up @@ -149,6 +165,13 @@ export default function ScheduledBackups() {
initialValues={{ remember: true }}
autoComplete="on"
>
<Form.Item label="Cluster">
<Select>
{clusters.clusters.map(cluster => (
<Select.Option value="{cluster.cluster}">{cluster.cluster}</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item<FieldType>
label="Schedule"
name="schedule"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/Clusters/Clusters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Cluster {
nodes: ClusterNode[]
}

interface Clusters {
export interface Clusters {
clusters: Cluster[]
}

Expand Down Expand Up @@ -70,7 +70,7 @@ export default function Clusters() {
<br />
<Row gutter={8} style={{ paddingBottom: 8 }}>
<ul>
{clusters.clusters.map((cluster) => (
{clusters.clusters.map(cluster => (
<>
<h1 key={cluster.cluster}>{cluster.cluster}</h1>
<Table columns={columns} dataSource={cluster.nodes} loading={loadingClusters} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.1.1 on 2023-08-24 01:33

from django.db import migrations, models
import uuid


class Migration(migrations.Migration):

dependencies = [
('housewatch', '0008_remove_scheduledbackup_aws_endpoint_url_and_more'),
]

operations = [
migrations.AddField(
model_name='scheduledbackup',
name='cluster',
field=models.CharField(max_length=255, null=True),
),
migrations.AlterField(
model_name='scheduledbackup',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
]
1 change: 1 addition & 0 deletions housewatch/models/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ScheduledBackup(models.Model):
schedule: models.CharField = models.CharField(max_length=255)
table: models.CharField = models.CharField(max_length=255, null=True)
database: models.CharField = models.CharField(max_length=255)
cluster: models.CharField = models.CharField(max_length=255, null=True)
bucket: models.CharField = models.CharField(max_length=255)
path: models.CharField = models.CharField(max_length=255)
# if set these will override the defaults from settings
Expand Down

0 comments on commit 1b6a10a

Please sign in to comment.