From 0bfd14df281e76c7243908538dda95b770b3d01b Mon Sep 17 00:00:00 2001 From: Sungmin kim Date: Mon, 8 Apr 2013 16:26:41 +0900 Subject: [PATCH] [DIBS web] code refactoring for using DB ID --- dibs-web/app/controllers/admin_controller.rb | 15 +- .../admin_distribution_controller.rb | 77 ++----- .../app/controllers/admin_group_controller.rb | 50 +++-- .../controllers/admin_project_controller.rb | 166 ++++++++------ .../controllers/admin_server_controller.rb | 203 ++++++++++++------ .../app/controllers/admin_user_controller.rb | 50 +++-- .../app/controllers/projects_controller.rb | 146 ++++++++----- dibs-web/config/routes.rb | 24 +-- dibs-web/public/index.html | 70 +++--- .../javascripts/admin-distribution-modify.js | 9 +- .../public/javascripts/admin-distribution.js | 56 ++--- .../public/javascripts/admin-group-modify.js | 35 ++- dibs-web/public/javascripts/admin-group.js | 27 +-- .../public/javascripts/admin-project-add.js | 28 +-- .../javascripts/admin-project-modify.js | 101 ++++----- dibs-web/public/javascripts/admin-project.js | 63 +++--- .../public/javascripts/admin-server-add.js | 28 +-- .../public/javascripts/admin-server-modify.js | 101 +++++---- .../public/javascripts/admin-server-remove.js | 32 ++- dibs-web/public/javascripts/admin-server.js | 24 +-- .../public/javascripts/admin-user-modify.js | 22 +- dibs-web/public/javascripts/admin-user.js | 12 +- dibs-web/public/javascripts/build.js | 127 ++++------- dibs-web/public/javascripts/dibs-api.js | 54 ++--- dibs-web/public/javascripts/jobs.js | 5 +- dibs-web/public/javascripts/main.js | 15 -- dibs-web/public/javascripts/projects.js | 23 +- dibs-web/public/upload.html | 6 +- 28 files changed, 817 insertions(+), 752 deletions(-) diff --git a/dibs-web/app/controllers/admin_controller.rb b/dibs-web/app/controllers/admin_controller.rb index c6ea473..c97a5e9 100644 --- a/dibs-web/app/controllers/admin_controller.rb +++ b/dibs-web/app/controllers/admin_controller.rb @@ -31,7 +31,9 @@ class AdminController < ApplicationController before_filter :check_login_status, :check_admin_group def queryAllOS - os_list = SupportedOs.find_by_sql("SELECT supported_os.name AS os_name + os_list = SupportedOs.find_by_sql("SELECT supported_os.id AS os_id + , supported_os.name AS os_name + , os_category.id AS category_id , os_category.name AS category_name FROM supported_os , os_category @@ -45,8 +47,10 @@ class AdminController < ApplicationController doc.Data { os_list.each do |os| doc.OS { - doc.OsName(os.os_name) - doc.OsCategory(os.category_name) + doc.Id(os.os_id) + doc.Name(os.os_name) + doc.CategoryId(os.category_id) + doc.CategoryName(os.category_name) } end } @@ -65,7 +69,10 @@ class AdminController < ApplicationController doc.Data { os_category_list.each do |category| - doc.OsCategoryName(category.name) + doc.OsCategory{ + doc.Id(category.id) + doc.Name(category.name) + } end } } diff --git a/dibs-web/app/controllers/admin_distribution_controller.rb b/dibs-web/app/controllers/admin_distribution_controller.rb index aa91a87..00b5ad4 100644 --- a/dibs-web/app/controllers/admin_distribution_controller.rb +++ b/dibs-web/app/controllers/admin_distribution_controller.rb @@ -31,22 +31,22 @@ class AdminDistributionController < ApplicationController before_filter :check_login_status, :check_admin_group def queryDistributionInfo - dist_name = params[:distribution] + dist_id = params[:distId] - if dist_name.nil? or dist_name.empty? - render :text => "Distribution name is empty", :content_type => "text/xml", :status => 406 + if dist_id.nil? or dist_id.empty? + render :text => "Distribution id is empty", :content_type => "text/xml", :status => 406 return end # get distribution - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) + distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id]) if distribution.nil? - render :text => "Can't find distribution : #{dist_name}", :content_type => "text/xml", :status => 406 + render :text => "Can't find distribution: [#{dist_id}]", :content_type => "text/xml", :status => 406 return end # get sync package server - sync_package_server = SyncPkgServer.find(:first, :conditions => ["distribution_id = ?", distribution.id]) + sync_package_server = SyncPkgServer.find(:first, :conditions => ["distribution_id = ?", dist_id]) doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 ) doc.Response { @@ -55,7 +55,8 @@ class AdminDistributionController < ApplicationController #generate to XML doc.Data{ doc.DistributionInfo{ - doc.DistributionName(distribution.name) + doc.Id(distribution.id) + doc.Name(distribution.name) doc.PackageServerUrl(distribution.pkgsvr_url) doc.PackageServerAddress(distribution.pkgsvr_addr) doc.Status(distribution.status) @@ -87,7 +88,7 @@ class AdminDistributionController < ApplicationController dist_name = change_item[:DistributionName] if dist_name.nil? or dist_name.empty? then - errmsg = "Can't find [#{dist_name}] information" + errmsg = "Distribution name is empty" render :json => { :error => errmsg }, :status => 406 return end @@ -95,7 +96,7 @@ class AdminDistributionController < ApplicationController dist = Distribution.find(:first, :conditions => ["name = ?", dist_name]) if dist.nil? dist = Distribution.new - dist.name = change_item[:DistributionName] + dist.name = dist_name dist.pkgsvr_url = change_item[:URL] dist.pkgsvr_addr = change_item[:Address] dist.status = change_item[:DistStatus] @@ -109,7 +110,7 @@ class AdminDistributionController < ApplicationController sync_pkg_svr.description = change_item[:SyncPkgSvrDescription] sync_pkg_svr.save else - errmsg = "Distribution[#{dist_name}] already exist" + errmsg = "Distribution [#{dist_name}] already exist" end if errmsg.empty? @@ -124,16 +125,16 @@ class AdminDistributionController < ApplicationController change_item = change_group_list[0] errmsg = "" - dist_name = change_item[:DistributionName] - if dist_name.nil? or dist_name.empty? then - errmsg = "Can't find [#{dist_name}] information" + dist_id = change_item[:DistributionId] + if dist_id.nil? or dist_id.empty? then + errmsg = "Distribution id is empty" render :json => { :error => errmsg }, :status => 406 return end - dist = Distribution.find(:first, :conditions => ["name = ?", dist_name]) + dist = Distribution.find(:first, :conditions => ["id = ?", dist_id]) if dist.nil? - errmsg = "Distribution[#{dist_name}] not exist" + errmsg = "Can't find distribution: [#{dist_id}]" else # first, remove sync package server sync_pkg_svr = SyncPkgServer.find(:first, :conditions => ["distribution_id = ?", dist.id]) @@ -158,16 +159,16 @@ class AdminDistributionController < ApplicationController change_item = change_group_list[0] errmsg = "" - dist_name = change_item[:DistributionName] - if dist_name.nil? or dist_name.empty? then - errmsg = "Can't find [#{dist_name}] information" + dist_id = change_item[:DistributionId] + if dist_id.nil? or dist_id.empty? then + errmsg = "Distribution id is empty" render :json => { :error => errmsg }, :status => 406 return end - dist = Distribution.find(:first, :conditions => ["name = ?", dist_name]) + dist = Distribution.find(:first, :conditions => ["id = ?", dist_id]) if dist.nil? - errmsg = "Distribution[#{dist_name}] not exist" + errmsg = "Can't find distribution: [#{dist_id}]" else dist.pkgsvr_url = change_item[:URL] dist.pkgsvr_addr = change_item[:Address] @@ -200,40 +201,4 @@ class AdminDistributionController < ApplicationController render :json => { :error=> errmsg }, :status => 406 end end - - def fullBuildDistribution - change_group_list = params[:ChangeInfoList] - change_item = change_group_list[0] - errmsg = "" - - dist_name = change_item[:DistributionName] - if dist_name.nil? or dist_name.empty? then - errmsg = "Can't find [#{dist_name}] information" - render :json => { :error => errmsg }, :status => 406 - return - end - - dist = Distribution.find(:first, :conditions => ["name = ?", dist_name]) - if dist.nil? - errmsg = "Distribution[#{dist_name}] not exist" - end - - server_config = Server_config.find(:first, :conditions => ["property = \"id\""]) - if server_config.nil? - errmsg = "Server name can't find" - else - server_name = server_config.value - - if server_name.nil? or server_name.empty? - errmsg = "Server name can't find" - end - end - - if errmsg.empty? - Utils.sbi_fullbuild_command(server_name, dist_name) - render :json => { :success => "OK!" } - else - render :json => { :error=> errmsg }, :status => 406 - end - end end diff --git a/dibs-web/app/controllers/admin_group_controller.rb b/dibs-web/app/controllers/admin_group_controller.rb index 6820593..309d0c8 100644 --- a/dibs-web/app/controllers/admin_group_controller.rb +++ b/dibs-web/app/controllers/admin_group_controller.rb @@ -41,6 +41,7 @@ class AdminGroupController < ApplicationController doc.Data { group_list.each do |group| doc.Group { + doc.GroupId(group.id) doc.GroupName(group.name) doc.AdminFlag(group.admin) doc.Description(group.description) @@ -71,15 +72,15 @@ class AdminGroupController < ApplicationController end def queryGroupInfo - group_name = params[:groupName] - if group_name.nil? or group_name.empty? - render :text => "Group name is empty", :content_type => "text/xml", :status => 406 + group_id = params[:groupId] + if group_id.nil? or group_id.empty? + render :text => "Group id is empty", :content_type => "text/xml", :status => 406 return end - group = Group.find(:first, :conditions => ["name = ?", group_name]) + group = Group.find(:first, :conditions => ["id = ?", group_id]) if group.nil? - render :text => "Can't find group : #{group_name}", :content_type => "text/xml", :status => 406 + render :text => "Can't find group: #{group_id}", :content_type => "text/xml", :status => 406 return end @@ -98,8 +99,8 @@ class AdminGroupController < ApplicationController project_list.each do |project| doc.Project{ - doc.Name(project.project_name) doc.Id(project.project_id) + doc.Name(project.project_name) doc.DistName(project.distribution_name) } end @@ -126,23 +127,24 @@ class AdminGroupController < ApplicationController change_item = change_group_list[0] errmsg = "" - group_name = change_item[:GroupName] - if group_name.nil? or group_name.empty? - render :text => "Group name is invalid", :status => 406 + group_id = change_item[:GroupId] + if group_id.nil? or group_id.empty? + errmsg = "group id is empty" + render :json => { :error => errmsg }, :status => 406 return else - group = Group.find(:first, :conditions => ["name= ?", group_name]) + group = Group.find(:first, :conditions => ["id= ?", group_id]) end if group.nil? - errmsg = "Can't find group" + errmsg = "Can't find group: #{group_id}" else - new_group_name = change_item[:NewGroupName] + group_name = change_item[:GroupName] admin_flag = change_item[:AdminFlag] description = change_item[:Description] project_id_list = change_item[:ProjectList].split(",") - group.name = new_group_name + group.name = group_name group.admin = admin_flag group.description = description group.save @@ -162,7 +164,7 @@ class AdminGroupController < ApplicationController if errmsg.empty? render :json => { :success => "OK!" } else - render :text => errmsg, :status => 406 + render :json => { :error=> errmsg }, :status => 406 end end @@ -171,30 +173,31 @@ class AdminGroupController < ApplicationController change_item = change_group_list[0] errmsg = "" - group_name = change_item[:GroupName] - if group_name.nil? or group_name.empty? - render :text => "Group name is invalid", :status => 406 + group_id = change_item[:GroupId].to_s + if group_id.nil? or group_id.empty? + errmsg = "group id is empty" + render :json => { :error => errmsg }, :status => 406 return else - group = Group.find(:first, :conditions => ["name= ?", group_name]) + group = Group.find(:first, :conditions => ["id = ?", group_id]) end if group.nil? - errmsg = "Can't find group" + errmsg = "Can't find group: #{group_id}" else user_group = UserGroup.find(:first, :conditions => ["group_id = ?", group.id]) if user_group.nil? GroupProjectAccess.delete_all(["group_id = ?", group.id]) group.destroy else - errmsg = "Can't remove. #{group_name} has users." + errmsg = "Can't remove. #{group.id} has users." end end if errmsg.empty? render :json => { :success => "OK!" } else - render :text => errmsg, :status => 406 + render :json => { :error=> errmsg }, :status => 406 end end @@ -205,7 +208,8 @@ class AdminGroupController < ApplicationController group_name = change_item[:GroupName] if group_name.nil? or group_name.empty? - render :text => "Group name is invalid", :status => 406 + errmsg = "Group name is invalid" + render :json => { :error => errmsg }, :status => 406 return else group = Group.find(:first, :conditions => ["name= ?", group_name]) @@ -232,7 +236,7 @@ class AdminGroupController < ApplicationController if errmsg.empty? render :json => { :success => "OK!" } else - render :text => errmsg, :status => 406 + render :json => { :error=> errmsg }, :status => 406 end end end diff --git a/dibs-web/app/controllers/admin_project_controller.rb b/dibs-web/app/controllers/admin_project_controller.rb index 7c67a69..04baa94 100644 --- a/dibs-web/app/controllers/admin_project_controller.rb +++ b/dibs-web/app/controllers/admin_project_controller.rb @@ -30,6 +30,7 @@ class AdminProjectController < ApplicationController def queryAllProject project_list = Project.find_by_sql("SELECT projects.name AS project_name , projects.id AS project_id + , distributions.id AS distribution_id , distributions.name AS distribution_name FROM projects , distributions @@ -43,8 +44,9 @@ class AdminProjectController < ApplicationController doc.Data { project_list.each do |project| doc.Project{ - doc.Name(project.project_name) doc.Id(project.project_id) + doc.Name(project.project_name) + doc.DistId(project.distribution_id) doc.DistName(project.distribution_name) } end @@ -56,17 +58,10 @@ class AdminProjectController < ApplicationController end def queryProjectsInDistributionForAdmin - dist_name = params[:distribution] - - if dist_name.nil? or dist_name.empty? - render :text => "Distribution name is empty", :content_type => "text/xml", :status => 406 - return - end + dist_id = params[:distId] - # get distribution - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) - if distribution.nil? - render :text => "Can't find distribution : #{dist_name}", :content_type => "text/xml", :status => 406 + if dist_id.nil? or dist_id.empty? + render :text => "Distribution id is empty", :content_type => "text/xml", :status => 406 return end @@ -83,13 +78,14 @@ class AdminProjectController < ApplicationController , projects.password FROM projects , distributions - WHERE distributions.name = \"#{dist_name}\" + WHERE distributions.id = \"#{dist_id}\" AND distributions.id = projects.distribution_id ORDER BY projects.name") project_list.each do |project| doc.Project { - doc.ProjectName(project.name) + doc.Id(project.id) + doc.Name(project.name) doc.Type(project.ptype) doc.ProjectStatus(project.status) doc.ProjectPassword(project.password) @@ -133,35 +129,43 @@ class AdminProjectController < ApplicationController change_item = change_group_list[0] errmsg = "" + dist_id = change_item[:DistId] project_name = change_item[:Name] project_type = change_item[:ProjectType].upcase - project_dist_name = change_item[:Distribution] project_password = change_item[:ProjectPass] project_status = change_item[:ProjectStatus].upcase - if project_name.nil? or project_name.empty? then - errmsg = "Can't find [Name] information" + if dist_id.nil? or dist_id.empty? or + project_name.nil? or project_name.empty? or + project_type.nil? or project_type.empty? or + project_status.nil? or project_status.empty? then + errmsg = "add project information invalid" render :json => { :error => errmsg }, :status => 406 return end + if not project_type.eql? "GIT" and not project_type.eql? "BINARY" + errmsg = "project type is invalid" + render :json => { :error => errmsg }, :status => 406 + return + end if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE" errmsg = "project status is invalid" render :json => { :error => errmsg }, :status => 406 return end - distribution = Distribution.find(:first, :conditions => ["name = ?", project_dist_name]) - project = Project.find(:first, :conditions => ["name = ? and distribution_id = ? and ptype = ?", project_name, distribution.id, project_type]) - - if not project.nil? - errmsg = "project already exist" + distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id]) + if distribution.nil? + errmsg = "Can't find distribution: #{dist_id}" render :json => { :error => errmsg }, :status => 406 return end - if not project_type.eql? "GIT" and not project_type.eql? "BINARY" - errmsg = "project type is invalid" + project = Project.find(:first, :conditions => ["name = ? and distribution_id = ?", project_name, dist_id]) + + if not project.nil? + errmsg = "project already exist" render :json => { :error => errmsg }, :status => 406 return end @@ -171,16 +175,21 @@ class AdminProjectController < ApplicationController project.ptype = project_type project.status = project_status project.password = project_password - project.distribution_id = distribution.id + project.distribution_id = dist_id #TODO: set project user is admin. admin user id is '1' project.user_id = 1 project.save - if not change_item[:OSNameList].nil? - os_name_list = change_item[:OSNameList].split(",") - os_name_list.each do |os_name| - supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name]) - #need check not found + if not change_item[:OSIdList].nil? + os_id_list = change_item[:OSIdList].split(",") + os_id_list.each do |os_id| + supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id]) + if supported_os.nil? + errmsg = "project os id is invalid: #{os_id}" + render :json => { :error => errmsg }, :status => 406 + return + end + project_os = ProjectOs.new project_os.project_id = project.id project_os.supported_os_id = supported_os.id @@ -210,32 +219,30 @@ class AdminProjectController < ApplicationController change_item = change_group_list[0] errmsg = "" - if change_item[:Name].nil? or change_item[:Name].empty? then - errmsg = "Can't find [Name] information" + if change_item[:ProjectId].nil? or change_item[:ProjectId].empty? then + errmsg = "project id is empty" render :json => { :error => errmsg }, :status => 406 return end - dist_name = change_item[:Distribution] - project_name = change_item[:Name] - project_type = change_item[:ProjectType] - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) - project = Project.find(:first, :conditions => ["name = ? and distribution_id = ?", project_name, distribution.id]) + project_id = change_item[:ProjectId] + + project = Project.find(:first, :conditions => ["id = ?", project_id]) if project.nil? - errmsg = "project does not exist" + errmsg = "project does not exist: #{project_id}" render :json => { :error => errmsg }, :status => 406 return end - case project_type.upcase + case project.ptype when "GIT" - ProjectGit.delete_all(["project_id = ?", project.id]) - ProjectOs.delete_all(["project_id = ?", project.id]) - GroupProjectAccess.delete_all(["project_id = ?", project.id]) + ProjectGit.delete_all(["project_id = ?", project_id]) + ProjectOs.delete_all(["project_id = ?", project_id]) + GroupProjectAccess.delete_all(["project_id = ?", project_id]) when "BINARY" - ProjectBin.delete_all(["project_id = ?", project.id]) - GroupProjectAccess.delete_all(["project_id = ?", project.id]) + ProjectBin.delete_all(["project_id = ?", project_id]) + GroupProjectAccess.delete_all(["project_id = ?", project_id]) else errmsg = "project type is invalid" render :json => { :error => errmsg }, :status => 406 @@ -243,7 +250,7 @@ class AdminProjectController < ApplicationController end # remove project os - ProjectOs.delete_all(["project_id = ?", project.id]) + ProjectOs.delete_all(["project_id = ?", project_id]) # remove project project.destroy @@ -256,54 +263,71 @@ class AdminProjectController < ApplicationController change_item = change_group_list[0] errmsg = "" - dist_name = change_item[:Distribution] - old_project_name = change_item[:Name] - project_type = change_item[:ProjectType].upcase + project_id = change_item[:Id] + project_name = change_item[:Name] project_status = change_item[:ProjectStatus].upcase + project_password = change_item[:ProjectPass] - if old_project_name.nil? or old_project_name.empty? then - errmsg = "Can't find [#{old_project_name}] information" + if project_id.nil? or project_id.empty? or + project_name.nil? or project_name.empty? or + project_status.nil? or project_status.empty? then + errmsg = "project information invalid" render :json => { :error => errmsg }, :status => 406 return end - if not project_type.eql? "GIT" and not project_type.eql? "BINARY" - errmsg = "project type is invalid" + if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE" + errmsg = "project status is invalid" render :json => { :error => errmsg }, :status => 406 return end - if not project_status.eql? "OPEN" and not project_status.eql? "CLOSE" - errmsg = "project status is invalid" + project = Project.find(:first, :conditions => ["id = ?", project_id]) + if project.nil? + errmsg = "project does not exist" render :json => { :error => errmsg }, :status => 406 return end - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) - project = Project.find(:first, :conditions => ["name = ? and distribution_id = ? and ptype = ?", old_project_name, distribution.id, project_type]) - project.name = change_item[:NewProjectName] - project.password = change_item[:ProjectPass] + # project data update + if not project.name.eql? project_name then + name_check_project = Project.find(:first, :conditions => ["name = ? and distribution_id = ?", project_name, project.distribution_id]) + + if not name_check_project.nil? + errmsg = "project already exist" + render :json => { :error => errmsg }, :status => 406 + return + end + + project.name = project_name + end + project.password = project_password project.status = project_status # remove project os and reset project os - ProjectOs.delete_all(["project_id = ?", project.id]) - if not change_item[:OSNameList].nil? - os_name_list = change_item[:OSNameList].split(",") - os_name_list.each do |os_name| - supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name]) - #need check not found + ProjectOs.delete_all(["project_id = ?", project_id]) + if not change_item[:OSIdList].nil? + os_id_list = change_item[:OSIdList].split(",") + os_id_list.each do |os_id| + supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id]) + if supported_os.nil? + errmsg = "project os id is invalid: #{os_id}" + render :json => { :error => errmsg }, :status => 406 + return + end + project_os = ProjectOs.new - project_os.project_id = project.id + project_os.project_id = project_id project_os.supported_os_id = supported_os.id project_os.save end end - case project_type + case project.ptype when "GIT" - project_git = ProjectGit.find(:first, :conditions => ["project_id = ?", project.id]) + project_git = ProjectGit.find(:first, :conditions => ["project_id = ?", project_id]) if project_git.nil? - project_git.project_id = project.id + project_git.project_id = project_id project_git = ProjectGit.new end project_git.git_repos = change_item[:ProjectAddress] @@ -311,10 +335,10 @@ class AdminProjectController < ApplicationController project_git.save when "BINARY" - project_bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id]) + project_bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project_id]) if project_bin.nil? project_bin = ProjectBin.new - project_bin.project_id = project.id + project_bin.project_id = project_id end project_bin.pkg_name = change_item[:PackageName] project_bin.save @@ -329,7 +353,7 @@ class AdminProjectController < ApplicationController change_item = change_group_list[0] errmsg = "" - dist_name = change_item[:Distribution] + dist_id = change_item[:DistId] projectStatus = change_item[:ProjectStatus] if projectStatus.nil? or not (projectStatus.eql? "OPEN" or projectStatus.eql? "CLOSE") then @@ -338,7 +362,7 @@ class AdminProjectController < ApplicationController return end - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) + distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id]) Project.update_all("status=\"#{projectStatus}\"", :distribution_id => distribution.id) render :json => { :success => "OK!" } diff --git a/dibs-web/app/controllers/admin_server_controller.rb b/dibs-web/app/controllers/admin_server_controller.rb index 35f0d5a..aa55578 100644 --- a/dibs-web/app/controllers/admin_server_controller.rb +++ b/dibs-web/app/controllers/admin_server_controller.rb @@ -40,6 +40,7 @@ class AdminServerController < ApplicationController doc.Data { server_config.each do |info| doc.ServerConfig { + doc.Id( info.id ) doc.Property( info.property ) doc.Value( info.value ) } @@ -47,6 +48,7 @@ class AdminServerController < ApplicationController remote_build_servers.each do |server| doc.RemoteBuildServer { + doc.Id(server.id) doc.Address(server.svr_addr) supported_os = SupportedOs.find(:first, :conditions => ["id = ?", server.supported_os_id]) if supported_os.nil? @@ -68,6 +70,93 @@ class AdminServerController < ApplicationController render :text => out_string, :content_type => "text/xml" end + def queryServerConfig + config_id = params[:configId] + if config_id.nil? + #send_data + render :text => "Config id value is invalid", :content_type => "text/xml" + return + end + + server_config = Server_config.find(:first, :conditions => ["id = ?", config_id]) + if server_config.nil? + #send_data + render :text => "Can't find server config: #{config_id}", :content_type => "text/xml" + return + end + + doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 ) + doc.Response { + generate_xml_header(doc) + + #generate to XML + doc.Data { + doc.Id(server_config.id) + doc.Property(server_config.property) + doc.Value(server_config.value) + } + } + + #send_data + render :text => out_string, :content_type => "text/xml" + end + + def querySupportedOS + os_id = params[:osId] + if os_id.nil? + #send_data + render :text => "Supported os id is invalid", :content_type => "text/xml" + return + end + + supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id]) + if supported_os.nil? + #send_data + render :text => "Can't find supported os: #{os_id}", :content_type => "text/xml" + return + end + + doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 ) + doc.Response { + generate_xml_header(doc) + + #generate to XML + doc.Data { + doc.Id(supported_os.id) + doc.Name(supported_os.name) + doc.CategoryId(supported_os.os_category_id) + } + } + + #send_data + render :text => out_string, :content_type => "text/xml" + end + + def queryRemoteBuildServer + server_id = params[:serverId] + remote_server = RemoteBuildServer.find(:first, :conditions => ["id = ?", server_id]) + if remote_server.nil? + #send_data + render :text => "Can't find server: #{server_id}", :content_type => "text/xml" + return + end + + doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 ) + doc.Response { + generate_xml_header(doc) + + #generate to XML + doc.Data { + doc.Id(remote_server.id) + doc.Address(remote_server.svr_addr) + doc.Description(remote_server.description) + } + } + + #send_data + render :text => out_string, :content_type => "text/xml" + end + def addRemoteBuildServer change_group_list = params[:ChangeInfoList] change_item = change_group_list[0] @@ -86,14 +175,13 @@ class AdminServerController < ApplicationController if server.nil? server = RemoteBuildServer.new - server.svr_addr = address + server.svr_addr = address.strip server.description = description server.save render :json => { :success => "OK!" } else errmsg = "Server already exist" - render :json => { :error => errmsg }, :status => 406 end end @@ -103,32 +191,34 @@ class AdminServerController < ApplicationController change_item = change_group_list[0] errmsg = "" + id = change_item[:Id] address = change_item[:Address] - if address.nil? or address.empty? - errmsg = "Server address is empty" + description = change_item[:Description] + if id.nil? or + address.nil? or address.empty? + errmsg = "Server information is invalid" render :json => { :error => errmsg }, :status => 406 return end - server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", address]) + server = RemoteBuildServer.find(:first, :conditions => ["id = ?", id]) if server.nil? errmsg = "Server does not exist" else - new_address = change_item[:NewAddress] - description = change_item[:Description] - # error check for server already exist - if not address.eql? new_address - new_server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", new_address]) + if not server.svr_addr.eql? address + check_server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", address]) - if not new_server.nil? + if not check_server.nil? errmsg = "Server already exist" + render :json => { :error => errmsg }, :status => 406 + return end end - server.svr_addr = new_address - server.description = description + server.svr_addr = address.strip + server.description = description.strip server.save end @@ -145,14 +235,14 @@ class AdminServerController < ApplicationController change_item = change_group_list[0] errmsg = "" - address = change_item[:Address] - if address.nil? or address.empty? - errmsg = "Server address is empty" + id = change_item[:Id] + if id.nil? or id.empty? + errmsg = "Server id is empty" render :json => { :error => errmsg }, :status => 406 return end - server = RemoteBuildServer.find(:first, :conditions => ["svr_addr = ?", address]) + server = RemoteBuildServer.find(:first, :conditions => ["id = ?", id]) if server.nil? errmsg = "Server does not exist" @@ -163,7 +253,7 @@ class AdminServerController < ApplicationController end end - def addOsCategory + def addOSCategory change_group_list = params[:ChangeInfoList] change_item = change_group_list[0] errmsg = "" @@ -186,25 +276,24 @@ class AdminServerController < ApplicationController render :json => { :success => "OK!" } else errmsg = "Os category already exist" - render :json => { :error => errmsg }, :status => 406 end end - def removeOsCategory + def removeOSCategory change_group_list = params[:ChangeInfoList] change_item = change_group_list[0] errmsg = "" - name = change_item[:Name] - if name.nil? or name.empty? - errmsg = "Os category name is empty" + id = change_item[:Id] + if id.nil? or id.empty? + errmsg = "Os category id is empty" render :json => { :error => errmsg }, :status => 406 return end # get server for error check - osCategory = OsCategory.find(:first, :conditions => ["name = ?", name]) + osCategory = OsCategory.find(:first, :conditions => ["id = ?", id]) if osCategory.nil? errmsg = "Can't find os category" @@ -221,36 +310,33 @@ class AdminServerController < ApplicationController errmsg = "" os_name = change_item[:Name] - category_name = change_item[:OsCategory] + category_id = change_item[:OsCategoryId] if os_name.nil? or os_name.empty? errmsg = "Os name is empty" render :json => { :error => errmsg }, :status => 406 return end - if category_name.nil? or category_name.empty? + if category_id.nil? or category_id.empty? errmsg = "Os category is empty" render :json => { :error => errmsg }, :status => 406 return end # get server for error check - os_category = OsCategory.find(:first, :conditions => ["name = ?", category_name]) + os_category = OsCategory.find(:first, :conditions => ["id = ?", category_id]) supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name]) if os_category.nil? errmsg = "Os category does not exist" - render :json => { :error => errmsg }, :status => 406 elsif not supported_os.nil? errmsg = "supported os already exist" - render :json => { :error => errmsg }, :status => 406 else supported_os = SupportedOs.new - supported_os.name = os_name + supported_os.name = os_name.strip supported_os.os_category_id = os_category.id supported_os.save - render :json => { :success => "OK!" } end end @@ -260,25 +346,23 @@ class AdminServerController < ApplicationController change_item = change_group_list[0] errmsg = "" - os_name = change_item[:Name] - if os_name.nil? or os_name.empty? - errmsg = "Os name is empty" + os_id = change_item[:Id] + if os_id.nil? or os_id.empty? + errmsg = "Os id is empty" render :json => { :error => errmsg }, :status => 406 return end # get server for error check - supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name]) + supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id]) if supported_os.nil? errmsg = "supported os does not exist" - render :json => { :error => errmsg }, :status => 406 - else - supported_os.destroy - - render :json => { :success => "OK!" } end + + supported_os.destroy + render :json => { :success => "OK!" } end def modifySupportedOS @@ -286,18 +370,20 @@ class AdminServerController < ApplicationController change_item = change_group_list[0] errmsg = "" + os_id = change_item[:Id] os_name = change_item[:Name] - new_os_name = change_item[:NewName] - category_name = change_item[:OsCategory] - if os_name.nil? or os_name.empty? - errmsg = "Os name is empty" + category_id = change_item[:OsCategoryId] + if os_id.nil? or os_id.empty? or + os_name.nil? or os_name.empty? or + category_id.nil? or category_id.empty? + errmsg = "modify os data is invalid" render :json => { :error => errmsg }, :status => 406 return end # get server for error check - os_category = OsCategory.find(:first, :conditions => ["name = ?", category_name]) - supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name]) + os_category = OsCategory.find(:first, :conditions => ["id = ?", category_id]) + supported_os = SupportedOs.find(:first, :conditions => ["id = ?", os_id]) if os_category.nil? errmsg = "Os category does not exist" @@ -308,13 +394,12 @@ class AdminServerController < ApplicationController render :json => { :error => errmsg }, :status => 406 else - if not os_name.eql? new_os_name - new_supported_os = SupportedOs.find(:first, :conditions => ["name = ?", new_os_name]) - if new_supported_os.nil? - supported_os.name = new_os_name + if not supported_os.name.eql? os_name + check_supported_os = SupportedOs.find(:first, :conditions => ["name = ?", os_name]) + if check_supported_os.nil? + supported_os.name = os_name else errmsg = "supported os already exist" - render :json => { :error => errmsg }, :status => 406 return end @@ -322,7 +407,6 @@ class AdminServerController < ApplicationController supported_os.os_category_id = os_category.id supported_os.save - render :json => { :success => "OK!" } end end @@ -366,26 +450,25 @@ class AdminServerController < ApplicationController change_item = change_group_list[0] errmsg = "" + id = change_item[:Id] property = change_item[:Property] value = change_item[:Value] - if property.nil? or property.empty? - errmsg = "Property is empty" - render :json => { :error => errmsg }, :status => 406 - return - end - if value.nil? or value.empty? - errmsg = "Value is empty" + if id.nil? or id.empty? or + value.nil? or value.empty? or + property.nil? or property.empty? + errmsg = "server info is invalid" render :json => { :error => errmsg }, :status => 406 return end # get server for error check - config = Server_config.find(:first, :conditions => ["property = ?", property]) + config = Server_config.find(:first, :conditions => ["id = ?", id]) if config.nil? errmsg = "Config does not exist" render :json => { :error => errmsg }, :status => 406 else + config.property = property config.value = value config.save diff --git a/dibs-web/app/controllers/admin_user_controller.rb b/dibs-web/app/controllers/admin_user_controller.rb index 17791c3..07158e1 100644 --- a/dibs-web/app/controllers/admin_user_controller.rb +++ b/dibs-web/app/controllers/admin_user_controller.rb @@ -114,24 +114,37 @@ class AdminUserController < ApplicationController change_item = change_user_list[0] errmsg = "" + id = change_item[:Id] email = change_item[:Email] + name = change_item[:Name] group_id_list = change_item[:GroupIdList].split(",") - user_name = change_item[:UserName] - if email.nil? or email.empty? - render :text => "Email is invalid", :status => 406 + if id.nil? or + email.nil? or email.empty? + render :text => "User data is invalid", :status => 406 return - else - user = User.find(:first, :conditions => ["email = ?", email]) + end + + user = User.find(:first, :conditions => ["id = ?", id]) + + if user.nil? + errmsg = "Can't find user information" + render :text => errmsg, :status => 406 + return + end - if user.nil? - errmsg = "Can't find user information" + if not user.email.eql? email + check_user = User.find(:first, :conditions => ["email = ?", email]) + if not check_user.nil? + errmsg = "Email address already used" render :text => errmsg, :status => 406 return end + + user.email = email end - user.name = user_name + user.name = name user.save UserGroup.delete_all(["user_id = ?", user.id]) @@ -155,22 +168,23 @@ class AdminUserController < ApplicationController change_item = change_user_list[0] errmsg = "" - email = change_item[:Email] - if email.nil? or email.empty? - render :text => "Email is invalid", :status => 406 + id = change_item[:Id] + if id.nil? + render :text => "User infomation invalid", :status => 406 return - else - user = User.find(:first, :conditions => ["email = ?", email]) end + + user = User.find(:first, :conditions => ["id = ?", id]) if user.nil? errmsg = "Can't find user information" render :text => errmsg, :status => 406 - else - UserGroup.delete_all(["user_id = ?", user.id]) - - user.destroy - render :json => { :success => "OK!" } + return end + + UserGroup.delete_all(["user_id = ?", user.id]) + + user.destroy + render :json => { :success => "OK!" } end end diff --git a/dibs-web/app/controllers/projects_controller.rb b/dibs-web/app/controllers/projects_controller.rb index 8aafe4e..a4460b2 100644 --- a/dibs-web/app/controllers/projects_controller.rb +++ b/dibs-web/app/controllers/projects_controller.rb @@ -43,43 +43,64 @@ class ProjectsController < ApplicationController # get information : dist_name, project_hash, password change_group_list = params[:ChangeInfoList] + distribution_list = [] project_list = [] os_list = [] password_list = [] dist_name = nil - change_group_list.each do |change_item| - dist_name = change_item[:distribution] - project_name = change_item[:projectName] - os = change_item[:os] + if change_group_list.nil? or change_group_list.empty? + errmsg = "Build project is empty" + render :json => { :error => errmsg }, :status => 406 + return + end - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) - project = Project.find(:first, :conditions => ["name = ? AND distribution_id =?", project_name, distribution.id]) + change_group_list.each do |change_item| + project_id = change_item[:projectId] + os_id = change_item[:osId] + + project = Project.find(:first, :conditions => ["id = ?", project_id]) + if project_list.nil? + errmsg = "Can't find project information: [#{project_id}]" + render :json => { :error => errmsg }, :status => 406 + return + end + os = SupportedOs.find(:first, :conditions => ["id = ?", os_id]) + if os.nil? + errmsg = "Can't find os information: [#{os_id}]" + render :json => { :error => errmsg }, :status => 406 + return + end + distribution_list.push project.distribution_id project_list.push project.name password_list.push project.password - os_list.push os + os_list.push os.name end + distribution_list.uniq! project_list.uniq! os_list.uniq! password_list.uniq! - if (project_list.length > 1) or (not (project_list[0].nil? or project_list[0].empty?)) - # execute build command - begin - result, job_id, msg = Utils.sbi_build_command(dist_name, project_list, os_list, password_list, get_user_email) - if result then - render :json => { :result => "SUCCESS", :job_id => job_id } - else - render :json => { :result => "ERROR", :message => msg } - end - rescue => e - render :text => e.message, :status => 406 + if(distribution_list.length > 1) + errmsg = "Can't build multiple distribution" + render :json => { :error => errmsg }, :status => 406 + return + end + distribution = Distribution.find(:first, :conditions => ["id = ?", distribution_list[0]]) + + # execute build command + begin + result, job_id, msg = Utils.sbi_build_command(distribution.name, project_list, os_list, password_list, get_user_email) + if result then + render :json => { :result => "SUCCESS", :job_id => job_id } + else + render :json => { :result => "ERROR", :message => msg } end - else - render :text => "Can't build project", :status => 406 + rescue => e + render :text => e.message, :status => 406 end end @@ -129,7 +150,12 @@ class ProjectsController < ApplicationController end def queryProjectsInfoInDistribution - dist_name = params[:distribution] + dist_id = params[:distId] + if dist_id.nil? + errmsg = "Distribution id is null" + render :json => { :error => errmsg }, :status => 406 + return + end user_id = get_user_id projects = Project.find_by_sql("SELECT projects.name AS project_name @@ -137,11 +163,10 @@ class ProjectsController < ApplicationController , projects.id AS project_id , users.email AS maintainer FROM projects - , distributions , users - WHERE distributions.name = \"#{dist_name}\" - AND projects.distribution_id = distributions.id - AND users.id = projects.user_id") + WHERE projects.distribution_id = #{dist_id} + AND users.id = projects.user_id + ORDER BY projects.name") #generate to XML doc = Builder::XmlMarkup.new( :target => out_string = "", :indent => 2 ) @@ -151,6 +176,7 @@ class ProjectsController < ApplicationController doc.ProjectList { projects.each { |project| doc.Project { + doc.Id(project.project_id) doc.Name(project.project_name) doc.Type(project.project_type) doc.Maintainer(project.maintainer) @@ -255,9 +281,18 @@ class ProjectsController < ApplicationController end def queryProjectsInDistribution - dist_name = params[:distribution] + dist_id = params[:distId] + if dist_id.nil? + render :text => "Distribution id is empty", :content_type => "text/xml", :status => 406 + return + end + + distribution = Distribution.find(:first, :conditions => ["id = ?", dist_id]) + if distribution.nil? + render :text => "Can't find distribution information: #{dist_id}", :content_type => "text/xml", :status => 406 + return + end - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) projects = Project.find(:all, :conditions => ["distribution_id = ?", distribution.id], :order => "name") osList = SupportedOs.find(:all) @@ -269,10 +304,11 @@ class ProjectsController < ApplicationController generate_xml_header(doc) doc.Data { doc.BuildServerInfo { - if not osList.nil? - osList.each do |os| - doc.supportedOs(os.name) - end + osList.each do |os| + doc.SupportedOs{ + doc.Id(os.id) + doc.Name(os.name) + } end doc.DistributionStatus(distribution.status) } @@ -282,41 +318,43 @@ class ProjectsController < ApplicationController bin = ProjectBin.find(:first, :conditions => ["project_id = ?", project.id]) if checkUserAccessProject(user_id, project.id) doc.BinaryProject { - doc.ProjectName(project.name) - doc.ProjectStatus(project.status) + doc.Id(project.id) + doc.Name(project.name) + doc.Status(project.status) if not bin.nil? then doc.PackageName(bin.pkg_name) end } else doc.OtherBinaryProject { - doc.ProjectName(project.name) - doc.ProjectStatus(project.status) + doc.Id(project.id) + doc.Name(project.name) + doc.Status(project.status) if not bin.nil? then doc.PackageName(bin.pkg_name) end } end else - buildOsNameList = [] - prjOsLists = ProjectOs.find(:all, :conditions => ["project_id = ?", project.id]) - - prjOsLists.each do |list| - supported_os = SupportedOs.find(:first, :conditions => ["id = ?", list.supported_os_id]) - buildOsNameList.push(supported_os.name) + buildOsIdList = [] + projectOsList = ProjectOs.find(:all, :conditions => ["project_id = ?", project.id]) + projectOsList.each do |projectOs| + buildOsIdList.push(projectOs.supported_os_id) end if checkUserAccessProject(user_id, project.id) doc.Project { - doc.ProjectName(project.name) - doc.ProjectStatus(project.status) - doc.OsList(buildOsNameList.join(",")) + doc.Id(project.id) + doc.Name(project.name) + doc.Status(project.status) + doc.OsList(buildOsIdList.join(",")) } else doc.OtherProject { - doc.ProjectName(project.name) - doc.ProjectStatus(project.status) - doc.OsList(buildOsNameList.join(",")) + doc.Id(project.id) + doc.Name(project.name) + doc.Status(project.status) + doc.OsList(buildOsIdList.join(",")) } end end @@ -341,7 +379,10 @@ class ProjectsController < ApplicationController doc.Data { distribution_list.each do |distribution| - doc.DistributionName(distribution.name) + doc.Distribution { + doc.Id(distribution.id) + doc.Name(distribution.name) + } end } } @@ -358,8 +399,7 @@ class ProjectsController < ApplicationController end def binaryFileUpload - dist_name = params[:distribution] - project = params[:project] + project_id = params[:ProjectId] uploaded_io = params[:file] file_path = Rails.root.join('public', 'data', uploaded_io.original_filename) @@ -367,10 +407,10 @@ class ProjectsController < ApplicationController file.write(uploaded_io.read) end - distribution = Distribution.find(:first, :conditions => ["name = ?", dist_name]) - project = Project.find(:first, :conditions => ["name = ? AND distribution_id =?", project, distribution.id]) + project = Project.find(:first, :conditions => ["id = ?", project_id]) + distribution = Distribution.find(:first, :conditions => ["id = ?", project.distribution_id]) if project.nil? - render :nothing => true + render :text => "Can't find project information: [#{project_id}]", :content_type => "text/xml" return end diff --git a/dibs-web/config/routes.rb b/dibs-web/config/routes.rb index 1e19b74..543e371 100644 --- a/dibs-web/config/routes.rb +++ b/dibs-web/config/routes.rb @@ -34,7 +34,6 @@ Dibs::Application.routes.draw do get "jobs" => "jobs#list" - get "projects" => "projects#projects" get "projects/fileUpload" get "signup" => "users#new", :as => "signup" @@ -63,18 +62,16 @@ Dibs::Application.routes.draw do get "projects/queryDistribution" - match "projects/queryProject/:distribution" => "projects#queryProject", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } post "projects/binaryFileUpload" # projects - match "projects/queryRunningProjectsInfoInDistribution/:distribution" => "projects#queryRunningProjectsInfoInDistribution", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } - match "projects/queryProjectsInfoInDistribution/:distribution" => "projects#queryProjectsInfoInDistribution", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } - match "projects/queryProjectsInDistribution/:distribution" => "projects#queryProjectsInDistribution" , :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } + match "projects/queryProjectsInfoInDistribution/:distId" => "projects#queryProjectsInfoInDistribution" + match "projects/queryProjectsInDistribution/:distId" => "projects#queryProjectsInDistribution" post "projects/buildProject" # admin group get "admin_group/queryAllGroup" - match "admin_group/queryGroupInfo/:groupName" => "admin_group#queryGroupInfo" + match "admin_group/queryGroupInfo/:groupId" => "admin_group#queryGroupInfo" post "admin_group/addGroup" post "admin_group/removeGroup" post "admin_group/modifyGroup" @@ -87,12 +84,15 @@ Dibs::Application.routes.draw do # admin server get "admin_server/queryAllServer" + match "admin_server/queryServerConfig/:configId" => "admin_server#queryServerConfig" + match "admin_server/querySupportedOS/:osId" => "admin_server#querySupportedOS" + match "admin_server/queryRemoteBuildServer/:serverId" => "admin_server#queryRemoteBuildServer" post "admin_server/addRemoteBuildServer" post "admin_server/removeRemoteBuildServer" post "admin_server/modifyRemoteBuildServer" - post "admin_server/addOsCategory" - post "admin_server/removeOsCategory" - post "admin_server/modifyOsCategory" + post "admin_server/addOSCategory" + post "admin_server/removeOSCategory" + post "admin_server/modifyOSCategory" post "admin_server/addSupportedOS" post "admin_server/removeSupportedOS" post "admin_server/modifySupportedOS" @@ -102,20 +102,18 @@ Dibs::Application.routes.draw do # admin project get "admin_project/queryAllProject" - match "admin_project/queryProjectsInDistributionForAdmin/:distribution" => "admin_project#queryProjectsInDistributionForAdmin", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } + match "admin_project/queryProjectsInDistributionForAdmin/:distId" => "admin_project#queryProjectsInDistributionForAdmin" post "admin_project/addProject" post "admin_project/removeProject" post "admin_project/modifyProject" post "admin_project/changeAllProjectStatus" # admin distribution - match "admin_distribution/queryDistributionInfo/:distribution" => "admin_distribution#queryDistributionInfo", :constraints => { :distribution => /[0-9A-Za-z\-\.\_]+/ } + match "admin_distribution/queryDistributionInfo/:distId" => "admin_distribution#queryDistributionInfo" post "admin_distribution/addDistribution" post "admin_distribution/removeDistribution" post "admin_distribution/modifyDistribution" - post "admin_distribution/fullBuildDistribution" - get "admin/queryAllOS" get "admin/queryAllOSCategory" diff --git a/dibs-web/public/index.html b/dibs-web/public/index.html index 597bad7..0c5ca4d 100644 --- a/dibs-web/public/index.html +++ b/dibs-web/public/index.html @@ -145,20 +145,20 @@ Contributors:
-

- + - + - + - +
@@ -333,11 +333,13 @@ Contributors:
+ +
- +
- +
@@ -492,9 +494,6 @@ Contributors:
-
- -

Package server url

@@ -578,6 +577,8 @@ Contributors:
+ +

@@ -678,10 +679,10 @@ Contributors:
- +
- - + +
@@ -710,10 +711,10 @@ Contributors:
- +
- - + +
@@ -779,10 +780,10 @@ Contributors:
- +
- - + +
@@ -829,10 +830,10 @@ Contributors:
- +
- - + +
@@ -874,13 +875,15 @@ Contributors:
- - + +
+ +

-
@@ -896,9 +899,10 @@ Contributors:
- - - + +
+ +
@@ -920,8 +924,8 @@ Contributors:
- - + +
@@ -931,7 +935,7 @@ Contributors:
-

Add os category

+

Remove os category

@@ -970,8 +974,10 @@ Contributors:
+ +
- +
diff --git a/dibs-web/public/javascripts/admin-distribution-modify.js b/dibs-web/public/javascripts/admin-distribution-modify.js index 21c1c92..8565e84 100644 --- a/dibs-web/public/javascripts/admin-distribution-modify.js +++ b/dibs-web/public/javascripts/admin-distribution-modify.js @@ -27,7 +27,7 @@ Contributors: */ function adminDistributionModifyPopupInit() { - var distName = $("#adminDistribution-distribution-select option:selected").val(); + var distId = $("#adminDistribution-distribution-select option:selected").val(); var packageServerUrl = $("#adminDistribution-url").html(); var packageServeraddress = $("#adminDistribution-address").html(); var serverStatusText = $("#adminDistribution-status").html(); @@ -54,6 +54,7 @@ function adminDistributionModifyPopupInit() { syncPkgSvrDescription = "" } + $("#adminDistributionModify-id").val(distId); $("#adminDistributionModify-url").val(packageServerUrl); $("#adminDistributionModify-address").val(packageServeraddress); $("#adminDistributionModify-description").val(serverDescription); @@ -82,7 +83,7 @@ function adminDistributionModifyPopupInit() { function adminDistributionModify() { var changeInfoList = []; var changeInfoItem; - var distName = $("#adminDistribution-distribution-select option:selected").val(); + var distId = $("#adminDistributionModify-id").val(); var url = $("#adminDistributionModify-url").val(); var address = $("#adminDistributionModify-address").val(); var description = $("#adminDistributionModify-description").val(); @@ -91,7 +92,7 @@ function adminDistributionModify() { var syncPkgSvrPeriod = $("#adminDistributionModify-syncPackageServer-period").val(); var syncPkgSvrDescription = $("#adminDistributionModify-syncPackageServer-description").val(); - if(distName == "" || url == "" || address == ""){ + if(distId == "" || url == "" || address == ""){ alert("You must input full data"); return; } @@ -100,7 +101,7 @@ function adminDistributionModify() { distStatus = "OPEN"; } - changeInfoItem = {"DistributionName":distName, "URL":url, "Address":address, "DistStatus":distStatus, "Description":description, "SyncPkgSvrUrl":syncPkgSvrUrl, "SyncPkgSvrPeriod":syncPkgSvrPeriod, "SyncPkgSvrDescription":syncPkgSvrDescription}; + changeInfoItem = {"DistributionId":distId, "URL":url, "Address":address, "DistStatus":distStatus, "Description":description, "SyncPkgSvrUrl":syncPkgSvrUrl, "SyncPkgSvrPeriod":syncPkgSvrPeriod, "SyncPkgSvrDescription":syncPkgSvrDescription}; changeInfoList.push(changeInfoItem); modifyDistribution( changeInfoList, function () { diff --git a/dibs-web/public/javascripts/admin-distribution.js b/dibs-web/public/javascripts/admin-distribution.js index 7fd24de..92e8db6 100644 --- a/dibs-web/public/javascripts/admin-distribution.js +++ b/dibs-web/public/javascripts/admin-distribution.js @@ -28,22 +28,23 @@ Contributors: function adminDistributionInit() { queryDistribution( function (xml) { - var oldDistName = $("#adminDistribution-distribution-select option:selected").val(); + var oldDistId = $("#adminDistribution-distribution-select option:selected").val(); var find = false; - var distributionList = $(xml).find("Data").find("DistributionName"); + var distributionList = $(xml).find("Data").find("Distribution"); // remove old select options $("#adminDistribution-distribution-select").empty(); distributionList.each(function(){ - var name = $(this).text(); + var distId = $(this).find("Id").text(); + var distName = $(this).find("Name").text(); - if( oldDistName == name ) { - $("#adminDistribution-distribution-select").append(""); + if( oldDistId == distId ) { + $("#adminDistribution-distribution-select").append(""); find = true; } else { - $("#adminDistribution-distribution-select").append(""); + $("#adminDistribution-distribution-select").append(""); } }); @@ -60,16 +61,17 @@ function adminDistributionInit() { } function adminDistributionSetInfo() { - var distName = $("#adminDistribution-distribution-select option:selected").val(); + var distId = $("#adminDistribution-distribution-select option:selected").val(); - queryDistributionInfo( distName, function (xml) { - var data = $(xml).find("Data").find("DistributionInfo"); + queryDistributionInfo( distId, function (xml) { var syncPackageServer = $(xml).find("Data").find("SyncPackageServer"); - var name = data.find("DistributionName").text(); - var url = data.find("PackageServerUrl").text(); - var address = data.find("PackageServerAddress").text(); - var distStatus = data.find("Status").text(); - var distDescription = data.find("Description").text(); + var distInfo = $(xml).find("Data").find("DistributionInfo"); + var id = distInfo.find("Id").text(); + var name = distInfo.find("Name").text(); + var url = distInfo.find("PackageServerUrl").text(); + var address = distInfo.find("PackageServerAddress").text(); + var distStatus = distInfo.find("Status").text(); + var distDescription = distInfo.find("Description").text(); $("#adminDistribution-url").text(url); $("#adminDistribution-address").text(address); @@ -83,12 +85,12 @@ function adminDistributionSetInfo() { function adminDistributionRemove() { var changeInfoList = []; var changeInfoItem; - var distName = $("#adminDistribution-distribution-select option:selected").val(); + var distId = $("#adminDistribution-distribution-select option:selected").val(); - changeInfoItem = {"DistributionName":distName}; + changeInfoItem = {"DistributionId":distId}; changeInfoList.push(changeInfoItem); - var r=confirm("Distribution ["+distName+"] will be removed!!!"); + var r=confirm("Distribution will be removed!!!"); if (r==false) { return; @@ -108,23 +110,3 @@ function adminDistributionInitSyncPackageServer(serverInfo){ $("#adminDistribution-syncPackageServer").append(info); } - -function adminDistributionFullBuild() { - var changeInfoList = []; - var changeInfoItem; - var distName = $("#adminDistribution-distribution-select option:selected").val(); - - changeInfoItem = {"DistributionName":distName}; - changeInfoList.push(changeInfoItem); - - var r=confirm("Distribution ["+distName+"] fullbuild will be started!!! it takes several time"); - if (r==false) - { - return; - } - - fullBuildDistribution( changeInfoList, function (xml) { - $.mobile.changePage("#adminDistribution"); - }); -} - diff --git a/dibs-web/public/javascripts/admin-group-modify.js b/dibs-web/public/javascripts/admin-group-modify.js index 51b4e65..ee0012d 100644 --- a/dibs-web/public/javascripts/admin-group-modify.js +++ b/dibs-web/public/javascripts/admin-group-modify.js @@ -26,14 +26,13 @@ Contributors: - S-Core Co., Ltd */ -function adminGroupModifyInit() { - var index = localStorage.groupTableIndex; - var groupName = $("#adminGroup-contents-"+index+"-name").html(); - var adminFlagText = $("#adminGroup-contents-"+index+"-flag").html(); - var description = $("#adminGroup-contents-"+index+"-description").html(); - - $("#adminGroupModify-oldName").val(groupName); - $("#adminGroupModify-newName").val(groupName); +function adminGroupModifyInit(groupId) { + var groupName = $("#adminGroup-contents-"+groupId+"-name").html(); + var adminFlagText = $("#adminGroup-contents-"+groupId+"-flag").html(); + var description = $("#adminGroup-contents-"+groupId+"-description").html(); + + $("#adminGroupModify-id").val(groupId); + $("#adminGroupModify-name").val(groupName); $("#adminGroupModify-description").val(description); $("#adminGroupModify-admin").empty(); @@ -48,9 +47,10 @@ function adminGroupModifyInit() { } else { $("#adminGroupModify-admin").append(''); } + $("#adminGroupModify-admin").selectmenu(); $("#adminGroupModify-admin").selectmenu("refresh"); - queryGroupInfo(groupName, function(xml) { + queryGroupInfo(groupId, function(xml) { var fullProjectList = $(xml).find("Data").find("Project"); var projectIdList = $(xml).find("Data").find("Group").find("ProjectIdList").text().split(","); @@ -61,8 +61,8 @@ function adminGroupModifyInit() { function adminGroupModifyGenerateProjectSelect(fullProjectList, projectIdList) { $("#adminGroupModify-project").empty(); fullProjectList.each(function(){ - var projectName = $(this).find("Name").text(); var projectId = $(this).find("Id").text(); + var projectName = $(this).find("Name").text(); var projectDistName = $(this).find("DistName").text(); var input; @@ -83,21 +83,18 @@ function adminGroupModifyGenerateProjectSelect(fullProjectList, projectIdList) { } function adminGroupModifyGroup() { - var oldGroupName = $("#adminGroupModify-oldName").val(); - var groupName = $("#adminGroupModify-newName").val(); + var groupId = $("#adminGroupModify-id").val(); + var groupName = $("#adminGroupModify-name").val(); var description = $("#adminGroupModify-description").val(); var adminFlag = $("#adminGroupModify-admin option:selected").val(); var selectProjectList = []; var changeInfoList = []; - var selectArray = $("input[name='adminGroupModify-project-checkbox']"); - for(var i = 0; i < selectArray.length; i++) { - if (selectArray[i].checked == true) { - selectProjectList.push(selectArray[i].value); - } - } + $("input[name='adminGroupModify-project-checkbox']:checked").each(function() { + selectProjectList.push($(this).val()); + }); - changeItem = {"GroupName" : oldGroupName, "NewGroupName":groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList":selectProjectList.toString()}; + changeItem = {"GroupId" : groupId, "GroupName":groupName, "AdminFlag":adminFlag, "Description":description, "ProjectList":selectProjectList.toString()}; changeInfoList.push(changeItem); changeGroup(changeInfoList, function() { diff --git a/dibs-web/public/javascripts/admin-group.js b/dibs-web/public/javascripts/admin-group.js index f897766..2084bb3 100644 --- a/dibs-web/public/javascripts/admin-group.js +++ b/dibs-web/public/javascripts/admin-group.js @@ -46,20 +46,19 @@ function adminGroupFillTableInfo(groupList) { $("#adminGroup-contents").append(tableHeader); - var index = 2; - groupList.each(function(){ var row = groupTable.insertRow(-1); var cell; + var groupId = $(this).find("GroupId").text(); var groupName = $(this).find("GroupName").text(); var adminFlag = $(this).find("AdminFlag").text(); var description = $(this).find("Description").text(); var projectList = $(this).find("AccessableProject"); - row.setAttribute('id', 'table:'+index); + row.setAttribute('id', 'adminGroup-contents-'+groupId); cell = row.insertCell(-1); - cell.setAttribute('id', 'adminGroup-contents-'+index+'-name'); + cell.setAttribute('id', 'adminGroup-contents-'+groupId+'-name'); cell.innerHTML = groupName cell = row.insertCell(-1); @@ -67,11 +66,11 @@ function adminGroupFillTableInfo(groupList) { cell.appendChild(div); cell = row.insertCell(-1); - cell.setAttribute('id', 'adminGroup-contents-'+index+'-flag'); + cell.setAttribute('id', 'adminGroup-contents-'+groupId+'-flag'); cell.innerHTML = adminFlag; cell = row.insertCell(-1); - cell.setAttribute('id', 'adminGroup-contents-'+index+'-description'); + cell.setAttribute('id', 'adminGroup-contents-'+groupId+'-description'); cell.innerHTML = description; cell = row.insertCell(-1); @@ -79,7 +78,7 @@ function adminGroupFillTableInfo(groupList) { button.setAttribute('href','#adminGroupModify'); button.setAttribute('data-role','button'); button.setAttribute('data-rel','dialog'); - button.setAttribute('onClick','adminGroupModifySetup(\"'+index+'\")'); + button.setAttribute('onClick','adminGroupModifyInit(\"'+groupId+'\")'); button.setAttribute('class','adminGroup-contents-button'); button.innerHTML = " " cell.appendChild(button); @@ -87,21 +86,15 @@ function adminGroupFillTableInfo(groupList) { cell = row.insertCell(-1); var button = document.createElement('input'); button.setAttribute('type','button'); - button.setAttribute('onClick','adminGroupRemoveGroup('+index+')'); + button.setAttribute('onClick','adminGroupRemoveGroup('+groupId+')'); button.setAttribute('class','adminGroup-contents-button'); cell.appendChild(button); - - index = index + 1; }); $(".adminGroup-projectList").collapsible(); $(".adminGroup-contents-button").button(); } -function adminGroupModifySetup(index) { - localStorage.groupTableIndex = index; -} - function adminGroupGenerateProjectListCell(projectList) { var div = document.createElement('div'); div.setAttribute('data-role', 'collapsible'); @@ -128,8 +121,8 @@ function adminGroupGenerateProjectListCell(projectList) { return div; } -function adminGroupRemoveGroup(index) { - var groupName = $("#adminGroup-contents-"+index+"-name").html(); +function adminGroupRemoveGroup(groupId) { + var groupName = $("#adminGroup-contents-"+groupId+"-name").html(); var r=confirm("User ["+groupName+"] will be removed!!!"); if (r==false) @@ -139,7 +132,7 @@ function adminGroupRemoveGroup(index) { var changeInfoList = []; var changeInfoItem; - changeInfoItem = {"GroupName":groupName}; + changeInfoItem = {"GroupId":groupId}; changeInfoList.push(changeInfoItem); removeGroup(changeInfoList, function() { diff --git a/dibs-web/public/javascripts/admin-project-add.js b/dibs-web/public/javascripts/admin-project-add.js index 4ee55da..2acc880 100644 --- a/dibs-web/public/javascripts/admin-project-add.js +++ b/dibs-web/public/javascripts/admin-project-add.js @@ -41,16 +41,17 @@ function adminProjectAddGitInit() { $("#adminProjectAddGit-status").selectmenu("refresh"); queryAllOS( function (xml) { - var osList = $(xml).find("Data").find("OsName"); + var osList = $(xml).find("Data").find("OS"); $("#adminProjectAddGit-os").empty(); $("#adminProjectAddGit-os").append("os list"); osList.each(function(){ - var osName = $(this).text(); + var osId = $(this).find("Id").text(); + var osName = $(this).find("Name").text(); - var input = '' - var label = '