Add checks for a new release available

This commit is contained in:
Nick Denry 2020-05-17 21:12:36 +03:00
parent ae24404edd
commit bb21c38ac1
11 changed files with 114 additions and 12 deletions

View File

@ -1,6 +1,9 @@
let angApp = require(__dirname+'/../init')
angApp.controller('AboutController', function($scope, AppStateService) {
angApp.controller('AboutController', function($scope, AppStateService, AppInfo) {
$scope.appInfo = AppInfo
$scope.closeAbout = () => {
AppStateService.set(AppStateService.previousState)
}

View File

@ -1,5 +1,45 @@
let angApp = require(__dirname+'/../init')
angApp.controller('DefaultController', function($scope) {
// Do nothing atm.
angApp.controller('DefaultController', function($scope, $timeout, $http, AppInfo) {
$scope.appInfo = AppInfo
let getUpdateInfo = () => {
$http({
url: $scope.appInfo.APP_RELEASES_CHECK_URL,
method: 'GET'
}).then((response) => {
let releaseVersion = response.data[0].tag_name
if (releaseVersion == $scope.appInfo.APP_VERSION) {
$scope.checkingForUpdate = 'latest'
}
else {
$scope.checkingForUpdate = 'updateAvailable'
}
}, (error) => {
$scope.checkingForUpdate = 'checkErr'
})
}
let checkForUpdate = (timeout = 5000) => {
$scope.checkingForUpdate = 'inProgress'
$timeout(() => {
getUpdateInfo()
}, timeout)
}
let checkForUpdateDelayed = (timeout = 5000) => {
$timeout(() => {
checkForUpdate()
}, timeout)
}
checkForUpdateDelayed()
$scope.checkRetry = ($event) => {
$event.preventDefault()
checkForUpdate()
}
})

View File

@ -0,0 +1,7 @@
let angApp = require(__dirname+'/../init')
angApp.controller('FooterController', function($scope, AppInfo) {
$scope.appInfo = AppInfo
})

View File

@ -1,4 +1,12 @@
const angular = require('angular')
let angApp = angular.module('app', [])
angApp.constant('AppInfo', {
APP_NAME: 'Chimeverse',
APP_VERSION: 'v0.1.52',
APP_HOME: 'https://github.com/nick-denry/Chimeverse',
APP_RELEASES_CHECK_URL: 'https://api.github.com/repos/nick-denry/Chimeverse/releases',
APP_RELEASES_URL: 'https://github.com/nick-denry/Chimeverse/releases'
});
module.exports = angApp

View File

@ -6,7 +6,7 @@
class="chimeverse-branding__img" />
</div>
<div class="about-card__description">
<h3 class="about__title">About Chimeverse v.0.1.52</h3>
<h3 class="about__title">About {{appInfo.APP_NAME}} {{appInfo.APP_VERSION}}</h3>
<div class="about__description">Jabber/XMPP client based on Converse.js and Electron</div>
<div>&nbsp;</div>
<div class="about__converse-version">

View File

@ -1,9 +1,22 @@
<div class="page-default">
<div class="chimeverse-branding">
<div class="page-default" ng-controller="DefaultController">
<div class="chimeverse-branding noselect">
<img src="./resources/images/logo.png" srcset="./resources/images/logo@2x.png 2x" alt=""
class="chimeverse-branding__img" />
<h3 class="chimeverse-branding__header">Chimeverse</h3>
<div class="chimeverse-branding__version">v0.1.52</div>
<h3 class="chimeverse-branding__header">{{appInfo.APP_NAME}}</h3>
<div class="chimeverse-branding__version">
<span>{{appInfo.APP_VERSION}} </span>
<span class="chimeverse-branding__update">
<span class="update__checking" ng-show="checkingForUpdate == 'inProgress'">checking for update...</span>
<span class="update__error" ng-show="checkingForUpdate == 'checkErr'">
&gt;_&lt; check for update failed <a href="#" ng-click="checkRetry($event)">retry</a>
</span>
<span class="update__latest" ng-show="checkingForUpdate == 'latest'">latest version</span>
<a class="update__available" href="{{appInfo.APP_RELEASES_URL}}" target="_blank"
ng-show="checkingForUpdate == 'updateAvailable'">
Update available
</a>
</span>
</div>
</div>
<div class="conversejs-adoption">
<div id="conversejs"></div>

View File

@ -1,4 +1,4 @@
<div class="page__footer">
<span class="footer__version">Chimeverse v0.1.52.</span>
<a class="github-button" href="https://github.com/nick-denry/Chimeverse" data-icon="octicon-star" aria-label="Star nick-denry/Chimeverse on GitHub">Star</a>
<div class="page__footer" ng-controller="FooterController">
<span class="footer__version">{{appInfo.APP_NAME}} {{appInfo.APP_VERSION}}.</span>
<a class="github-button" href="{{appInfo.APP_HOME}}" data-icon="octicon-star" aria-label="Star nick-denry/Chimeverse on GitHub">Star</a>
</div>

View File

@ -64,7 +64,7 @@ function createWindow () {
menuService.createMenu()
// Open the DevTools.
// mainWindow.webContents.openDevTools()
mainWindow.webContents.openDevTools()
// Before close
let minimizeOnClose = settingsService.get('minimizeOnClose')

View File

@ -13,6 +13,7 @@ require('./app/controllers/settings-controller')
require('./app/controllers/login-controller')
require('./app/controllers/default-controller')
require('./app/controllers/about-controller')
require('./app/controllers/footer-controller')
angApp.controller('AppController', function ($scope, $timeout, ChimeVerseService, SettingsService, AppStateService) {

View File

@ -31,9 +31,19 @@ a {
}
.conversejs-adoption {
background: transparent;
pointer-events: none;
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
#conversejs .converse-chatboxes {
pointer-events: none;
}
#conversejs .converse-chatboxes > * {
pointer-events: auto;
}

View File

@ -21,4 +21,24 @@
font-size: 12px;
color: #999;
margin-top: 10px;
}
.update__latest {
background: #bbb;
color: #fff;
border-radius: 3px;
padding: 3px 5px;
}
.update__available {
background: rgb(5,93,228);
background: linear-gradient(0deg, rgba(5,93,228,1) 0%, rgba(76,145,255,1) 100%);
padding: 3px 5px;
color: #fff;
text-decoration: none;
border-radius: 3px;
}
.update__error {
color: #da0000;
}