little progress and bugfixes

This commit is contained in:
Ronald A. Richardson
2024-09-06 12:17:30 +08:00
parent c60c460257
commit ea47bdc09d
10 changed files with 59 additions and 12 deletions

View File

@@ -138,7 +138,8 @@ jobs:
echo "//npm.pkg.github.com/:_authToken=${{ secrets._GITHUB_AUTH_TOKEN }}" > .npmrc
fi
if [[ -n "${{ secrets.FLEETBASE_REGISTRY_TOKEN }}" ]]; then
echo "//registry.fleetbase.io/:_authToken=${{ secrets.FLEETBASE_REGISTRY_TOKEN }}" > .npmrc
echo "//registry.fleetbase.io/:_authToken=${{ secrets.FLEETBASE_REGISTRY_TOKEN }}" >> .npmrc
echo "@fleetbase:registry=https://registry.fleetbase.io" >> .npmrc
fi
working-directory: ./console

View File

@@ -5,13 +5,25 @@ import { action } from '@ember/object';
export default class PortalController extends Controller {
@service session;
/**
* Action handler.
*
* @void
*/
@action onAction(action, ...params) {
if (typeof this[action] === 'function') {
this[action](...params);
}
}
/**
* Action to invalidate and log user out
*
* @void
*/
@action invalidateSession(event) {
event.preventDefault();
console.log('invalidateSession', ...arguments)
// event.preventDefault();
this.session.invalidateWithLoader();
}
}

View File

@@ -14,7 +14,7 @@ export default class ConsoleRoute extends Route {
* @return {Promise}
* @memberof ConsoleRoute
*/
async beforeModel (transition) {
async beforeModel(transition) {
this.session.requireAuthentication(transition, 'auth.login');
if (this.session.data.authenticated.type === 'customer') {
@@ -30,7 +30,7 @@ export default class ConsoleRoute extends Route {
* @return {BrandModel}
* @memberof ConsoleRoute
*/
model () {
model() {
return this.store.findRecord('brand', 1);
}
}

View File

@@ -4,13 +4,14 @@ import { inject as service } from '@ember/service';
export default class PortalRoute extends Route {
@service store;
@service session;
@service theme;
/**
* Require authentication to access all `portal` routes.
*
* @param {Transition} transition
* @return {Promise}
* @memberof ConsoleRoute
* @memberof PortalRoute
*/
async beforeModel(transition) {
this.session.requireAuthentication(transition, 'auth.portal-login');
@@ -22,9 +23,18 @@ export default class PortalRoute extends Route {
* Get the branding settings.
*
* @return {BrandModel}
* @memberof ConsoleRoute
* @memberof PortalRoute
*/
model() {
return this.store.findRecord('brand', 1);
}
/**
* Add the fleetbase-portal body class.
*
* @memberof PortalRoute
*/
activate() {
this.theme.setRoutebodyClassNames(['fleetbase-portal']);
}
}

View File

@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';
export default class PortalAccountRoute extends Route {}

View File

@@ -1,8 +1,14 @@
{{page-title "Portal"}}
<div class="portal-container">
<div class="container">
<Portal::Container>
<Portal::Header @onAction={{this.onAction}} />
<Portal::Main>
<Portal::Sidebar />
<Portal::Section>{{outlet}}</Portal::Section>
</Portal::Main>
</Portal::Container>
{{!-- <div class="container">
<div class="flex flex-row">
<a href="javascript:;" {{on "click" this.invalidateSession}}>Sign out</a>
</div>
</div>
</div>
</div> --}}

View File

@@ -0,0 +1,2 @@
{{page-title "Account"}}
{{outlet}}

View File

@@ -3,7 +3,7 @@ module.exports = function asArray(value) {
return value;
}
if (typeof value === 'string' && value.includes(',')) {
if (typeof value === 'string') {
return value.split(',');
}

View File

@@ -7,6 +7,7 @@ export default class Router extends EmberRouter {
}
Router.map(function () {
this.route('install');
this.route('auth', function () {
this.route('login', { path: '/' });
this.route('forgot-password');
@@ -22,6 +23,9 @@ Router.map(function () {
this.route('for-driver', { path: '/fleet/:public_id' });
this.route('for-user', { path: '/org/:public_id' });
});
this.route('portal', function () {
this.route('account');
});
this.route('console', { path: '/' }, function () {
this.route('home', { path: '/' });
this.route('notifications');
@@ -59,6 +63,4 @@ Router.map(function () {
});
});
});
this.route('portal');
this.route('install');
});

View File

@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from '@fleetbase/console/tests/helpers';
module('Unit | Route | portal/account', function (hooks) {
setupTest(hooks);
test('it exists', function (assert) {
let route = this.owner.lookup('route:portal/account');
assert.ok(route);
});
});