diff --git a/.eslintignore b/.eslintignore index 9385391..02adf1b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,8 +6,18 @@ # misc /coverage/ +/scripts/ !.* .*/ # ember-try /.node_modules.ember-try/ +/bower.json.ember-try +/npm-shrinkwrap.json.ember-try +/package.json.ember-try +/package-lock.json.ember-try +/yarn.lock.ember-try + +#server +/server +/server_vendor diff --git a/.eslintrc.js b/.eslintrc.js index 2eba0f1..d483054 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -24,7 +24,7 @@ module.exports = { 'ember/no-get': 'off', 'ember/classic-decorator-no-classic-methods': 'off', 'no-prototype-builtins': 'off', - 'node/no-unpublished-require': [ + 'n/no-unpublished-require': [ 'error', { allowModules: ['resolve', 'broccoli-funnel'], diff --git a/.stylelintrc.js b/.stylelintrc.js index 021c539..62d4554 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -1,5 +1,5 @@ 'use strict'; module.exports = { - extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'], + extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'], }; diff --git a/.template-lintrc.js b/.template-lintrc.js index 07d5ad8..5b9387e 100644 --- a/.template-lintrc.js +++ b/.template-lintrc.js @@ -5,7 +5,7 @@ module.exports = { rules: { 'no-invalid-interactive': 'off', 'no-yield-only': 'off', - 'no-down-event-binding': 'off', + 'no-pointer-down-event-binding': 'off', 'table-groups': 'off', 'link-href-attributes': 'off', 'require-input-label': 'off', diff --git a/addon/components/admin/solid-server-config.hbs b/addon/components/admin/solid-server-config.hbs new file mode 100644 index 0000000..6657096 --- /dev/null +++ b/addon/components/admin/solid-server-config.hbs @@ -0,0 +1,19 @@ +{{#if this.configLoaded}} + + + + + + Secure Server + + + + +
+
+{{else}} +
+ +
+{{/if}} \ No newline at end of file diff --git a/addon/components/admin/solid-server-config.js b/addon/components/admin/solid-server-config.js new file mode 100644 index 0000000..bb9cfe5 --- /dev/null +++ b/addon/components/admin/solid-server-config.js @@ -0,0 +1,52 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { task } from 'ember-concurrency'; + +export default class AdminSolidServerConfigComponent extends Component { + @service fetch; + @service notifications; + @tracked configLoaded = false; + @tracked host; + @tracked port; + @tracked secure; + + constructor() { + super(...arguments); + this.loadServerConfig.perform(); + } + + getConfig() { + return { + host: this.host, + port: this.port, + secure: this.secure, + }; + } + + setConfig(config) { + this.host = config.host; + this.port = config.port; + this.secure = config.secure; + } + + @task *loadServerConfig() { + const config = yield this.fetch.get('server-config', {}, { namespace: 'solid/int/v1' }); + if (config) { + this.setConfig(config); + this.configLoaded = true; + } + } + + @task *saveServerConfig() { + try { + const config = yield this.fetch.post('server-config', { server: this.getConfig() }, { namespace: 'solid/int/v1' }); + if (config) { + this.setConfig(config); + this.notifications.success('Solid server config udpated successfully.'); + } + } catch (error) { + this.notifications.serverError(error); + } + } +} diff --git a/addon/components/solid-brand-icon.hbs b/addon/components/solid-brand-icon.hbs new file mode 100644 index 0000000..59356a8 --- /dev/null +++ b/addon/components/solid-brand-icon.hbs @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/addon/components/solid-brand-icon.js b/addon/components/solid-brand-icon.js new file mode 100644 index 0000000..68f8497 --- /dev/null +++ b/addon/components/solid-brand-icon.js @@ -0,0 +1,13 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; + +export default class SolidBrandIconComponent extends Component { + @tracked width = 19; + @tracked height = 19; + constructor(owner, { options }) { + super(...arguments); + const { width = 19, height = 19 } = options || {}; + this.width = width; + this.height = height; + } +} diff --git a/addon/controllers/application.js b/addon/controllers/application.js new file mode 100644 index 0000000..a87cc82 --- /dev/null +++ b/addon/controllers/application.js @@ -0,0 +1,27 @@ +import Controller from '@ember/controller'; +import { inject as service } from '@ember/service'; +import { task } from 'ember-concurrency'; + +export default class ApplicationController extends Controller { + @service universe; + @service fetch; + + constructor() { + super(...arguments); + this.universe.on('sidebarContext.available', (sidebarContext) => { + sidebarContext.hideNow(); + }); + } + + @task *authenticate() { + const { authenticationUrl, identifier } = yield this.fetch.get('request-authentication', {}, { namespace: 'solid/int/v1' }); + if (authenticationUrl) { + window.location.href = `${authenticationUrl}/${identifier}`; + } + } + + @task *getAccountIndex() { + const response = yield this.fetch.get('account', {}, { namespace: 'solid/int/v1' }); + console.log('[response]', response); + } +} diff --git a/addon/engine.js b/addon/engine.js index f92a014..4e91ba4 100644 --- a/addon/engine.js +++ b/addon/engine.js @@ -3,6 +3,8 @@ import loadInitializers from 'ember-load-initializers'; import Resolver from 'ember-resolver'; import config from './config/environment'; import services from '@fleetbase/ember-core/exports/services'; +import AdminSolidServerConfigComponent from './components/admin/solid-server-config'; +import SolidBrandIconComponent from './components/solid-brand-icon'; const { modulePrefix } = config; const externalRoutes = ['console', 'extensions']; @@ -14,7 +16,25 @@ export default class SolidEngine extends Engine { services, externalRoutes, }; - setupExtension = function (app, engine, universe) {}; + setupExtension = function (app, engine, universe) { + // register menu item in header + universe.registerHeaderMenuItem('Solid', 'console.solid-protocol', { iconComponent: SolidBrandIconComponent, iconComponentOptions: { width: 19, height: 19 }, priority: 5 }); + + // register admin settings -- create a solid server menu panel with it's own setting options + universe.registerAdminMenuPanel( + 'Solid Protocol', + [ + { + title: 'Solid Server Config', + icon: 'sliders', + component: AdminSolidServerConfigComponent, + }, + ], + { + slug: 'solid-server', + } + ); + }; } loadInitializers(SolidEngine, modulePrefix); diff --git a/addon/routes.js b/addon/routes.js index ad6ac01..fbe9f1b 100644 --- a/addon/routes.js +++ b/addon/routes.js @@ -1,3 +1,3 @@ import buildRoutes from 'ember-engines/routes'; -export default buildRoutes(); +export default buildRoutes(function () {}); diff --git a/addon/routes/application.js b/addon/routes/application.js new file mode 100644 index 0000000..0229bad --- /dev/null +++ b/addon/routes/application.js @@ -0,0 +1,14 @@ +import Route from '@ember/routing/route'; +import getWithDefault from '@fleetbase/ember-core/utils/get-with-default'; +import { inject as service } from '@ember/service'; + +export default class ApplicationRoute extends Route { + @service notifications; + + beforeModel(transition) { + const queryParams = getWithDefault(transition, 'router._lastQueryParams', {}); + if (queryParams.error) { + this.notifications.error(queryParams.error); + } + } +} diff --git a/addon/styles/solid-engine.css b/addon/styles/solid-engine.css new file mode 100644 index 0000000..9681a09 --- /dev/null +++ b/addon/styles/solid-engine.css @@ -0,0 +1,29 @@ +.solid-fleetbase-home-container { + margin: auto; + width: 1200px; + padding: 2rem; +} + +.solid-fleetbase-home-container h1 { + font-size: 1.5rem; + font-weight: 600; + margin-bottom: 0.75rem; +} + +.solid-fleetbase-home-container h2 { + font-size: 1.25rem; + font-weight: 500; + margin-bottom: 0.75rem; +} + +body[data-theme='light'] .solid-fleetbase-home-container a:not([class*='text-']), +body[data-theme='dark'] .solid-fleetbase-home-container a:not([class*='text-']), +.solid-fleetbase-home-container a { + color: #60a5fa; + text-decoration: underline; + text-decoration-line: underline; +} + +.solid-fleetbase-home-container a:hover { + opacity: 0.5; +} diff --git a/addon/templates/application.hbs b/addon/templates/application.hbs new file mode 100644 index 0000000..6b8d727 --- /dev/null +++ b/addon/templates/application.hbs @@ -0,0 +1,15 @@ + + + + +

Welcome to Solid for Fleetbase

+

Getting Started

+
+

+ Sign up for an account to get started with your own Pod and WebID. Once you are logged in you can begin to manage your pods and sync data directly from Fleetbase to your Pods. +

+
+ {{!--