mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 18:27:25 +08:00
Add hostname to instance name
This commit is contained in:
parent
bea093e67a
commit
46a186f28b
@ -105,7 +105,7 @@ func CreateInstance(net string, dindImage string) (*Instance, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Instance{Name: strings.Replace(cinfo.Name, "/", "", 1), IP: cinfo.NetworkSettings.Networks[net].IPAddress}, nil
|
return &Instance{Name: strings.Replace(cinfo.Name, "/", "", 1), Hostname: cinfo.Config.Hostname, IP: cinfo.NetworkSettings.Networks[net].IPAddress}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeleteContainer(id string) error {
|
func DeleteContainer(id string) error {
|
||||||
|
@ -12,12 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Instance struct {
|
type Instance struct {
|
||||||
Session *Session `json:"-"`
|
Session *Session `json:"-"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
IP string `json:"ip"`
|
Hostname string `json:"hostname"`
|
||||||
Conn *types.HijackedResponse `json:"-"`
|
IP string `json:"ip"`
|
||||||
ExecId string `json:"-"`
|
Conn *types.HijackedResponse `json:"-"`
|
||||||
Ctx context.Context `json:"-"`
|
ExecId string `json:"-"`
|
||||||
|
Ctx context.Context `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var dindImage string
|
var dindImage string
|
||||||
@ -51,7 +52,7 @@ func NewInstance(session *Session) (*Instance, error) {
|
|||||||
|
|
||||||
go instance.Exec()
|
go instance.Exec()
|
||||||
|
|
||||||
wsServer.BroadcastTo(session.Id, "new instance", instance.Name, instance.IP)
|
wsServer.BroadcastTo(session.Id, "new instance", instance.Name, instance.IP, instance.Hostname)
|
||||||
|
|
||||||
return instance, nil
|
return instance, nil
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,8 @@
|
|||||||
socket.on('viewport', function(rows, cols) {
|
socket.on('viewport', function(rows, cols) {
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('new instance', function(name, ip) {
|
socket.on('new instance', function(name, ip, hostname) {
|
||||||
$scope.upsertInstance({name: name, ip: ip});
|
$scope.upsertInstance({name: name, ip: ip, hostname: hostname});
|
||||||
$scope.$apply(function() {
|
$scope.$apply(function() {
|
||||||
if ($scope.instances.length == 1) {
|
if ($scope.instances.length == 1) {
|
||||||
$scope.showInstance($scope.instances[0]);
|
$scope.showInstance($scope.instances[0]);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
<md-list>
|
<md-list>
|
||||||
<md-list-item class="md-3-line" ng-repeat="instance in instances" ng-click="showInstance(instance)" ng-class="instance.name == selectedInstance.name ? 'selected' : false">
|
<md-list-item class="md-3-line" ng-repeat="instance in instances" ng-click="showInstance(instance)" ng-class="instance.name == selectedInstance.name ? 'selected' : false">
|
||||||
<div class="md-list-item-text">{{instance.name}}</div>
|
<div class="md-list-item-text">{{instance.name}} ({{instance.hostname}})</div>
|
||||||
<md-divider ng-if="!$last"></md-divider>
|
<md-divider ng-if="!$last"></md-divider>
|
||||||
</md-list-item>
|
</md-list-item>
|
||||||
</md-list>
|
</md-list>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user