Skip to content

Commit

Permalink
Merge branch 'revenz:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pippo73 authored Jan 9, 2025
2 parents 7059cdf + cc85697 commit 966d774
Show file tree
Hide file tree
Showing 15 changed files with 283 additions and 32 deletions.
18 changes: 18 additions & 0 deletions Apps/Smart/Coder/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Name": "Coder",
"Icon": "coder.png",
"TestFunction":true,
"Interval": 10,
"Info":{
"Authors": ["mindofbeholder"],
"AppUrl":"https://coder.com"
},
"Properties": [
{
"Name": "Token",
"Id": "token",
"Type": "string",
"Help" : "Found at Account -> Tokens"
}
]
}
72 changes: 72 additions & 0 deletions Apps/Smart/Coder/code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
class Coder {

cleanUrl(args)
{
if(args.url.endsWith('/'))
return args.url.substring(0, args.url.length - 1);
else
return args.url
}

fetchWorkspaces(args) {
let cleanedUrl = this.cleanUrl(args)

let allWorkspacesData = args.fetch({
url: cleanedUrl + "/api/v2/workspaces",
method: "GET",
headers: {
'Coder-Session-Token': args.properties['token'],
'Accept': 'application/json'
}
}).data;

let totalWorkspaces = allWorkspacesData.count;

let runningWorkspacesData = args.fetch({
url: cleanedUrl + "/api/v2/workspaces?q=status:running",
method: "GET",
headers: {
'Coder-Session-Token': args.properties['token'],
'Accept': 'application/json'
}
}).data;

let runningWorkspaces = runningWorkspacesData.count;

return { "total": totalWorkspaces, "active": runningWorkspaces }
}

status(args) {

let results = this.fetchWorkspaces(args)

return args.liveStats([
['Active Workspaces', results.active],
['Total Workspaces', results.total]
]);
}

test(args) {

if (!args.properties || !args.properties['token']) {
args.log("No API Key");
return false
}

let results = args.fetch({
url: this.cleanUrl(args) + "/api/v2/workspaces",
method: "GET",
headers: {
'Coder-Session-Token': args.properties['token'],
'Accept': 'application/json'
}
});

if (results.status == 200) {
return true
} else {
args.log(JSON.stringify(results));
return false
}
}
}
Binary file added Apps/Smart/Coder/coder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion Apps/Smart/FileFlows/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@
"Authors": ["John Andrews"],
"AppUrl":"https://fileflows.com/",
"Description": "Shows information from FileFlows including files that are currently processing, files that have been processed.\n\nCan show a carousel for currently processing files. Bar charts for processed files, or basic information if the size of app is set to medium."
}
},
"Properties": [
{
"Name": "API Token",
"Id": "apiToken",
"Type": "string"
}
]
}
41 changes: 29 additions & 12 deletions Apps/Smart/FileFlows/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,27 @@
pfImages = {};

fetch(args, url) {
let prefix = args.url;
if(prefix.endsWith('/') === false)
prefix += '/';
url = prefix + url;
args.log('Fetching URL: ' + url);
return args.fetch(url).data;
if(!args.properties["apiToken"])
return args.fetch(url).data;

return args.fetch({
url: url,
method: 'GET',
headers: {
'x-token': args.properties['apiToken']
}
}).data;
}

status(args)
{
let data = this.fetch(args, 'api/status');
let shrinkage = this.fetch(args, 'api/library-file/shrinkage-groups');
let data = this.fetch(args, 'remote/info/status');
let shrinkage = this.fetch(args, 'remote/info/shrinkage-groups');
let updateAvailable = this.updateAvailable(args);

args.setStatusIndicator(updateAvailable ? 'update' : '');
Expand All @@ -27,7 +40,7 @@
}

updateAvailable(args){
let data = this.fetch(args, 'api/status/update-available');
let data = this.fetch(args, 'remote/info/update-available');
if(data.exception)
{
args.log('Exception fetching update-available: ' + (data.message || 'Unknown reason'));
Expand All @@ -46,7 +59,7 @@

statusXLarge(args, data, shrinkage){
if(!data.processingFiles?.length){
if(shrinkage && Object.keys(shrinkage).length)
if(shrinkage?.length)
return this.statusShrinkage(args, shrinkage)
return this.statusMedium(args, data);
}
Expand Down Expand Up @@ -119,26 +132,30 @@
statusShrinkage(args, shrinkage){
let items = [];

Object.keys(shrinkage).forEach(group =>
for(let item of shrinkage)
{
let item = shrinkage[group];
let increase = item.FinalSize > item.OriginalSize;
let percent;
let tooltip;
if(increase){
if(item.FinalSize === 0)
{
percent = 100;
tooltip = 'No Change';
}
else if(increase){
percent = 100 + ((item.FinalSize - item.OriginalSize) / item.OriginalSize * 100);
tooltip = args.Utils.formatBytes(item.FinalSize - item.OriginalSize) + ' Increase';
}else{
percent = (item.FinalSize / item.OriginalSize) * 100;
tooltip = args.Utils.formatBytes(item.OriginalSize - item.FinalSize) + ' Saved';
}
items.push({
label: group === '###TOTAL###' ? 'Total' : group,
label: item.Library === '###TOTAL###' ? 'Total' : item.Library,
percent: percent,
tooltip: tooltip,
icon: '/common/hdd.svg'
});
});
}

return args.barInfo(items);
}
Expand All @@ -162,8 +179,8 @@
`;
}

test(args){
let data = args.fetch(args.url + '/api/status').data;
test(args){
let data = this.fetch(args, 'remote/info/status');
args.log('data: ' + (data === null ? 'null' : JSON.stringify(data)));
return isNaN(data.processed) === false;
}
Expand Down
2 changes: 1 addition & 1 deletion Apps/Smart/NextCloud/code.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class NextCloud
{
doFetch (args) {
let url = `ocs/v1.php/cloud/users/${args.properties['username']}?format=json`;
let url = `ocs/v2.php/cloud/users/${args.properties['username']}?format=json`;
return args.fetch({
url: url, timeout: 10, headers: {
'Authorization': 'Basic ' + args.Utils.btoa(args.properties['username'] + ':' + args.properties['password']),
Expand Down
6 changes: 3 additions & 3 deletions Components/Inputs/InputColor/InputColor.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ private async Task MoveSlider(MouseEventArgs e)
baseB = AdjustColorPercent(c1b, c2b, newP);
BaseColor = "#" + baseR.ToString("X2") + baseG.ToString("X2") + baseB.ToString("X2");

CalcuateColor();
CalculateColor();
}

void CalcuateColor()
void CalculateColor()
{
var wPercent = PointerX / 211.2d;
var r = AdjustColorPercent(255, baseR, wPercent);
Expand All @@ -110,6 +110,6 @@ void MainPickerClicked(MouseEventArgs e)
{
PointerX = e.OffsetX;
PointerY = e.OffsetY;
CalcuateColor();
CalculateColor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,10 @@ async Task TestApp()
else if (str?.ToLowerInvariant() == "false")
{
if (string.IsNullOrEmpty(logStr))
ToastService.ShowError(message: logStr, heading: lblTestFailed);
else
ToastService.ShowError(lblTestFailed);
else
ToastService.ShowError(message: logStr, heading: lblTestFailed);
}
else if (str?.ToLowerInvariant() == "false")
ToastService.ShowInfo(message: logStr, heading: str?.EmptyAsNull() ?? "Test Unknown");
else
ToastService.ShowInfo(str?.EmptyAsNull() ?? "Test Unknown");
}
Expand Down
3 changes: 3 additions & 0 deletions Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ public async Task<IActionResult> OAuthLogin()
string username = User?.Identity?.Name ?? string.Empty;
if (string.IsNullOrEmpty(username))
username = User.Claims.FirstOrDefault(x => x.Type == "name")?.Value ?? string.Empty;

if (string.IsNullOrEmpty(username))
username = User.Claims.FirstOrDefault(x => x.Type == "preferred_username")?.Value ?? string.Empty;

if (string.IsNullOrEmpty(username))
return ReturnUnauthorized("No username returned from OAuth");
Expand Down
57 changes: 57 additions & 0 deletions Models/ReverseProxySettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
namespace Fenrus.Models;

/// <summary>
/// Configuration object that maps to the ReverseProxySettings section in appsettings.json
/// </summary>
public class ReverseProxySettings
{
/// <summary>
/// If the request headers should be printed to the console when being redirected to the
/// authentication provider.
/// </summary>
public bool DebugPrintRequestHeaders { get; set; }

/// <summary>
/// If the forwarded headers should be used.
/// </summary>
public bool UseForwardedHeaders { get; set; }

/// <summary>
/// The IP-addresses of known proxies.
/// </summary>
public string[] KnownProxies { get; set; } = Array.Empty<string>();

/// <summary>
/// The IP-address specification of a known network in IPv4 format
/// For example: 192.168.2.0/24, which will allow all IP-addresses from
/// 192.168.2.1 - 192.168.2.254
/// </summary>
public KnownNetwork KnownIpv4Network { get; set; } = new();

/// <summary>
/// The IP-address specification of a known network in IPv6 format
/// For example: 2001:db8::/32, which will allow all IP-addresses from
/// 2001:db8:0:0:0:0:0:0 - 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff
/// </summary>
public KnownNetwork KnownIpv6Network { get; set; } = new();

}

public class KnownNetwork
{
/// <summary>
/// If the known network should be added to the list of known networks.
/// </summary>
public bool Enabled { get; set; }

/// <summary>
/// The IP-address of the known network.
/// For example: 192.168.2.0 or 2001:db8::
/// </summary>
public string IpAddress { get; set; }

/// <summary>
/// The prefix length of the known network. For example: 24
/// </summary>
public int PrefixLength { get; set; }
}
Loading

0 comments on commit 966d774

Please sign in to comment.