You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
iot/projects/IoTDameon/Views/Home/Index.cshtml

66 lines
2.2 KiB

@model string
@using System.Reflection
@{ Layout = null;
var version = Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion; }
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>更新程序|@version</title>
</head>
<body>
<div>
<input type="text" id="command" name="command" value="@Model" placeholder="ssh#" />
<button id="run">run</button>
<button id="update">update</button>
<button id="clear">clear</button>
</div>
<pre id="log" style="background: #666; color: #ddd; line-height: 1.5em;"></pre>
<div style="text-align:center">v @version</div>
<script src="~/lib/jquery/jquery.min.js"></script>
<script src="~/lib/signalr/signalr.min.js"></script>
<script>
var connection = new signalR.HubConnectionBuilder().withUrl('/hub').build();
function log(message) {
$('#log').append(message + '\n');
};
function connect() {
log('check connection state :' + connection.state);
if (connection.state === signalR.HubConnectionState.Disconnected) {
connection.start().then(function () {
log('connect successful');
}).catch(function () {
'connect closed'
log('connect failed');
setTimeout(connect, 5000);
});
}
}
connection.onclose(function () {
log('connect closed');
connect();
});
connection.on("ServerToClient", function (message) {
log(message);
});
connect();
$('#run').click(function () {
$.get('/Home/Command', { command: $('#command').val() }, function (data) {
if (data) {
log(data);
}
});
});
$('#update').click(function () {
$.get('/Home/Update', function (data) {
if (data) {
log(data);
}
});
});
$('#clear').click(function () {
$('#log').html('');
});
</script>
</body>
</html>