Skip to content

Commit

Permalink
* Insert port into instance access url.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjianhua committed Dec 15, 2022
1 parent 7724b45 commit 21c91ec
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
20 changes: 18 additions & 2 deletions frontend/module/instance/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,22 @@ public function canDo($action, $instance)
}
}

/**
* Get URL for visiting instance service.
*
* @param object $instance
* @access public
* @return string
*/
public function url($instance)
{
$url = "//" . $instance->domain;
$port = getenv('APP_HTTPS_PORT');
if($port and $port != '443') $url .= ":$port/";

return $url;
}

/**
* Create third domain.
*
Expand Down Expand Up @@ -1562,7 +1578,7 @@ public function printIconActions($instance)
if($instance->domain)
{
$disableVisit = !$this->canDo('visit', $instance);
$actionHtml .= html::a('//' . $instance->domain, '<i class="icon icon-menu-my"></i>', '_blank', "title='{$this->lang->instance->visit}' class='btn btn-lg btn-action btn-link'" . ($disableVisit ? ' disabled style="pointer-events: none;"' : ''));
$actionHtml .= html::a($this->url($instance), '<i class="icon icon-menu-my"></i>', '_blank', "title='{$this->lang->instance->visit}' class='btn btn-lg btn-action btn-link'" . ($disableVisit ? ' disabled style="pointer-events: none;"' : ''));
}

echo $actionHtml;
Expand Down Expand Up @@ -1591,7 +1607,7 @@ public function printTextActions($instance)
if($instance->domain)
{
$disableVisit = !$this->canDo('visit', $instance);
$actionHtml .= html::a('//' . $instance->domain, $this->lang->instance->visit, '_blank', "title='{$this->lang->instance->visit}' class='btn btn-primary label-lg'" . ($disableVisit ? ' disabled style="pointer-events: none;"' : ''));
$actionHtml .= html::a($this->url($instance), $this->lang->instance->visit, '_blank', "title='{$this->lang->instance->visit}' class='btn btn-primary label-lg'" . ($disableVisit ? ' disabled style="pointer-events: none;"' : ''));
}

echo $actionHtml;
Expand Down
2 changes: 1 addition & 1 deletion frontend/module/space/view/browsebycard.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
<div class="instance-actions">
<?php $canVisit = $this->instance->canDo('visit', $instance);?>
<?php echo html::a('//' . $instance->domain, $lang->instance->visit, '_blank', "class='btn btn-primary' title='{$lang->instance->visit}'". ($canVisit ? '' : ' disabled style="pointer-events: none;"'));?>
<?php echo html::a($this->instance->url($instance), $lang->instance->visit, '_blank', "class='btn btn-primary' title='{$lang->instance->visit}'". ($canVisit ? '' : ' disabled style="pointer-events: none;"'));?>
<?php if(!empty($instance->latestVersion)):?>
<?php echo html::a(helper::createLink('instance', 'upgrade', "id=$instance->id", '', true), "<i class='icon-sync'></i>" . $lang->space->upgrade, '', "class='btn btn-link iframe' title='{$lang->space->upgrade}' data-width='500' data-app='space'");?>
<?php endif;?>
Expand Down
9 changes: 7 additions & 2 deletions frontend/module/system/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public function ajaxLdapInfo()
$password = openssl_decrypt($ldapSetting->auth->password, 'DES-ECB', $secretKey);
if(!$password) $password = openssl_decrypt($ldapSetting->auth->password, 'DES-ECB', $ldapInstance->createdAt); // Secret key was createdAt field value less v2.2.

$this->send(array('result' => 'success', 'message' => '', 'data' => array('domain' => $ldapInstance->domain, 'account' => $ldapSetting->auth->username, 'pass' => $password)));
$this->send(array('result' => 'success', 'message' => '', 'data' => array('domain' => $this->instance->url($ldapInstance), 'account' => $ldapSetting->auth->username, 'pass' => $password)));
}

/**
Expand All @@ -504,8 +504,13 @@ public function ajaxOssInfo()
$minioInstance->spaceData->k8space = 'cne-system';

$ossAccount = $this->loadModel('cne')->getDefaultAccount($minioInstance, '', 'minio');

$ossDomain = $this->cne->getDomain($minioInstance, '', 'minio');
if($ossAccount and $ossAccount) return $this->send(array('result' => 'success', 'message' => '', 'data' => array('account' => $ossAccount, 'domain' => $ossDomain)));
$ossDomain->domain = $ossDomain->access_host;

$url = $this->loadModel('instance')->url($ossDomain);

if($ossAccount and $ossAccount) return $this->send(array('result' => 'success', 'message' => '', 'data' => array('account' => $ossAccount, 'url' => $url)));

$this->send(array('result' => 'fail', 'message' => $this->lang->system->errors->failGetOssAccount));
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/module/system/js/ossview.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $(function()
{
$('#ossAdmin').text(res.data.account.username);
$('#ossPassword').val(res.data.account.password);
$('#ossVisitUrl').attr('href', '//' + res.data.domain.access_host);
$('#ossVisitUrl').attr('href', res.data.url);
$('#ossAccountModal').modal('show');
}
});
Expand Down

0 comments on commit 21c91ec

Please sign in to comment.