%%#-------------------------------------------------------------------------------------------------%% %%# HIP Install Dialog %% %%# (action = dialog.portal.install.action) %% %%# %% %%# 1999-12-17 %% %%# Author: Michael Gartler %% %%#-------------------------------------------------------------------------------------------------%% %%macro dialog_install%% // -------------------------------------------------------------------------------------------------- resdef ("v1.0/components/portal/langres/portal.lrc","port"); // language support // -------------------------------------------------------------------------------------------------- var path=HW_Settings.HTML_DIR+"/packages/available"; // the parent directory of the packages var isInstalledFileName="installed.xml"; // file containing information about package status // e.g. installed, not installed... // -------------------------------------------------------------------------------------------------- function setAction(Name,Version,Action) { // // CSJS // var checkBoxName=pkg[Name][Version].checkBoxName; if (typeof(checkBoxName)=='undefined') return; switch (Action) { case 'install' : if (!document.f1[checkBoxName].checked) { pkg[Name][Version].Action=pkg[Name][Version].Action=='nochange'?'install':'nochange'; document.f1[checkBoxName].checked=true; } break; case 'uninstall' : if (document.f1[checkBoxName].checked) { pkg[Name][Version].Action=pkg[Name][Version].Action=='nochange'?'uninstall':'nochange'; document.f1[checkBoxName].checked=false; } break; } } // -------------------------------------------------------------------------------------------------- function getHighestVersion(Name,Version) { // // CSJS // // This function is used by // - checkInstallDependency // // (1) return the highest available Version of package [Name] // // // In: // - Name : string; package name // - Version : string; package version // // Out: string; highest version // // var hv_str = ''; // represents "package does not exist" if (typeof pkg[Name] == "undefined") return hv_str; hv_str = ''; hv_nr = 0; for (var v in pkg[Name]) { var version = portal_convertVersion(v); if (version>hv_nr) { hv_str = v; hv_nr = version; } } return hv_str; } // -------------------------------------------------------------------------------------------------- function getInstalledVersion(Name,Version) { // // CSJS // for (var v in pkg[Name]) { var cb=document.f1[pkg[Name][v].checkBoxName]; if (typeof(cb)=='undefined') continue; if (cb.checked) return (v);} return (''); } // -------------------------------------------------------------------------------------------------- function checkInstallDependency(Name,Version) { // // CSJS // // automatically selects all packages needed for package ID=(Name,Version) // // In: // Name, Version : string; name and version of a package // // Out: // auto-selection (checkboxes in ui) of all packages needed for the package (Name,Version) // // Note: for information about the client side datastructure (pkg[Name][Version]) see function writeInstallUI // var list = []; if (typeof(pkg[Name])!='undefined') if (typeof(pkg[Name][Version])!='undefined') var dep=pkg[Name][Version].Dependency; // get dependency information for this package else return list; // package not found -> error -> Status=false else return list; if (dep.length==0) return list; // no more dependencies -> exit recursion else for (var i=0; i=portal_convertVersion(dep[i].Version)) || (the_operator=="eq" && portal_convertVersion(the_installedVersion)==portal_convertVersion(dep[i].Version))) { the_Status = true; the_Version = the_installedVersion; } else { if ((the_operator=="ge" && portal_convertVersion(the_highestVersion)>=portal_convertVersion(dep[i].Version)) || (the_operator=="eq" && portal_convertVersion(the_highestVersion)==portal_convertVersion(dep[i].Version))) { the_Status = true; the_Version = the_highestVersion; } } // append package data to the list list[list.length]={Name:the_Name,Version:the_Version,Status:the_Status}; // append list and start new recursion list=list.concat(checkInstallDependency(the_Name,the_Version)); } } return list; } // -------------------------------------------------------------------------------------------------- function checkUnInstallDependency(Name,Version) { // // CSJS // // displays an alert message if the user wants to uninstall a package (Name,Version) // which is possibly needed by other installed packages // // In: // - Name (string) // - Version (string): name and version of the package to check for uninstall // // Out: alert message box (ui) // // Note: for information about the client side datastructure (pkg[Name][Version]) see function writeInstallUI // var msg=""; // the alert message for (var i in pkg) { // go thru all packages for (var j in pkg[i]) { // go thru all versions var the_Dependency=pkg[i][j].Dependency; // get dependencies of a package if (typeof(pkg[i][j].checkBoxName)=='undefined') continue; for (var d=0; dhighestVersion) highestVersion=version_number; if (packs[Name][v].installed) installedVersion=v; } var vobj=new PkgVersion(highestVersion); var upgradeVersion=vobj.toId(); if (upgradeVersion==installedVersion) { return ([installedVersion]);} if (installedVersion=="") { return ([upgradeVersion]);} return ([installedVersion,upgradeVersion]); } //------------------------------------------------------------------------------------------------------------------ function convertVersion2Number (version_str) { if (typeof version_str != "string") return 0; var arr = version_str.split("."); var ret = 0; for (var i=0; i<3; i++) { ret *= 100; if (typeof(arr[i])!="undefined") ret += parseInt(arr[i]); } return ret; } // -------------------------------------------------------------------------------------------------- function writeSortedTree(the_Name) { // // display the package tree recursively // if (typeof(packs[the_Name])=='undefined') // Error Handling: package not found return; var installed_product = portal_extractInstallInfo(hw_readGlobalProductInfo({file:HW_Settings.HTML_DIR+"/"+(HW_Settings.VERSION_DIR || "v1.0")+"/lib/products.xml",prefix:HW_Settings.HTML_DIR+"/"+(HW_Settings.VERSION_DIR || "v1.0")+"/lib/"})); if (installed_product == null) installed_product = {Product:"Hyperwave Information Portal", Version:"1.0"} var order=getInstalledAndUpgradeVersion(the_Name); // display order: installed version, highest version available // the version sortorder for a package: // 1: installed version 2: highest available version for (var i=0; ipkg_order[pkg_order.length]={Name:"'+the_Name+'",Version:"'+the_Version+'"};'); var the_attributes = packs[the_Name][the_Version].packageId; var str = ""; write(''); // the package order is also stored on the client side (pkg_order) var the_Title=packs[the_Name][the_Version].Title[0].value; // package title var the_VersionObject=packs[the_Name][the_Version].packageId.VersionObject; var the_Description=packs[the_Name][the_Version].Description[0].value; // package description var the_Directory=packs[the_Name][the_Version].directoryName; // package directory name var the_Fullpath=packs[the_Name][the_Version].fullpath; // full path to package in filesystem var the_Dependency=typeof(packs[the_Name][the_Version].Dependency)=='undefined'?[]:packs[the_Name][the_Version].Dependency; // contains all packages that must be installed in order to install this package // Note: the HIP_BaseClasses don't have any dependencies var the_checkBoxName=pkgCheckboxName(the_Name,the_Version); // the name of the checkbox for this package in the ui var the_CSObject='pkg.'+the_Name+'.'+the_Version; // the object that stores the package data on the client side writeln('\n\n'); writeln(''); if (i==1) { the_Title=""; the_Description="upgrade"; } // is there a higher version available -> upgrade is possible //--- write package table entry, checkbox etc. ------------------------------------------------ writeln(''); write(the_Title+''); /* writeln(''); if (i==0) writeln(the_Name); writeln(''); */ writeln(''+the_VersionObject.toString()+''); writeln('
'); var product_str = ""; var the_product = ""; var product_version = ""; var product_SP = ""; var product_obj; if (the_Version!='xml_error') { var the_deinstall = packs[the_Name][the_Version].packageId.DeInstall; for (var j=0; j'); } else write(' '); } else write(' '); } else write(' '); write('
'+the_Description+''); writeln(''); for (var d=0; d'); writeln(''); } for (var i=0; i. // object containing package information; has the following members: // // - Dependency[] : array containing the packages which are required for this package // - Name : // - Version : // - RequiredBy[] : array containing the packages which need this package // - Name : // - Version : // - checkBoxName : name of corresponding checkbox // - Action : the action to perform with this package ("install" or "uninstall") // // ---- init client side objects ----------------------------------------------------- // // --- step 1 ---------------------------------------------------------------------- writeln(''); writeln(''+lrc('instDlgTxt8','port','Package')+'Version '+lrc('instDlgTxt9','port','Description')+''+lrc('instDlgTxt10','port','Required Packages')+''); writeSortedTree('HIP_BaseClasses'); for (var the_Name in packs) { for (var the_Version in packs[the_Name]) { if (!packs[the_Name][the_Version].visited) writeSortedTree(the_Name); } } writeln(' '+lrc('instDlgTxt11','port','select/de-select packages to install/uninstall...')+''); } // -------------------------------------------------------------------------------------------------- function writeBackupCheckBox() { writeln('  '+lrc('instDlgTxt17','port','Create Backup before uninstall')+'    '); } // -------------------------------------------------------------------------------------------------- function prepareUpgrade() { // // CSJS // // for (var name in pkg) { var found=[]; var existing=''; var upgrade=''; for (var version in pkg[name]) { if (typeof(pkg[name][version]).checkBoxName=='undefined') continue; found[found.length]=version; } found.sort(); if (found.length==1) existing=found[0]; else { existing=found[0]; upgrade=found[1];} // alert(name+' '+version); //alert('existing: '+existing); //alert('upgrade: '+upgrade); if (upgrade!='') if ((pkg[name][upgrade].Action=='install') && (pkg[name][existing].Action!='uninstall')) pkg[name][existing].Action='backup'; } } // -------------------------------------------------------------------------------------------------- function getPackageSelection() // // csjs // // Event handler for onSubmit() // Get Package selection. Checkboxes with name PACKAGEn_s (n is an integer). // The Values of these checkboxes contain the filesystem path to each package // // In: - // // Out: a commaseparated string containing the paths of all selected packages is stored in the // hidden input field 'selected_new' // { if (!HW_DC_verifySubmit(document.f1)) return; var str=""; // "username","password","","action", .... // action: install, uninstall, nochange // this info is sent to portal.doInstall.action as Parameter var the_form=document.f1; // the form object var the_username=the_form.USERNAME.value; // username var the_password=the_form.PASSWD.value; // password var do_Backup=the_form.backup.checked?'backup_yes':'backup_no'; // backup yes/no var isChange=false; prepareUpgrade(); // for (var i=0; i\ \ \ '); document.close(); // create Frameset: progressview, hiddenframe; load progress page into progressview document.writeln('\ \ \ \ \ \ '); document.close(); } // -------------------------------------------------------------------------------------------------- function PkgVersion_toString() { // // // if (this.versionmajor=='0') var result='Beta'+this.versionminor; else var result='V'+this.versionmajor+'.'+this.versionminor; return result; } // -------------------------------------------------------------------------------------------------- function PkgVersion_toId() { // // // var result=this.toString(); var result=result.replace(/\./,'_'); return result; } // --------------------------------------------------------------------------------------------------- function PkgVersion_toNumber() { // // // var result=(this.versionmajor+'.'+this.versionminor)-0; return result; } // --------------------------------------------------------------------------------------------------- function PkgVersion(version) { // // // version+=""; var arr=version.split('.'); this.versionmajor=arr[0]; this.versionminor=arr.length==2?arr[1]:"0"; this.toString=PkgVersion_toString; this.toNumber=PkgVersion_toNumber; this.toId=PkgVersion_toId; } // -------------------------------------------------------------------------------------------------- function getAvailablePackages(path) { // // Reads the available packages in specific directory (path) // // In: path - a string containing the directory path // // Out: package information objects for all available packages; // package info object: // .... with the following attributes: // - packageId : the package id object // - Name // - Version // - VersionObject (see function PkgVersion) // - Title[0].value : package title // - Description[0].value : package description // - Dependency[1..n].attributes : the dependencies // - Name : the name of the package that is required to use this package // - Version : the version of the package that is required to use this package // - RequiredBy[1..n] : // - Name // - Version // - fullpath : complete path to package directory, // - directoryName: package directory name, // - isInstalled : true, if this package has been installed // - visited var dir = new Directory(path+'/'); // the package parentdirectory object var result = {}; // the result object var error=lrc('instDlgTxt12','port','There are no packages available.'); var count=0; if (!dir.open()) return ({result:{},error:lrc('instDlgTxt13','port','could not open directory')+': '+path }); for (;;) { // --------------------------------------------------------------------- packages var name= dir.read(); // get next entry if (!name) break; var f=new File(dir.name+name); if ( (f.isDirectory()) && (name!=".") && (name!="..")) { var pkgdir= new Directory(f.name+'/'); if(!pkgdir.open()) return ({result:{},error:lrc('instDlgTxt13','port','could not open directory')+': '+f.name}); for (;;) { // versions var name2=pkgdir.read(); if (!name2) break; var f2=new File(pkgdir.name+name2); if ( (f2.isDirectory()) && (name2!=".") && (name2!="..") && (name2!="CVS")) { var instfname=pkgdir.name+name2+'/'+isInstalledFileName; // installed.xml var installed_obj=parseInstalledXML({filename:instfname}); // parse installed.xml: installed, uninstalled ? if (installed_obj.Status=='installed') var isInstalled=true; else var isInstalled=false; var the_Info=parsePkgXML({filename:pkgdir.name+name2+"/pkg.xml"}); // parsePkgXML: get info from pkg.xml var vobj=new PkgVersion(the_Info.packageId.Version); the_Info.packageId.Version=vobj.toId(); // build the version id string the_Info.packageId.VersionObject=vobj; // store version object if (typeof(the_Info.Dependency)!='undefined') for (var i=0; i'+packs_obj.error+''); HW_dialogFooter(dlg_spec,true);} else { var param_spec2={paramspecs:[{prompt:0,name:"selected_packages"}, // hidden input field 'selected_packages' {type:"plainfunction",name:"writeInstallUI(packs)"}]}; var param_spec3={paramspecs:[{type:"plainfunction",name:"writeBackupCheckBox()"}]}; HW_DC_defaultMultiDialog(dlg_spec,[{caption:lrc("instDlgCap2","port","Install"),boxes:[param_spec1]},{caption:lrc("instDlgCap3","port","Available Packages"),boxes:[param_spec2]},{caption:lrc('instDlgCap6','port','Backup'),boxes:[param_spec3]}]);}
%%endmacro%%