dashboard tab 추가
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
import streamlit as st
|
import streamlit as st
|
||||||
|
from datetime import datetime
|
||||||
from streamlit_js_eval import streamlit_js_eval
|
from streamlit_js_eval import streamlit_js_eval
|
||||||
from settings import *
|
from settings import *
|
||||||
from sidebar import show_sidebar
|
from sidebar import show_sidebar
|
||||||
@@ -7,42 +8,53 @@ from sidebar import show_sidebar
|
|||||||
def highlight_disabled_col(value):
|
def highlight_disabled_col(value):
|
||||||
return 'background-color: #F0F2F6'
|
return 'background-color: #F0F2F6'
|
||||||
|
|
||||||
def init_page():
|
if __name__=='__main__':
|
||||||
|
|
||||||
st.set_page_config(
|
st.set_page_config(
|
||||||
page_title='DataSaker Version Management',
|
page_title='DataSaker Version Management',
|
||||||
layout='wide'
|
layout='wide'
|
||||||
)
|
)
|
||||||
st.header('DataSaker Version Management')
|
|
||||||
st.subheader(get_datasaker())
|
|
||||||
|
|
||||||
if __name__=='__main__':
|
tab1, tab2 = st.tabs(["Deploy DataSaker", "Release Info"])
|
||||||
|
|
||||||
init_page()
|
with tab1:
|
||||||
|
st.header('DataSaker')
|
||||||
|
st.write(f"##### {get_datasaker()}")
|
||||||
|
|
||||||
|
col1, col2 = st.columns([7, 3])
|
||||||
|
with col1:
|
||||||
|
st.subheader('Service')
|
||||||
|
|
||||||
|
if st.button('Data Reload'):
|
||||||
|
git_pull()
|
||||||
|
streamlit_js_eval(js_expressions='parent.window.location.reload()')
|
||||||
|
|
||||||
|
df = pd.DataFrame.from_dict(get_service())
|
||||||
|
regex = '^release-[0-9]+.[0-9]+.[0-9]+$'
|
||||||
|
edited_df = st.data_editor(
|
||||||
|
df.style.applymap(highlight_disabled_col),
|
||||||
|
key='data_editor',
|
||||||
|
column_config={
|
||||||
|
'type': st.column_config.TextColumn('Type', disabled=True),
|
||||||
|
'name': st.column_config.TextColumn('Name', disabled=True, width='medium'),
|
||||||
|
'latest_candidate_version': st.column_config.TextColumn('Candidate Latest Version', disabled=True),
|
||||||
|
'candidate_version': st.column_config.TextColumn('Candidate Version', validate=regex),
|
||||||
|
'release_version': st.column_config.TextColumn('Release Version', validate=regex),
|
||||||
|
'product_version': st.column_config.TextColumn('Product Version', validate=regex)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
with col2:
|
||||||
|
st.text('Edited Rows')
|
||||||
|
st.write(st.session_state['data_editor']['edited_rows'])
|
||||||
|
|
||||||
col1, col2 = st.columns([7, 3])
|
with tab2:
|
||||||
with col1:
|
releases = get_github_releases()
|
||||||
st.subheader('Service')
|
for release in releases:
|
||||||
|
st.write(f"### {release['name']}")
|
||||||
if st.button('Data Reload'):
|
st.write(release['html_url'])
|
||||||
git_pull()
|
st.write(datetime.strptime(release['published_at'], "%Y-%m-%dT%H:%M:%SZ"))
|
||||||
streamlit_js_eval(js_expressions='parent.window.location.reload()')
|
# st.write(datetime.strptime(release['published_at'], "%Y-%m-%dT%H:%M:%SZ").strftime('%Y-%m-%d %H:%M:%S'))
|
||||||
|
st.write(release['body'].replace('#', ''))
|
||||||
df = pd.DataFrame.from_dict(get_service())
|
st.divider()
|
||||||
regex = '^release-[0-9]+.[0-9]+.[0-9]+$'
|
|
||||||
edited_df = st.data_editor(
|
|
||||||
df.style.applymap(highlight_disabled_col),
|
|
||||||
key='data_editor',
|
|
||||||
column_config={
|
|
||||||
'type': st.column_config.TextColumn('Type', disabled=True),
|
|
||||||
'name': st.column_config.TextColumn('Name', disabled=True, width='medium'),
|
|
||||||
'latest_candidate_version': st.column_config.TextColumn('Candidate Latest Version', disabled=True),
|
|
||||||
'candidate_version': st.column_config.TextColumn('Candidate Version', validate=regex),
|
|
||||||
'release_version': st.column_config.TextColumn('Release Version', validate=regex),
|
|
||||||
'product_version': st.column_config.TextColumn('Product Version', validate=regex)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
with col2:
|
|
||||||
st.text('Edited Rows')
|
|
||||||
st.write(st.session_state['data_editor']['edited_rows'])
|
|
||||||
|
|
||||||
show_sidebar(df, edited_df)
|
show_sidebar(df, edited_df)
|
||||||
@@ -18,6 +18,13 @@ def get_commit_id():
|
|||||||
def get_tags():
|
def get_tags():
|
||||||
return repo.tags
|
return repo.tags
|
||||||
|
|
||||||
|
def get_github_releases():
|
||||||
|
api_url = 'https://api.github.com/repos/cloudmoa/dsk-version-management/releases'
|
||||||
|
github_token = os.environ.get('GITHUB_TOKEN')
|
||||||
|
headers = {'Authorization': f'Bearer {github_token}', 'Accept': 'application/vnd.github.v3+json'}
|
||||||
|
releases = requests.get(api_url, headers=headers).json()
|
||||||
|
return releases
|
||||||
|
|
||||||
def diff():
|
def diff():
|
||||||
if len(repo.index.diff(repo.head.commit)) > 0:
|
if len(repo.index.diff(repo.head.commit)) > 0:
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user