Fixed progressbar
This commit is contained in:
@@ -16,20 +16,28 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
progress_value: INTEGER
|
control: detachable WSF_PROGRESS_CONTROL
|
||||||
|
|
||||||
make
|
make ()
|
||||||
do
|
do
|
||||||
progress_value := 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Implementation
|
feature -- Implementation
|
||||||
|
|
||||||
|
set_control (c: WSF_PROGRESS_CONTROL)
|
||||||
|
do
|
||||||
|
control := c
|
||||||
|
end
|
||||||
|
|
||||||
progress: INTEGER
|
progress: INTEGER
|
||||||
do
|
do
|
||||||
Result := progress_value
|
if attached control as c then
|
||||||
if progress_value < 100 then
|
Result := c.progress
|
||||||
progress_value := progress_value + 1
|
if c.progress < 100 then
|
||||||
|
Result := Result + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Result := 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ feature
|
|||||||
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]
|
||||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||||
|
source: INCREASING_PROGRESSSOURCE
|
||||||
do
|
do
|
||||||
Precursor
|
Precursor
|
||||||
create form.make_form_control ("panel")
|
create form.make_form_control ("panel")
|
||||||
@@ -75,7 +76,9 @@ feature
|
|||||||
|
|
||||||
--Progress bar
|
--Progress bar
|
||||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h4","","Number1/Number2"))
|
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h4","","Number1/Number2"))
|
||||||
create progress.make_progress_with_source ("progress1", create {INCREASING_PROGRESSSOURCE}.make)
|
create source.make
|
||||||
|
create progress.make_progress_with_source ("progress1", source)
|
||||||
|
source.set_control (progress)
|
||||||
container.add_control (progress)
|
container.add_control (progress)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ trigger_callback = (control_name,event,event_parameter)->
|
|||||||
for name,state of new_states
|
for name,state of new_states
|
||||||
controls[name]?.update(state)
|
controls[name]?.update(state)
|
||||||
return
|
return
|
||||||
|
|
||||||
class WSF_VALIDATOR
|
class WSF_VALIDATOR
|
||||||
constructor: (@parent_control, @settings)->
|
constructor: (@parent_control, @settings)->
|
||||||
@error = @settings.error
|
@error = @settings.error
|
||||||
@@ -256,13 +257,14 @@ class WSF_PROGRESS_CONTROL extends WSF_CONTROL
|
|||||||
|
|
||||||
attach_events:() ->
|
attach_events:() ->
|
||||||
self = @
|
self = @
|
||||||
setInterval(@fetch, 1000)
|
runfetch= ()->
|
||||||
|
self.fetch()
|
||||||
|
setInterval(runfetch, 100)
|
||||||
|
|
||||||
fetch: ()->
|
fetch: ()->
|
||||||
trigger_callback(@control_name, 'progress_fetch')
|
trigger_callback(@control_name, 'progress_fetch')
|
||||||
|
|
||||||
update: (state)->
|
update: (state)->
|
||||||
alert('update')
|
|
||||||
if state.progress?
|
if state.progress?
|
||||||
window.states[@control_name]['progress'] = state.progress
|
window.states[@control_name]['progress'] = state.progress
|
||||||
@$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
@$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
||||||
|
|||||||
@@ -478,9 +478,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.attach_events = function() {
|
WSF_PROGRESS_CONTROL.prototype.attach_events = function() {
|
||||||
var self;
|
var runfetch, self;
|
||||||
self = this;
|
self = this;
|
||||||
return setInterval(this.fetch, 1000);
|
runfetch = function() {
|
||||||
|
return self.fetch();
|
||||||
|
};
|
||||||
|
return setInterval(runfetch, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
||||||
@@ -488,7 +491,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
||||||
alert('update');
|
|
||||||
if (state.progress != null) {
|
if (state.progress != null) {
|
||||||
window.states[this.control_name]['progress'] = state.progress;
|
window.states[this.control_name]['progress'] = state.progress;
|
||||||
return this.$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%');
|
return this.$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%');
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ feature -- State handling
|
|||||||
|
|
||||||
set_state (new_state: JSON_OBJECT)
|
set_state (new_state: JSON_OBJECT)
|
||||||
do
|
do
|
||||||
|
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("progress")) as new_progress then
|
||||||
|
progress := new_progress.item.to_integer
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
state: JSON_OBJECT
|
state: JSON_OBJECT
|
||||||
|
|||||||
Reference in New Issue
Block a user