define([ 'require' , 'jquery' , 'nbextensions/visualpython/src/common/vpCommon' , 'nbextensions/visualpython/src/common/constant' , 'nbextensions/visualpython/src/common/StringBuilder' , 'nbextensions/visualpython/src/common/vpFuncJS' ], function (requirejs, $, vpCommon, vpConst, sb, vpFuncJS) { // ìµì ìì± const funcOptProp = { stepCount : 1 , funcName : "Import" , funcID : "com_import" , funcArgs : [ { caption : "arg1", type : "number", nullable : false } , { caption : "arg2", type : Array, nullable : true } , { caption : "arg3", type : "string", nullable : true } ] , funcRetruns : Array } /** * html load ì½ë°±. ê³ ì id ìì±íì¬ ë¶ê³¼íë©° js ê°ì²´ í´ëì¤ ìì±íì¬ ì»¨í ì´ëë¡ ì ë¬ * @param {function} callback í¸ì¶ì(컨í ì´ë) ì ì½ë°±í¨ì * @param {JSON} meta ë©í ë°ì´í° */ var optionLoadCallback = function(callback, meta) { // document.getElementsByTagName("head")[0].appendChild(link); // 컨í ì´ëìì ì ë¬ë callback í¨ìê° ì¡´ì¬íë©´ ì¤í. if (typeof(callback) === 'function') { var uuid = vpCommon.getUUID(); // ìµë 10í ì¤ë³µëì§ ìëë¡ ì²´í¬ for (var idx = 0; idx < 10; idx++) { // ì´ë¯¸ ì¬ì©ì¤ì¸ uuid ì¸ ê²½ì° ë¤ì ìì± if ($(vpCommon.wrapSelector(vpCommon.formatString(".{0}", uuid))).length > 0) { uuid = vpCommon.getUUID(); } } $(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM))).find(vpCommon.formatString(".{0}", vpConst.API_OPTION_PAGE)).addClass(uuid); // ìµì ê°ì²´ ìì± var ipImport = new ImportPackage(uuid); ipImport.metadata = meta; // ìµì ìì± í ë¹. ipImport.setOptionProp(funcOptProp); // html ì¤ì . ipImport.initHtml(); callback(ipImport); // ê³µíµ ê°ì²´ë¥¼ callback ì¸ìë¡ ì ë¬ } } /** * html ë¡ë. * @param {function} callback í¸ì¶ì(컨í ì´ë) ì ì½ë°±í¨ì * @param {JSON} meta ë©í ë°ì´í° */ var initOption = function(callback, meta) { // console.log('import íë©´ ì¤í'); vpCommon.loadHtml(vpCommon.wrapSelector(vpCommon.formatString("#{0}", vpConst.OPTION_GREEN_ROOM)), "file_io/import.html", optionLoadCallback, callback, meta); } /** * 본 ìµì ì²ë¦¬ ìí í´ëì¤ * @param {String} uuid ê³ ì id */ var ImportPackage = function(uuid) { this.uuid = uuid; // Load html ììì uuid. // Import 기본 í¨í¤ì§ ëª©ë¡ this.packageList = [ { library:'numpy', alias:'np'} , { library:'pandas', alias:'pd'} , { library:'matplotlib.pyplot', alias:'plt' , include: [ '%matplotlib inline' ] } , { library:'seaborn', alias:'sns'} ]; this.package = { id: 'import', name: 'import package', library: 'common', description: 'ê³µíµ í¨í¤ì§ ìí¬í¸', code: '', input: [ { name: 'vp_importMeta' } ], variable: [], output: [ { } ] } } /** * vpFuncJS ìì ìì */ ImportPackage.prototype = Object.create(vpFuncJS.VpFuncJS.prototype); /** * ì í¨ì± ê²ì¬ * @returns ì í¨ì± ê²ì¬ ê²°ê³¼. ì í©ì true */ ImportPackage.prototype.optionValidation = function() { return true; // ë¶ëª¨ í´ëì¤ ì í¨ì± ê²ì¬ í¸ì¶. // vpFuncJS.VpFuncJS.prototype.optionValidation.apply(this); } /** * html ë´ë¶ binding ì²ë¦¬ */ ImportPackage.prototype.initHtml = function() { this.bindImportPackageGrid(); // if need additional css // this.loadCss(Jupyter.notebook.base_url + vpConst.BASE_PATH + vpConst.SOURCE_PATH + "file_io/test.css"); } /** * Import 기본 í¨í¤ì§ ë°ì¸ë© */ ImportPackage.prototype.bindImportPackageGrid = function() { var that = this; if (this.metadata) { try { var importMeta = JSON.parse(decodeURIComponent(this.metadata.options.find(x=>x.id=='vp_importMeta').value)); importMeta && importMeta.forEach((obj, i) => { var tagTr = $(`