diff --git a/qcms-manifest.json b/qcms-manifest.json index 68734e6..ff389c5 100644 --- a/qcms-manifest.json +++ b/qcms-manifest.json @@ -22,9 +22,8 @@ } ], "header": { - "title": "Wrangle Workbench", - "subtitle": "Powered by data-transport" - }, + "title": "Data Transport", + "subtitle": "Open Workbench: Read, write & wrangle data"}, "index": "index.html", "on": { "load": { @@ -46,9 +45,9 @@ "apply", "version" ], + "register":["get","add"], "io": [ - "read", "open", - "write" + "read", "open", "write" ] } } diff --git a/www/html/_assets/js/forms.js b/www/html/_assets/js/forms.js new file mode 100644 index 0000000..f4f8239 --- /dev/null +++ b/www/html/_assets/js/forms.js @@ -0,0 +1,198 @@ + +var _config = { + "sql":{ + + "host":{"type":"text","default":"localhost"},"database":"text","table":"text","username":"text","password":"password" + }, + "cloudant":{ + "host":{"type":"text","default":"localhost"}, + "port":{"type":"number","default":5984}, + "dbname":{"type":"text","label":"database"}, + "username":{"type":"text"}, + "password":"password", + "doc":{"type":"text","label":"document"} + }, + "couchdb":{"@ref":"cloudant"}, + "bigquery":{ + "database":"text","table":"text", + "auth_file":{"type":"file","label":"service account json file"} + }, + "postgresql":{ + "@ref":"sql", + "port":{"type":"number","default":5432} + }, + "redshift":{"@ref":"postgresql"}, + "mariadb":{ + "@ref":"sql", + "port":{"type":"number","default":3306} + }, + "mysql":{ + "@ref":"sql", + "port":{"type":"number","default":3306} + }, + "netezza":{ + "@ref":"sql", + "port":{"type":"number","default":5480}}, + "sqlserver":{ + "@ref":"sql", + "port":{"type":"number","default":1433} + }, + + "mongodb":{ + + "host":{"type":"text","default":"localhost"}, + + "port":{"type":"number","default":2717}, + "db":{"type":"text","label":"database"}, + "collection":{"type":"text"},"mechanism":{"type":"text","default":"SCRAM-SHA-256","values":["SCRAM-SHA-256","MONGODB-X509","MONGODB-CR"]} + }, + "nextcloud":{ + "uid":{"type":"text","label":"user id"}, + "url":{"type":"text","label":"url of server"}, + "token":"text" + + }, + "databricks":{ + "host":"text","token":"text","cluster_path":"text","schema":"text","catalog":"text" + + }, + "s3":{ + "bucket":"text","file":{"type":"text","desc":"aws s3 path of the file"}, + "region":"text" + }, + "sqlite":{"database":{"type":"text","desc":"path on disk"},"table":"text"}, + "sqlite3":{"@ref":"sqlite"}, + "duckdb":{"database":{"type":"text","desc":"path on disk"},"table":"text"}, + "drill":{ + "host":"text","port":{"type":"number","default":8047},"ssl":{"type":"bool","values":[true,false],"default":false} + + }, + "iceberg":{ + "catalog":"text","database":"text","table":"text" + } +} + +var ProviderInputForm = function (_provider){ + this._provider = _provider + /** + * This section will setup the configuration file as it is intended to be + * The configuration fully specified will be used to build the input form + */ + this._config = {} + _parent = {} + var _tmpconfig = _config[_provider] + this._config = _config[_provider] + if (_tmpconfig['@ref'] != null){ + _pkey = _tmpconfig['@ref'] + _parent = _config[_pkey] + } + //-- merge the objects ... + this._config = Object.assign({'label':{'type':'text',desc:'reference to this database'}},_parent, _config[_provider]) + if (this._config['@ref']){ + delete this._config['@ref'] + } + + this.getInput = function(_item){//_type,_text,_desc){ + // if(_type.match(/text|number|password/ig)){ + + _item.label= (_item.label == null)?_item.context: _item.label + _item.desc = (_item.desc != null)?_item.desc:_item.label + _label = $('').html(_item.label) + _input = $('') + $(_input).attr('type',_item.type) + + if(_item.type.match(/number/)) { + $(_input).attr("pattern","^[1-9]([0-9])*$") + } + + $(_input).attr('placeholder',_item.desc) + $(_input).addClass(_item.context) + $(_input).attr('id',_item.context) + if (_item.default != null){ + $(_input).val(_item.default) + } + $(_label).attr('for',_item.context) + return $('
').append(_label,_input) + // } + + } + this.submit = function (_data){ + var http = HttpClient.instance() + http.setData(JSON.stringify(_data)) + http.setHeader('Content-Type','application/json') + var uri = 'api/register/add' + http.post(uri,(x)=>{ + if(x.status == 200 && x.readyState == 4){ + // + // + _init(_data.label) + $('.jxmodal').slideUp() + } + }) + } + this.build = function(_id){ + // + // This will build the form on a pane + + var _form = $('') + Object.keys(this._config).forEach(_key=>{ + var _item = this._config[_key] + var _type = (_item.constructor == String)?_key:_item.type + if(_item.constructor == String){ + _item = {type:_type} + } + _item.type = _type + _item.context = _key + // var _values = (_item.values)?[]:_item.values + var _inputLine = this.getInput(_item) //_type,_key,_item.label) + $(_form).append(_inputLine) + // } + }) + + // + // adding all the items to where they need to be + // + _back = $('