diff --git a/module/artifactrepo/control.php b/module/artifactrepo/control.php index 80cacf5d41..fdb9577351 100644 --- a/module/artifactrepo/control.php +++ b/module/artifactrepo/control.php @@ -57,6 +57,7 @@ class artifactrepo extends control { $repo = form::data($this->config->artifactrepo->form->create) ->join('products', ',') + ->add('editedBy', $this->app->user->account) ->add('createdBy', $this->app->user->account) ->add('createdDate', helper::now()) ->get(); @@ -138,7 +139,9 @@ class artifactrepo extends control { $repos = $this->artifactrepo->getServerRepos($serverID); - return print(json_encode($repos)); + if(!$repos['result']) return $this->send(array('result' => 'fail', 'message' => $this->lang->artifactrepo->loseConnect)); + + return print(json_encode($repos['data'])); } public function ajaxUpdateArtifactRepos() diff --git a/module/artifactrepo/js/create.ui.js b/module/artifactrepo/js/create.ui.js index 8ce9d80e57..aeab6790da 100644 --- a/module/artifactrepo/js/create.ui.js +++ b/module/artifactrepo/js/create.ui.js @@ -11,12 +11,19 @@ function getArtifactRepo(event) { const server = $(event.target).val(); const url = $.createLink('artifactrepo', 'ajaxGetArtifactRepos', 'serverID=' + server); + if(!server) return; toggleLoading('#repoName', true); $.get(url, function(response) { repoData = JSON.parse(response); + if(repoData.result !== undefined && repoData.result === 'fail') + { + zui.Modal.alert(repoData.message); + toggleLoading('#repoName', false); + return; + } var repoItems = []; for(i in repoData) { diff --git a/module/artifactrepo/lang/de.php b/module/artifactrepo/lang/de.php index c8c94518f1..1c77b37e39 100644 --- a/module/artifactrepo/lang/de.php +++ b/module/artifactrepo/lang/de.php @@ -15,3 +15,4 @@ $lang->artifactrepo->url = 'Repo Address'; $lang->artifactrepo->confirmDelete = 'Are you sure you want to delete this aritfact repo?'; $lang->artifactrepo->deleteError = 'The artifact repo is already associated with a build. Please cancel the association and try again'; +$lang->artifactrepo->loseConnect = 'Artifact repo server not responding'; diff --git a/module/artifactrepo/lang/en.php b/module/artifactrepo/lang/en.php index 79a94ee882..6aadf8c98d 100644 --- a/module/artifactrepo/lang/en.php +++ b/module/artifactrepo/lang/en.php @@ -15,3 +15,4 @@ $lang->artifactrepo->url = 'Repo Address'; $lang->artifactrepo->confirmDelete = 'Are you sure you want to delete this artifact repo?'; $lang->artifactrepo->deleteError = 'The artifact repo is already associated with a build. Please cancel the association and try again'; +$lang->artifactrepo->loseConnect = 'Artifact repo server not responding'; diff --git a/module/artifactrepo/lang/fr.php b/module/artifactrepo/lang/fr.php index c8c94518f1..1c77b37e39 100644 --- a/module/artifactrepo/lang/fr.php +++ b/module/artifactrepo/lang/fr.php @@ -15,3 +15,4 @@ $lang->artifactrepo->url = 'Repo Address'; $lang->artifactrepo->confirmDelete = 'Are you sure you want to delete this aritfact repo?'; $lang->artifactrepo->deleteError = 'The artifact repo is already associated with a build. Please cancel the association and try again'; +$lang->artifactrepo->loseConnect = 'Artifact repo server not responding'; diff --git a/module/artifactrepo/lang/zh-cn.php b/module/artifactrepo/lang/zh-cn.php index febb6955ce..24ec126a1a 100644 --- a/module/artifactrepo/lang/zh-cn.php +++ b/module/artifactrepo/lang/zh-cn.php @@ -15,3 +15,4 @@ $lang->artifactrepo->url = '库地址'; $lang->artifactrepo->confirmDelete = '您确认要删除该制品库吗?'; $lang->artifactrepo->deleteError = '当前制品库中制品已关联版本,请取消关联后重试。'; +$lang->artifactrepo->loseConnect = '制品库服务器无法连接'; diff --git a/module/artifactrepo/model.php b/module/artifactrepo/model.php index 844c0d2d01..7b52fa0289 100644 --- a/module/artifactrepo/model.php +++ b/module/artifactrepo/model.php @@ -74,9 +74,9 @@ class artifactrepoModel extends model $url = $server->url . '/service/rest/v1/repositorySettings'; $auth = "{$server->account}:{$server->password}"; - $response = common::http($url, '', array(CURLOPT_USERPWD => $auth)); - $data = json_decode($response); - return is_array($data) ? $data : array(); + $response = common::http($url, '', array(CURLOPT_USERPWD => $auth), array(), 'data', 'POST', 10, true); + $data = array('result' => $response[1] == 200, 'data' => json_decode($response['body'])); + return $data; } return array();