This commit is contained in:
Piotr Dobrowolski 2021-04-14 20:23:43 +02:00
parent a149b40b8e
commit 06c6d4540d
6 changed files with 224 additions and 53 deletions

View File

@ -4,6 +4,9 @@
"description": "An Enyo-based template to build web applications using HTML, CSS and JavaScript.", "description": "An Enyo-based template to build web applications using HTML, CSS and JavaScript.",
"main": "index.js", "main": "index.js",
"moduleDir": "src", "moduleDir": "src",
"scripts": {
"pack": "enyo pack"
},
"assets": [ "assets": [
"favicon.ico", "favicon.ico",
"assets/**/*.*", "assets/**/*.*",

View File

@ -17,6 +17,9 @@ var
Collection = require('enyo/Collection'), Collection = require('enyo/Collection'),
SettingsPanel = require('./SettingsPanel.js'); SettingsPanel = require('./SettingsPanel.js');
var repositoryBaseURL = new URL('webosbrew-repository/index.json', window.location.href).href;
var AppListItem = kind({ var AppListItem = kind({
name: 'AppListItem', name: 'AppListItem',
kind: Item, kind: Item,
@ -40,7 +43,7 @@ var AppListItem = kind({
}, },
bindings: [ bindings: [
{from: 'model.name', to: '$.caption.content'}, {from: 'model.title', to: '$.caption.content'},
{from: 'model.id', to: '$.subCaption.content'}, {from: 'model.id', to: '$.subCaption.content'},
{from: 'model.iconUri', to: '$.img.src'}, {from: 'model.iconUri', to: '$.img.src'},
] ]
@ -51,7 +54,7 @@ module.exports = kind({
kind: Panel, kind: Panel,
title: 'Homebrew Channel', title: 'Homebrew Channel',
titleBelow: 'webosbrew.org', titleBelow: 'webosbrew.org',
// headerType: 'small', headerType: 'medium',
headerComponents: [ headerComponents: [
{kind: IconButton, icon: 'rollbackward', ontap: 'refresh'}, {kind: IconButton, icon: 'rollbackward', ontap: 'refresh'},
{kind: IconButton, icon: 'gear', ontap: 'openSettings'}, {kind: IconButton, icon: 'gear', ontap: 'openSettings'},
@ -66,15 +69,15 @@ module.exports = kind({
}, },
], ],
bindings: [ bindings: [
{from: 'apps', to: '$.appList.collection'}, {from: 'repository', to: '$.appList.collection'},
{ {
from: 'apps.status', to: '$.spinner.showing', transform: function (value) { from: 'repository.status', to: '$.spinner.showing', transform: function (value) {
return this.apps.isBusy() && !this.apps.isError(); return this.repository.isBusy() && !this.repository.isError();
} }
}, },
{ {
from: 'apps.status', to: '$.errorPopup.showing', transform: function (value) { from: 'repository.status', to: '$.errorPopup.showing', transform: function (value) {
return this.apps.isError(); return this.repository.isError();
} }
}, },
], ],
@ -84,18 +87,22 @@ module.exports = kind({
}, },
refresh: function () { refresh: function () {
console.info('refresh'); console.info('refresh');
this.set('apps', new Collection({ this.set('repository', new Collection({
source: new AjaxSource(), source: new AjaxSource(),
url: '/webosbrew-repository/index.json', url: repositoryBaseURL,
options: {parse: true},
parse: function (data) {
return data.packages;
},
})); }));
this.apps.fetch(); this.repository.fetch();
}, },
events: { events: {
onRequestPushPanel: '' onRequestPushPanel: ''
}, },
itemSelected: function (sender, ev) { itemSelected: function (sender, ev) {
if (ev.model) { if (ev.model) {
this.doRequestPushPanel({panel: {kind: DetailsPanel, model: ev.model}}); this.doRequestPushPanel({panel: {kind: DetailsPanel, model: ev.model, repositoryURL: repositoryBaseURL}});
} }
}, },
openSettings: function (sender, ev) { openSettings: function (sender, ev) {

View File

@ -1,6 +1,19 @@
var var
kind = require('enyo/kind'), kind = require('enyo/kind'),
Panel = require('moonstone/Panel'); Panel = require('moonstone/Panel'),
AjaxSource = require('enyo/AjaxSource'),
Spinner = require('moonstone/Spinner'),
Popup = require('moonstone/Popup'),
Icon = require('moonstone/Icon'),
Divider = require('moonstone/Divider'),
Item = require('moonstone/Item'),
Model = require('enyo/Model'),
Button = require('moonstone/Button'),
ProgressButton = require('moonstone/ProgressButton'),
Marquee = require('moonstone/Marquee'),
MarqueeText = Marquee.Text,
BodyText = require('moonstone/BodyText'),
LabeledTextItem = require('moonstone/LabeledTextItem');
module.exports = kind({ module.exports = kind({
name: 'DetailsPanel', name: 'DetailsPanel',
@ -8,8 +21,128 @@ module.exports = kind({
title: '', title: '',
titleBelow: '', titleBelow: '',
headerType: 'medium', headerType: 'medium',
bindings: [ loading: true,
{from: 'model.name', to: 'title'}, error: false,
{from: 'model.id', to: 'titleBelow'}, components: [
{kind: Spinner, name: 'spinner', content: 'Loading...', center: true, middle: true},
{kind: Popup, name: 'errorPopup', content: 'An error occured while loading app info.', modal: false, autoDismiss: true, allowBackKey: true},
{
classes: 'moon-hspacing top', components: [
{
components: [
{kind: Divider, content: 'App information'},
{
kind: LabeledTextItem,
label: 'Version',
name: 'version',
text: 'unknown',
disabled: true,
},
{
kind: LabeledTextItem,
label: 'Root required',
name: 'rootRequired',
text: 'unknown',
disabled: true,
},
{
components: [
{
name: 'installButton', kind: ProgressButton, content: 'Install', postContent: 'Launch', progress: 0,
style: 'width:100%;min-width:100%;', ontap: 'installApp',
},
], ],
},
{
components: [
{
name: 'removeButton', kind: Button, content: 'Remove', style: 'width:100%;min-width:100%', small: true
},
],
},
],
classes: 'moon-6h',
},
{
components: [
{kind: Divider, content: 'Description'},
{kind: BodyText, content: 'Some long-ish project description......'},
{
kind: LabeledTextItem,
label: 'Project page',
name: 'projectPage',
text: 'unknown',
disabled: true,
ontap: 'openProjectPage',
},
],
classes: 'moon-16h',
},
],
},
],
bindings: [
// This is model passed when launching the view
{from: 'model.title', to: 'title'},
{from: 'model.id', to: 'titleBelow'},
// This is data loaded from the web service
{from: 'appInfo.title', to: 'title'},
{from: 'appInfo.id', to: 'titleBelow'},
{from: 'appInfo.version', to: '$.version.text'},
{from: 'appInfo.sourceUrl', to: '$.projectPage.text'},
{
from: 'appInfo.sourceUrl', to: '$.projectPage.disabled', transform: function (v) {
return v instanceof String && v.trim().length
}
},
{
from: 'appInfo.rootRequired', to: '$.rootRequired.text', transform: function (value) {
return value === true ? 'yes' : value === false ? 'no' : value === 'optional' ? 'optional' : 'unknown';
}
},
{
from: 'appInfo.status', to: '$.spinner.showing', transform: function (value) {
console.info(this.appInfo.isReady(), this.appInfo.isError(), this.appInfo.status);
return !this.appInfo.isReady() && !this.appInfo.isError();
}
},
{
from: 'appInfo.status', to: '$.errorPopup.showing', transform: function (value) {
console.info('error:', this.appInfo.isError());
return this.appInfo.isError();
}
},
],
transitionFinished: function () {
// We are launching a web request in post transition to fix a race condition
// when showing the error popup, whoops.
console.info('transitionFinished');
this.refresh();
},
refresh: function () {
console.info('refresh');
this.set('appInfo', new Model(undefined, {
source: new AjaxSource(),
url: new URL(this.model.get('manifestUrl'), this.repositoryURL).href,
}));
this.appInfo.fetch({
// Why is model.status non-observable by default!?
success: function (t) {t.set('status', t.status);},
error: function (t) {t.set('status', t.status);},
});
},
openProjectPage: function () {
// TODO luna://com.webos.applicationManager/launch
// {
// id: "com.webos.app.browser",
// params: {target: "..."},
// }
},
installApp: function () {
this.$.installButton.animateProgressTo(100);
},
}); });

View File

@ -5,7 +5,14 @@ var
Divider = require('moonstone/Divider'), Divider = require('moonstone/Divider'),
ToggleItem = require('moonstone/ToggleItem'), ToggleItem = require('moonstone/ToggleItem'),
Tooltip = require('moonstone/Tooltip'), Tooltip = require('moonstone/Tooltip'),
Group = require('enyo/Group'), Icon = require('moonstone/Icon'),
IconButton = require('moonstone/IconButton'),
ObjectActionDecorator = require('moonstone/ObjectActionDecorator'),
ItemOverlay = require('moonstone/ItemOverlay'),
ItemOverlaySupport = ItemOverlay.ItemOverlaySupport,
Marquee = require('moonstone/Marquee'),
MarqueeText = Marquee.Text,
Item = require('moonstone/Item'),
Popup = require('moonstone/Popup'), Popup = require('moonstone/Popup'),
TooltipDecorator = require('moonstone/TooltipDecorator'), TooltipDecorator = require('moonstone/TooltipDecorator'),
LabeledTextItem = require('moonstone/LabeledTextItem'); LabeledTextItem = require('moonstone/LabeledTextItem');
@ -21,7 +28,7 @@ module.exports = kind({
{ {
kind: Scroller, fit: true, components: [ kind: Scroller, fit: true, components: [
{ {
classes: 'moon-hspacing', components: [ classes: 'moon-hspacing top', components: [
{ {
components: [ components: [
{kind: Divider, content: 'Root configuration'}, {kind: Divider, content: 'Root configuration'},
@ -29,7 +36,7 @@ module.exports = kind({
{kind: ToggleItem, content: 'SSH Server', onchange: 'itemChanged'}, {kind: ToggleItem, content: 'SSH Server', onchange: 'itemChanged'},
{ {
kind: TooltipDecorator, components: [ kind: TooltipDecorator, components: [
{kind: ToggleItem, content: 'Disable metrics', onchange: 'itemChanged'}, {kind: ToggleItem, content: 'Disable metrics', onchange: 'itemChanged', checked: true},
{kind: Tooltip, content: 'This disables certain metrics reporting to TV manufacturer (crash logs, system logs)', position: 'below'}, // , position: 'right-below'} {kind: Tooltip, content: 'This disables certain metrics reporting to TV manufacturer (crash logs, system logs)', position: 'below'}, // , position: 'right-below'}
], style: 'width: 100%', ], style: 'width: 100%',
}, },
@ -48,20 +55,21 @@ module.exports = kind({
}, },
], ],
classes: 'moon-6h', classes: 'moon-6h',
style: 'vertical-align: top',
}, },
{ {
components: [ components: [
{kind: Divider, content: 'Repositories'}, {kind: Divider, content: 'Repositories (Coming Soon...)'},
{kind: ToggleItem, content: 'Default repository - https://repo.webosbrew.org', checked: true, disabled: true},
{ {
kind: Group, onActivate: 'groupChanged', components: [ kind: Item, mixins: [ItemOverlaySupport], components: [
{kind: ToggleItem, content: 'Group Option 1'}, {kind: MarqueeText, content: 'https://repo.webosbrew.org/demo'}
{kind: ToggleItem, content: 'Group Option 5'} ], endingComponents: [
] {kind: Icon, icon: 'trash', small: true}
} ], disabled: true,
},
{kind: Item, content: 'Add repository', centered: true, style: 'margin-top: 3rem', disabled: true},
], ],
classes: 'moon-16h', classes: 'moon-16h',
style: 'vertical-align: top',
} }
] ]
} }

View File

@ -1,27 +1,34 @@
[ {
"packages": [
{ {
"id": "com.moonlight", "id": "com.moonlight",
"name": "Moonlight <i>TV</i>", "title": "Moonlight <i>TV</i>",
"manifestUrl": "moonlight.json",
"iconUri": "https://raw.githubusercontent.com/mariotaku/moonlight-tv/main/deploy/webos/icon.png" "iconUri": "https://raw.githubusercontent.com/mariotaku/moonlight-tv/main/deploy/webos/icon.png"
}, },
{ {
"id": "hbchannel", "id": "hbchannel",
"name": "Homebrew Channel", "title": "Homebrew Channel",
"manifestUrl": "hbchannel.json",
"iconUri": "https://raw.githubusercontent.com/webosbrew/webos-homebrew-channel/main/frontend/icon160.png" "iconUri": "https://raw.githubusercontent.com/webosbrew/webos-homebrew-channel/main/frontend/icon160.png"
}, },
{ {
"id": "choclate-doom", "id": "choclate-doom",
"name": "Choclate Doom", "title": "Choclate Doom",
"manifestUrl": "chocolate-doom.json",
"iconUri": "https://raw.githubusercontent.com/webosbrew/chocolate-doom/webos-tv/data/doom.png" "iconUri": "https://raw.githubusercontent.com/webosbrew/chocolate-doom/webos-tv/data/doom.png"
}, },
{ {
"id": "youtube.webos", "id": "youtube.webos",
"name": "YouTube (adfree)", "title": "YouTube (adfree)",
"manifestUrl": "youtube.json",
"iconUri": "https://raw.githubusercontent.com/FriedChickenButt/youtube-webos/main/largeIcon.png" "iconUri": "https://raw.githubusercontent.com/FriedChickenButt/youtube-webos/main/largeIcon.png"
}, },
{ {
"id": "youtube.webosaaaaaaaaaaaaaaaaaaaaa", "id": "youtube.webosaaaaaaaaaaaaaaaaaaaaa",
"name": "YouTube (adfree) longnaaaaaaaaaaaaaaameeeeeeeeeeeeeeeeeeeee", "title": "YouTube (adfree) longnaaaaaaaaaaaaaaameeeeeeeeeeeeeeeeeeeee",
"manifestUrl": "youtube.json",
"iconUri": "https://raw.githubusercontent.com/FriedChickenButt/youtube-webos/main/largeIcon.png" "iconUri": "https://raw.githubusercontent.com/FriedChickenButt/youtube-webos/main/largeIcon.png"
} }
] ]
}

View File

@ -0,0 +1,13 @@
{
"id": "com.moonlight",
"version": "0.6.8",
"type": "native",
"title": "Moonlight TV",
"iconUri": "",
"sourceUrl": "https://github.com/mariotaku/moonlight-tv",
"rootRequired": false,
"ipkUrl": "https://github.com/mariotaku/moonlight-tv/releases/download/v0.6.8/com.limelight.webos_0.6.8_arm.ipk",
"ipkHash": {
"sha256": ""
}
}