Demo upload
This commit is contained in:
@@ -34,6 +34,7 @@ feature {NONE} -- Initialization
|
|||||||
make_multi_control
|
make_multi_control
|
||||||
tag_name := "form"
|
tag_name := "form"
|
||||||
label_width := w
|
label_width := w
|
||||||
|
add_class ("form-horizontal")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature
|
feature
|
||||||
|
|||||||
@@ -36,12 +36,13 @@ feature {NONE} -- Initialization
|
|||||||
do
|
do
|
||||||
make_control ("div")
|
make_control ("div")
|
||||||
add_class ("form-group")
|
add_class ("form-group")
|
||||||
if attached {WSF_HTML_CONTROL} c then
|
if not attached {WSF_VALUE_CONTROL [LIST[ANY]]} c then
|
||||||
c.add_class ("form-control-static")
|
|
||||||
elseif not attached {WSF_VALUE_CONTROL [LIST[ANY]]} c then
|
|
||||||
|
|
||||||
c.add_class ("form-control")
|
c.add_class ("form-control")
|
||||||
|
else
|
||||||
|
c.add_class ("form-control-static")
|
||||||
end
|
end
|
||||||
|
|
||||||
label_width := 2
|
label_width := 2
|
||||||
value_control := c
|
value_control := c
|
||||||
validators := v
|
validators := v
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ feature -- Router and Filter
|
|||||||
map_agent_uri ("/grid", agent grid_demo, Void)
|
map_agent_uri ("/grid", agent grid_demo, Void)
|
||||||
map_agent_uri ("/repeater", agent repeater_demo, Void)
|
map_agent_uri ("/repeater", agent repeater_demo, Void)
|
||||||
map_agent_uri ("/slider", agent slider_demo, Void)
|
map_agent_uri ("/slider", agent slider_demo, Void)
|
||||||
|
map_agent_uri ("/upload", agent upload_demo, Void)
|
||||||
map_agent_uri ("/codeview", agent codeview, Void)
|
map_agent_uri ("/codeview", agent codeview, Void)
|
||||||
|
|
||||||
-- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/"
|
-- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/"
|
||||||
@@ -137,6 +138,16 @@ feature -- Execution
|
|||||||
page.execute
|
page.execute
|
||||||
end
|
end
|
||||||
|
|
||||||
|
upload_demo (request: WSF_REQUEST; response: WSF_RESPONSE)
|
||||||
|
local
|
||||||
|
page: UPLOAD_PAGE
|
||||||
|
do
|
||||||
|
-- To send a response we need to setup, the status code and
|
||||||
|
-- the response headers.
|
||||||
|
create page.make (request, response)
|
||||||
|
page.execute
|
||||||
|
end
|
||||||
|
|
||||||
codeview (request: WSF_REQUEST; response: WSF_RESPONSE)
|
codeview (request: WSF_REQUEST; response: WSF_RESPONSE)
|
||||||
local
|
local
|
||||||
page: CODEVIEW_PAGE
|
page: CODEVIEW_PAGE
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ feature
|
|||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/grid%"", "Grid"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/grid%"", "Grid"))
|
||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/repeater%"", "Repeater"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/repeater%"", "Repeater"))
|
||||||
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Slider"))
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Slider"))
|
||||||
|
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/upload%"", "File Upload"))
|
||||||
navbar.add_element (dropdown)
|
navbar.add_element (dropdown)
|
||||||
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/about%"", "About"))
|
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/about%"", "About"))
|
||||||
create btn.make ("Show Code")
|
create btn.make ("Show Code")
|
||||||
|
|||||||
@@ -20,13 +20,9 @@ create
|
|||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
local
|
|
||||||
form: WSF_FORM_CONTROL
|
|
||||||
do
|
do
|
||||||
Precursor
|
Precursor
|
||||||
create slider.make
|
create slider.make
|
||||||
create form.make
|
|
||||||
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING]}.make ("Input", create {WSF_INPUT_CONTROL}.make ("Test")))
|
|
||||||
--slider.add_control (form, Void)
|
--slider.add_control (form, Void)
|
||||||
--slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
--slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
||||||
slider.add_image ("http://31.media.tumblr.com/43f3edae3fb569943047077cddf93c79/tumblr_mtw7wdX9cm1st5lhmo1_1280.jpg", "car")
|
slider.add_image ("http://31.media.tumblr.com/43f3edae3fb569943047077cddf93c79/tumblr_mtw7wdX9cm1st5lhmo1_1280.jpg", "car")
|
||||||
|
|||||||
@@ -26,14 +26,11 @@ feature
|
|||||||
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
n4_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n4_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
n5_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
n5_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||||
n6_container: WSF_FORM_ELEMENT_CONTROL [detachable WSF_PENDING_FILE]
|
|
||||||
n7_container: WSF_FORM_ELEMENT_CONTROL [detachable WSF_PENDING_FILE]
|
|
||||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||||
source: INCREASING_PROGRESSSOURCE
|
source: INCREASING_PROGRESSSOURCE
|
||||||
do
|
do
|
||||||
Precursor
|
Precursor
|
||||||
create form.make
|
create form.make
|
||||||
form.add_class ("form-horizontal")
|
|
||||||
--Number 1
|
--Number 1
|
||||||
create textbox1.make ("1")
|
create textbox1.make ("1")
|
||||||
create n1_container.make ("Number1", textbox1)
|
create n1_container.make ("Number1", textbox1)
|
||||||
@@ -66,21 +63,6 @@ feature
|
|||||||
cats_container.add_validator (create {WSF_MIN_VALIDATOR [LIST [STRING]]}.make (1, "Choose at least one category"))
|
cats_container.add_validator (create {WSF_MIN_VALIDATOR [LIST [STRING]]}.make (1, "Choose at least one category"))
|
||||||
cats_container.add_validator (create {WSF_MAX_VALIDATOR [LIST [STRING]]}.make (2, "Choose at most two category"))
|
cats_container.add_validator (create {WSF_MAX_VALIDATOR [LIST [STRING]]}.make (2, "Choose at most two category"))
|
||||||
form.add_control (cats_container)
|
form.add_control (cats_container)
|
||||||
--File
|
|
||||||
create filebox.make
|
|
||||||
filebox.set_upload_function (agent upload_file)
|
|
||||||
create n6_container.make ("File Upload", filebox)
|
|
||||||
n6_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
|
||||||
form.add_control (n6_container)
|
|
||||||
--File
|
|
||||||
create filebox2.make
|
|
||||||
filebox2.set_upload_function (agent upload_file)
|
|
||||||
filebox2.set_change_event (agent do
|
|
||||||
filebox2.start_upload
|
|
||||||
end)
|
|
||||||
create n7_container.make ("Auto Upload", filebox2)
|
|
||||||
n7_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
|
||||||
form.add_control (n7_container)
|
|
||||||
--Button 1
|
--Button 1
|
||||||
create button1.make ("Update")
|
create button1.make ("Update")
|
||||||
button1.set_click_event (agent handle_click)
|
button1.set_click_event (agent handle_click)
|
||||||
@@ -105,23 +87,12 @@ feature
|
|||||||
navbar.set_active (1)
|
navbar.set_active (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
upload_file (f: ITERABLE [WSF_UPLOADED_FILE]): detachable String
|
|
||||||
do
|
|
||||||
-- Store file on server and return link
|
|
||||||
across
|
|
||||||
f as i
|
|
||||||
loop
|
|
||||||
Result:=i.item.filename
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
handle_click
|
handle_click
|
||||||
local
|
local
|
||||||
text: STRING
|
text: STRING
|
||||||
do
|
do
|
||||||
form.validate
|
form.validate
|
||||||
if form.is_valid then
|
if form.is_valid then
|
||||||
filebox.start_upload
|
|
||||||
--progress.set_progress ((textbox1.text.to_integer_64 / textbox2.text.to_integer_64 * 100).ceiling)
|
--progress.set_progress ((textbox1.text.to_integer_64 / textbox2.text.to_integer_64 * 100).ceiling)
|
||||||
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
|
||||||
text.append ("<ul>")
|
text.append ("<ul>")
|
||||||
@@ -150,10 +121,6 @@ feature
|
|||||||
|
|
||||||
button2: WSF_BUTTON_CONTROL
|
button2: WSF_BUTTON_CONTROL
|
||||||
|
|
||||||
filebox: WSF_FILE_CONTROL
|
|
||||||
|
|
||||||
filebox2: WSF_FILE_CONTROL
|
|
||||||
|
|
||||||
textbox1: WSF_INPUT_CONTROL
|
textbox1: WSF_INPUT_CONTROL
|
||||||
|
|
||||||
textbox2: WSF_INPUT_CONTROL
|
textbox2: WSF_INPUT_CONTROL
|
||||||
|
|||||||
95
examples/widgetapp/upload_page.e
Normal file
95
examples/widgetapp/upload_page.e
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {UPLOAD_PAGE}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
UPLOAD_PAGE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
|
||||||
|
BASE_PAGE
|
||||||
|
redefine
|
||||||
|
initialize_controls
|
||||||
|
end
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature -- Implementation
|
||||||
|
|
||||||
|
initialize_controls
|
||||||
|
local
|
||||||
|
do
|
||||||
|
Precursor
|
||||||
|
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", "File Upload Demo"))
|
||||||
|
create form.make
|
||||||
|
--File
|
||||||
|
create filebox.make
|
||||||
|
filebox.set_upload_function (agent upload_file)
|
||||||
|
create n0_container.make ("File Upload", filebox)
|
||||||
|
n0_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
||||||
|
form.add_control (n0_container)
|
||||||
|
--File
|
||||||
|
create filebox2.make
|
||||||
|
create n1_container.make ("Auto start Upload", filebox2)
|
||||||
|
filebox2.set_upload_function (agent upload_file)
|
||||||
|
filebox2.set_change_event (agent
|
||||||
|
do
|
||||||
|
n1_container.validate
|
||||||
|
if n1_container.is_valid then
|
||||||
|
filebox2.start_upload
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
n1_container.add_validator (create {WSF_FILESIZE_VALIDATOR}.make (10000000, "File must be smaller than 10MB"))
|
||||||
|
form.add_control (n1_container)
|
||||||
|
|
||||||
|
--Button 1
|
||||||
|
create button1.make ("Update")
|
||||||
|
button1.set_click_event (agent submit_form)
|
||||||
|
button1.add_class ("col-lg-offset-2")
|
||||||
|
form.add_control (button1)
|
||||||
|
|
||||||
|
control.add_control (form)
|
||||||
|
navbar.set_active (5)
|
||||||
|
end
|
||||||
|
|
||||||
|
submit_form
|
||||||
|
do
|
||||||
|
form.validate
|
||||||
|
if form.is_valid then
|
||||||
|
filebox.start_upload
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
upload_file (f: ITERABLE [WSF_UPLOADED_FILE]): detachable String
|
||||||
|
do
|
||||||
|
-- Store file on server and return link
|
||||||
|
across
|
||||||
|
f as i
|
||||||
|
loop
|
||||||
|
Result := i.item.filename
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
process
|
||||||
|
do
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Properties
|
||||||
|
|
||||||
|
form: WSF_FORM_CONTROL
|
||||||
|
|
||||||
|
button1: WSF_BUTTON_CONTROL
|
||||||
|
|
||||||
|
filebox: WSF_FILE_CONTROL
|
||||||
|
|
||||||
|
filebox2: WSF_FILE_CONTROL
|
||||||
|
|
||||||
|
n0_container: WSF_FORM_ELEMENT_CONTROL [detachable WSF_PENDING_FILE]
|
||||||
|
|
||||||
|
n1_container: WSF_FORM_ELEMENT_CONTROL [detachable WSF_PENDING_FILE]
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user