create system for creating deployment methods
This commit is contained in:
parent
c79458eb32
commit
83afae8e54
@ -181,6 +181,20 @@ class ListMedia(APIView):
|
|||||||
else:
|
else:
|
||||||
return Response({'error': 'File not found'}, status=status.HTTP_404_NOT_FOUND)
|
return Response({'error': 'File not found'}, status=status.HTTP_404_NOT_FOUND)
|
||||||
|
|
||||||
|
class PublishMethods(APIView):
|
||||||
|
def get(self, request, format=None):
|
||||||
|
deployment_methods = [
|
||||||
|
{
|
||||||
|
"key_name": "server_deploy",
|
||||||
|
"name": "Server Deploy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key_name": "github_deploy",
|
||||||
|
"name": "Github Deploy"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
return Response(deployment_methods, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
class Publish(APIView):
|
class Publish(APIView):
|
||||||
def get(self, request, deploy_type, format=None):
|
def get(self, request, deploy_type, format=None):
|
||||||
storage = CustomStorage()
|
storage = CustomStorage()
|
||||||
@ -232,7 +246,6 @@ class Publish(APIView):
|
|||||||
|
|
||||||
|
|
||||||
def create_blog_data_json(self, instance, storage):
|
def create_blog_data_json(self, instance, storage):
|
||||||
print(instance)
|
|
||||||
if not instance.exists():
|
if not instance.exists():
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|||||||
@ -34,6 +34,7 @@ from apimanager.views import (
|
|||||||
BlogsByCategoryAPIView,
|
BlogsByCategoryAPIView,
|
||||||
MediaUpload,
|
MediaUpload,
|
||||||
ListMedia,
|
ListMedia,
|
||||||
|
PublishMethods,
|
||||||
Publish
|
Publish
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ urlpatterns = [
|
|||||||
path('data/blog/delete/<slug:blog_id>/', BlogDeleteAPIView.as_view(), name='blog-delete-view'),
|
path('data/blog/delete/<slug:blog_id>/', BlogDeleteAPIView.as_view(), name='blog-delete-view'),
|
||||||
path('data/upload/', MediaUpload.as_view(), name='media-upload'),
|
path('data/upload/', MediaUpload.as_view(), name='media-upload'),
|
||||||
path('data/media/<str:resource_type>/<str:resource_id>/', ListMedia.as_view(), name='list-media'),
|
path('data/media/<str:resource_type>/<str:resource_id>/', ListMedia.as_view(), name='list-media'),
|
||||||
|
path('data/publish/methods/', PublishMethods.as_view(), name='publish-methods'),
|
||||||
path('data/publish/<str:deploy_type>/', Publish.as_view(), name='publish'),
|
path('data/publish/<str:deploy_type>/', Publish.as_view(), name='publish'),
|
||||||
]
|
]
|
||||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
@ -10,6 +10,7 @@ import {
|
|||||||
} from 'reactstrap';
|
} from 'reactstrap';
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect } from 'react';
|
||||||
import EditableMediaService from '../../../services/editable-media-service'
|
import EditableMediaService from '../../../services/editable-media-service'
|
||||||
|
import Publish from './publish'
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { faSun, faMoon, faPen, faBrush } from '@fortawesome/free-solid-svg-icons';
|
import { faSun, faMoon, faPen, faBrush } from '@fortawesome/free-solid-svg-icons';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
@ -23,6 +24,9 @@ function Header(props) {
|
|||||||
const [collapseClasses, setCollapseClasses] = useState('');
|
const [collapseClasses, setCollapseClasses] = useState('');
|
||||||
const [themeSelected, setThemeSelected] = useState('lightTheme');
|
const [themeSelected, setThemeSelected] = useState('lightTheme');
|
||||||
const [defaultThemeConfig, setDefaultThemeConfig] = useState('lightTheme');
|
const [defaultThemeConfig, setDefaultThemeConfig] = useState('lightTheme');
|
||||||
|
const [modal, setModal] = useState(false)
|
||||||
|
|
||||||
|
const toggle = () => {setModal(!modal)}
|
||||||
|
|
||||||
const setInfo = async (colorArea, color, defaultThemeConfig) => {
|
const setInfo = async (colorArea, color, defaultThemeConfig) => {
|
||||||
let localThemeConfig = {...ThemeConfig}
|
let localThemeConfig = {...ThemeConfig}
|
||||||
@ -58,6 +62,7 @@ function Header(props) {
|
|||||||
<Navbar className={`navbar-horizontal ${ThemeConfig[GlobalTheme].navBar['navBarTheme']} ${ThemeConfig[GlobalTheme].navBar['background']}`}
|
<Navbar className={`navbar-horizontal ${ThemeConfig[GlobalTheme].navBar['navBarTheme']} ${ThemeConfig[GlobalTheme].navBar['background']}`}
|
||||||
expand="lg">
|
expand="lg">
|
||||||
<Container>
|
<Container>
|
||||||
|
<Publish notificationToggler={props.notificationToggler} modal={modal} toggle={toggle} />
|
||||||
<NavbarBrand>
|
<NavbarBrand>
|
||||||
<Link to="/">
|
<Link to="/">
|
||||||
{
|
{
|
||||||
@ -152,7 +157,14 @@ function Header(props) {
|
|||||||
outline
|
outline
|
||||||
onClick={() => setInfo(null, null, 'darkTheme')}>Dark Theme</Button>
|
onClick={() => setInfo(null, null, 'darkTheme')}>Dark Theme</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
<Button color={`${ThemeConfig ? ThemeConfig[GlobalTheme].navBar['buttonColor'] : ""}`} className='ms-5' outline>Publish Data</Button>
|
<Button
|
||||||
|
color={`${ThemeConfig ? ThemeConfig[GlobalTheme].navBar['buttonColor'] : ""}`}
|
||||||
|
className='ms-5'
|
||||||
|
outline
|
||||||
|
onClick={() => toggle()}
|
||||||
|
>
|
||||||
|
Publish Data
|
||||||
|
</Button>
|
||||||
</NavItem>
|
</NavItem>
|
||||||
</Nav>
|
</Nav>
|
||||||
</Container>
|
</Container>
|
||||||
|
|||||||
63
frontend/src/components/editable/shared/publish.jsx
Normal file
63
frontend/src/components/editable/shared/publish.jsx
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||||
|
import EditableDataService from '../../../services/editable-data-service';
|
||||||
|
|
||||||
|
function Publish(props) {
|
||||||
|
const [publishMethods, setPublishMethods] = useState(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchPublishMethods()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const fetchPublishMethods = async () => {
|
||||||
|
try {
|
||||||
|
const response = await EditableDataService.getData('/data/publish/methods/');
|
||||||
|
setPublishMethods(response.data)
|
||||||
|
} catch (error) {
|
||||||
|
props.notificationToggler('Error fetching methods', 'danger')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const publishData = async (deploy_method) => {
|
||||||
|
try {
|
||||||
|
const response = await EditableDataService.getData(`/data/publish/${deploy_method}/`);
|
||||||
|
props.notificationToggler('Deployment Sucess')
|
||||||
|
} catch (error) {
|
||||||
|
props.notificationToggler('Deployment Failed', 'danger')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Modal isOpen={props.modal} toggle={props.toggle}>
|
||||||
|
<ModalHeader toggle={props.toggle}>Publish Website</ModalHeader>
|
||||||
|
<ModalBody>
|
||||||
|
<h4>
|
||||||
|
Select a publish method
|
||||||
|
</h4>
|
||||||
|
{
|
||||||
|
publishMethods ?
|
||||||
|
publishMethods.map((item) =>
|
||||||
|
<div className='mb-3'>
|
||||||
|
<Button
|
||||||
|
key={item.key_name}
|
||||||
|
color='danger'
|
||||||
|
onClick={() => publishData(item.key_name)}
|
||||||
|
>
|
||||||
|
{item.name}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
):""
|
||||||
|
}
|
||||||
|
</ModalBody>
|
||||||
|
<ModalFooter>
|
||||||
|
<Button color="secondary" onClick={props.toggle}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</ModalFooter>
|
||||||
|
</Modal>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Publish;
|
||||||
Loading…
Reference in New Issue
Block a user