File size: 2,201 Bytes
176326d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import streamlit as st
import os
import pandas as pd
import sys

################################
######### Variables ############
################################
# -- Loading Variables
script_directory = os.path.dirname(os.path.abspath(sys.argv[0]))

# -- Loading Session Data
if 'project_data' not in st.session_state:
    st.session_state.project_data = pd.read_csv(script_directory+'/data/project.csv')

################################
####### Display of data ########
################################
# -- Streamlit Settings
st.set_page_config(layout='wide')
st.title("Project")

# -- Add Project Details
st.text("")
st.text("")
st.text("")
col1, col2, col3 = st.columns(3)
project = col1.text_input(label="Enter Project Name",placeholder="Project Name",key="project",label_visibility="collapsed")
source_app = col1.text_input(label="Enter Source Application Name",placeholder="Source Application Name",key="source_app",label_visibility="collapsed")
destination_app = col1.text_input(label="Enter Destination Application Name",placeholder="Destination Application Name",key="destination_app",label_visibility="collapsed")

# -- Add Project
col1, col2, col3 = st.columns([0.3,0.2,2.5])
if col1.button("Add Project"):
    # -- Create new Row
    new_data = {"Project": project, "Source": source_app, "Destination": destination_app}
    
    # -- Add new row
    st.session_state.project_data = pd.concat([st.session_state.project_data, pd.DataFrame([new_data])], ignore_index=True)
    st.session_state.project_data = st.session_state.project_data.drop_duplicates(subset='Project', keep="last")
    
    # -- Save data to CSV
    st.session_state.project_data['Id'] = st.session_state.project_data.index
    st.session_state.project_data.to_csv(script_directory+'/data/project.csv', index=False)

if col2.button("Save"):
    # -- Save data to CSV
    st.session_state.project_data['Id'] = st.session_state.project_data.index
    st.session_state.project_data.to_csv(script_directory+'/data/project.csv', index=False)

st.text("")
st.text("")
st.text("")

if len(st.session_state.project_data)>0:
        st.session_state.project_data=st.data_editor(st.session_state.project_data, hide_index=True)