[Title] modify dibs web server
authordibs <dibs@core1compiler.(none)>
Tue, 13 Nov 2012 06:59:32 +0000 (15:59 +0900)
committerdibs <dibs@core1compiler.(none)>
Tue, 13 Nov 2012 06:59:32 +0000 (15:59 +0900)
12 files changed:
dibs-web/Gemfile [new file with mode: 0644]
dibs-web/app/controllers/jobs_controller.rb
dibs-web/app/controllers/projects_controller.rb
dibs-web/app/controllers/utils.rb
dibs-web/public/index.html
dibs-web/public/javascripts/admin-group.js
dibs-web/public/javascripts/admin-project.js
dibs-web/public/javascripts/jobs.js
dibs-web/public/javascripts/main.js
dibs-web/public/javascripts/projects.js
dibs-web/public/javascripts/session.js
dibs-web/public/upload.html

diff --git a/dibs-web/Gemfile b/dibs-web/Gemfile
new file mode 100644 (file)
index 0000000..e8419ca
--- /dev/null
@@ -0,0 +1,45 @@
+source 'https://rubygems.org'
+
+gem 'rails', '3.2.8'
+
+# Bundle edge Rails instead:
+# gem 'rails', :git => 'git://github.com/rails/rails.git'
+
+gem 'sqlite3'
+
+gem 'json'
+
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+  gem 'sass-rails',   '~> 3.2.3'
+  gem 'coffee-rails', '~> 3.2.1'
+
+  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+  # gem 'therubyracer', :platforms => :ruby
+
+  gem 'uglifier', '>= 1.0.3'
+end
+
+gem 'jquery-rails'
+
+# user
+gem 'builder'
+
+# For encrypt password
+gem "bcrypt-ruby", :require => "bcrypt"
+
+# To use ActiveModel has_secure_password
+# gem 'bcrypt-ruby', '~> 3.0.0'
+
+# To use Jbuilder templates for JSON
+# gem 'jbuilder'
+
+# Use unicorn as the app server
+# gem 'unicorn'
+
+# Deploy with Capistrano
+# gem 'capistrano'
+
+# To use debugger
+# gem 'ruby-debug'
index 0ed309d9a5ae15ece9606af29badaa35786e2941..ab726bdbd33e367bb77c13e0088e082e2a22375d 100644 (file)
@@ -135,6 +135,19 @@ puts request_page_number
                                        doc.UserName(job.user_name)
                                        doc.LogLink("/jobs/log/#{job.id}")
                                }
+                               child_cnt = Job.count(:conditions => ["parent_id = ?", job.id])
+                               if (job.job_attribute == "MULTI" and child_cnt == 0)
+                                       doc.Job {
+                                               doc.Id(job.id)
+                                               doc.Distribution(job.distribution)
+                                               doc.ProjectName(job.project_name)
+                                               doc.JobAttribute(job.job_type)
+                                               doc.Os("MULTI")
+                                               doc.Status(job.status)
+                                               doc.UserName(job.user_name)
+                                               doc.LogLink("/jobs/log/#{job.id}")
+                                       }
+                               end
                        }
 
                        doc.PageList{
@@ -168,7 +181,7 @@ puts request_page_number
                line = params[:line].to_i
        
                file_name = "log"
-               directory = "~/sdk-build/test/build-server.basic1/buildsvr01/jobs/#{id}"
+               directory = "~/sdk-build/test/build-server.multi-svr1/buildsvr01/jobs/#{id}"
        
                # create the file path                                                                         
                path = File.join(directory, file_name)                                                              
index 74c6eead49468d2dd3c72735b2e9728e7b74dd6e..f963ca8e3ba9e2a9a9ea2963d4e4f19c22320829 100644 (file)
@@ -58,11 +58,11 @@ class ProjectsController < ApplicationController
 
        if (project_list.length > 1) or (not (project_list[0].nil? or project_list[0].empty?))
                # execute build command
-               ret = Utils.sbi_build_command(build_type, dist_name, project_list, os_list, password_list)
+               ret = Utils.sbi_build_command(build_type, dist_name, project_list, os_list, password_list,get_user_id)
     
-               render :text => "Success", :content_type => "text/json"
+               render :json => { :success => "OK!" }
        else
-               render :text => "Can't build project", :content_type => "text/xml"
+               render :text => "Can't build project", :status => 406
        end
 
   end
@@ -94,9 +94,22 @@ class ProjectsController < ApplicationController
 
                projects.each do |project|
                        if project.ptype.eql? "BINARY" 
-                               doc.BinaryProject {
-                                       doc.projectName(project.name)
-                               }
+                               bin = ProjectBin.find(:first, :conditions => ["prj_id = ?", project.id])
+                               if project_access_list.include? project.id 
+                                       doc.BinaryProject {
+                                               doc.ProjectName(project.name)
+                                               if not bin.nil? then
+                                                       doc.PackageName(bin.pkg_name)
+                                               end
+                                       }
+                               else
+                                       doc.OtherProject {
+                                               doc.ProjectName(project.name)
+                                               if not bin.nil? then
+                                                       doc.PackageName(bin.pkg_name)
+                                               end
+                                       }
+                               end
                        else
                                prjOsList = ""
                                prjOsLists = ProjectOs.find(:all, :conditions => ["prj_id = ?", project.id])
@@ -111,13 +124,13 @@ class ProjectsController < ApplicationController
 
                                if project_access_list.include? project.id 
                                        doc.Project {
-                                               doc.projectName(project.name)
-                                               doc.osList(prjOsList)
+                                               doc.ProjectName(project.name)
+                                               doc.OsList(prjOsList)
                                        }
                                else
                                        doc.OtherProject {
-                                               doc.projectName(project.name)
-                                               doc.osList(prjOsList)
+                                               doc.ProjectName(project.name)
+                                               doc.OsList(prjOsList)
                                        }
                                end
                        end
@@ -159,14 +172,22 @@ class ProjectsController < ApplicationController
   end
 
   def binaryFileUpload
-    uploaded_io = params[:datafile]
-puts uploaded_io
+    distribution = params[:distribution]
+    project = params[:project]
+    uploaded_io = params[:file]
  
        file_path = Rails.root.join('public', 'data', uploaded_io.original_filename)
     File.open(file_path, 'wb') do |file|
        file.write(uploaded_io.read)
     end
-               ret = Utils.sbi_register_command(build_type, dist_name, project_list, os_list, password_list)
+
+       project = Project.find(:first, :conditions => ["name = ? AND dist_name =?", project, distribution])
+       if project.nil? 
+               render :nothing => true
+               return
+       end
+
+       ret = Utils.sbi_register_command(distribution, file_path,  project.password, get_user_id)
 
        render :nothing => true
        return
index 96d4348bea4c3e7bd7f8e0431f2c0ee497a2ed9d..4b478c65caf093108d29ae373d5d08f702b168c7 100644 (file)
@@ -51,15 +51,19 @@ class Utils
     return server
   end
   
-  def Utils.sbi_build_command(sub_cmd, distribution, project_list, os_list, password_list)
+  def Utils.sbi_build_command(sub_cmd, distribution, project_list, os_list, password_list, email)
        options = "-d #{BUILD_SERVER_ADDRESS} --async "
-       options = options + "-N #{project_list.join(",")} -D #{distribution} " 
+       options = options + " -N #{project_list.join(",")} -D #{distribution} " 
        if (os_list.length > 1) or (not os_list[0].nil?)
-               options = options + "-o #{os_list.join(",")} "
+               options = options + " -o #{os_list.join(",")} "
        end
        if (password_list.length > 1) or (not (password_list[0].nil? or password_list[0].empty?))
-               options = options + "-w #{password_list.join(",")} "
+               options = options + " -w #{password_list.join(",")} "
        end
+       if not email.nil?
+               options = options + " -U #{email} "
+       end
+
        cmd = "#{DIBS_PATH}/build-cli #{sub_cmd} #{options}"
 puts "Build command"
 puts "[[[#{cmd}]]]"
@@ -67,13 +71,18 @@ puts "[[[#{cmd}]]]"
        return execute_shell_return(cmd)
   end
 
-  def Utils.sbi_register_command(distribution, file_path, password)
+  def Utils.sbi_register_command(distribution, file_path, password, email)
        options = "-P #{file_path} -d #{BUILD_SERVER_ADDRESS} -D #{distribution}"
-       if (password_list.length > 1) or (not (password_list[0].nil? or password_list[0].empty?))
-               options = options + "-w #{password_list.join(",")}"
+       if (not password.nil?)
+               options = options + " -w #{password}"
+       end
+       if not email.nil?
+               options = options + " -U #{email} "
        end
 
        cmd = "#{DIBS_PATH}/build-cli register #{options}"
+puts "Register command"
+puts "[[[#{cmd}]]]"
        return execute_shell_return(cmd)
   end
 
index ada83bddc0bc53a5e6929f034dc7d44ca3c8bbab..dbc4c135a3ffba0b104ecc285fb6b0b6cb09363e 100644 (file)
 
                <div data-role="content" >
                        <div class="content-primary">
-                               <h2>Introduction</h2>
-                               <p>This template is for a master-detail structured application.</p>
+                               <h2>Welcome to DIBS</h2>
                                <ul>
-                                       <li>Left bars to navigate details (master)
-                                       <li>Right content pane (detail)
+                                       <li>BUILD is menu for general user.
+                                       <li>ADMIN is menu for administrator.
                                </ul>
                        </div><!--/content-primary -->
 
                </div>
                <div data-role="content">
                        <form id="signupForm">
-                               <label for="user_email" class="clearable" style="text-align: left; font-size: 12px">Email</label>
+                               <label for="user_email" style="text-align: left; font-size: 12px">Email</label>
                                <input id="user_email" name="user[email]" type="text" style="font-size: 12px"/>
-                               <label for="user_name" class="clearable" style="text-align: left; font-size: 12px">Name</label>
+                               <label for="user_name" style="text-align: left; font-size: 12px">Name</label>
                                <input id="user_name" name="user[name]" type="text" style="font-size: 12px"/>
-                               <label for="user_password" class="clearable" style="text-align: left; font-size: 12px">Password</label>
+                               <label for="user_password" style="text-align: left; font-size: 12px">Password</label>
                                <input id="user_password" name="user[password]" type="password" style="font-size: 12px"/>
-                               <label for="user_password_confirmation" class="clearable" style="text-align: left; font-size: 12px">Password Comfirmation</label>
+                               <label for="user_password_confirmation" style="text-align: left; font-size: 12px">Password Comfirmation</label>
                                <input id="password_confirmation" name="user[password_confirmation]" type="password" style="font-size: 12px"/>
                                <div data-role="controlgroup" id="applyGroupRadio">
                                </div>
                                <div data-role="collapsible" data-collapsed="false">
                                        <h3>Binary Project</h3>
                                        <div data-role="content">
-                                               <table class="imagetable" style="font-size: 14px" id="binaryProjectTable">
-                                               </table>
-                                       </div>
-                                       <div align="right">
-                                               <div style="width: 200px; height: 50px; font-size: 10px">
-                                                       <a href="upload.html" class="uploadWindow" data-role="button" data-ajax="false"> Binary package upload</a>
-                                               </div>
-                                       </div>
-                                       <div data-role="content">
-                                               <table class="imagetable" id="binaryProjectTable">
+                                               <table class="projectTableStyle" style="font-size: 14px" id="binaryProjectTable">
                                                </table>
                                        </div>
                                </div>
index 5687c80f5b46f8f707b9aa9d89034f6cf511b52f..130638f88a3ecadb3a4935a9b609c306f0d981a4 100644 (file)
@@ -128,8 +128,14 @@ function modifyGroup() {
                data: JSON.stringify({ ChangeInfoList: changeInfoList }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
-               error: function(errMsg) {
-                       alert(errMsg);
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                       }
                }
        });
 }
@@ -160,8 +166,14 @@ function addGroup() {
                data: JSON.stringify({ ChangeInfoList: changeInfoList }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
-               failure: function(errMsg) {
-                       alert(errMsg);
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                       }
                }
        });
 }
@@ -235,14 +247,20 @@ function queryAdminGroup() {
                type: 'GET',
                dataType: 'xml',
                timeout: 1000,
-               error: function() {
-                       alert('Error loading XML document');
-               },
                success: function(xml) {
                        var projectList = $(xml).find("Groups").find("AllProject");
                        var groupList = $(xml).find("Groups").find("Group");
 
                        fillGroupTable(projectList, groupList);
+               },
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                       }
                }
        });
 }
@@ -267,7 +285,14 @@ function removeGroup(index) {
                data: JSON.stringify({ ChangeInfoList: changeInfoList }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
-               error: function(errMsg) {
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                       }
                }
        });
 }
@@ -288,14 +313,20 @@ function setupModifyGroup() {
                type: 'GET',
                dataType: 'xml',
                timeout: 1000,
-               error: function() {
-                       alert('Error loading XML document');
-               },
                success: function(xml) {
                        var fullProjectList = $(xml).find("GroupInfo").find("AllProject");
-                       var projectIdList = $(xml).find("GroupInfo").find("Group").find("ProjectList").text();
+                       var projectIdList = $(xml).find("GroupInfo").find("Group").find("ProjectList").text().split(",");
 
                        generateModifyGroupProjectSelect(fullProjectList, projectIdList);
+               },
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                       }
                }
        });
 }
@@ -306,13 +337,19 @@ function setupAddGroup() {
                type: 'GET',
                dataType: 'xml',
                timeout: 1000,
-               error: function() {
-                       alert('Error loading XML document');
-               },
                success: function(xml) {
                        var fullProjectList = $(xml).find("AllProject").find("Project");
 
                        generateAddGroupProjectSelect(fullProjectList);
+               },
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                       }
                }
        });
 }
index 7390de0094f3502be8736baae4909bfce484162c..ccd1dbeb84c832b80aad86d70a753dc63a00bf90 100644 (file)
@@ -23,9 +23,15 @@ function addDistribution() {
                success: function() {
                        $.mobile.changePage("#adminProject"); 
                },
-               error: function(errMsg) {
-                       alert('errMsg');
-                       $.mobile.changePage("#adminProject"); 
+               error: function(jqXHR) {
+                       switch (jqXHR.status) {
+                       case 401:
+                               expireSession();
+                               break;
+                       default:
+                               alert(jqXHR);
+                               $.mobile.changePage("#adminProject"); 
+                       }
                }
        });
 }
@@ -256,11 +262,8 @@ function modifyGitProject() {
        });
 }
 
-function removeProject(button) {
+function removeProject(projectType, tableIndex, projectName ) {
        var distName = $("#select-admin-distribution option:selected").val();
-       var projectType = button.id.split(':')[1].toUpperCase();
-       var tableIndex = button.id.split(':')[2];
-       var projectName = button.id.split(':')[3];
 
        var r=confirm("Project ["+projectName+"] is removed!!!");
        if (r==false)
@@ -367,10 +370,9 @@ function updateProjectInfo(projectList) {
                        button.setAttribute('data-rel','dialog');
                        button.setAttribute('data-mini','true');
                        button.setAttribute('onClick','popupModifyProject(\"'+name+'\")');
-                       button.setAttribute('id',"input:modifyGitProject:"+name);
+                       button.setAttribute('class','binaryProjectTableButton');
                        button.innerHTML = " "
                        cell.appendChild(button);
-                       $("#input\\:modifyGitProject\\:"+name).button();
 
                        cell = row.insertCell(-1);
                        var button = document.createElement('input');
@@ -378,9 +380,9 @@ function updateProjectInfo(projectList) {
                        button.setAttribute('id','button:git:'+projectIdx+':'+name);
                        button.setAttribute('data-mini','true');
                        button.setAttribute('name',name);
-                       button.setAttribute('onClick','removeProject(this)');
+                       button.setAttribute('class','binaryProjectTableButton');
+                       button.setAttribute('onClick','removeProject(\"GIT\",'+binaryProjectIdx+',\"'+name+'\"'+')');
                        cell.appendChild(button);
-                       $("#button\\:git\\:"+projectIdx+"\\:"+name).button();
 
                        projectIdx = projectIdx + 1;
                }
@@ -407,19 +409,17 @@ function updateProjectInfo(projectList) {
                        button.setAttribute('data-mini','true');
                        button.setAttribute('data-rel','dialog');
                        button.setAttribute('onClick','popupModifyProject(\"'+name+'\")');
-                       button.setAttribute('id','input:modifyBinaryProject:'+name);
+                       button.setAttribute('class','binaryProjectTableButton');
                        cell.appendChild(button);
-                       $("#input\\:modifyBinaryProject\\:"+name).button();
 
                        cell = row.insertCell(-1);
                        var button = document.createElement('input');
                        button.setAttribute('type','button');
-                       button.setAttribute('id','button:binary:'+binaryProjectIdx+':'+name);
+                       button.setAttribute('class','binaryProjectTableButton');
                        button.setAttribute('data-mini','true');
                        button.setAttribute('name',name);
-                       button.setAttribute('onClick','removeProject(this)');
+                       button.setAttribute('onClick','removeProject(\"BINARY\",'+binaryProjectIdx+',\"'+name+'\"'+')');
                        cell.appendChild(button);
-                       $("#button\\:binary\\:"+binaryProjectIdx+"\\:"+name).button();
 
                        binaryProjectIdx = binaryProjectIdx + 1;
                }
@@ -428,6 +428,7 @@ function updateProjectInfo(projectList) {
 
        });
 
+       $(".binaryProjectTableButton").button();
        $(".groupProjectList").collapsible();
 }
 
index 7e7471ea90890537b1ebd40c50f7c6af63b15dd8..c17ec1b1a0d7f7e98715d182f7c131b1bdbd4fe0 100644 (file)
@@ -10,7 +10,7 @@ function queryJobList(requestUrl) {
                dataType: 'xml',
                timeout: 1000,
                error: function(jqXHR) {
-                       errorProcess(jqXHR.status, "");
+                       errorProcess(jqXHR.status);
                },
                success: function(xml) {
                        $("#jobtable tr:not(:first)").remove();
index fe761f52e672725feac997deae3166745d1ff6e1..46785dcd3a75f65f71b3cc47f53eaf7cdfac4bec 100644 (file)
@@ -18,6 +18,14 @@ $( document ).bind( "pagechange", function( event, data ){
        if($.mobile.activePage.attr('id') == 'index')
        {
        }
+       else if($.mobile.activePage.attr('id') == 'signup')
+       {
+               clearFormData('signupForm');
+       }
+       else if($.mobile.activePage.attr('id') == 'login')
+       {
+               clearFormData('loginForm');
+       }
        else if($.mobile.activePage.attr('id') == 'projects')
        {
                queryDistribution();
@@ -100,6 +108,7 @@ function errorProcess(httpStatus){
                        break;
        }
 }
+
 //$(document).ready(function() {
 //    var hdhtml = $($.mobile.activePage).children('div').eq(0).clone();
 //    var fthtml = $($.mobile.activePage).children('div').eq(2).clone();
@@ -114,3 +123,22 @@ function errorProcess(httpStatus){
 //        $('div:jqmData(role="page")').prepend(hdhtml).append(fthtml);
 //    }
 //});
+
+function clearFormData(elementId){
+       $("#"+elementId).find(':input').each(function() {
+               switch(this.type) {
+                       case 'text':
+                       case 'password':
+                       case 'select-multiple':
+                       case 'select-one':
+                       case 'textarea':
+                               $(this).val('');
+                               break;
+                       case 'checkbox':
+                       case 'radio':
+                               $(this).checked = false;
+                               break;
+               }
+       });
+}
+
index cd270ab5e8cf42d6e59d81d63745219e9bd85bf9..379d455acd43eb69cfecbd0b6e3c49ee75aba62d 100644 (file)
@@ -59,8 +59,8 @@ function addTableRow(supportedOs, projectList, otherProjectList) {
        var index = 2;
 
        projectList.each(function(){
-               var name = $(this).find("projectName").text();
-               var osLists = $(this).find("osList").text();
+               var name = $(this).find("ProjectName").text();
+               var osLists = $(this).find("OsList").text();
                var osList = osLists.split(",");
        
                var row = projectTable.insertRow(-1);
@@ -107,7 +107,7 @@ function addTableRow(supportedOs, projectList, otherProjectList) {
        });
 
        otherProjectList.each(function(){
-               var name =  $(this).find("projectName").text();
+               var name =  $(this).find("ProjectName").text();
                var row = projectTable.insertRow(-1);
                
                var cell = row.insertCell(0);
@@ -133,29 +133,62 @@ function addTableRow(supportedOs, projectList, otherProjectList) {
        });
 }
 
-function addBinaryTableRow(binaryProjectList) {
+function addBinaryTableRow(binaryProjectList, otherProjectList) {
        var binaryProjectTable = document.getElementById("binaryProjectTable");
        var row = binaryProjectTable.insertRow(-1);
        var thCell = document.createElement('th');
        thCell.innerHTML = "Project";
        row.appendChild(thCell);
        thCell = document.createElement('th');
-       thCell.innerHTML = "Status";
+       thCell.innerHTML = "Package name";
+       row.appendChild(thCell);
+       thCell = document.createElement('th');
+       thCell.innerHTML = "Register";
        row.appendChild(thCell);
 
        /* insert binary project in binary project table */
        binaryProjectList.each(function(){
-               var name =  $(this).find("projectName").text();
+               var name =  $(this).find("ProjectName").text();
+               var packageName =  $(this).find("PackageName").text();
+               var row = '<tr><td bgcolor="#dcddc0" style="text-align:left">'+name+'</td>';
+               row += '<td bgcolor="#dcddc0" style="text-align:left">' + packageName + '</td>'
+               row += '<td bgcolor="#dcddc0" style="text-align:left"><a href="upload.html" onClick="uploadBinaryName(\'' +name+'\')" class="binary_project_button" data-role="button" data-ajax="false" data-mini="true">REGISTER</a>';
+               row += '</tr>'
+               
+               $("#binaryProjectTable tr:last").after(row);
+       });
+
+       otherProjectList.each(function(){
+               var name =  $(this).find("ProjectName").text();
+               var packageName =  $(this).find("PackageName").text();
                var row = binaryProjectTable.insertRow(-1);
                
-               var cell = row.insertCell(-1);
+               /* add project name */
+               var cell = row.insertCell(0);
+               cell.setAttribute('style', 'text-align: left');
+               cell.setAttribute('bgcolor', '#c0c0c0');
                cell.innerHTML = name;
-               
-               /* add empty cell for status */
+       
+               /* add package name */
+               cell = row.insertCell(-1);
+               cell.setAttribute('style', 'text-align: left');
+               cell.setAttribute('bgcolor', '#c0c0c0');
+               cell.innerHTML = packageName; 
+       
+               /* add empty cell for register */
                cell = row.insertCell(-1);
-               cell.setAttribute('id', "table"+":"+name);
+               cell.setAttribute('style', 'text-align: left');
+               cell.setAttribute('bgcolor', '#c0c0c0');
                cell.innerHTML = "";
        });
+
+       $('.binary_project_button').button();
+       $('.binary_project_button').popupWindow({ 
+               height:200, 
+               width:400, 
+               top:50, 
+               left:50 
+       });
 }
 
 function buildProject(type) {
@@ -185,7 +218,8 @@ function buildProject(type) {
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function() {
-                       alert("test");
+                       alert("Build started! Move to jobs page");
+                       $.mobile.changePage("#jobs"); 
                },
                error: function(jqXHR) {
                        switch (jqXHR.status) {
@@ -212,7 +246,8 @@ function queryProjectList() {
                        addTableRow( $(xml).find("ProjectInfo").find("BuildServerInfo").find("supportedOs"),
                                                 $(xml).find("ProjectInfo").find("Project"),
                                                 $(xml).find("ProjectInfo").find("OtherProject"));
-                       addBinaryTableRow( $(xml).find("ProjectInfo").find("BinaryProject"));
+                       addBinaryTableRow( $(xml).find("ProjectInfo").find("BinaryProject"),
+                                                $(xml).find("ProjectInfo").find("OtherProject"));
                }
        });
 }
@@ -246,3 +281,8 @@ function queryDistribution() {
                }
        });
 }
+
+function uploadBinaryName(project_name) {
+       localStorage.distibutionName = $("#select-distribution option:selected").val();
+       localStorage.uploadBinaryProjectName = project_name;
+}
index 845829bfc9aeea1ca4561a4298708d69507ebf0f..2b7ada86997f641debacfbc020f68c4236b7dd4d 100644 (file)
@@ -48,10 +48,11 @@ $(function(){
                        data: formData,
                        timeout: 1000,
                        error: function() {
+                               $inputs.removeAttr("disabled");
                                alert('Error loading XML document');
                        },
                        success: function(xml) {
-                               $inputs.attr("abled", "abled");
+                               $inputs.removeAttr("disabled");
                                $(xml).find("LogInInfo").each(function(){ 
                                        var succ = $(this).find("Success").text();
                                        var email = $(this).find("UserInfo").find("Email").text();
@@ -59,6 +60,8 @@ $(function(){
                                        localStorage.sessionInfoEmail = email;
                                        localStorage.sessionInfoName = name;
 
+                                       clearFormData('loginForm');
+
                                        console.log(document.cookie);
                                        var cookies = document.cookie.split(';');
                                        for (var i = 0; i < cookies.length; i++) {
@@ -124,7 +127,7 @@ $(function(){
                                        
                                        if(succ == "TRUE")
                                        {
-                                               $('.clearable').val("");        
+                                               clearFormData('signupForm');
                                                $.mobile.changePage("#index"); 
                                        } 
                                        else
index 0846e2bcff40ecd29d6b016ce5f49ebd518efb77..59c3d7d4bf68633625918484792cca04aafab111 100644 (file)
@@ -1,66 +1,70 @@
 <html>
-       <script language="Javascript">
-       Function fileUpload(form, action_url, div_id) {
-           // Create the iframe...
-           var iframe = document.createElement("iframe");
-           iframe.setAttribute("id", "upload_iframe");
-           iframe.setAttribute("name", "upload_iframe");
-           iframe.setAttribute("width", "0");
-           iframe.setAttribute("height", "0");
-           iframe.setAttribute("border", "0");
-           iframe.setAttribute("style", "width: 0; height: 0; border: none;");
-        
-           // Add to document...
-           form.parentNode.appendChild(iframe);
-           window.frames['upload_iframe'].name = "upload_iframe";
-        
-           iframeId = document.getElementById("upload_iframe");
-        
-           // Add event...
-           var eventHandler = function () {
-        
-                   if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler);
-                   else iframeId.removeEventListener("load", eventHandler, false);
-        
-                   // Message from server...
-                   if (iframeId.contentDocument) {
-                       content = iframeId.contentDocument.body.innerHTML;
-                   } else if (iframeId.contentWindow) {
-                       content = iframeId.contentWindow.document.body.innerHTML;
-                   } else if (iframeId.document) {
-                       content = iframeId.document.body.innerHTML;
-                   }
-        
-                   document.getElementById(div_id).innerHTML = content;
-        
-                   // Del the iframe...
-                   setTimeout('iframeId.parentNode.removeChild(iframeId)', 250);
-               }
-        
-           if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true);
-           if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler);
-        
-           // Set properties of form...
-           form.setAttribute("target", "upload_iframe");
-           form.setAttribute("action", action_url);
-           form.setAttribute("method", "post");
-           form.setAttribute("enctype", "multipart/form-data");
-           form.setAttribute("encoding", "multipart/form-data");
-        
-           // Submit the form...
-           form.submit();
-        
-           document.getElementById(div_id).innerHTML = "Uploading...";
-       }
-       </script>
-        
-       <!-- index.php could be any script server-side for receive uploads. -->
-       <form>
-               <input type="file" name="datafile" /></br>
-               <input type="button" value="upload"
-               onClick="fileUpload(this.form,'projects/binaryFileUpload','upload'); return false;" >
-               <div id="upload"></div>
+<head>
+       <script type="text/javascript" src="javascripts/jquery-1.7.1.js"></script>
+</head>
+<body>
+       <form enctype="multipart/form-data">
+               <input name="file" type="file" />
+               <input id="register" type="button" value="Upload" />
        </form>
+       <progress hidden="hidden"></progress>
+</body>
 </html>
+
+<script>
+$('#register').click(function(){
+       var dist_name = localStorage.distibutionName;
+       var prj_name = localStorage.uploadBinaryProjectName;
+    var formData = new FormData($('form')[0]);
+
+       formData.append("distribution", dist_name);
+       formData.append("project", prj_name);
+
+       $('progress').removeAttr("hidden");
+
+    $.ajax({
+        url: 'projects/binaryFileUpload',  //server script to process data
+        type: 'POST',
+        xhr: function() {  // custom xhr
+            myXhr = $.ajaxSettings.xhr();
+            if(myXhr.upload){ // check if upload property exists
+                myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload
+            }
+            return myXhr;
+        },
+        //Ajax events
+        beforeSend: beforeSendHandler,
+        success: completeHandler,
+        error: errorHandler,
+
+        // Form data
+        data: formData,
+
+        //Options to tell JQuery not to process data or worry about content-type
+        cache: false,
+        contentType: false,
+        processData: false
+    });
+});
+
+function beforeSendHandler(e){
+}
+
+function completeHandler(e){
+       alert("Register started! Closed this page");
+
+       //close window
+       window.open('about:blank','_self');
+       opener = window;
+       window.close();
+}
+
+function errorHandler(e){
+}
+
+function progressHandlingFunction(e){
+    if(e.lengthComputable){
+        $('progress').attr({value:e.loaded,max:e.total});
+    }
+}
+</script>