dashboard tab 추가

This commit is contained in:
dsk-minchulahn
2023-08-11 17:28:53 +09:00
parent 281352a5cd
commit 91f5f4e7aa
2 changed files with 50 additions and 31 deletions

View File

@@ -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]) col1, col2 = st.columns([7, 3])
with col1: with col1:
st.subheader('Service') st.subheader('Service')
if st.button('Data Reload'): if st.button('Data Reload'):
git_pull() git_pull()
streamlit_js_eval(js_expressions='parent.window.location.reload()') streamlit_js_eval(js_expressions='parent.window.location.reload()')
df = pd.DataFrame.from_dict(get_service()) df = pd.DataFrame.from_dict(get_service())
regex = '^release-[0-9]+.[0-9]+.[0-9]+$' regex = '^release-[0-9]+.[0-9]+.[0-9]+$'
edited_df = st.data_editor( edited_df = st.data_editor(
df.style.applymap(highlight_disabled_col), df.style.applymap(highlight_disabled_col),
key='data_editor', key='data_editor',
column_config={ column_config={
'type': st.column_config.TextColumn('Type', disabled=True), 'type': st.column_config.TextColumn('Type', disabled=True),
'name': st.column_config.TextColumn('Name', disabled=True, width='medium'), 'name': st.column_config.TextColumn('Name', disabled=True, width='medium'),
'latest_candidate_version': st.column_config.TextColumn('Candidate Latest Version', disabled=True), 'latest_candidate_version': st.column_config.TextColumn('Candidate Latest Version', disabled=True),
'candidate_version': st.column_config.TextColumn('Candidate Version', validate=regex), 'candidate_version': st.column_config.TextColumn('Candidate Version', validate=regex),
'release_version': st.column_config.TextColumn('Release Version', validate=regex), 'release_version': st.column_config.TextColumn('Release Version', validate=regex),
'product_version': st.column_config.TextColumn('Product Version', validate=regex) 'product_version': st.column_config.TextColumn('Product Version', validate=regex)
} }
) )
with col2: with col2:
st.text('Edited Rows') st.text('Edited Rows')
st.write(st.session_state['data_editor']['edited_rows']) st.write(st.session_state['data_editor']['edited_rows'])
with tab2:
releases = get_github_releases()
for release in releases:
st.write(f"### {release['name']}")
st.write(release['html_url'])
st.write(datetime.strptime(release['published_at'], "%Y-%m-%dT%H:%M:%SZ"))
# 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('#', ''))
st.divider()
show_sidebar(df, edited_df) show_sidebar(df, edited_df)

View File

@@ -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