Skip to content

Commit

Permalink
同步最新版本
Browse files Browse the repository at this point in the history
  • Loading branch information
yaming116 committed Apr 22, 2024
1 parent 303a718 commit f567c8c
Show file tree
Hide file tree
Showing 8 changed files with 2,346 additions and 371 deletions.
1,970 changes: 1,970 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions routes/containers.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const returnContainersRouter = (io) => {

});

router.get('/console/:id', (req, res, next) => {
router.get('/console/:id/:cc', (req, res, next) => {
res.render('terminal');
});

Expand All @@ -131,14 +131,18 @@ const returnContainersRouter = (io) => {
});

io.on('connection', (socket) => {
socket.on('exec', (id, w, h) => {
socket.on('exec', (id,cc, w, h) => {
let c = 'bash'
if (cc !== 'bash') {
c = 'sh'
}
const container = docker.getContainer(id);
let cmd = {
'AttachStdout': true,
'AttachStderr': true,
'AttachStdin': true,
'Tty': true,
Cmd: ['/bin/bash']
Cmd: [`/bin/${c}`]
};
socket.on('resize', (data) => {
container.resize({h: data.rows, w: data.cols}, () => {
Expand Down
15 changes: 10 additions & 5 deletions views/containers.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%- include('include/header.html') %>
<div class="col-md-12">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> New container
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 创建容器
</button>
<hr>
</div>
Expand All @@ -12,7 +12,7 @@
<tr>
<th>名称</th>
<th>镜像</th>
<th>命令</th>
<th>启动命令</th>
<th>端口</th>
<th>状态</th>
<th>CPU</th>
Expand Down Expand Up @@ -75,8 +75,13 @@
<% } %>
<a class="btn btn-primary btn-xs"
data-loading-text="<i class='fa fa-spinner fa-spin fa-fw' aria-hidden='true'></i> Waiting..."
href="/containers/console/<%= container.Id %>">
<span class="glyphicon glyphicon-console"></span> 控制台
href="/containers/console/<%= container.Id %>/bash">
<span class="glyphicon glyphicon-console"></span> bash 控制台
</a>
<a class="btn btn-primary btn-xs"
data-loading-text="<i class='fa fa-spinner fa-spin fa-fw' aria-hidden='true'></i> Waiting..."
href="/containers/console/<%= container.Id %>/sh">
<span class="glyphicon glyphicon-console"></span> sh 控制台
</a>
<% } %>
<% if(container.State=='exited' ){ %>
Expand Down Expand Up @@ -150,7 +155,7 @@ <h4 class="modal-title" id="myModalLabel">新建容器</h4>

<div class="col-md-6">
<label>
<input type="checkbox" name="isAlways" id="isAlways"> Always restart
<input type="checkbox" name="isAlways" id="isAlways"> 总是重新启动
</label>
</div>
</div>
Expand Down
146 changes: 74 additions & 72 deletions views/images.html
Original file line number Diff line number Diff line change
@@ -1,82 +1,84 @@
<%- include('include/header.html') %>
<div class="container">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modelImage">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 下载镜像
</button>
<hr>
</div>
<div class="container" data-page="images">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>名字</th>
<th>版本</th>
<th>大小</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<% if(images){ %>
<% images.forEach(function(image,index){ %>
<tr>
<td>
<%= imageName(image.RepoTags) %>
</td>
<td>
<%= imageTag(image.RepoTags) %>
</td>
<td>
<%= imageSize(image.Size) %> MB
</td>
<td>
<a class="btn btn-danger btn-xs" data-loading-text="<i class='fa fa-spinner fa-spin fa-fw' aria-hidden='true'></i> Waiting..."
href="/images/remove/<%= image.Id %>">
<span class="glyphicon glyphicon-trash"></span> 删除
</a>
</td>
</tr>
<% }) %>
<div class="container">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modelImage">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> 下载镜像
</button>
<hr>
</div>
<div class="container" data-page="images">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>名字</th>
<th>版本</th>
<th>大小</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<% if(images){ %>
<% images.forEach(function(image,index){ %>
<tr>
<td>
<%= imageName(image.RepoTags) %>
</td>
<td>
<%= imageTag(image.RepoTags) %>
</td>
<td>
<%= imageSize(image.Size) %> MB
</td>
<td>
<a class="btn btn-danger btn-xs"
data-loading-text="<i class='fa fa-spinner fa-spin fa-fw' aria-hidden='true'></i> Waiting..."
href="/images/remove/<%= image.Id %>">
<span class="glyphicon glyphicon-trash"></span> 删除
</a>
</td>
</tr>
<% }) %>

<% } %>
</tbody>
</table>
</div>
<div class="modal fade" id="modelImage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content modal-lg">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel">下载镜像</h4>
</div>
<div class="modal-body">
<div class="form-group">
<div class="form-inline">
<div class="row">
<div class="col-md-6">
<label for="imageName">镜像名称: </label>
<input type="text" class="form-control typeahead" data-provide="typeahead" autocomplete="off"
name="imageName" id="imageName">
</div>
<div class="col-md-6">
<label for="imageVersionName">版本: </label>
<input type="text" class="form-control typeahead" placeholder="latest" autocomplete="off"
name="imageVersionName" id="imageVersionName">
<% } %>
</tbody>
</table>
</div>
<div class="modal fade" id="modelImage" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content modal-lg">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel">下载镜像</h4>
</div>
<div class="modal-body">
<div class="form-group">
<div class="form-inline">
<div class="row">
<div class="col-md-6">
<label for="imageName">镜像名称: </label>
<input type="text" style="width: 70% ;" class="form-control typeahead"
data-provide="typeahead" autocomplete="off" name="imageName" id="imageName">
</div>
<div class="col-md-6">
<label for="imageVersionName">版本: </label>
<input type="text" class="form-control typeahead" placeholder="latest"
autocomplete="off" name="imageVersionName" id="imageVersionName">
</div>
</div>
</div>
</div>
<div class="form-group">
<div id="terminal"></div>
</div>
</div>
<div class="form-group">
<div id="terminal"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button id="pullImage" type="submit"
data-loading-text="<i class='fa fa-spinner fa-spin fa-fw' aria-hidden='true'></i> Waiting..."
class="btn btn-primary">下载</button>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button id="pullImage" type="submit" data-loading-text="<i class='fa fa-spinner fa-spin fa-fw' aria-hidden='true'></i> Waiting..."
class="btn btn-primary">下载</button>
</div>
</div>
</div>
</div>
<%- include('include/footer.html') %>
<%- include('include/footer.html') %>
3 changes: 2 additions & 1 deletion views/logs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<%- include('include/header.html') %>
<div class="container" data-page="logs">
<a href="#" class="btn btn-danger" style="margin-bottom: 10px;" onclick="javascript:history.back(-1);">返回</a>
<div id="terminal"></div>
</div>
<%- include('include/footer.html') %>
<%- include('include/footer.html') %>
90 changes: 31 additions & 59 deletions views/overview.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
<% include include/header.html %>
<div class="container" data-page="overview">

<div class="row">
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">系统</h3>
</div>
<div class="panel-body">
<%= info.OperatingSystem %>
</div>
<%- include('include/header.html') %>
<div class="container" data-page="overview">
<div class="row">
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">操作系统</h3>
</div>
<div class="panel-body">
<%= info.OperatingSystem %>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Docker 版本</h3>
</div>
<div class="panel-body">
<%= info.ServerVersion %>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Docker 版本</h3>
</div>
<div class="panel-body">
<%= info.ServerVersion %>
</div>
</div>
</div>
Expand All @@ -33,40 +31,14 @@ <h3 class="panel-title">CPU</h3>
<%= info.NCPU %>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">计算机名称</h3>
</div>
<div class="panel-body">
<%= info.Name %>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-md-6">
<div class="panel panel-success">
<a href="/containers" class="panel-heading panel-title btn btn-success btn-sm"
style="width: 100%;">容器</a>
<div class="panel-body">
<div class="col-md-4">
<p class="text-success">运行 :
<%= info.ContainersRunning %>
</p>
</div>
<div class="col-md-4">
<p class="text-warning">暂停 :
<%= info.ContainersPaused %>
</p>
</div>
<div class="col-md-4">
<p class="text-danger">停止 :
<%= info.ContainersStopped %>
</p>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">名称</h3>
</div>
<div class="panel-body">
<%= info.Name %>
</div>
</div>
</div>
Expand All @@ -75,11 +47,10 @@ <h3 class="panel-title">计算机名称</h3>
<div class="row">
<div class="col-md-6">
<div class="panel panel-success">
<a href="/containers" class="panel-heading panel-title btn btn-success btn-sm"
style="width: 100%;">容器</a>
<a href="/containers" class="panel-heading panel-title btn btn-success btn-sm" style="width: 100%;">容器</a>
<div class="panel-body">
<div class="col-md-4">
<p class="text-success">运行 :
<p class="text-success">运行中 :
<%= info.ContainersRunning %>
</p>
</div>
Expand All @@ -99,7 +70,8 @@ <h3 class="panel-title">计算机名称</h3>

<div class="col-md-6">
<div class="panel panel-success">
<a href="/images" class="panel-heading panel-title btn btn-success btn-sm" style="width: 100%;">镜像</a>
<a href="/images" class="panel-heading panel-title btn btn-success btn-sm"
style="width: 100%;">镜像</a>
<div class="panel-body">
<p class="text-center">
<%= info.Images %>
Expand All @@ -109,5 +81,5 @@ <h3 class="panel-title">计算机名称</h3>
</div>
</div>

</div>
<%- include('include/footer.html') %>
</div>
<%- include('include/footer.html') %>
4 changes: 3 additions & 1 deletion views/terminal.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@
lineHeight: 16,
},
});
var id = window.location.pathname.split('/')[3];
var params = window.location.pathname.split('/');
var id = params[3];
var cmd = params[4]
var host = window.location.origin;
var socket = io.connect(host);

Expand Down
Loading

0 comments on commit f567c8c

Please sign in to comment.