diff --git a/README.md b/README.md index d3aa5c4..a675538 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,9 @@ pip3 install smartchart -U (升级) ``` + [SmartChart入门文档入口](https://gitee.com/smartchart/smartchart/wikis/ "SmartChart入门") + + ### 应用场景一: 快速启动, 独立平台使用(推荐!) ```shell script 本地命令行启动: @@ -86,7 +89,7 @@ ``` **管理员帐号密码: admin/admin, 请及时更改密码** - [SmartChart入门文档入口](https://gitee.com/smartchart/smartchart/wikis/pages "SmartChart入门") + [SmartChart入门文档入口](https://gitee.com/smartchart/smartchart/wikis/ "SmartChart入门") ------------------------------------------------------------------------------- @@ -99,21 +102,7 @@ ------------------------------------------------------------------------------- ### 应用场景三: 外部系统对接方式 -```python -# 如果需要,你可以采用单点登录的方式与smartchart进行对接嵌入 -'/echart/smart_login?id=xxx&stamp=xxx&token=xxx&url=/' -''' -参数说明: -id: 用户名(在smartchart平台中管理) -stamp: 时间戳(1970年1月1日到生成时间的毫秒数) -token: 采用sha1加密, token=SHA1(链接秘钥+stamp+id) - 链接秘钥默认smartchart, - 请在环境变量设定SMART_KEY替换(重要) -url: 登录成功后跳转链接 -''' - -# 提示:为了数据安全,对外生产环境使用,务必设定你的环境变量SMART_KEY -``` +使用方法参考文档 ------------------------------------------------------------------------------- ### 应用场景四: 在django项目中当作apps使用 @@ -189,6 +178,7 @@ v3.9.9.12 优化后台数据处理性能,Jupyter使用体验 v3.9.9.16 新增模板编辑功能,增加嵌入报表TOKEN方式,优化编辑界面,优化连接池选择 v3.9.9.18 修复vue bug, 增加elementUI支持, 优化DataV开发体验 v3.9.9.24 模板开发界面增加编辑功能,自动建立数据集,新增数据集测试功能,Echarts升级到5.2 +v3.9.9.25 增加变更未保存提示,数据集选择执行,优化保存模板重复提交的问题 ``` ------------------------------------------------------------------------------- @@ -204,9 +194,11 @@ v3.9.9.24 模板开发界面增加编辑功能,自动建立数据集,新增数 - 但如果要使用好smart chart, 建意了解下javascript, H5, Echarts这些前端知识, 可以让你的应用更加得心应手,创作更炫的效果 - 如果你需要更进一步订制你的数据, 你需要了解下SQL的使用,本项目高级应用语言都是通用的技能, 象js, h5,sql 学习成本低 -- [SmartChart入门文档入口](https://gitee.com/smartchart/smartchart/wikis/pages "SmartChart入门") +- [SmartChart入门文档入口](https://gitee.com/smartchart/smartchart/wikis/ "SmartChart入门") **参考视屏,建意观看,有些可能有些久,可进入后关注作者头条号, 查看最新视屏, 请对比最新文档** + +**产品迭代较快, 请关注作者头条号, 查看最新视屏!!!** - [Smartchart数据库与数据集SQL](https://www.ixigua.com/6910413586208653837?id=6902584882958959116 "SQL") - [Smartchart页面快速布局](https://www.ixigua.com/6910413586208653837?id=6907784122065191438 "布局") - [Smartchart数据库与图形的对话](https://www.ixigua.com/6910413586208653837?id=6910373199603565063 "布局") diff --git a/static/echart/echartedit/snippets/javascript.js b/static/echart/echartedit/snippets/javascript.js deleted file mode 100644 index 01355e1..0000000 --- a/static/echart/echartedit/snippets/javascript.js +++ /dev/null @@ -1,202 +0,0 @@ -define("ace/snippets/javascript",["require","exports","module"], function(require, exports, module) { -"use strict"; - -exports.snippetText = "# Prototype\n\ -snippet proto\n\ - ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {\n\ - ${4:// body...}\n\ - };\n\ -# Function\n\ -snippet fun\n\ - function ${1?:function_name}(${2:argument}) {\n\ - ${3:// body...}\n\ - }\n\ -# Anonymous Function\n\ -regex /((=)\\s*|(:)\\s*|(\\()|\\b)/f/(\\))?/\n\ -snippet f\n\ - function${M1?: ${1:functionName}}($2) {\n\ - ${0:$TM_SELECTED_TEXT}\n\ - }${M2?;}${M3?,}${M4?)}\n\ -# Immediate function\n\ -trigger \\(?f\\(\n\ -endTrigger \\)?\n\ -snippet f(\n\ - (function(${1}) {\n\ - ${0:${TM_SELECTED_TEXT:/* code */}}\n\ - }(${1}));\n\ -# if\n\ -snippet if\n\ - if (${1:true}) {\n\ - ${0}\n\ - }\n\ -# if ... else\n\ -snippet ife\n\ - if (${1:true}) {\n\ - ${2}\n\ - } else {\n\ - ${0}\n\ - }\n\ -# tertiary conditional\n\ -snippet ter\n\ - ${1:/* condition */} ? ${2:a} : ${3:b}\n\ -# switch\n\ -snippet switch\n\ - switch (${1:expression}) {\n\ - case '${3:case}':\n\ - ${4:// code}\n\ - break;\n\ - ${5}\n\ - default:\n\ - ${2:// code}\n\ - }\n\ -# case\n\ -snippet case\n\ - case '${1:case}':\n\ - ${2:// code}\n\ - break;\n\ - ${3}\n\ -\n\ -# while (...) {...}\n\ -snippet wh\n\ - while (${1:/* condition */}) {\n\ - ${0:/* code */}\n\ - }\n\ -# try\n\ -snippet try\n\ - try {\n\ - ${0:/* code */}\n\ - } catch (e) {}\n\ -# do...while\n\ -snippet do\n\ - do {\n\ - ${2:/* code */}\n\ - } while (${1:/* condition */});\n\ -# Object Method\n\ -snippet :f\n\ -regex /([,{[])|^\\s*/:f/\n\ - ${1:method_name}: function(${2:attribute}) {\n\ - ${0}\n\ - }${3:,}\n\ -# setTimeout function\n\ -snippet setTimeout\n\ -regex /\\b/st|timeout|setTimeo?u?t?/\n\ - setTimeout(function() {${3:$TM_SELECTED_TEXT}}, ${1:10});\n\ -# Get Elements\n\ -snippet gett\n\ - getElementsBy${1:TagName}('${2}')${3}\n\ -# Get Element\n\ -snippet get\n\ - getElementBy${1:Id}('${2}')${3}\n\ -# console.log (Firebug)\n\ -snippet cl\n\ - console.log(${1});\n\ -# return\n\ -snippet ret\n\ - return ${1:result}\n\ -# for (property in object ) { ... }\n\ -snippet fori\n\ - for (var ${1:prop} in ${2:Things}) {\n\ - ${0:$2[$1]}\n\ - }\n\ -# hasOwnProperty\n\ -snippet has\n\ - hasOwnProperty(${1})\n\ -# docstring\n\ -snippet /**\n\ - /**\n\ - * ${1:description}\n\ - *\n\ - */\n\ -snippet @par\n\ -regex /^\\s*\\*\\s*/@(para?m?)?/\n\ - @param {${1:type}} ${2:name} ${3:description}\n\ -snippet @ret\n\ - @return {${1:type}} ${2:description}\n\ -# JSON.parse\n\ -snippet jsonp\n\ - JSON.parse(${1:jstr});\n\ -# JSON.stringify\n\ -snippet jsons\n\ - JSON.stringify(${1:object});\n\ -# self-defining function\n\ -snippet sdf\n\ - var ${1:function_name} = function(${2:argument}) {\n\ - ${3:// initial code ...}\n\ -\n\ - $1 = function($2) {\n\ - ${4:// main code}\n\ - };\n\ - }\n\ -# singleton\n\ -snippet sing\n\ - function ${1:Singleton} (${2:argument}) {\n\ - // the cached instance\n\ - var instance;\n\ -\n\ - // rewrite the constructor\n\ - $1 = function $1($2) {\n\ - return instance;\n\ - };\n\ - \n\ - // carry over the prototype properties\n\ - $1.prototype = this;\n\ -\n\ - // the instance\n\ - instance = new $1();\n\ -\n\ - // reset the constructor pointer\n\ - instance.constructor = $1;\n\ -\n\ - ${3:// code ...}\n\ -\n\ - return instance;\n\ - }\n\ -# class\n\ -snippet class\n\ -regex /^\\s*/clas{0,2}/\n\ - var ${1:class} = function(${20}) {\n\ - $40$0\n\ - };\n\ - \n\ - (function() {\n\ - ${60:this.prop = \"\"}\n\ - }).call(${1:class}.prototype);\n\ - \n\ - exports.${1:class} = ${1:class};\n\ -# \n\ -snippet for-\n\ - for (var ${1:i} = ${2:Things}.length; ${1:i}--; ) {\n\ - ${0:${2:Things}[${1:i}];}\n\ - }\n\ -# for (...) {...}\n\ -snippet for\n\ - for (var ${1:i} = 0; $1 < ${2:Things}.length; $1++) {\n\ - ${3:$2[$1]}$0\n\ - }\n\ -# for (...) {...} (Improved Native For-Loop)\n\ -snippet forr\n\ - for (var ${1:i} = ${2:Things}.length - 1; $1 >= 0; $1--) {\n\ - ${3:$2[$1]}$0\n\ - }\n\ -\n\ -\n\ -#modules\n\ -snippet def\n\ - define(function(require, exports, module) {\n\ - \"use strict\";\n\ - var ${1/.*\\///} = require(\"${1}\");\n\ - \n\ - $TM_SELECTED_TEXT\n\ - });\n\ -snippet req\n\ -guard ^\\s*\n\ - var ${1/.*\\///} = require(\"${1}\");\n\ - $0\n\ -snippet requ\n\ -guard ^\\s*\n\ - var ${1/.*\\/(.)/\\u$1/} = require(\"${1}\").${1/.*\\/(.)/\\u$1/};\n\ - $0\n\ -"; -exports.scope = "javascript"; - -}); diff --git a/static/editor/common.js b/static/editor/common.js index b5919fe..93b53dd 100644 --- a/static/editor/common.js +++ b/static/editor/common.js @@ -12,8 +12,8 @@ $("#ace-theme").change(function () { }); function GetQueryString(name) { - var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); - var r = window.location.search.substr(1).match(reg); + let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); + let r = window.location.search.substr(1).match(reg); if (r != null) { return unescape(r[2]); } @@ -39,7 +39,7 @@ function load_help(name) { } function theme_init(){ - theme_option = ` + let theme_option = ` @@ -91,7 +91,7 @@ function open_select(name) { if(name==='chart'){url= `/echart/editor_min/?chartid=${dashDict.chartid}&dataid=${dashDict.dsid}&divid=${dashDict.divid}`} else if(name==='ds'){url= `/echart/ds_editor/?divid=${dashDict.divid}&dsid=${dashDict.dsid}&seq=${dashDict.seq}`} else if(name==='div'){url= `/echart/div_editor/?divid=${dashDict.divid}`} - $('#iframepage').attr('src', url); + if(url!==$('#iframepage').attr('src')){$('#iframepage').attr('src', url)} $('#modal_iframe').modal('show'); }else if(data.status===501){r=confirm(data.msg + ', 是否新增数据集?'); if(r===true){create_div(dashid)}} }}); diff --git a/static/editor/ds_editor.js b/static/editor/ds_editor.js index 937e662..b88fea8 100644 --- a/static/editor/ds_editor.js +++ b/static/editor/ds_editor.js @@ -3,12 +3,13 @@ var divid = GetQueryString('divid') || ''; var on = GetQueryString('on') || '1'; var dsname =''; var seq = GetQueryString('seq') || ''; +let mflag = false; + +if(divid) {dssq_init(16);set_onoff();}else{$('#dsseq').css('display', 'None');$('#onoff').css('display', 'None');} -if(divid) {dssq_init(16);}else{$('#dsseq').css('display', 'None');} -$.ajax({type: "get",url: '/echart/get_sqlstr/?dsid='+ dsid,success: function (data) - {editor1.setValue(data['msg']);dsname=data['name'];$('#title').text('#'+seq+":"+dsid+dsname);$('#conn').text(data['connname']);} }); -if(divid){set_onoff();}else{$('#onoff').css('display', 'None');} editor1 = init_editor('sql'); +$.ajax({type: "get",async:false, url: '/echart/get_sqlstr/?dsid='+ dsid,success: function (data) + {editor1.setValue(data['msg']); dsname=data['name'];$('#title').text('#'+seq+":"+dsid+dsname);$('#conn').text(data['connname']);} }); function set_onoff() { @@ -48,6 +49,8 @@ $('#submit').click(function () {let e = editor1.getValue();console.log(e); success: function(data) { console.log(data); $('#printlog').html(data['msg']); + $('#submit').css('background-color', 'green'); + mflag = false; dsid = data['dsid']; dsname = data['dsname']; $('#title').text('#'+seq+":"+dsid+dsname); @@ -58,12 +61,11 @@ $('#submit').click(function () {let e = editor1.getValue();console.log(e); else{window.opener.location.reload();}} catch (e) {console.log('no opener');} } // window.opener=null;window.close(); - // else{window.location.href="/echart/?type=z.chart&dev=1&dataset="+dsid } } }); }); -editor1.getSession().on('change', function(e) {$("#printlog").html('');}); +editor1.getSession().on('change', function(e) {$("#printlog").html(''); mflag=true}); $("#dsseq").change(function () { @@ -107,15 +109,17 @@ function dssq_init(qty){ $('#dsseq').val(seq); } -$('#runsql').click(function () {let e = editor1.getValue();console.log(e); +$('#runsql').click(function () { +let sText=editor1.session.getTextRange(editor1.getSelectionRange()); +if(sText.length < 10){sText = editor1.getValue();} $.ajax({ type: "POST", url: "/echart/run_ds/", - data: { dsid: dsid, sqlstr:e}, + data: { dsid: dsid, sqlstr:sText}, success: function(data) { - console.log(data); $('#printlog').html(data.msg); $('#preview').html(JSON.stringify(data.data), data.data); + if(mflag){$('#submit').css('background-color', 'red')} } }); }); \ No newline at end of file diff --git a/templates/echart/ds_editor.html b/templates/echart/ds_editor.html index bed2425..b6239e7 100644 --- a/templates/echart/ds_editor.html +++ b/templates/echart/ds_editor.html @@ -84,8 +84,8 @@ 提交更改 - - + + - - + + diff --git a/templates/echart/template_editor.html b/templates/echart/template_editor.html index 3991b1c..801d10c 100644 --- a/templates/echart/template_editor.html +++ b/templates/echart/template_editor.html @@ -67,10 +67,14 @@ \ No newline at end of file