bugfix
This commit is contained in:
parent
1e6acc19ca
commit
91e24f567f
@ -105,8 +105,10 @@ bricks.AudioRecorder = class extends bricks.HBox {
|
|||||||
this.add_widget(this.rec_btn);
|
this.add_widget(this.rec_btn);
|
||||||
this.add_widget(this.rec_time);
|
this.add_widget(this.rec_time);
|
||||||
this.recordData = null;
|
this.recordData = null;
|
||||||
|
if (this.upload_url){
|
||||||
this.bind('record_ended', this.upload.bind(this));
|
this.bind('record_ended', this.upload.bind(this));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
rec_btn_pressed(){
|
rec_btn_pressed(){
|
||||||
bricks.debug(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon);
|
bricks.debug(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon);
|
||||||
if(this.rec_btn.url == this.start_icon){
|
if(this.rec_btn.url == this.start_icon){
|
||||||
|
@ -214,7 +214,7 @@ bricks.buildEventHandler = async function(w, desc, event){
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
var rtdata = {};
|
var rtdata = {};
|
||||||
|
desc.event_params = event.params || {} ;
|
||||||
if (desc.rtdata) rtdata = desc.rtdata;
|
if (desc.rtdata) rtdata = desc.rtdata;
|
||||||
else if (desc.datawidget){
|
else if (desc.datawidget){
|
||||||
var data_desc = {
|
var data_desc = {
|
||||||
@ -225,9 +225,15 @@ bricks.buildEventHandler = async function(w, desc, event){
|
|||||||
}
|
}
|
||||||
rtdata = await bricks.getRealtimeData(w, data_desc);
|
rtdata = await bricks.getRealtimeData(w, data_desc);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
if (typeof event.params == typeof {}){
|
if (typeof event.params == typeof {}){
|
||||||
rtdata = bricks.extend(rtdata, event.params);
|
rtdata = bricks.extend(rtdata, event.params);
|
||||||
|
} else if (event.params instanceof FormData){
|
||||||
|
for ( const [key, value] of Object.entries(rtdata)){
|
||||||
|
params.append(key, value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
switch (desc.actiontype){
|
switch (desc.actiontype){
|
||||||
case 'urlwidget':
|
case 'urlwidget':
|
||||||
return bricks.buildUrlwidgetHandler(w, target, rtdata, desc);
|
return bricks.buildUrlwidgetHandler(w, target, rtdata, desc);
|
||||||
@ -312,8 +318,21 @@ bricks.buildUrlwidgetHandler = function(w, target, rtdata, desc){
|
|||||||
}
|
}
|
||||||
var options = objcopy(desc.options||{});
|
var options = objcopy(desc.options||{});
|
||||||
var params = options.params || {};
|
var params = options.params || {};
|
||||||
|
if (desc.event_params instanceof FormData){
|
||||||
|
var params = desc.event_params;
|
||||||
|
for ( const [key, value] of Object.entries(rtdata)){
|
||||||
|
params.append(key, value);
|
||||||
|
}
|
||||||
|
options = bricks.apply_data(options, rtdata);
|
||||||
|
for ( const [key, value] of Object.entries(options.params||{})){
|
||||||
|
params.append(key, value);
|
||||||
|
}
|
||||||
|
options.params = params;
|
||||||
|
} else {
|
||||||
|
rtdata = bricks.extend(rtdata, desc.event_params);
|
||||||
options = bricks.apply_data(options, rtdata);
|
options = bricks.apply_data(options, rtdata);
|
||||||
options.params = bricks.extend(params, rtdata);
|
options.params = bricks.extend(params, rtdata);
|
||||||
|
}
|
||||||
|
|
||||||
var opts = {
|
var opts = {
|
||||||
"widgettype":"urlwidget",
|
"widgettype":"urlwidget",
|
||||||
|
@ -8,7 +8,7 @@ SOURCES=" page_data_loader.js factory.js uitypesdef.js utils.js uitype.js \
|
|||||||
floaticonbar.js miniform.js wterm.js dynamicaccordion.js \
|
floaticonbar.js miniform.js wterm.js dynamicaccordion.js \
|
||||||
binstreaming.js streaming_audio.js vadtext.js rtc.js docxviewer.js \
|
binstreaming.js streaming_audio.js vadtext.js rtc.js docxviewer.js \
|
||||||
llm_dialog.js llm.js websocket.js datarow.js tabular.js \
|
llm_dialog.js llm.js websocket.js datarow.js tabular.js \
|
||||||
line.js pie.js bar.js gobang.js period.js "
|
line.js pie.js bar.js gobang.js period.js pdfviewer.js"
|
||||||
echo ${SOURCES}
|
echo ${SOURCES}
|
||||||
cat ${SOURCES} > ../dist/bricks.js
|
cat ${SOURCES} > ../dist/bricks.js
|
||||||
# uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js
|
# uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js
|
||||||
|
@ -177,6 +177,12 @@ bricks.FormBase = class extends bricks.Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
getValue(){
|
getValue(){
|
||||||
|
if (this.data) {
|
||||||
|
var ret = this.data;
|
||||||
|
this.data = null;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
return this.get_formdata();
|
||||||
var data = {};
|
var data = {};
|
||||||
for (var name in this.name_inputs){
|
for (var name in this.name_inputs){
|
||||||
if (! this.name_inputs.hasOwnProperty(name)){
|
if (! this.name_inputs.hasOwnProperty(name)){
|
||||||
@ -204,11 +210,12 @@ bricks.FormBase = class extends bricks.Layout {
|
|||||||
var w = this.name_inputs[name];
|
var w = this.name_inputs[name];
|
||||||
var d = w.getValue();
|
var d = w.getValue();
|
||||||
if (w.required && ( d[name] == '' || d[name] === null)){
|
if (w.required && ( d[name] == '' || d[name] === null)){
|
||||||
bricks.debug('data=', data, 'd=', d);
|
|
||||||
new bricks.Error({title:'Requirement', message:'required field must input"' + w.label + '"'})
|
new bricks.Error({title:'Requirement', message:'required field must input"' + w.label + '"'})
|
||||||
w.focus();
|
w.focus();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
w.set_formdata(data);
|
||||||
|
/*
|
||||||
if (bricks.need_formdata_fields.includes(w.uitype)){
|
if (bricks.need_formdata_fields.includes(w.uitype)){
|
||||||
var files = w.get_files();
|
var files = w.get_files();
|
||||||
for (var i=0;i<files.length;i++){
|
for (var i=0;i<files.length;i++){
|
||||||
@ -218,23 +225,28 @@ bricks.FormBase = class extends bricks.Layout {
|
|||||||
} else {
|
} else {
|
||||||
data.append(name, d[name]);
|
data.append(name, d[name]);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
this.data = data;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
async validation(){
|
async validation(){
|
||||||
var running = new bricks.Running({target:this});
|
var running = new bricks.Running({target:this});
|
||||||
try {
|
try {
|
||||||
var data;
|
var data;
|
||||||
|
data = this.get_formdata();
|
||||||
|
/*
|
||||||
if (this.need_formdata){
|
if (this.need_formdata){
|
||||||
data = this.get_formdata();
|
data = this.get_formdata();
|
||||||
} else {
|
} else {
|
||||||
data = this.getValue();
|
data = this.getValue();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (! data) {
|
if (! data) {
|
||||||
running.dismiss();
|
running.dismiss();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data = bricks.delete_null_values(data);
|
// data = bricks.delete_null_values(data);
|
||||||
this.dispatch('submit', data);
|
this.dispatch('submit', data);
|
||||||
if (this.submit_url){
|
if (this.submit_url){
|
||||||
var rc = new bricks.HttpResponse();
|
var rc = new bricks.HttpResponse();
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.7/dist/bundle.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@ricky0123/vad-web@0.0.7/dist/bundle.min.js"></script>
|
||||||
<script src="https://unpkg.com/docx-js@3.2.0/lib/docx.min.js"></script>
|
<script src="https://unpkg.com/docx-js@3.2.0/lib/docx.min.js"></script>
|
||||||
-->
|
-->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/js-docx-viewer/dist/js-docx-viewer.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/2.14.305/pdf.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/mammoth/1.4.2/mammoth.browser.min.js"></script>
|
||||||
<script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.1/files/dist/echarts.min.js"></script>
|
<script type="text/javascript" src="https://registry.npmmirror.com/echarts/5.5.1/files/dist/echarts.min.js"></script>
|
||||||
|
|
||||||
<script src="/bricks/3parties/marked.min.js"></script>
|
<script src="/bricks/3parties/marked.min.js"></script>
|
||||||
|
@ -17,6 +17,9 @@ bricks.UiType =class extends bricks.Layout {
|
|||||||
}
|
}
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
set_formdata(formdata){
|
||||||
|
formdata.append(this.name, this.resultValue());
|
||||||
|
}
|
||||||
resultValue(){
|
resultValue(){
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
@ -71,7 +74,8 @@ bricks.UiAudioText = class extends bricks.UiType {
|
|||||||
this.text_w.setValue('');
|
this.text_w.setValue('');
|
||||||
}
|
}
|
||||||
getValue(){
|
getValue(){
|
||||||
return this.text_w.getValue();
|
this.value = this.text_w.getValue();
|
||||||
|
return this.value;
|
||||||
}
|
}
|
||||||
setValue(v){
|
setValue(v){
|
||||||
this.text_w.setValue(v);
|
this.text_w.setValue(v);
|
||||||
@ -265,6 +269,7 @@ bricks.UiFloat =class extends bricks.UiInt {
|
|||||||
this.dom_element.step = step;
|
this.dom_element.step = step;
|
||||||
}
|
}
|
||||||
resultValue(){
|
resultValue(){
|
||||||
|
super.resultValue();
|
||||||
return parseFloat(this.value);
|
return parseFloat(this.value);
|
||||||
}
|
}
|
||||||
setValue(v){
|
setValue(v){
|
||||||
@ -403,6 +408,9 @@ bricks.UiImage =class extends bricks.VBox {
|
|||||||
};
|
};
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
}
|
}
|
||||||
|
set_formdata(formdata){
|
||||||
|
formdata.append(this.name, this.value);
|
||||||
|
}
|
||||||
getValue(){
|
getValue(){
|
||||||
var ret = {}
|
var ret = {}
|
||||||
if (this.imgw){
|
if (this.imgw){
|
||||||
|
@ -77,8 +77,6 @@ bricks.HttpText = class {
|
|||||||
return await resp.text();
|
return await resp.text();
|
||||||
}
|
}
|
||||||
add_own_params(params){
|
add_own_params(params){
|
||||||
if (! params)
|
|
||||||
params = {};
|
|
||||||
var session = bricks.app.get_session();
|
var session = bricks.app.get_session();
|
||||||
if (params instanceof FormData){
|
if (params instanceof FormData){
|
||||||
for ( const [key, value] of Object.entries(this.params)){
|
for ( const [key, value] of Object.entries(this.params)){
|
||||||
@ -89,6 +87,8 @@ bricks.HttpText = class {
|
|||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
if (! params)
|
||||||
|
params = {};
|
||||||
var p = bricks.extend({}, this.params);
|
var p = bricks.extend({}, this.params);
|
||||||
p = bricks.extend(p, params);
|
p = bricks.extend(p, params);
|
||||||
if (session){
|
if (session){
|
||||||
@ -109,13 +109,13 @@ bricks.HttpText = class {
|
|||||||
var _params = {
|
var _params = {
|
||||||
method:method
|
method:method
|
||||||
}
|
}
|
||||||
// _params.headers = headers;
|
if (data instanceof FormData){
|
||||||
|
method = 'POST';
|
||||||
|
_params.body = data;
|
||||||
|
} else {
|
||||||
if (method == 'GET' || method == 'HEAD') {
|
if (method == 'GET' || method == 'HEAD') {
|
||||||
let pstr = url_params(data);
|
let pstr = url_params(data);
|
||||||
url = url + '?' + pstr;
|
url = url + '?' + pstr;
|
||||||
} else {
|
|
||||||
if (data instanceof FormData){
|
|
||||||
_params.body = data;
|
|
||||||
} else {
|
} else {
|
||||||
_params.body = JSON.stringify(data);
|
_params.body = JSON.stringify(data);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ bricks.PDFviewer = class extends bricks.VBox {
|
|||||||
this.curpage = null;
|
this.curpage = null;
|
||||||
this.pdf = null;
|
this.pdf = null;
|
||||||
bricks.app.bind('keydown', this.key_action.bind(this));
|
bricks.app.bind('keydown', this.key_action.bind(this));
|
||||||
schedule_once(this.renderPage(1), 0.2);
|
schedule_once(this.renderPage(1), 1);
|
||||||
}
|
}
|
||||||
key_action(e){
|
key_action(e){
|
||||||
if (!this.curpage) return;
|
if (!this.curpage) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user