Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,7 +37,7 @@ def show_s(name,token,save_list):
|
|
37 |
else:
|
38 |
spaces.append(space_ea)
|
39 |
#print (space_ea)
|
40 |
-
return(gr.update(label="Spaces", choices=[s for s in spaces]))
|
41 |
#gr.update(choices=[s for s in spaces],interactive=True))
|
42 |
|
43 |
def show_f(repo,name,token,tog):
|
@@ -137,7 +137,7 @@ def add_save(space,save_state):
|
|
137 |
if this:
|
138 |
#save_list.append(space)
|
139 |
save_state.append(space)
|
140 |
-
return save_state,gr.update(choices=[f for f in save_state],interactive=True)
|
141 |
|
142 |
def rem_save(space,save_state):
|
143 |
save_out=[]
|
@@ -146,30 +146,32 @@ def rem_save(space,save_state):
|
|
146 |
print(ea)
|
147 |
if not space == ea:
|
148 |
save_out.append(space)
|
149 |
-
return save_out, gr.update(choices=[f for f in save_out],interactive=True)
|
150 |
|
151 |
with gr.Blocks(css=css) as build:
|
152 |
save_state=gr.State()
|
|
|
153 |
with gr.Row(visible=False) as no:
|
154 |
pass_box=gr.Textbox()
|
155 |
pass_btn=gr.Button()
|
156 |
-
with gr.Group(visible=True) as yes:
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
166 |
with gr.Tab("View 1"):
|
167 |
with gr.Row():
|
168 |
with gr.Column(scale=1):
|
169 |
with gr.Group():
|
170 |
space_radio=gr.Radio(label="Spaces",choices=[])
|
171 |
with gr.Column(scale=3):
|
172 |
-
|
173 |
with gr.Tab("Space Info"):
|
174 |
with gr.Row():
|
175 |
with gr.Column(scale=3):
|
@@ -190,13 +192,29 @@ with gr.Blocks(css=css) as build:
|
|
190 |
save_list=gr.Radio(label="Protected",choices=[])
|
191 |
with gr.Column():
|
192 |
save_btn=gr.Button("Protect")
|
193 |
-
rem_btn=gr.Button("Remove")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
-
save_btn.click(add_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio])
|
196 |
-
rem_btn.click(rem_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio])
|
197 |
|
198 |
-
move_btn.click(move,[r_name,space_radio,dest,token]).then(show_s,[r_name,token,save_state],[space_radio])
|
199 |
-
s_btn.click(show_s,[r_name,token,save_list],[space_radio])
|
200 |
|
201 |
space_radio.change(show_f,[r_name,space_radio,token,tog],[files,file_radio,space_info_json])
|
202 |
file_radio.change(show_f_cont,[r_name,space_radio,file_radio,token],[file_contents])
|
|
|
37 |
else:
|
38 |
spaces.append(space_ea)
|
39 |
#print (space_ea)
|
40 |
+
return(gr.update(label="Spaces", choices=[s for s in spaces]),spaces)
|
41 |
#gr.update(choices=[s for s in spaces],interactive=True))
|
42 |
|
43 |
def show_f(repo,name,token,tog):
|
|
|
137 |
if this:
|
138 |
#save_list.append(space)
|
139 |
save_state.append(space)
|
140 |
+
return save_state,gr.update(choices=[f for f in save_state],interactive=True),save_state
|
141 |
|
142 |
def rem_save(space,save_state):
|
143 |
save_out=[]
|
|
|
146 |
print(ea)
|
147 |
if not space == ea:
|
148 |
save_out.append(space)
|
149 |
+
return save_out, gr.update(choices=[f for f in save_out],interactive=True),save_out
|
150 |
|
151 |
with gr.Blocks(css=css) as build:
|
152 |
save_state=gr.State()
|
153 |
+
space_list=gr.State()
|
154 |
with gr.Row(visible=False) as no:
|
155 |
pass_box=gr.Textbox()
|
156 |
pass_btn=gr.Button()
|
157 |
+
#with gr.Group(visible=True) as yes:
|
158 |
+
with gr.Group():
|
159 |
+
with gr.Row():
|
160 |
+
with gr.Column(scale=2):
|
161 |
+
r_name = gr.Textbox(label="Repo")
|
162 |
+
token = gr.Textbox(label="auth")
|
163 |
+
s_btn = gr.Button("Show Spaces")
|
164 |
+
with gr.Column(scale=1):
|
165 |
+
tog=gr.Checkbox(label="Show Files",value=True)
|
166 |
+
files=gr.File(file_count="directory")
|
167 |
+
with gr.Group():
|
168 |
with gr.Tab("View 1"):
|
169 |
with gr.Row():
|
170 |
with gr.Column(scale=1):
|
171 |
with gr.Group():
|
172 |
space_radio=gr.Radio(label="Spaces",choices=[])
|
173 |
with gr.Column(scale=3):
|
174 |
+
|
175 |
with gr.Tab("Space Info"):
|
176 |
with gr.Row():
|
177 |
with gr.Column(scale=3):
|
|
|
192 |
save_list=gr.Radio(label="Protected",choices=[])
|
193 |
with gr.Column():
|
194 |
save_btn=gr.Button("Protect")
|
195 |
+
rem_btn=gr.Button("Remove")
|
196 |
+
with gr.Tab("Controls"):
|
197 |
+
com_off = gr.Button("Turn OFF Commenting")
|
198 |
+
com_on = gr.Button("Turn ON Commenting")
|
199 |
+
|
200 |
+
|
201 |
+
def toggle_comments_off(space_list,token):
|
202 |
+
api = HfApi(token=token)
|
203 |
+
|
204 |
+
api.change_discussion_status(
|
205 |
+
new_status='closed',
|
206 |
+
token=token,
|
207 |
+
repo_type='space',
|
208 |
+
)
|
209 |
+
|
210 |
+
|
211 |
+
com_off.click(toggle_comments_off, [])
|
212 |
|
213 |
+
save_btn.click(add_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,space_list])
|
214 |
+
rem_btn.click(rem_save,[space_radio,save_state],[save_state,save_list]).then(show_s,[r_name,token,save_state],[space_radio,space_list])
|
215 |
|
216 |
+
move_btn.click(move,[r_name,space_radio,dest,token]).then(show_s,[r_name,token,save_state],[space_radio,space_list])
|
217 |
+
s_btn.click(show_s,[r_name,token,save_list],[space_radio,space_list])
|
218 |
|
219 |
space_radio.change(show_f,[r_name,space_radio,token,tog],[files,file_radio,space_info_json])
|
220 |
file_radio.change(show_f_cont,[r_name,space_radio,file_radio,token],[file_contents])
|