diff --git a/.gitignore b/.gitignore index a471f98..a77fa96 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,9 @@ riderModule.iml /dataSources.local.xml /.idea cover.jpg -cover.png \ No newline at end of file +cover.png +.vs/slnx.sqlite +.vs/tranga-website/config/applicationhost.config +.vs/tranga-website/FileContentIndex/91a465d3-1190-42e0-95eb-fa3694744e58.vsidx +.vs/tranga-website/v17/.wsuo +.vs/VSWorkspaceState.json diff --git a/Website/apiConnector.js b/Website/apiConnector.js index 580b821..64dca93 100644 --- a/Website/apiConnector.js +++ b/Website/apiConnector.js @@ -1,4 +1,4 @@ -let apiUri = `http://${window.location.host.split(':')[0]}:6531` +let apiUri = `${window.location.protocol}//${window.location.host.split(':')[0]}:6531` if(getCookie("apiUri") != ""){ apiUri = getCookie("apiUri"); @@ -39,10 +39,11 @@ async function GetData(uri){ return json; } -function PostData(uri){ - fetch(uri, { +async function PostData(uri){ + let request = await fetch(uri, { method: 'POST' }); + //console.log(request); } function DeleteData(uri){ @@ -143,6 +144,12 @@ async function GetLibraryConnectors(){ return json; } +async function GetRateLimits() { + var uri = `${apiUri}/Settings/customRequestLimit` + let json = await GetData(uri); + return json; +} + function CreateMonitorJob(connector, internalId, language){ var uri = `${apiUri}/Jobs/MonitorManga?connector=${connector}&internalId=${internalId}&interval=03:00:00&translatedLanguage=${language}`; PostData(uri); @@ -163,46 +170,164 @@ function UpdateDownloadLocation(downloadLocation){ PostData(uri); } -function ChangeStyleSheet(sheet){ - var uri = `${apiUri}/Settings/ChangeStyleSheet?styleSheet=${sheet}`; - PostData(uri); -} - function RefreshLibraryMetadata() { var uri = `${apiUri}/Jobs/UpdateMetadata`; PostData(uri); } +async function DownloadLogs() { + var uri = `${apiUri}/LogFile`; + + //Below taken from https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream + fetch(uri) + .then((response) => response.body) + .then((rb) => { + const reader = rb.getReader(); + + return new ReadableStream({ + start(controller) { + // The following function handles each data chunk + function push() { + // "done" is a Boolean and value a "Uint8Array" + reader.read().then(({ done, value }) => { + // If there is no more data to read + if (done) { + console.log("done", done); + controller.close(); + return; + } + // Get the data and send it to the browser via the controller + controller.enqueue(value); + // Check chunks by logging to the console + console.log(done, value); + push(); + }); + } + + push(); + }, + }); + }) + .then((stream) => + // Respond with our stream + new Response(stream, { headers: { "Content-Type": "text/html" } }).text(), + ) + .then((result) => { + // Do things with result + //console.log(result); + + //Below download taken from https://stackoverflow.com/questions/3665115/how-to-create-a-file-in-memory-for-user-to-download-but-not-through-server + var element = document.createElement('a'); + element.setAttribute('href', 'data:text/plain;charset-utf-8,' + encodeURIComponent(result)); + var newDate = new Date(); + var filename = "Tranga_Logs_" + newDate.today() + "_" + newDate.timeNow() + ".log"; + element.setAttribute('download', filename); + element.click(); + }); +} + +//Following date-time code taken from: https://stackoverflow.com/questions/10211145/getting-current-date-and-time-in-javascript +// For todays date; +Date.prototype.today = function () { + return ((this.getDate() < 10)?"0":"") + this.getDate() +"/"+(((this.getMonth()+1) < 10)?"0":"") + (this.getMonth()+1) +"/"+ this.getFullYear(); +} + +// For the time now +Date.prototype.timeNow = function () { + return ((this.getHours() < 10)?"0":"") + this.getHours() +"_"+ ((this.getMinutes() < 10)?"0":"") + this.getMinutes() +"_"+ ((this.getSeconds() < 10)?"0":"") + this.getSeconds(); +} + +//Komga function UpdateKomga(komgaUrl, komgaAuth){ var uri = `${apiUri}/LibraryConnectors/Update?libraryConnector=Komga&komgaUrl=${komgaUrl}&komgaAuth=${komgaAuth}`; PostData(uri); } +function ResetKomga(){ + var uri = `${apiUri}/LibraryConnectors/Reset?libraryConnector=Komga`; + PostData(uri); +} + +function TestKomga(komgaUrl, komgaAuth){ + var uri = `${apiUri}/LibraryConnectors/Test?libraryConnector=Komga&komgaUrl=${komgaUrl}&komgaAuth=${komgaAuth}`; + PostData(uri); +} + + +//Kavita function UpdateKavita(kavitaUrl, kavitaUsername, kavitaPassword){ var uri = `${apiUri}/LibraryConnectors/Update?libraryConnector=Kavita&kavitaUrl=${kavitaUrl}&kavitaUsername=${kavitaUsername}&kavitaPassword=${kavitaPassword}`; PostData(uri); } +function ResetKavita(){ + var uri = `${apiUri}/LibraryConnectors/Reset?libraryConnector=Kavita`; + PostData(uri); +} + +function TestKavita(kavitaUrl, kavitaUsername, kavitaPassword){ + var uri = `${apiUri}/LibraryConnectors/Test?libraryConnector=Kavita&kavitaUrl=${kavitaUrl}&kavitaUsername=${kavitaUsername}&kavitaPassword=${kavitaPassword}`; + PostData(uri); +} + +//Gotify function UpdateGotify(gotifyUrl, gotifyAppToken){ var uri = `${apiUri}/NotificationConnectors/Update?notificationConnector=Gotify&gotifyUrl=${gotifyUrl}&gotifyAppToken=${gotifyAppToken}`; PostData(uri); } +function ResetGotify(){ + var uri = `${apiUri}/NotificationConnectors/Reset?notificationConnector=Gotify`; + PostData(uri); +} + +function TestGotify(gotifyUrl, gotifyAppToken){ + var uri = `${apiUri}/NotificationConnectors/Test?notificationConnector=Gotify&gotifyUrl=${gotifyUrl}&gotifyAppToken=${gotifyAppToken}`; + PostData(uri); +} + +//LunaSea function UpdateLunaSea(lunaseaWebhook){ var uri = `${apiUri}/NotificationConnectors/Update?notificationConnector=LunaSea&lunaseaWebhook=${lunaseaWebhook}`; PostData(uri); } +function ResetLunaSea(){ + var uri = `${apiUri}/NotificationConnectors/Reset?notificationConnector=LunaSea`; + PostData(uri); +} + +function TestLunaSea(lunaseaWebhook){ + var uri = `${apiUri}/NotificationConnectors/Test?notificationConnector=LunaSea&lunaseaWebhook=${lunaseaWebhook}`; + PostData(uri); +} + +//Ntfy function UpdateNtfy(ntfyEndpoint, ntfyAuth){ var uri = `${apiUri}/NotificationConnectors/Update?notificationConnector=Ntfy&ntfyUrl=${ntfyEndpoint}&ntfyAuth=${ntfyAuth}`; PostData(uri); } +function ResetNtfy(){ + var uri = `${apiUri}/NotificationConnectors/Reset?notificationConnector=Ntfy`; + PostData(uri); +} + +function TestNtfy(ntfyEndpoint, ntfyAuth){ + var uri = `${apiUri}/NotificationConnectors/Test?notificationConnector=Ntfy&ntfyUrl=${ntfyEndpoint}&ntfyAuth=${ntfyAuth}`; + PostData(uri); +} + function UpdateUserAgent(userAgent){ var uri = `${apiUri}/Settings/userAgent?userAgent=${userAgent}`; PostData(uri); } +function UpdateRateLimit(byteValue, rateLimit) { + var uri = `${apiUri}/Settings/customRequestLimit?requestType=${byteValue}&requestsPerMinute=${rateLimit}`; + PostData(uri); +} + function RemoveJob(jobId){ var uri = `${apiUri}/Jobs?jobId=${jobId}`; DeleteData(uri); @@ -216,5 +341,6 @@ function CancelJob(jobId){ async function GetLogmessages(count){ var uri = `${apiUri}/LogMessages?count=${count}`; let json = await GetData(uri); + console.log(json); return json; } \ No newline at end of file diff --git a/Website/connector-icons/bato.ico b/Website/connector-icons/bato.ico new file mode 100644 index 0000000..42c201a Binary files /dev/null and b/Website/connector-icons/bato.ico differ diff --git a/Website/connector-icons/gotify-logo.png b/Website/connector-icons/gotify-logo.png new file mode 100644 index 0000000..5d29004 Binary files /dev/null and b/Website/connector-icons/gotify-logo.png differ diff --git a/Website/connector-icons/kavita.png b/Website/connector-icons/kavita.png new file mode 100644 index 0000000..00a4ba7 Binary files /dev/null and b/Website/connector-icons/kavita.png differ diff --git a/Website/connector-icons/komga.svg b/Website/connector-icons/komga.svg new file mode 100644 index 0000000..af9f28d --- /dev/null +++ b/Website/connector-icons/komga.svg @@ -0,0 +1,113 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Website/connector-icons/lunasea.png b/Website/connector-icons/lunasea.png new file mode 100644 index 0000000..868e849 Binary files /dev/null and b/Website/connector-icons/lunasea.png differ diff --git a/Website/connector-icons/mangadex-logo.svg b/Website/connector-icons/mangadex-logo.svg new file mode 100644 index 0000000..696dd8b --- /dev/null +++ b/Website/connector-icons/mangadex-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Website/connector-icons/mangakatana.png b/Website/connector-icons/mangakatana.png new file mode 100644 index 0000000..2d3e044 Binary files /dev/null and b/Website/connector-icons/mangakatana.png differ diff --git a/Website/connector-icons/mangalife.png b/Website/connector-icons/mangalife.png new file mode 100644 index 0000000..af14c64 Binary files /dev/null and b/Website/connector-icons/mangalife.png differ diff --git a/Website/connector-icons/manganato.png b/Website/connector-icons/manganato.png new file mode 100644 index 0000000..0df9c28 Binary files /dev/null and b/Website/connector-icons/manganato.png differ diff --git a/Website/connector-icons/mangasee.png b/Website/connector-icons/mangasee.png new file mode 100644 index 0000000..7965217 Binary files /dev/null and b/Website/connector-icons/mangasee.png differ diff --git a/Website/connector-icons/mangaworld.png b/Website/connector-icons/mangaworld.png new file mode 100644 index 0000000..04b30e5 Binary files /dev/null and b/Website/connector-icons/mangaworld.png differ diff --git a/Website/connector-icons/ntfy.svg b/Website/connector-icons/ntfy.svg new file mode 100644 index 0000000..8530901 --- /dev/null +++ b/Website/connector-icons/ntfy.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Website/index.html b/Website/index.html index e757319..1bb8c4c 100644 --- a/Website/index.html +++ b/Website/index.html @@ -3,22 +3,50 @@ Tranga - + + + website image is Blahaj Tranga - - - + filterFunnel settingscog + + + + Filter by: + × + + + + + + + Clear Filter + + +
@@ -53,65 +81,150 @@ - + - Settings + + Settings + × + -
-

Download Location:

- + + -
-

API-URI

- + + -
- Komga -
Configured: ✅❌
- - - -
-
- Kavita -
Configured: ✅❌
- - - -
-
- Gotify -
Configured: ✅❌
- - -
-
- LunaSea -
Configured: ✅❌
- -
-
- Ntfy -
Configured: ✅❌
- - -
-
- UserAgent
- -
-
- -
-
-
- -
-
- + + + + + + +
+ Apply Settings +
+
+ @@ -136,18 +249,39 @@ - + - + -
-
-
-
-
-
+ + Jobs + × + + + + + + + + + + + + +
-