Jeangg commited on
Commit
de93fff
·
1 Parent(s): b36b9b1

test dynamic

Browse files
Files changed (1) hide show
  1. app.py +32 -39
app.py CHANGED
@@ -107,41 +107,35 @@ def reset_inputs():
107
  # Gradio UI Layout
108
  def main():
109
  with gr.Blocks() as ui:
110
- # Set page title and favicon using HTML
111
- gr.HTML("""
112
- <head>
113
- <title>LINE Audience Manager</title>
114
- <link rel="icon" href="https://media.licdn.com/dms/image/v2/C560BAQE6RcoYoG2AKw/company-logo_200_200/company-logo_200_200/0/1631385097016?e=1736380800&v=beta&t=KjZtErojYcSYLGCH1OskFpEAUMXsfqSMTbnmbRdETXU" type="image/x-icon">
115
- </head>
116
- """)
117
-
118
- gr.Markdown("# YDM RDA: LINE Push message dynamic URL link")
119
 
120
  # User input fields
121
  line_access_token = gr.Textbox(label="LINE Channel Access Token")
122
- audience_main_id = gr.Textbox(label="Main LINE Audience")
123
- option = gr.Radio(label="Select Option", choices=["Single message","Single Image map", "Image map with text", "Text with Image map"])
124
  with gr.Row():
125
- age_min = gr.Dropdown([15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],label="Age Min")
126
- age_max= gr.Dropdown([15 ,20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],label="Age Max")
127
  # age = gr.Slider(minimum=15, maximum=70, step=15,label='Age', info="Choose age range", interactive=True)
128
  with gr.Row():
129
- friend_duration_min = gr.Dropdown([7, 30, 90, 180, 365],label="Friend Duration Min")
130
- friend_duration_max = gr.Dropdown([7, 30, 90, 180, 365],label="Friend Duration Max")
131
  # friend_duration = gr.Slider(minimum=30, maximum=180, step=30, label="Friend Duration", info="Choose friend duration", randomize=True)
132
  with gr.Row():
133
- gender = gr.CheckboxGroup(["Male", "Female"], label="Gender")
134
- system = gr.CheckboxGroup(["ios", "Android"], info="Select Mobile system", label='Mobile System')
135
- region = gr.CheckboxGroup(['Bangkok', 'Pattaya', 'Northern', 'Central', 'Southern', 'Eastern', 'NorthEastern', 'Western'], label="Thailand Region", info="Select Thailand Region")
 
 
 
136
 
137
  # Message Conditional Inputs
138
- # image_address = gr.Textbox(label="Your Image address", visible=False)
139
- # image_alt = gr.Textbox(label="Your Image ALT", visible=False)
140
- # image_width= gr.Textbox(label="Your Image Width", visible=False)
141
- # image_height= gr.Textbox(label="Your Image Height", visible=False)
142
- # text_message = gr.Textbox(label="Your Text message", visible=False)
143
- # endpoint_url = gr.Textbox(label="Your Endpint URL", visible=False)
144
- # dynamic_parameter = gr.Textbox(label="Your dynamic LINE UID parameter name", visible=False)
145
 
146
  def toggle_inputs_file(option):
147
  if option == "Text":
@@ -154,29 +148,28 @@ def main():
154
  )
155
 
156
  def toggle_inputs(option):
157
- if option == "Single Image map":
158
- # Show only image-related fields
 
 
 
 
159
  return (
160
  gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
161
- gr.update(visible=True), gr.update(visible=False), gr.update(visible=True),
162
- gr.update(visible=True)
163
  )
164
- elif option == "Image map with text":
165
- # Show all fields
166
  return (
167
  gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
168
- gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
169
- gr.update(visible=True)
170
  )
171
- elif option == "Text with Image map":
172
- # Show only text-related fields
173
  return (
174
  gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
175
- gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
176
- gr.update(visible=True)
177
  )
178
- # file_option.change(fn=toggle_inputs_file, inputs=file_option, outputs=[list_uid, line_uid_file])
179
- # option.change(fn=toggle_inputs, inputs=option, outputs=[image_address, image_alt, image_width, image_height, text_message, endpoint_url, dynamic_parameter])
180
 
181
  # # Submit button and output
182
  submit_btn = gr.Button("Submit")
 
107
  # Gradio UI Layout
108
  def main():
109
  with gr.Blocks() as ui:
110
+
111
+ gr.Markdown("# Happy LINE Service: LINE Personlaized boardcast")
 
 
 
 
 
 
 
112
 
113
  # User input fields
114
  line_access_token = gr.Textbox(label="LINE Channel Access Token")
115
+ audience_main_id = gr.Textbox(label="Main LINE Audience ID")
 
116
  with gr.Row():
117
+ age_min = gr.Dropdown([15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],label="อายุขั้นต่ำ: ปี")
118
+ age_max= gr.Dropdown([15 ,20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],label="อายุสูงไม่เกิน: ปี")
119
  # age = gr.Slider(minimum=15, maximum=70, step=15,label='Age', info="Choose age range", interactive=True)
120
  with gr.Row():
121
+ friend_duration_min = gr.Dropdown([7, 30, 90, 180, 365],label="ระยะเวลาที่เพิ่มเพื่อนขั้นต่ำ: วัน")
122
+ friend_duration_max = gr.Dropdown([7, 30, 90, 180, 365],label="ระยะเวลาที่เพิ่มเพื่อนไม่เกิน: วัน")
123
  # friend_duration = gr.Slider(minimum=30, maximum=180, step=30, label="Friend Duration", info="Choose friend duration", randomize=True)
124
  with gr.Row():
125
+ gender = gr.CheckboxGroup(["Male", "Female"], label="เพศ")
126
+ system = gr.CheckboxGroup(["ios", "Android"], label='ระบบปฏิบัติการ')
127
+ region = gr.CheckboxGroup(['Bangkok', 'Pattaya', 'Northern', 'Central', 'Southern', 'Eastern', 'NorthEastern', 'Western'], label="ภูมิภาค")
128
+
129
+ with gr.Row():
130
+ option = gr.Radio(label="Select Option", choices=["ข้อความแบบเดี่ยว","รูปภาพแบบเดี่ยว", "รูปภาพ ตามด้วยข้อความ", "ข้อความ ตามด้วยรูปภาพ"])
131
 
132
  # Message Conditional Inputs
133
+ image_address = gr.Textbox(label="Your Image address", visible=False)
134
+ image_alt = gr.Textbox(label="Your Image ALT", visible=False)
135
+ image_width= gr.Textbox(label="Your Image Width", visible=False)
136
+ image_height= gr.Textbox(label="Your Image Height", visible=False)
137
+ text_message = gr.Textbox(label="Your Text message", visible=False)
138
+ endpoint_url = gr.Textbox(label="Your Endpint URL", visible=False)
 
139
 
140
  def toggle_inputs_file(option):
141
  if option == "Text":
 
148
  )
149
 
150
  def toggle_inputs(option):
151
+ if option == "ข้อความแบบเดี่ยว":
152
+ return (
153
+ gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
154
+ gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)
155
+ )
156
+ elif option == "รูปภาพแบบเดี่ยว":
157
  return (
158
  gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
159
+ gr.update(visible=True), gr.update(visible=False), gr.update(visible=True)
 
160
  )
161
+ elif option == "รูปภาพ ตามด้วยข้อความ":
 
162
  return (
163
  gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
164
+ gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
 
165
  )
166
+ elif option == "ข้อความ ตามด้วยรูปภาพ":
 
167
  return (
168
  gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
169
+ gr.update(visible=True), gr.update(visible=True), gr.update(visible=True)
 
170
  )
171
+
172
+ option.change(fn=toggle_inputs, inputs=option, outputs=[image_address, image_alt, image_width, image_height, text_message, endpoint_url])
173
 
174
  # # Submit button and output
175
  submit_btn = gr.Button("Submit")