Unverified Commit 06028cfb authored by akiraohgaki's avatar akiraohgaki Committed by GitHub
Browse files

Merge pull request #39 from opendesktop/develop

Develop
parents ddeb47ca eca35c27
......@@ -16,35 +16,37 @@ export default class InstalledItemsPage extends Component {
for (const itemKey of Object.keys(this.state.installedItems)) {
const installedItem = this.state.installedItems[itemKey];
if (installedItem.install_type === type) {
const previewPic = `file://${electron.remote.app.getPath('userData')}/previewpic/${btoa(installedItem.url).slice(-255)}`;
const previewPic = `file://${electron.remote.app.getPath('userData')}/previewpic/${this.previewPicFilename(installedItem.url)}`;
for (const file of installedItem.files) {
totalFiles++;
const filePath = `${this.state.installTypes[type].destination}/${file}`;
const openFileParams = JSON.stringify({path: filePath});
const updateItemParams = JSON.stringify({itemKey: itemKey});
const applyThemeParams = JSON.stringify({path: filePath, installType: type});
const updateItemParams = JSON.stringify({itemKey: itemKey});
const openFileParams = JSON.stringify({path: filePath});
const removeFileParams = JSON.stringify({itemKey: itemKey});
let openButton = '';
if (type === 'bin') {
openButton = `<button data-dispatch="open-file" data-params='${openFileParams}'>Run</button>`;
}
else {
openButton = `<button data-dispatch="open-file" data-params='${openFileParams}'>Open</button>`;
let applyThemeButton = '';
if (this.state.isApplicableType) {
applyThemeButton = `<button data-dispatch="apply-theme" data-params='${applyThemeParams}'>Apply</button>`;
}
let listItemImportant = '';
let updateButton = '';
let updateItemButton = '';
if (this.state.updateAvailableItems[itemKey]) {
listItemImportant = 'important';
updateButton = `<button data-dispatch="update-item" data-params='${updateItemParams}'>Update</button>`;
updateItemButton = `<button data-dispatch="update-item" data-params='${updateItemParams}'>Update</button>`;
}
let applyButton = '';
if (this.state.isApplicableType) {
applyButton = `<button data-dispatch="apply-theme" data-params='${applyThemeParams}'>Apply</button>`;
let openFileButton = '';
if (type === 'bin') {
openFileButton = `<button data-dispatch="open-file" data-params='${openFileParams}'>Run</button>`;
}
else {
openFileButton = `<button data-dispatch="open-file" data-params='${openFileParams}'>Open</button>`;
}
const removeFileButton = `<button data-dispatch="remove-file" data-params='${removeFileParams}'>Remove</button>`;
list += `
<tr data-item-key="${itemKey}">
......@@ -54,10 +56,10 @@ export default class InstalledItemsPage extends Component {
${file}
</a>
</td>
<td>${openButton}</td>
<td>${updateButton}</td>
<td>${applyButton}</td>
<td><button data-dispatch="remove-file" data-params='${removeFileParams}'>Remove</button></td>
<td>${applyThemeButton}</td>
<td>${updateItemButton}</td>
<td>${openFileButton}</td>
<td>${removeFileButton}</td>
</tr>
`;
}
......@@ -153,22 +155,27 @@ export default class InstalledItemsPage extends Component {
disableItemControl(itemKey) {
const installedItem = this.element.querySelector(`[data-item-key="${itemKey}"]`);
const openFileButton = installedItem.querySelector('[data-dispatch="open-file"]');
if (openFileButton && openFileButton.hasAttribute('data-dispatch')) {
openFileButton.removeAttribute('data-dispatch');
const openFileLink = installedItem.querySelector('a[data-dispatch="open-file"]');
if (openFileLink && openFileLink.hasAttribute('data-dispatch')) {
openFileLink.removeAttribute('data-dispatch');
}
const applyThemeButton = installedItem.querySelector('button[data-dispatch="apply-theme"]');
if (applyThemeButton && !applyThemeButton.disabled) {
applyThemeButton.disabled = true;
}
const updateItemButton = installedItem.querySelector('[data-dispatch="update-item"]');
const updateItemButton = installedItem.querySelector('button[data-dispatch="update-item"]');
if (updateItemButton && !updateItemButton.disabled) {
updateItemButton.disabled = true;
}
const applyThemeButton = installedItem.querySelector('[data-dispatch="apply-theme"]');
if (applyThemeButton && !applyThemeButton.disabled) {
applyThemeButton.disabled = true;
const openFileButton = installedItem.querySelector('button[data-dispatch="open-file"]');
if (openFileButton && !openFileButton.disabled) {
openFileButton.disabled = true;
}
const removeItemButton = installedItem.querySelector('[data-dispatch="remove-file"]');
const removeItemButton = installedItem.querySelector('button[data-dispatch="remove-file"]');
if (removeItemButton && !removeItemButton.disabled) {
removeItemButton.disabled = true;
}
......@@ -189,4 +196,9 @@ export default class InstalledItemsPage extends Component {
listItem.querySelector('.update-progress-bar').value = progress;
}
previewPicFilename(url) {
// See also window-renderer.js
return btoa(url).slice(-255);
}
}
......@@ -7,7 +7,6 @@ import OcsUrlDialog from './OcsUrlDialog.js';
import BrowsePage from './BrowsePage.js';
import CollectionPage from './CollectionPage.js';
import InstalledItemsPage from './InstalledItemsPage.js';
import UpgradePage from './UpgradePage.js';
export default class Root extends Component {
......@@ -20,7 +19,6 @@ export default class Root extends Component {
<article data-component="BrowsePage"></article>
<article data-component="CollectionPage"></article>
<article data-component="InstalledItemsPage"></article>
<article data-component="UpgradePage"></article>
`;
}
......@@ -41,7 +39,6 @@ export default class Root extends Component {
this.browsePage = new BrowsePage('[data-component="BrowsePage"]');
this.collectionPage = new CollectionPage('[data-component="CollectionPage"]');
this.installedItemsPage = new InstalledItemsPage('[data-component="InstalledItemsPage"]');
this.upgradePage = new UpgradePage('[data-component="UpgradePage"]');
this.hideAllPages();
}
......
......@@ -13,7 +13,6 @@ export default class ToolBar extends Component {
homeAction: '',
collectionAction: '',
indicator: false,
upgrade: false,
updateAvailable: false
};
}
......@@ -42,7 +41,6 @@ export default class ToolBar extends Component {
<option value="https://www.opendesktop.org/s/Window-Managers">box-look.org</option>
<option value="https://www.opendesktop.org/s/Enlightenment">enlightenment-themes.org</option>
</select>
<button class="toolbar-button icon-info page-button important" data-dispatch="upgrade-page"></button>
<button class="toolbar-button icon-menu" data-dispatch="side-panel"></button>
`;
}
......@@ -134,7 +132,6 @@ export default class ToolBar extends Component {
script() {
this.state.indicator ? this.showIndicator() : this.hideIndicator();
this.state.upgrade ? this.showUpgradeButton() : this.hideUpgradeButton();
const config = new electronConfig({name: 'application'});
......@@ -164,14 +161,4 @@ export default class ToolBar extends Component {
this.element.querySelector('.toolbar-indicator').style.display = 'none';
}
showUpgradeButton() {
this.state.upgrade = true;
this.element.querySelector('[data-dispatch="upgrade-page"]').style.display = 'inline-block';
}
hideUpgradeButton() {
this.state.upgrade = false;
this.element.querySelector('[data-dispatch="upgrade-page"]').style.display = 'none';
}
}
import Component from '../../libs/chirit/Component.js';
import packageMeta from '../../../package.json';
export default class UpgradePage extends Component {
html() {
if (!this.state) {
return '';
}
let list = '';
for (const releasefile of this.state.releasefiles) {
const params = JSON.stringify({
ocsUrl: `ocs://download?url=${encodeURIComponent(releasefile.url)}&type=downloads`,
providerKey: '',
contentId: ''
});
list += `
<tr>
<td class="file-description-cell">
<h4>${releasefile.name}</h4>
<p>${releasefile.description}</p>
</td>
<td class="file-download-cell">
<button data-dispatch="ocs-url-dialog" data-params='${params}'>Download</button>
</td>
</tr>
`;
}
return `
<div class="upgrade-page-content">
<div class="banner icon-opendesktop-app"></div>
<h1 class="title">${packageMeta.productName}</h1>
<h3 class="version">Version ${this.state.versionname} available</h3>
<p class="description">Current version ${packageMeta.version}</p>
<table class="releasefiles">${list}</table>
<p>Visit <a href="${this.state.releasepage}" target="_blank">${this.state.releasepage}</a> for more details.</p>
</div>
`;
}
style() {
this.element.style.width = '100%';
this.element.style.height = '100%';
this.element.style.overflow = 'auto';
return `
.upgrade-page-content {
width: 720px;
margin: 2em auto;
}
.upgrade-page-content > h1,
.upgrade-page-content > h3,
.upgrade-page-content > p {
text-align: center;
}
.upgrade-page-content .banner {
height: 128px;
margin-bottom: 2em;
background-position: center center;
background-repeat: no-repeat;
background-size: contain;
}
.upgrade-page-content .description {
margin: 1em 0;
}
.upgrade-page-content .releasefiles {
width: 100%;
margin-bottom: 1em;
border-top: 1px solid rgba(0,0,0,0.1);
border-bottom: 1px solid rgba(0,0,0,0.1);
border-collapse: collapse;
}
.upgrade-page-content .releasefiles tr {
border-top: 1px solid rgba(0,0,0,0.1);
}
.upgrade-page-content .releasefiles .file-description-cell {
width: 100%;
padding: 0.6em;
}
.upgrade-page-content .releasefiles button {
margin: 0 0.2em;
padding: 0.3em 0.5em;
}
`;
}
}
......@@ -97,7 +97,6 @@ import Root from '../components/Root.js';
homeAction: root.toolBar.state.homeAction,
collectionAction: root.toolBar.state.collectionAction,
indicator: root.toolBar.state.indicator,
upgrade: root.toolBar.state.upgrade,
updateAvailable: Object.keys(updateAvailableItems).length ? true : false
});
......@@ -130,7 +129,6 @@ import Root from '../components/Root.js';
homeAction: 'browse-page',
collectionAction: 'collection-page',
indicator: root.toolBar.state.indicator,
upgrade: root.toolBar.state.upgrade,
updateAvailable: root.toolBar.state.updateAvailable
});
......@@ -167,7 +165,7 @@ import Root from '../components/Root.js';
previewPicUrl = `${data.data[0].metadata.provider}content/previewpic/${data.data[0].metadata.content_id}`;
}
if (previewPicUrl) {
downloadPreviewPic(previewPicUrl, btoa(data.data[0].metadata.url).slice(-255));
downloadPreviewPic(previewPicUrl, previewPicFilename(data.data[0].metadata.url));
}
}
);
......@@ -209,7 +207,7 @@ import Root from '../components/Root.js';
sendWebSocketMessage('', 'ConfigHandler::getUsrConfigInstalledItems', []);
}
else if (data.func === 'ItemHandler::uninstall') {
removePreviewPic(btoa(data.id).slice(-255));
removePreviewPic(previewPicFilename(data.id));
}
else if (data.func === 'ItemHandler::uninstallStarted') {
if (data.data[0].status !== 'success_uninstallstart') {
......@@ -285,7 +283,6 @@ import Root from '../components/Root.js';
homeAction: 'start-page',
collectionAction: 'collection-page',
indicator: root.toolBar.state.indicator,
upgrade: root.toolBar.state.upgrade,
updateAvailable: root.toolBar.state.updateAvailable
});
......@@ -324,7 +321,6 @@ import Root from '../components/Root.js';
homeAction: 'browse-page',
collectionAction: 'collection-page',
indicator: root.toolBar.state.indicator,
upgrade: root.toolBar.state.upgrade,
updateAvailable: root.toolBar.state.updateAvailable
});
......@@ -356,21 +352,6 @@ import Root from '../components/Root.js';
sendWebSocketMessage(params.itemKey, 'ItemHandler::uninstall', [params.itemKey]);
});
statusManager.registerAction('upgrade-page', () => {
root.toolBar.update({
active: 'upgrade-page',
backAction: '',
forwardAction: '',
homeAction: 'browse-page',
collectionAction: 'collection-page',
indicator: root.toolBar.state.indicator,
upgrade: root.toolBar.state.upgrade,
updateAvailable: root.toolBar.state.updateAvailable
});
root.mainArea.changePage('upgradePage');
});
statusManager.registerAction('check-self-update', (resolve, reject) => {
console.log('Checking for self update');
......@@ -387,7 +368,7 @@ import Root from '../components/Root.js';
if (process.env.APPIMAGE === path.join(remote.app.getPath('home'), '.local', 'bin', 'opendesktop-app.AppImage')) {
for (const releasefile of data.releasefiles) {
if (releasefile.url.toLowerCase().endsWith('x86_64.appimage')) {
if (releasefile.url.endsWith('x86_64.AppImage')) {
const dirPath = path.join(remote.app.getPath('home'), '.cache', 'opendesktop-app');
const filePath = path.join(dirPath, 'opendesktop-app.AppImage');
......@@ -405,9 +386,9 @@ import Root from '../components/Root.js';
}
}
}
else {
resolve(data);
}
//else {
// resolve(data);
//}
}
})
.catch((error) => {
......@@ -415,10 +396,8 @@ import Root from '../components/Root.js';
});
});
statusManager.registerView('check-self-update', (state) => {
root.toolBar.showUpgradeButton();
root.mainArea.upgradePage.update(state);
});
//statusManager.registerView('check-self-update', (state) => {
//});
statusManager.dispatch('check-self-update');
}
......@@ -540,6 +519,11 @@ import Root from '../components/Root.js';
return false;
}
function previewPicFilename(url) {
// See also InstalledItemsPage.js
return btoa(url).slice(-255);
}
function downloadPreviewPic(url, filename) {
const dirPath = path.join(remote.app.getPath('userData'), 'previewpic');
const filePath = path.join(dirPath, filename);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment