Skip to content

Commit

Permalink
Fix viewport width. Derive outdated versions from max agent version.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Jan 5, 2021
1 parent 9858432 commit 26fe4c6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 50 deletions.
28 changes: 1 addition & 27 deletions Server/API/AgentUpdateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<ActionResult> DownloadPackage(string platform, string download

if (await CheckForDeviceBan(remoteIp))
{
return GetImmediateUninstaller(platform);
return BadRequest();
}

var startWait = DateTimeOffset.Now;
Expand Down Expand Up @@ -125,32 +125,6 @@ public async Task<ActionResult> DownloadPackage(string platform, string download
}
}

private ActionResult GetImmediateUninstaller(string platform)
{
switch (platform.ToLower())
{
case "win-x64":
case "win-x86":
{
var fileContents = "sc delete Remotely_Service & taskkill /im Remotely_Agent.exe /f";
return File(Encoding.UTF8.GetBytes(fileContents), "application/octet-stream");
}
case "linux":
{
var fileContents = "systemctl stop remotely-agent; rm -f /etc/systemd/system/remotely-agent.service;";
return File(Encoding.UTF8.GetBytes(fileContents), "application/octet-stream");
}
break;
default:
DataService.WriteEvent($"Unknown platform requested in {nameof(AgentUpdateController)}. " +
$"Platform: {platform}. " +
$"IP: {Request?.HttpContext?.Connection?.RemoteIpAddress}.",
EventType.Warning,
null);
return BadRequest();
}
}

private async Task<bool> CheckForDeviceBan(string deviceIp)
{
if (string.IsNullOrWhiteSpace(deviceIp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Remotely.Server.Services;
using Remotely.Shared.Enums;
using Remotely.Shared.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
Expand Down Expand Up @@ -70,13 +71,12 @@ public async Task<IActionResult> OnGet()
{
return Unauthorized();
}
if (System.IO.File.Exists("Remotely_Server.dll"))
{
var serverVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo("Remotely_Server.dll").FileVersion.ToString();
OutdatedDevices = AgentHub.ServiceConnections.Values
.Where(x => x.AgentVersion != serverVersion)
.Select(x => x.ID);
}

var highestVersion = AgentHub.ServiceConnections.Values.Max(x => Version.TryParse(x.AgentVersion, out var result) ? result : default);
OutdatedDevices = AgentHub.ServiceConnections.Values
.Where(x => x.AgentVersion != highestVersion.ToString())
.Select(x => x.ID);

Environment = HostEnv.EnvironmentName;

Configuration.Bind("ApplicationOptions", AppSettingsInput);
Expand Down
2 changes: 1 addition & 1 deletion Server/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
</footer>



<script src="~/site.js"></script>
@RenderSection("Scripts", required: false)
</body>
</html>
15 changes: 15 additions & 0 deletions Server/wwwroot/site.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function setViewportWidth() {
if (window.screen?.orientation?.type?.includes("portrait")) {
var desiredWidth = Math.max(550, window.screen.width);
document.querySelector('meta[name="viewport"').setAttribute("content", `width=${desiredWidth}, user-scalable=no`);
}
else {
var desiredHeight = Math.max(700, window.screen.height);
document.querySelector('meta[name="viewport"').setAttribute("content", `width=device-width, height=${desiredHeight}, user-scalable=no`);
}
}

window.addEventListener("load", () => {
setViewportWidth();
window.addEventListener("orientationchange", setViewportWidth);
});
15 changes: 0 additions & 15 deletions Server/wwwroot/src/Main/InputEventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ export function ApplyInputEventHandlers() {
window.addEventListener("resize", ev => {
PositionCommandCompletionWindow();
});

setViewportWidth();
window.addEventListener("orientationchange", setViewportWidth);
}

function addGridPaginationHandlers() {
Expand Down Expand Up @@ -262,15 +259,3 @@ function keyDownOnWindow() {
}
});
}

function setViewportWidth() {
if (window.screen?.orientation?.type?.includes("portrait")) {
var desiredWidth = Math.max(550, window.screen.width);
document.querySelector('meta[name="viewport"').setAttribute("content", `width=${desiredWidth}, user-scalable=no`);
}
else {
var desiredHeight = Math.max(700, window.screen.height);
document.querySelector('meta[name="viewport"').setAttribute("content", `width=device-width, height=${desiredHeight}, user-scalable=no`);
}
console.log(window.screen);
}

0 comments on commit 26fe4c6

Please sign in to comment.