Commit eb02771a authored by DFN2's avatar DFN2
Browse files

switch ui js to react - src/ , public/ , build/

parent 8f4e675b
react: npm start
electron: node src/electron-wait-react
\ No newline at end of file
{
"main.css": "static/css/main.8055198b.css",
"main.css.map": "static/css/main.8055198b.css.map",
"main.js": "static/js/main.31ce79a1.js",
"main.js.map": "static/js/main.31ce79a1.js.map"
}
\ No newline at end of file
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="shortcut icon" href="./favicon.ico"><link href="./static/css/main.8055198b.css" rel="stylesheet"></head><body><div id="root"></div><script type="text/javascript" src="./static/js/main.31ce79a1.js"></script></body></html>
\ No newline at end of file
.material-icons.md-12,.material-icons.md-smaller{font-size:12px}.material-icons.md-18,.material-icons.md-small{font-size:18px}.material-icons.md-24,.material-icons.md-medium{font-size:24px}.material-icons.md-36,.material-icons.md-large{font-size:36px}.material-icons.md-48,.material-icons.md-larger{font-size:48px}.material-icons.md-dark,.material-icons.md-dark.md-active{color:rgba(0,0,0,.54)}.material-icons.md-dark.md-inactive{color:rgba(0,0,0,.26)}.material-icons.md-light,.material-icons.md-light.md-active{color:#fff}.material-icons.md-light.md-inactive{color:hsla(0,0%,100%,.3)}div.background-overlay{z-index:999;height:100%}div.background-overlay,nav#menu-bar{position:absolute;top:0;left:0;width:100%}nav#menu-bar{height:40px;border-bottom:1px solid var(--color-border);background-color:var(--color-widget)}nav#menu-bar #main-menu{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-align:center;align-items:center;height:inherit;margin:0 4px}nav#menu-bar #main-menu>li{-ms-flex:0 0 auto;flex:0 0 auto;height:30px;margin:0 2px;width:30px}nav#menu-bar #main-menu>li>button{height:30px;width:30px}nav#menu-bar #main-menu>li>button i{height:24px;position:relative}nav#menu-bar #main-menu>li span.app-badge{display:inline-block;padding:3px 6px;border-radius:10px;font-size:11px;line-height:1;z-index:1;position:absolute;top:-5px;right:-12px;font-style:normal}nav#menu-bar #main-menu>li span.app-badge.low-emphasis{background-color:var(--color-active-secondary);color:var(--color-text)}nav#menu-bar #main-menu>li span.app-badge.medium-emphasis{background-color:var(--color-information);color:var(--color-content)}nav#menu-bar #main-menu>li span.app-badge.high-emphasis{background-color:var(--color-important);color:var(--color-content)}nav#menu-bar #main-menu>li#omnibox-menu{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex:1 1 auto;flex:1 1 auto;-ms-flex-pack:center;justify-content:center}nav#menu-bar #main-menu>li #user-menu-container button{padding-top:3px;height:30px}nav#menu-bar #main-menu>li ul#user-menu{z-index:1000;position:relative;top:0;left:-220px;width:250px;min-width:auto;max-width:auto;height:auto;min-height:auto;max-height:auto;padding:3px 0;border:1px solid var(--color-border);border-radius:5px;box-shadow:0 5px 20px 0 var(--color-shadow);background-color:var(--color-content)}nav#menu-bar #main-menu>li ul#user-menu li{width:100%;height:30px;margin:0}nav#menu-bar #main-menu>li ul#user-menu li a{display:block;padding:.5em 1em;background-color:transparent;color:var(--color-text);line-height:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;cursor:pointer}nav#menu-bar #main-menu>li ul#user-menu li a:hover{background-color:var(--color-active);color:var(--color-text)}@media (min-width:900px){nav#menu-bar ul li#omnibox-menu{margin-right:128px}}div#omnibox-container{max-width:500px;width:100%;height:30px}div#omnibox-container div#omnibox{position:relative;width:inherit;height:inherit}div#omnibox-container div#omnibox.active:after{background-color:var(--color-important)}div#omnibox-container div#omnibox.download-active:after{background:linear-gradient(90deg,transparent,var(--color-information) 50%,transparent);background-size:300% 300%;animation:gradient 2s ease-in-out infinite alternate;position:absolute;width:101%;height:36px;left:-2.5px}div#omnibox-container div#omnibox div#omnibox-wrapper{z-index:10;position:absolute;width:100%;height:100%;border-radius:3px;background-color:var(--color-widget);overflow:hidden}div#omnibox-container div#omnibox #progress-bar-container{width:100%;height:2px;position:absolute;bottom:0;left:0;z-index:11;overflow:hidden;border-radius:0 3px 3px 0}div#omnibox-container div#omnibox:after{display:block;content:"";z-index:9;position:absolute;top:-3px;width:106%;height:106%;border-radius:6px}div#omnibox-container div#omnibox-content{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-align:center;align-items:center;width:100%;height:100%;background-color:var(--color-active-secondary);line-height:1;transition:background-color .2s ease-out}div#omnibox-container div#omnibox-content #open-in-browser-container i .MuiSvgIcon-root{font-size:inherit}div#omnibox-container div#omnibox-content:hover{background-color:var(--color-active)}div#omnibox-container div#omnibox-content h3{-ms-flex:1 1 auto;flex:1 1 auto;border-right:1px solid var(--color-border);overflow:hidden;white-space:nowrap;text-overflow:ellipsis;line-height:24px;text-align:center;cursor:pointer}div#omnibox-container div#omnibox-content div{display:-ms-flexbox;display:flex;-ms-flex:0 0 auto;flex:0 0 auto;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:30px}div#omnibox-container div#omnibox-palette{z-index:1000;position:relative;top:0;left:0;width:inherit;padding:1em;border:1px solid var(--color-border);border-radius:5px;box-shadow:0 5px 20px 0 var(--color-shadow);background-color:var(--color-content)}div#omnibox-container div#omnibox-palette.inactive{display:none}div#omnibox-container div#omnibox-palette div.palette-content{padding:1em;border-bottom:1px solid var(--color-border)}div#omnibox-container div#omnibox-palette div.palette-content:last-child{border-bottom:0}div#omnibox-container div#omnibox-palette div.palette-content h4{margin:1em 0;text-align:center}div#omnibox-container div#omnibox-palette div.palette-content h4 i{position:relative;top:3px}div#omnibox-container div#omnibox-palette div.palette-content p{text-align:center}div#omnibox-container div#omnibox-palette div.palette-content nav ul{display:-ms-flexbox;display:flex;-ms-flex-flow:row wrap;flex-flow:row wrap;-ms-flex-pack:center;justify-content:center}div#omnibox-container div#omnibox-palette div.palette-content nav ul li{width:50%;padding:5px}div#omnibox-container div#omnibox-palette div.palette-content nav ul li button{padding:5px;width:100%;border:1px solid #ccc;transition:all .2s ease-out}div#omnibox-container div#omnibox-palette div.palette-content nav ul li button:hover{background-color:#fff;border-color:#999}div#omnibox-container div#omnibox-palette div.palette-content nav ul li button.active{border-color:#4949f3}@keyframes gradient{0%{background-position:0 0}to{background-position:100% 0}}#collections-container{position:relative;padding-left:200px}#collections-container,#collections-container aside{display:-ms-flexbox;display:flex;-ms-flex-flow:column nowrap;flex-flow:column nowrap;-ms-flex:1 1 auto;flex:1 1 auto}#collections-container aside{border-right:1px solid var(--color-border);background-color:var(--color-widget);overflow:auto;position:absolute;left:0;top:0;width:200px;height:100%}#collections-container aside h4{padding:.5em 1em}#collections-container aside ul.task{border-bottom:1px solid var(--color-border)}#collections-container aside ul li a{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-align:center;align-items:center;width:100%;padding:.5em 1em;background-color:transparent;color:var(--color-text);cursor:pointer}#collections-container aside ul li a.selected{background-color:var(--color-active)}#collections-container aside ul li a span.name{-ms-flex:1 1 auto;flex:1 1 auto;display:inline-block;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;line-height:1;text-transform:capitalize}#collections-container aside ul li a span.app-badge{-ms-flex:0 0 auto;flex:0 0 auto}#collections-container #collections-switch-view{display:-ms-flexbox;display:flex;-ms-flex-flow:column nowrap;flex-flow:column nowrap;-ms-flex:1 1 auto;flex:1 1 auto;overflow:auto}#collections-container #collections-switch-view ul{list-style:none}#collections-container #collections-switch-view ul li{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-align:center;align-items:center;margin:1em;padding:1em 2em;border:1px solid var(--color-border);border-radius:5px;transition:all .2s ease-out}#collections-container #collections-switch-view ul li:hover{border-color:rgba(0,0,0,.3)}#collections-container #collections-switch-view ul+ul li:first-of-type{margin-top:0}#collections-container #collections-switch-view figure{-ms-flex:0 0 auto;flex:0 0 auto;width:64px;height:64px;background-position:50%;background-repeat:no-repeat;background-size:contain}#collections-container #collections-switch-view figure i .MuiSvgIcon-root{font-size:inherit}#collections-container #collections-switch-view div.item-main{-ms-flex:1 1 auto;flex:1 1 auto;padding:0 1em}#collections-container #collections-switch-view nav.actions{-ms-flex:0 0 auto;flex:0 0 auto}#collections-container #collections-switch-view nav.actions button{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:inline-block;width:inherit;height:inherit;padding:.5em 1em;border:1px solid var(--color-border);border-radius:3px;background-color:var(--color-content);outline:none;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#collections-container #collections-switch-view nav.actions button:enabled{cursor:pointer}#collections-container #collections-switch-view nav.actions button:enabled:hover{background-color:var(--color-active)}#collections-container #collections-switch-view nav.actions button:checked,#collections-container #collections-switch-view nav.actions button:checked:hover{background-color:var(--color-information-secondary)}#collections-container #collections-switch-view nav.actions button+button{margin-left:3px}#collections-container #collections-switch-view .progress-bar-container{display:inline-block;width:100%;margin:.5em 0}#collections-container #collections-switch-view .progress-bar-container progress{width:100%}div#dialog-overlay,div#dialog-overlay-background{display:-ms-flexbox;display:flex;-ms-flex-flow:column nowrap;flex-flow:column nowrap;z-index:1000;position:absolute;top:0;left:0;width:100%;height:100%;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center}div#dialog-overlay.inactive{display:none}article.dialog{display:-ms-flexbox;display:flex;-ms-flex-flow:column nowrap;flex-flow:column nowrap;min-width:auto;max-width:auto;min-height:auto;max-height:auto;border:1px solid var(--color-border);border-radius:5px;box-shadow:0 0 20px 10px var(--color-shadow);background-color:var(--color-content);z-index:1001}article.dialog header{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex:0 0 auto;flex:0 0 auto;-ms-flex-align:center;align-items:center;padding:5px 10px;border-bottom:1px solid var(--color-border);border-top-left-radius:5px;border-top-right-radius:5px}article.dialog header div.header-content{-ms-flex:1 1 auto;flex:1 1 auto}article.dialog header div.header-control{-ms-flex:0 0 auto;flex:0 0 auto}article.dialog header div.header-control button{height:30px;width:30px}article.dialog header div.header-control button i{height:24px}article.dialog header.inactive{display:none}article.dialog article.content,article.dialog article.content .inner-content{display:-ms-flexbox;display:flex;-ms-flex-flow:column nowrap;flex-flow:column nowrap;-ms-flex:1 1 auto;flex:1 1 auto}article.dialog article.content .inner-content{-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;padding:1em}article.dialog article.content .inner-content h4,article.dialog article.content .inner-content p{margin:.5em 0;text-align:center;color:#444}article.dialog article.content figure{display:inline-block;width:128px;height:128px;background-position:50%;background-repeat:no-repeat;background-size:128px 128px;text-align:center}article.dialog article.content figure img{width:auto;height:100%;margin:0 auto}article.dialog article.content h3{margin:1em}article.dialog footer{-ms-flex:0 0 auto;flex:0 0 auto;padding:5px 10px;border-top:1px solid var(--color-border);border-bottom-left-radius:5px;border-bottom-right-radius:5px}article.dialog footer.inactive{display:none}article.dialog#loading-dialog{width:400px;height:300px}article.dialog#about-dialog{width:500px;height:auto}article.dialog#collections-dialog{width:80%;height:80%}#main{padding-top:40px;position:relative}#main,#main #webview-container,#main #webview-wrapper{width:100%;height:100%}#main #webview-container webview{height:100%}#main #webview-mask{background-color:#fff;position:absolute;width:100%;height:100%;top:40px;left:0}:host,:root{--color-text:#444;--color-text-secondary:#666;--color-content:#fff;--color-widget:#f5f5f5;--color-border:rgba(0,0,0,.15);--color-shadow:rgba(0,0,0,.2);--color-active:rgba(0,0,0,.1);--color-active-secondary:hsla(0,0%,39%,.1);--color-information:#4496d3;--color-information-secondary:#68a4d9;--color-help:var(--color-information);--color-help-secondary:var(--color-information-secondary);--color-important:#f3981d;--color-important-secondary:#ed6d35;--color-accept:#37a34a;--color-accept-secondary:#79c06e;--color-error:#ea5549;--color-error-secondary:#d83473;--color-warning:var(--color-error);--color-warning-secondary:var(--color-error-secondary)}:host{color:var(--color-text)}a{color:var(--color-information)}a:hover{color:var(--color-information-secondary)}.fade-in,.fade-out{animation:fade .2s}.fade-out{animation-direction:reverse;animation-fill-mode:forwards}@keyframes fade{0%{opacity:0}to{opacity:1}}app-root,body,html{width:100%;height:100%;overflow:hidden}*,:after,:before{box-sizing:inherit;font-family:inherit;font-size:inherit;line-height:inherit}:host,:root{box-sizing:border-box}:host{display:block}:host,body{font-family:Arial,sans-serif;font-size:13px;line-height:1.4;cursor:default}article,aside,canvas,details,embed,figcaption,figure,footer,header,main,nav,section,summary{display:block}datalist,keygen,mark,meter,progress,rp,rt,ruby,time,wbr{display:inline}address,article,aside,audio,blockquote,body,button,canvas,caption,dd,details,div,dl,dt,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hr,iframe,img,input,legend,li,main,nav,object,ol,p,pre,section,select,summary,table,tbody,td,textarea,tfoot,th,thead,tr,ul,video{margin:0;padding:0}nav ul{list-style:none}a{text-decoration:none;outline:none}#root{height:100%;width:100%}button{-webkit-appearance:none;-moz-appearance:none;appearance:none;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:inherit;height:inherit;border:0;border-radius:3px;background-color:transparent;outline:none;transition:background-color .2s ease-out}button:enabled{cursor:pointer}button:enabled:hover{background-color:var(--color-active)}button:checked,button:checked:hover{background-color:var(--color-information-secondary)}span.app-badge{display:inline-block;padding:3px 6px;border-radius:10px;font-size:11px;line-height:1}span.app-badge.low-emphasis{background-color:var(--color-active-secondary);color:var(--color-text)}span.app-badge.medium-emphasis{background-color:var(--color-information);color:var(--color-content)}span.app-badge.high-emphasis{background-color:var(--color-important);color:var(--color-content)}
/*# sourceMappingURL=main.8055198b.css.map*/
\ No newline at end of file
{"version":3,"sources":[],"names":[],"mappings":"","file":"static/css/main.8055198b.css","sourceRoot":""}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
{
"name": "pling-store",
"productName": "Pling-Store",
"version": "5.0.1",
"version": "5.1.1",
"description": "Store Frontend and Management Application based on OpenCollaborationServices (OCS) of Opendesktop.org.",
"author": "Pling.com",
"license": "GPL-3.0",
"homepage": "https://www.pling.com/",
"repository": "https://www.opencode.net/dfn2/pling-store",
"homepage": "./",
"repoHomepage": "https://www.pling.com/",
"repository": "https://www.opencode.net/dfn2/opendesktop-app",
"bugs": "https://www.opencode.net/dfn2/pling-store/issues",
"main": "app/main.js",
"main": "src/electron-starter.js",
"scripts": {
"start": "electron .",
"start": "react-scripts build && electron .",
"debug": "electron . --debug",
"package": "electron-packager . pling-store --platform=linux --arch=x64 --out=dist --overwrite --ignore='^/(\\.gitignore|\\.gitlab\\-ci\\.yml|Makefile|README\\.md|desktop|launcher|pkg|scripts|appimagebuild)($|/)'",
"watch": "webpack --mode development --watch"
"package": "electron-packager . opendesktop-app --platform=linux --arch=x64 --out=dist --overwrite --ignore='^/(\\.gitignore|\\.gitlab\\-ci\\.yml|Makefile|README\\.md|desktop|launcher|pkg|scripts|appimagebuild)($|/)'",
"watch": "webpack --mode development --watch",
"react-start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"electron": "electron .",
"dev": "nf start -p 3000"
},
"dependencies": {
"electron-store": "2.*.*",
"electron-updater": "^4.1.2",
"esm": "3.*.*",
"lit-html": "1.*.*",
"request": "2.*.*"
"request": "2.*.*",
"@material-ui/core": "^4.3.3",
"@material-ui/icons": "^4.2.1",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-electron-web-view": "^2.0.1"
},
"devDependencies": {
"electron": "4.*.*",
"electron-packager": "13.*.*"
"electron-packager": "13.*.*",
"foreman": "^2.0.0",
"react-scripts": "0.8.5"
}
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tag above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
</head>
<body>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
export default class OcsManagerApi {
constructor(url) {
this._url = url;
this._websocket = null;
this._callback = new Map();
this._autoReconnect = false;
}
get callback() {
return this._callback;
}
get isConnected() {
return (this._websocket && this._websocket.readyState === 1) ? true : false;
}
async connect() {
return new Promise((resolve, reject) => {
if (!this.isConnected) {
this._websocket = new WebSocket(this._url);
this._autoReconnect = true;
this._websocket.addEventListener('open', () => {
resolve(true);
});
this._websocket.addEventListener('message', (event) => {
// console.log(event);
const message = event.data ? JSON.parse(event.data) : {};
if (message.func && this._callback.has(message.func)) {
const callback = this._callback.get(message.func);
callback(message);
}
});
this._websocket.addEventListener('close', () => {
if (this._autoReconnect) {
setTimeout(() => {
this._websocket = null;
this.connect();
}, 3000);
}
});
this._websocket.addEventListener('error', () => {
this._websocket = null;
reject(new Error('WebSocket connection error'));
});
}
else {
reject(new Error('WebSocket is already connected'));
}
});
}
async disconnect() {
return new Promise((resolve, reject) => {
if (this.isConnected) {
this._autoReconnect = false;
this._websocket.addEventListener('close', () => {
this._websocket = null;
resolve(true);
});
this._websocket.close();
}
else {
reject(new Error('WebSocket is not connected'));
}
});
}
async send(func, data = [], id = '') {
return new Promise((resolve, reject) => {
id = id || this._generateId();
if (this.isConnected) {
this._websocket.send(JSON.stringify({
id: id,
func: func,
data: data
}));
resolve(id);
}
else {
reject(new Error('WebSocket is not connected'));
}
});
}
async sendSync(func, data = [], id = '') {
return new Promise((resolve, reject) => {
id = id || this._generateId();
let webSocket = new WebSocket(this._url);
webSocket.addEventListener('open', () => {
webSocket.send(JSON.stringify({
id: id,
func: func,
data: data
}));
});
webSocket.addEventListener('message', (event) => {
const message = event.data ? JSON.parse(event.data) : {};
if (message.id && message.id === id) {
webSocket.close();
resolve(message);
}
});
webSocket.addEventListener('close', () => {
webSocket = null;
});
webSocket.addEventListener('error', () => {
webSocket = null;
reject(new Error(`WebSocket connection error (id: ${id})`));
});
});
}
_generateId() {
const length = 16;
const strings = '0123456789'
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ 'abcdefghijklmnopqrstuvwxyz';
const stringArray = strings.split('');
let randomString = '';
for (let i = 0; i < length; i++) {
randomString += stringArray[Math.floor(Math.random() * stringArray.length)];
}
return randomString;
}
}
const electron = window.require('electron');
const ipcRenderer = electron.ipcRenderer;
import React, {useState} from 'react';
import OcsManagerApi from '../api/OcsManagerApi.js';
import {Context} from '../context-provider';
import appConfig from '../configs/application.json';
import MenuBar from './MenuBar';
import WebView from './WebView';
import AppDialogs from './AppDialogs';
import '../styles/App.css';
function App(){
const { appDispatch, browserDispatch, ocsApiState, ocsApiDispatch } = React.useContext(Context);
const [ isSubscribed, setIsSubscribed ] = useState(false);
const [ loading, setLoading ] = useState(true);
const [ webviewEl, setWebviewEl ] = useState();
const packageJson = ipcRenderer.sendSync('app','package');
React.useEffect(() => { initApp(); },[])
React.useEffect(() => {
if (ocsApiState.loading === false) connectOcsApi();
},[ocsApiState.loading])
React.useEffect(() => {
if (typeof webviewEl !== undefined & !isSubscribed){
if (ocsApiState.ocsManagerApi && ocsApiState.ocsManagerApi.callback){
setIsSubscribed(true);
subscribeToOcsApiCallback();
}
}
},[ocsApiState.ocsManagerApi, webviewEl])
function initApp(){
let homepageUrl = localStorage.getItem('homePageUrl'), homepageTitle = localStorage.getItem('homePageTitle');
if (homepageUrl === null) homepageUrl = packageJson.repoHomepage, homepageTitle = packageJson.productName;
browserDispatch({type:'SET_PAGE',url:homepageUrl,title:homepageTitle});
const ocsManagerApi = new OcsManagerApi(ipcRenderer.sendSync('ocs-manager', 'url'));
ocsApiDispatch({type:'SET_API',ocsManagerApi:ocsManagerApi});
}
function connectOcsApi(){
const connectToOcsApi = ocsApiState.ocsManagerApi.connect();
const getAppConfigInstallTypes = ocsApiState.ocsManagerApi.sendSync('ConfigHandler::getAppConfigInstallTypes', [])
const getUserConfigInstalledItems = ocsApiState.ocsManagerApi.sendSync('ConfigHandler::getUsrConfigInstalledItems', []);
const getUserConfigUpdateAvailableItems = ocsApiState.ocsManagerApi.sendSync('ConfigHandler::getUsrConfigUpdateAvailableItems', []);
const getUserConfigApplication = ocsApiState.ocsManagerApi.sendSync('ConfigHandler::getUsrConfigApplication', []);
connectToOcsApi.then(function(value){
return getAppConfigInstallTypes;
}).then(function(res){
ocsApiDispatch({type:'SET_INSTALL_TYPES',installTypes:res.data[0]});
return getUserConfigInstalledItems;
}).then(function(res){
ocsApiDispatch({type:'SET_INSTALLED_ITEMS',installedItems:res.data[0]});
return getUserConfigUpdateAvailableItems;
}).then(function(res){
if (res.data.length > 0){
/*const combinedUpdateAvailableItems = {};
for (const value of Object.values(updateAvailableItems)) {
const itemKey = value.installed_item;
combinedUpdateAvailableItems[itemKey] = installedItems[itemKey];
}*/
}
return getUserConfigApplication;
}).then(function(res){
const updateCheckedAt = res.data[0].update_checked_at;
const updateCheckAfter = ipcRenderer.sendSync('app', 'config').updateCheckAfter;
ocsApiDispatch({type:'SET_UPDATE_CHECK',updateCheckedAt:updateCheckedAt,updateCheckAfter:updateCheckAfter});
const shouldCheckForUpdates = !updateCheckedAt || (updateCheckedAt + updateCheckAfter) < new Date().getTime();
if (shouldCheckForUpdates) ocsApiState.ocsManagerApi.send('UpdateHandler::checkAll', []);
setAppInfo();
});
}
function setAppInfo(){
console.log(ocsApiState);
appDispatch({type:'SET_PACKAGE_JSON',packageJson:packageJson})
appDispatch({type:'SET_DOMAINS',domains:appConfig.domains});
setLoading(false);
}
function subscribeToOcsApiCallback(){
ocsApiState.ocsManagerApi.callback
.set('ItemHandler::metadataSetChanged', () => {
ocsApiState.ocsManagerApi.sendSync('ItemHandler::metadataSet', [])
})
.set('ItemHandler::downloadStarted', (message) => {
console.log('download started')
console.log(message);
ocsApiDispatch({type:'SET_DOWNLOAD_ITEM',item:message.data[0].metadata});
// Download preview picture
const selector = 'meta[property="og:image"]';
webviewEl.getWebContents().executeJavaScript(`document.querySelector('${selector}').content`, false, (result) => {
let previewpicUrl = result || '';
// FIXME: previewpic API maybe deprecated
/*if (!previewpicUrl
&& message.data[0].metadata.command === 'install'
&& message.data[0].metadata.provider
&& message.data[0].metadata.content_id
) {
previewpicUrl = `${message.data[0].metadata.provider}content/previewpic/${message.data[0].metadata.content_id}`;
}*/
console.log(result);
if (previewpicUrl) ipcRenderer.sendSync('previewpic', 'download', message.data[0].metadata.url, previewpicUrl);
});
})
.set('ItemHandler::downloadProgress', (message) => {
console.log('download progress');
ocsApiDispatch({
type:'UPDATE_ITEM_DOWNLOAD_PROGRESS',
itemUrl:message.data[0],
bytesRecieved:message.data[1],
bytesTotal:message.data[2]
})
})
.set('ItemHandler::downloadFinished', (message) => {
console.log('download started');
if (message.data[0].status !== 'success_download') console.error(new Error(message.data[0].message));
console.log(message.data[0].message)
ocsApiDispatch({
type:'UPDATE_ITEM_DOWNLOAD_PROGRESS',
itemUrl:message.data[0].metadata.url,
status:message.data[0].message
})
})
.set('ItemHandler::saveStarted', (message) => {
if (message.data[0].status !== 'success_savestart') console.error(new Error(message.data[0].message));
console.log(message.data[0].message)
ocsApiDispatch({
type:'UPDATE_ITEM_DOWNLOAD_PROGRESS',
itemUrl:message.data[0].metadata.url,
status:message.data[0].message
})
})
.set('ItemHandler::saveFinished', (message) => {
if (message.data[0].status !== 'success_save') console.error(new Error(message.data[0].message));
console.log(message.data[0].message)
ocsApiDispatch({
type:'UPDATE_ITEM_DOWNLOAD_PROGRESS',
itemUrl:message.data[0].metadata.url,
status:message.data[0].message
})
})
.set('ItemHandler::installStarted', (message) => {
if (message.data[0].status !== 'success_installstart') console.error(new Error(message.data[0].message));
console.log(message.data[0].message)
ocsApiDispatch({
type:'UPDATE_ITEM_DOWNLOAD_PROGRESS',
itemUrl:message.data[0].metadata.url,
status:message.data[0].message
})
})
.set('ItemHandler::installFinished', (message) => {
if (message.data[0].status !== 'success_install') console.error(new Error(message.data[0].message));
console.log(message.data[0].message)
ocsApiDispatch({
type:'UPDATE_ITEM_DOWNLOAD_PROGRESS',
itemUrl:message.data[0].metadata.url,
status:message.data[0].message
})
const getAppConfigInstallTypes = ocsApiState.ocsManagerApi.sendSync('ConfigHandler::getAppConfigInstallTypes', [])
const getUserConfigInstalledItems = ocsApiState.ocsManagerApi.sendSync('ConfigHandler::getUsrConfigInstalledItems', []);
getAppConfigInstallTypes.then(function(res){
ocsApiDispatch({type:'SET_INSTALL_TYPES',installTypes:res.data[0]});
return getUserConfigInstalledItems;
}).then(function(res){
ocsApiDispatch({type:'SET_INSTALLED_ITEMS',installedItems:res.data[0]});
});
});
/*.set('ItemHandler::uninstallStarted', (message) => {
if (message.data[0].status !== 'success_uninstallstart') {
console.error(new Error(message.data[0].message));
}
})
.set('ItemHandler::uninstallFinished', (message) => {
if (message.data[0].status !== 'success_uninstall') {
console.error(new Error(message.data[0].message));
}
this._stateManager.dispatch('ocsManager_installedItems', {});
this._stateManager.dispatch('ocsManager_updateAvailableItems', {});
})
.set('UpdateHandler::checkAllStarted', (message) => {
if (!message.data[0]) {
console.error(new Error('Item update check failed'));
}
})
.set('UpdateHandler::checkAllFinished', (message) => {
if (!message.data[0]) {
console.error(new Error('Item update check failed'));
}
this._stateManager.dispatch('ocsManager_updateAvailableItems', {});
})
.set('UpdateHandler::updateStarted', (message) => {
if (!message.data[1]) {
console.error(new Error('Item update failed'));
}
})
.set('UpdateHandler::updateFinished', (message) => {
if (!message.data[1]) {
console.error(new Error('Item update failed'));
}
this._stateManager.dispatch('ocsManager_installedItems', {});
this._stateManager.dispatch('ocsManager_updateAvailableItems', {});
})
.set('UpdateHandler::updateProgress', (message) => {
this._stateManager.dispatch('ocsManager_updateProgress', {
itemKey: message.data[0],
progress: message.data[1]
});
});*/
}
let menuBarDisplay, webViewDisplay, appDialogsDisplay;
if (!loading){
menuBarDisplay = <MenuBar/>
webViewDisplay = <WebView onSetWebviewEl={(webviewEl) => setWebviewEl(webviewEl)}/>
appDialogsDisplay = <AppDialogs/>
}
return (
<div id="main">
{menuBarDisplay}
{webViewDisplay}
{appDialogsDisplay}
</div>
);
}
export default App;
import React from 'react';
import {Context} from '../context-provider';
import AppLogo from '../images/app-icons/pling-store.png';
import Collections from './Collections';
import '../styles/AppDialogs.css';
import Close from '@material-ui/icons/Close';
function AppDialogs(){
const { appState, appDispatch } = React.useContext(Context);
function onCloseDialogClick(){
appDispatch({type:'HIDE_DIALOG'});
}
let appDialogDisplay,
dialogOverlayClass = "inactive",
dialogBackgroundOverlayDisplay;
if (appState.dialog.show === true){
dialogOverlayClass = "active";
if (appState.dialog.id === "loading") appDialogDisplay = <LoadingDialog/>
else if (appState.dialog.id === "about") appDialogDisplay = <AboutDialog onCloseDialogClick={onCloseDialogClick}/>
else if (appState.dialog.id === "collections") appDialogDisplay = <CollectionsDialog onCloseDialogClick={onCloseDialogClick}/>
if (appState.dialog.id !== "loading") dialogBackgroundOverlayDisplay = <div id="dialog-overlay-background" onClick={onCloseDialogClick}></div>
}
return (
<div id="dialog-overlay" className={dialogOverlayClass}>
{dialogBackgroundOverlayDisplay}
{appDialogDisplay}
</div>
)
}
function DialogHeader(props){
return (
<header>
<div className="header-content">
<h3>{props.title}</h3>
</div