Skip to content

Commit 21c91ec

Browse files
author
wangjianhua
committed
* Insert port into instance access url.
1 parent 7724b45 commit 21c91ec

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

frontend/module/instance/model.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,22 @@ public function canDo($action, $instance)
438438
}
439439
}
440440

441+
/**
442+
* Get URL for visiting instance service.
443+
*
444+
* @param object $instance
445+
* @access public
446+
* @return string
447+
*/
448+
public function url($instance)
449+
{
450+
$url = "//" . $instance->domain;
451+
$port = getenv('APP_HTTPS_PORT');
452+
if($port and $port != '443') $url .= ":$port/";
453+
454+
return $url;
455+
}
456+
441457
/**
442458
* Create third domain.
443459
*
@@ -1562,7 +1578,7 @@ public function printIconActions($instance)
15621578
if($instance->domain)
15631579
{
15641580
$disableVisit = !$this->canDo('visit', $instance);
1565-
$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;"' : ''));
1581+
$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;"' : ''));
15661582
}
15671583

15681584
echo $actionHtml;
@@ -1591,7 +1607,7 @@ public function printTextActions($instance)
15911607
if($instance->domain)
15921608
{
15931609
$disableVisit = !$this->canDo('visit', $instance);
1594-
$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;"' : ''));
1610+
$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;"' : ''));
15951611
}
15961612

15971613
echo $actionHtml;

frontend/module/space/view/browsebycard.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</div>
4242
<div class="instance-actions">
4343
<?php $canVisit = $this->instance->canDo('visit', $instance);?>
44-
<?php echo html::a('//' . $instance->domain, $lang->instance->visit, '_blank', "class='btn btn-primary' title='{$lang->instance->visit}'". ($canVisit ? '' : ' disabled style="pointer-events: none;"'));?>
44+
<?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;"'));?>
4545
<?php if(!empty($instance->latestVersion)):?>
4646
<?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'");?>
4747
<?php endif;?>

frontend/module/system/control.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ public function ajaxLdapInfo()
487487
$password = openssl_decrypt($ldapSetting->auth->password, 'DES-ECB', $secretKey);
488488
if(!$password) $password = openssl_decrypt($ldapSetting->auth->password, 'DES-ECB', $ldapInstance->createdAt); // Secret key was createdAt field value less v2.2.
489489

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

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

506506
$ossAccount = $this->loadModel('cne')->getDefaultAccount($minioInstance, '', 'minio');
507+
507508
$ossDomain = $this->cne->getDomain($minioInstance, '', 'minio');
508-
if($ossAccount and $ossAccount) return $this->send(array('result' => 'success', 'message' => '', 'data' => array('account' => $ossAccount, 'domain' => $ossDomain)));
509+
$ossDomain->domain = $ossDomain->access_host;
510+
511+
$url = $this->loadModel('instance')->url($ossDomain);
512+
513+
if($ossAccount and $ossAccount) return $this->send(array('result' => 'success', 'message' => '', 'data' => array('account' => $ossAccount, 'url' => $url)));
509514

510515
$this->send(array('result' => 'fail', 'message' => $this->lang->system->errors->failGetOssAccount));
511516
}

frontend/module/system/js/ossview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $(function()
99
{
1010
$('#ossAdmin').text(res.data.account.username);
1111
$('#ossPassword').val(res.data.account.password);
12-
$('#ossVisitUrl').attr('href', '//' + res.data.domain.access_host);
12+
$('#ossVisitUrl').attr('href', res.data.url);
1313
$('#ossAccountModal').modal('show');
1414
}
1515
});

0 commit comments

Comments
 (0)