Skip to content

Commit

Permalink
[feature] Add check version Aurora Toolbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy Zarubin committed Nov 1, 2024
1 parent dbe296e commit d0a9b86
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Subscribe and like!

[![Version](https://img.shields.io/badge/deb_package-0.0.7-blue)](https://github.com/keygenqt/aurora-toolbox/releases)
[![Version](https://img.shields.io/badge/deb_package-0.0.8-blue)](https://github.com/keygenqt/aurora-toolbox/releases)

![Preview](https://raw.githubusercontent.com/keygenqt/aurora-toolbox/refs/heads/main/files/images/preview_telegram.png)

Expand Down
2 changes: 1 addition & 1 deletion data/ui/dialogs/AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<property name="presentation-mode">floating</property>
<property name="application-icon">com.keygenqt.aurora-toolbox</property>
<property name="application-name" translatable="yes">Aurora Toolbox</property>
<property name="version">0.0.7</property>
<property name="version">0.0.8</property>
<property name="copyright">© 2024 KeyGenQt</property>
<property name="issue_url">https://github.com/keygenqt/aurora-toolbox/issues</property>
<property name="developer-name" translatable="yes">Vitaliy Zarubin</property>
Expand Down
2 changes: 1 addition & 1 deletion data/ui/pages/welcome/elements/WelcomeLoading.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<property name="spacing">24</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Search Aurora CLI...</property>
<property name="label" translatable="yes">Connection...</property>
<property name="wrap">true</property>
<property name="justify">center</property>
<style> <class name="CssInfoText"/></style>
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hide:
#### Install

```shell
sudo dpkg -i aurora-toolbox_0.0.7-1_amd64.deb
sudo dpkg -i aurora-toolbox_0.0.8-1_amd64.deb
```

#### Update/Install dependency
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Define our project
project(
'aurora-toolbox',
version: '0.0.7',
version: '0.0.8',
license: ['Apache 2.0'],
meson_version: '>= 0.59.0',
default_options: ['cpp_std=c++17', 'cpp_rtti=false', 'cpp_eh=none',
Expand Down
2 changes: 1 addition & 1 deletion po/com.keygenqt.aurora-toolbox.pot
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ msgid "Welcome to application Aurora Toolbox!"
msgstr ""

#: data/ui/pages/welcome/elements/WelcomeLoading.ui:10
msgid "Search Aurora CLI..."
msgid "Connection..."
msgstr ""

#: data/ui/pages/welcome/elements/WelcomeUpdate.ui:9
Expand Down
4 changes: 2 additions & 2 deletions po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ msgid "Welcome to application Aurora Toolbox!"
msgstr "Добро пожаловать в приложение Aurora Toolbox!"

#: data/ui/pages/welcome/elements/WelcomeLoading.ui:10
msgid "Search Aurora CLI..."
msgstr "Поиск Aurora CLI..."
msgid "Connection..."
msgstr "Подключение..."

#: data/ui/pages/welcome/elements/WelcomeUpdate.ui:9
msgid "Update available!"
Expand Down
2 changes: 1 addition & 1 deletion scripts/deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ dpkg -x $FOLDER/$DEB_FOLDER.deb $FOLDER/$DEB_FOLDER

# Install / Remove
sudo dpkg -r com.keygenqt.aurora-toolbox
sudo dpkg -i release/aurora-toolbox_0.0.7-1_amd64.deb
sudo dpkg -i release/aurora-toolbox_0.0.8-1_amd64.deb
2 changes: 2 additions & 0 deletions src/base/constants/AppConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import GLib from 'gi://GLib';

export const AppConstants = Object.freeze({
App: {
version: '0.0.8',
doc: 'https://keygenqt.github.io/aurora-toolbox/',
docInstall: 'https://keygenqt.github.io/aurora-toolbox/install/',
latestRelease: 'https://api.github.com/repos/keygenqt/aurora-toolbox/releases/latest',
},
AppCLI: {
doc: 'https://keygenqt.github.io/aurora-cli/',
Expand Down
40 changes: 40 additions & 0 deletions src/base/utils/Helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk';
import GLib from 'gi://GLib';
import Soup from 'gi://Soup';

import { Log } from './Log.js';
import { AuroraAPI } from '../connectors/AuroraAPI.js';
Expand Down Expand Up @@ -194,5 +195,44 @@ export const Helper = {
await new Promise(r => setTimeout(r, time));
dialog.close();
}
},
/**
* Http query
*/
httpRequest(url) {
return new Promise((resolve, reject) => {

if (Soup.MAJOR_VERSION === 3) {
let session = new Soup.Session();
session.set_timeout(5);
session.set_user_agent('aurora-toolbox');
let message = Soup.Message.new('GET', url);
session.send_and_read_async(
message,
GLib.PRIORITY_DEFAULT,
null,
function (session, result) {
try {
if (message.get_status() === Soup.Status.OK) {
let bytes = session.send_and_read_finish(result);
let decoder = new TextDecoder('utf-8');
let response = decoder.decode(bytes.get_data());
resolve({
code: result.status_code,
body: response,
});
} else {
resolve({
code: message.get_status() === 0 ? 500 : message.get_status(),
})
}
} catch (e) {
resolve({ code: 500 })
}
});
} else {
resolve({ code: 500 })
}
});
}
}
47 changes: 34 additions & 13 deletions src/feature/pages/welcome/WelcomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,53 @@ export const WelcomePage = GObject.registerClass({
#loadingConnect() {
this.#statePage(WelcomePageStates.LOADING);
this.utils.helper.getPromisePage(async () => {
return this.utils.helper.getLastObject(
const auroraCLI = this.utils.helper.getLastObject(
await this.connectors.exec.communicateAsync(this.connectors.aurora.appVersions())
);
const auroraToolbox = (await this.utils.helper.httpRequest(
this.utils.constants.App.latestRelease
))?.body?.parseMultipleJson();
return {
code: 200,
cliLatest: String(auroraCLI?.value?.LATEST) !== 'undefined' ? auroraCLI?.value?.LATEST : undefined,
cliInstalled: String(auroraCLI?.value?.INSTALLED) !== 'undefined' ? auroraCLI?.value?.INSTALLED : undefined,
toolboxLatest: auroraToolbox?.tag_name ?? undefined,
toolboxInstalled: this.utils.constants.App.version
}
}).then((response) => {
try {
if (response && response.code === 200) {
// Failed to retrieve data
if (response.value.LATEST === 'undefined') {
response.value.LATEST = response.value.INSTALLED;
if (response.cliLatest === undefined) {
response.cliLatest = response.cliInstalled;
}
if (response.toolboxLatest === undefined) {
response.toolboxLatest = response.toolboxInstalled;
}
// Check new version Aurora CLI
const hasNewVersion = response.value.INSTALLED !== response.value.LATEST;
// Check new version
const hasNewVersionCLI = response.cliInstalled !== response.cliLatest;
const hasNewVersionToolbox = response.toolboxInstalled !== response.toolboxLatest;
// If has new version
if (hasNewVersion) {
this.#setStateUpdate(response.value.LATEST, false /*@todo Now only aurora-cli check*/ );
if (hasNewVersionToolbox) {
this.#setStateUpdate(response.toolboxLatest, true);
this.#statePage(WelcomePageStates.UPDATE);
return
}
// If first app open
if (settings.get_boolean('first-open')) {
this._IdConnect.version = `${response.value.INSTALLED}`;
this.#statePage(WelcomePageStates.CONNECT);
else if (hasNewVersionCLI) {
this.#setStateUpdate(response.cliLatest, false);
this.#statePage(WelcomePageStates.UPDATE);
return
}
// Open tools
this.#window.navigation().push(this.utils.constants.Pages.ToolsPage);
else {
// If first app open
if (settings.get_boolean('first-open')) {
this._IdConnect.version = `${response.cliInstalled}`;
this.#statePage(WelcomePageStates.CONNECT);
return
}
// Open tools
this.#window.navigation().push(this.utils.constants.Pages.ToolsPage);
}
} else {
this.#statePage(WelcomePageStates.NOT_FOUND);
}
Expand Down

0 comments on commit d0a9b86

Please sign in to comment.