feat: add generated code
This commit is contained in:
27
frontend/src/App.tsx
Normal file
27
frontend/src/App.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Admin, Resource } from 'react-admin';
|
||||
import { dataProvider } from './dataProvider';
|
||||
import { authProvider } from './authProvider';
|
||||
|
||||
import { EquipmentList, EquipmentCreate, EquipmentEdit, EquipmentShow } from './resources/equipment';
|
||||
import { ChangeEquipmentStatusList, ChangeEquipmentStatusCreate, ChangeEquipmentStatusEdit, ChangeEquipmentStatusShow } from './resources/change-equipment-status';
|
||||
|
||||
const App = () => (
|
||||
<Admin dataProvider={dataProvider} authProvider={authProvider}>
|
||||
<Resource
|
||||
name="equipment"
|
||||
list={EquipmentList}
|
||||
create={EquipmentCreate}
|
||||
edit={EquipmentEdit}
|
||||
show={EquipmentShow}
|
||||
/>
|
||||
<Resource
|
||||
name="change-equipment-status"
|
||||
list={ChangeEquipmentStatusList}
|
||||
create={ChangeEquipmentStatusCreate}
|
||||
edit={ChangeEquipmentStatusEdit}
|
||||
show={ChangeEquipmentStatusShow}
|
||||
/>
|
||||
</Admin>
|
||||
);
|
||||
|
||||
export default App;
|
||||
13
frontend/src/main.tsx
Normal file
13
frontend/src/main.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { initKeycloak } from './authProvider';
|
||||
import App from './App';
|
||||
|
||||
// Initialize Keycloak before rendering the app
|
||||
initKeycloak().then(() => {
|
||||
ReactDOM.createRoot(document.getElementById('root')!).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { Create, SimpleForm, TextInput, DateInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
export const ChangeEquipmentStatusCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<ReferenceInput source="equipmentId" reference="equipment" label="Оборудование" required />
|
||||
<SelectInput
|
||||
source="newStatus"
|
||||
label="Новый статус"
|
||||
choices={statusChoices}
|
||||
required
|
||||
/>
|
||||
<TextInput source="number" label="Номер" fullWidth />
|
||||
<DateInput source="date" label="Дата изменения статуса" required />
|
||||
<TextInput source="responsible" label="Ответственный" fullWidth />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Edit, SimpleForm, TextInput, DateInput, SelectInput, ReferenceInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
export const ChangeEquipmentStatusEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<ReferenceInput source="equipmentId" reference="equipment" label="Оборудование" />
|
||||
<SelectInput
|
||||
source="newStatus"
|
||||
label="Новый статус"
|
||||
choices={statusChoices}
|
||||
/>
|
||||
<TextInput source="number" label="Номер" fullWidth />
|
||||
<DateInput source="date" label="Дата изменения статуса" />
|
||||
<TextInput source="responsible" label="Ответственный" fullWidth />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
@@ -0,0 +1,35 @@
|
||||
import { List, DataTable, TextField, DateField, EditButton, ShowButton, ReferenceField } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
const StatusField = ({ source, record }: { source: string; record?: any }) => {
|
||||
const status = record?.[source];
|
||||
const statusLabel = statusChoices.find(choice => choice.id === status)?.name || status;
|
||||
return <span>{statusLabel}</span>;
|
||||
};
|
||||
|
||||
export const ChangeEquipmentStatusList = () => (
|
||||
<List>
|
||||
<DataTable>
|
||||
<DataTable.Col source="equipmentId" label="Оборудование">
|
||||
<ReferenceField source="equipmentId" reference="equipment" />
|
||||
</DataTable.Col>
|
||||
<DataTable.Col source="newStatus" label="Новый статус">
|
||||
<StatusField source="newStatus" />
|
||||
</DataTable.Col>
|
||||
<DataTable.Col source="number" label="Номер" />
|
||||
<DataTable.Col source="date" label="Дата изменения статуса" field={DateField} />
|
||||
<DataTable.Col source="responsible" label="Ответственный" />
|
||||
<DataTable.Col source="createdAt" label="Создано" field={DateField} />
|
||||
<DataTable.Col>
|
||||
<ShowButton />
|
||||
<EditButton />
|
||||
</DataTable.Col>
|
||||
</DataTable>
|
||||
</List>
|
||||
);
|
||||
@@ -0,0 +1,28 @@
|
||||
import { Show, SimpleShowLayout, TextField, DateField, ReferenceField } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
const StatusField = ({ source, record }: { source: string; record?: any }) => {
|
||||
const status = record?.[source];
|
||||
const statusLabel = statusChoices.find(choice => choice.id === status)?.name || status;
|
||||
return <span>{statusLabel}</span>;
|
||||
};
|
||||
|
||||
export const ChangeEquipmentStatusShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<ReferenceField source="equipmentId" reference="equipment" label="Оборудование" />
|
||||
<StatusField source="newStatus" label="Новый статус" />
|
||||
<TextField source="number" label="Номер" />
|
||||
<DateField source="date" label="Дата изменения статуса" />
|
||||
<TextField source="responsible" label="Ответственный" />
|
||||
<DateField source="createdAt" label="Создано" />
|
||||
<DateField source="updatedAt" label="Обновлено" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
4
frontend/src/resources/change-equipment-status/index.ts
Normal file
4
frontend/src/resources/change-equipment-status/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export { ChangeEquipmentStatusList } from './ChangeEquipmentStatusList';
|
||||
export { ChangeEquipmentStatusCreate } from './ChangeEquipmentStatusCreate';
|
||||
export { ChangeEquipmentStatusEdit } from './ChangeEquipmentStatusEdit';
|
||||
export { ChangeEquipmentStatusShow } from './ChangeEquipmentStatusShow';
|
||||
1
frontend/src/resources/change-equipment-status/types.ts
Normal file
1
frontend/src/resources/change-equipment-status/types.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type EquipmentStatus = 'Active' | 'Repair' | 'Reserve' | 'WriteOff';
|
||||
24
frontend/src/resources/equipment/EquipmentCreate.tsx
Normal file
24
frontend/src/resources/equipment/EquipmentCreate.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Create, SimpleForm, TextInput, DateInput, SelectInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
export const EquipmentCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="name" label="Название оборудования" fullWidth required />
|
||||
<TextInput source="serialNumber" label="Заводской (серийный) номер" fullWidth required />
|
||||
<DateInput source="dateOfInspection" label="Дата поверки" />
|
||||
<DateInput source="commissionedAt" label="Дата изготовления" />
|
||||
<SelectInput
|
||||
source="status"
|
||||
label="Текущий статус"
|
||||
choices={statusChoices}
|
||||
/>
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
25
frontend/src/resources/equipment/EquipmentEdit.tsx
Normal file
25
frontend/src/resources/equipment/EquipmentEdit.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Edit, SimpleForm, TextInput, DateInput, SelectInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
export const EquipmentEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput disabled source="id" label="Идентификатор" />
|
||||
<TextInput source="name" label="Название оборудования" fullWidth />
|
||||
<TextInput source="serialNumber" label="Заводской (серийный) номер" fullWidth />
|
||||
<DateInput source="dateOfInspection" label="Дата поверки" />
|
||||
<DateInput source="commissionedAt" label="Дата изготовления" />
|
||||
<SelectInput
|
||||
source="status"
|
||||
label="Текущий статус"
|
||||
choices={statusChoices}
|
||||
/>
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
35
frontend/src/resources/equipment/EquipmentList.tsx
Normal file
35
frontend/src/resources/equipment/EquipmentList.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { List, DataTable, TextField, DateField, EditButton, ShowButton } from 'react-admin';
|
||||
import { EquipmentStatus } from './types';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
const StatusField = ({ source, record }: { source: string; record?: any }) => {
|
||||
const status = record?.[source];
|
||||
const statusLabel = statusChoices.find(choice => choice.id === status)?.name || status;
|
||||
return <span>{statusLabel}</span>;
|
||||
};
|
||||
|
||||
export const EquipmentList = () => (
|
||||
<List>
|
||||
<DataTable>
|
||||
<DataTable.Col source="id" />
|
||||
<DataTable.Col source="name" label="Название" />
|
||||
<DataTable.Col source="serialNumber" label="Серийный номер" />
|
||||
<DataTable.Col source="dateOfInspection" label="Дата поверки" field={DateField} />
|
||||
<DataTable.Col source="commissionedAt" label="Дата изготовления" field={DateField} />
|
||||
<DataTable.Col source="status" label="Статус">
|
||||
<StatusField source="status" />
|
||||
</DataTable.Col>
|
||||
<DataTable.Col source="createdAt" label="Создано" field={DateField} />
|
||||
<DataTable.Col>
|
||||
<ShowButton />
|
||||
<EditButton />
|
||||
</DataTable.Col>
|
||||
</DataTable>
|
||||
</List>
|
||||
);
|
||||
29
frontend/src/resources/equipment/EquipmentShow.tsx
Normal file
29
frontend/src/resources/equipment/EquipmentShow.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Show, SimpleShowLayout, TextField, DateField } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
|
||||
const StatusField = ({ source, record }: { source: string; record?: any }) => {
|
||||
const status = record?.[source];
|
||||
const statusLabel = statusChoices.find(choice => choice.id === status)?.name || status;
|
||||
return <span>{statusLabel}</span>;
|
||||
};
|
||||
|
||||
export const EquipmentShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="id" label="Идентификатор" />
|
||||
<TextField source="name" label="Название оборудования" />
|
||||
<TextField source="serialNumber" label="Заводской (серийный) номер" />
|
||||
<DateField source="dateOfInspection" label="Дата поверки" />
|
||||
<DateField source="commissionedAt" label="Дата изготовления" />
|
||||
<StatusField source="status" label="Текущий статус" />
|
||||
<DateField source="createdAt" label="Создано" />
|
||||
<DateField source="updatedAt" label="Обновлено" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
4
frontend/src/resources/equipment/index.ts
Normal file
4
frontend/src/resources/equipment/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export { EquipmentList } from './EquipmentList';
|
||||
export { EquipmentCreate } from './EquipmentCreate';
|
||||
export { EquipmentEdit } from './EquipmentEdit';
|
||||
export { EquipmentShow } from './EquipmentShow';
|
||||
1
frontend/src/resources/equipment/types.ts
Normal file
1
frontend/src/resources/equipment/types.ts
Normal file
@@ -0,0 +1 @@
|
||||
export type EquipmentStatus = 'Active' | 'Repair' | 'Reserve' | 'WriteOff';
|
||||
Reference in New Issue
Block a user