-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
244 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,29 @@ | ||
import Configuration from '@common/configuration/Configuration'; | ||
|
||
interface ExposedAPI { | ||
config: { | ||
readConfiguration: () => Promise<Configuration>, | ||
writeConfiguration: (contents: Configuration) => Promise<void>, | ||
resetConfiguration: () => Promise<Configuration> | ||
}, | ||
browser: { | ||
openInBrowser: (url: string) => void | ||
}, | ||
dialog: { | ||
showFolderPickerDialog: () => Promise<string[] | undefined> | ||
}, | ||
app: { | ||
restart: () => void | ||
} | ||
config: { | ||
readConfiguration: () => Promise<Configuration>, | ||
writeConfiguration: (contents: Configuration) => Promise<void>, | ||
resetConfiguration: () => Promise<Configuration> | ||
}, | ||
browser: { | ||
openInBrowser: (url: string) => void | ||
}, | ||
dialog: { | ||
showFolderPickerDialog: () => Promise<string[] | undefined> | ||
}, | ||
app: { | ||
restart: () => void, | ||
versions: { | ||
app: Promise<string>, | ||
chrome: Promise<string>, | ||
electron: Promise<string> | ||
} | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
api: ExposedAPI | ||
} | ||
interface Window { | ||
api: ExposedAPI | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,74 @@ | ||
<template> | ||
<v-container fluid> | ||
<v-row /> | ||
<v-row> | ||
<v-col> | ||
<div class="mx-12"> | ||
<h2>Project management</h2> | ||
</div> | ||
</v-col> | ||
<v-divider vertical /> | ||
<v-col> | ||
<div class="d-flex justify-center align-center mt-12"> | ||
<img | ||
src="@renderer/assets/images/icon.png" | ||
style="max-width: 200px;" | ||
> | ||
<div class="d-flex flex-column align-center justify-center ml-4"> | ||
<span class="logo-headline"> | ||
Unipept Desktop {{ appVersion }} | ||
</span> | ||
<span class="logo-subline"> | ||
Chrome v{{ chromeVersion }} | ||
</span> | ||
<span class="logo-subline"> | ||
Electron v{{ electronVersion }} | ||
</span> | ||
<span | ||
v-if="updateAvailable" | ||
class="logo-subline" | ||
@click="updateNotesActive = true" | ||
> | ||
<v-icon | ||
style="position: relative; bottom: 2px;" | ||
color="success" | ||
> | ||
mdi-arrow-up-bold | ||
</v-icon> | ||
<a>An update is available!</a> | ||
</span> | ||
</div> | ||
</div> | ||
<!-- Release notes (display changes compared previous version of the application) --> | ||
<!-- <release-notes-card class="mt-12 mx-12"></release-notes-card> --> | ||
</v-col> | ||
</v-row> | ||
</v-container> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
import GithubCommunicator from "@renderer/logic/communication/github/GithubCommunicator"; | ||
import ComparatorUtils from "@renderer/logic/utils/ComparatorUtils"; | ||
const appVersion = ref(await window.api.app.versions.app); | ||
const chromeVersion = ref(await window.api.app.versions.chrome); | ||
const electronVersion = ref(await window.api.app.versions.electron); | ||
const githubCommunicator = new GithubCommunicator(); | ||
const remoteVersion = ref(await githubCommunicator.getMostRecentVersion()); | ||
const updateAvailable = ref(ComparatorUtils.isVersionLargerThan(remoteVersion.value, appVersion.value)); | ||
</script> | ||
|
||
<style scoped> | ||
.logo-headline { | ||
margin-top: 8px; | ||
font-size: 24px; | ||
color: black; | ||
} | ||
.logo-subline { | ||
font-size: 16px; | ||
color: #777; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/renderer/logic/communication/github/GithubCommunicator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import NetworkUtils from "@renderer/logic/utils/NetworkUtils"; | ||
|
||
export default class GitHubCommunicator { | ||
private static checkedForUpdate = false; | ||
private static remoteAppVersion = ""; | ||
private static releaseNotesCache = ""; | ||
private static releaseNotesVersion = ""; | ||
|
||
public async getRemoteAppVersion(): Promise<string> { | ||
if (!GitHubCommunicator.checkedForUpdate) { | ||
GitHubCommunicator.checkedForUpdate = true; | ||
GitHubCommunicator.remoteAppVersion = await this.getMostRecentVersion(); | ||
} | ||
|
||
return GitHubCommunicator.remoteAppVersion; | ||
} | ||
|
||
/** | ||
* Returns the release content for a specific release version. This content is formatted as MarkDown. | ||
* | ||
* @param appVersion Version of the application for which changes need to be retrieved. Just should be the plain | ||
* version number (no "v"-prefix!), e.g.: 0.6.2 | ||
* @return A list of all changes that were made during this release. | ||
* @throws Error if the given release could not be found, or if no internet connection is established. | ||
*/ | ||
public async getReleaseNotes(appVersion: string): Promise<string> { | ||
if (GitHubCommunicator.releaseNotesCache === "" || GitHubCommunicator.releaseNotesVersion !== appVersion) { | ||
GitHubCommunicator.releaseNotesCache = (await NetworkUtils.getJSON( | ||
`https://api.github.com/repos/unipept/unipept-desktop/releases/tags/v${appVersion}` | ||
)).body; | ||
GitHubCommunicator.releaseNotesVersion = appVersion; | ||
} | ||
|
||
return GitHubCommunicator.releaseNotesCache; | ||
} | ||
|
||
public async getAllReleases(): Promise<string[]> { | ||
const result = await NetworkUtils.getJSON( | ||
"https://api.github.com/repos/unipept/unipept-desktop/releases" | ||
); | ||
|
||
return result.map((obj: any) => obj.tag_name).map((tag: string) => tag.replace("v", "")); | ||
} | ||
|
||
public async getMostRecentVersion(): Promise<string> { | ||
return (await this.getAllReleases())[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { compareVersions } from "compare-versions"; | ||
|
||
export default class ComparatorUtils { | ||
/** | ||
* Compares two version strings. | ||
* | ||
* @param firstVersion | ||
* @param secondVersion | ||
* @return True if firstVersion is larger than secondVersion | ||
*/ | ||
static isVersionLargerThan(firstVersion: string, secondVersion: string): boolean { | ||
return compareVersions(firstVersion, secondVersion) === 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default class NetworkUtils { | ||
public static async getJSON(url: string): Promise<any> { | ||
const response = await fetch(url); | ||
return response.json(); | ||
} | ||
} |
Oops, something went wrong.