Skip to content

Modular logistics and supply chain operating system (LSOS)

hotfix organizations browsers in admin w/ more details, better querying and admin based view, upgrade of dependencies with major patches

Ronald A. Richardsonf9685565852f
diff --git a/console/app/controllers/console/admin/organizations/index.js b/console/app/controllers/console/admin/organizations/index.js
index 704885af..149ece4a 100644
--- a/console/app/controllers/console/admin/organizations/index.js
+++ b/console/app/controllers/console/admin/organizations/index.js
@@ -1,7 +1,8 @@
import Controller from '@ember/controller';
+import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
-import { tracked } from '@glimmer/tracking';
+import { isBlank } from '@ember/utils';
import { task } from 'ember-concurrency';
/**
@@ -104,14 +105,33 @@ export default class ConsoleAdminOrganizationsController extends Controller {
filterable: true,
filterComponent: 'filter/string',
},
+ {
+ label: this.intl.t('console.admin.organizations.index.owner-name-column'),
+ valuePath: 'owner.name',
+ resizable: true,
+ sortable: true,
+ },
+ {
+ label: this.intl.t('console.admin.organizations.index.owner-email-column'),
+ valuePath: 'owner.email',
+ resizable: true,
+ sortable: true,
+ filterable: true,
+ },
{
label: this.intl.t('console.admin.organizations.index.phone-column'),
- valuePath: 'phone',
+ valuePath: 'owner.phone',
resizable: true,
sortable: true,
filterable: true,
filterComponent: 'filter/string',
},
+ {
+ label: this.intl.t('console.admin.organizations.index.users-count-column'),
+ valuePath: 'users_count',
+ resizable: true,
+ sortable: true
+ },
{
label: this.intl.t('common.created-at'),
valuePath: 'createdAt',
@@ -127,7 +147,12 @@ export default class ConsoleAdminOrganizationsController extends Controller {
* @public
*/
@task({ restartable: true }) *search(event) {
- this.companies = yield this.store.query('company', { query: event.target.value });
+ const query = event.target.value;
+ if (isBlank(query)) {
+ return;
+ }
+
+ // this.companies = yield this.store.query('company', { view: 'admin', query: event.target.value });
}
/**
diff --git a/console/app/models/company.js b/console/app/models/company.js
index e12753cd..af3368ec 100644
--- a/console/app/models/company.js
+++ b/console/app/models/company.js
@@ -13,6 +13,7 @@ export default class Company extends Model {
@attr('string') place_uuid;
/** @relationships */
+ @belongsTo('user') owner;
@belongsTo('file') logo;
@belongsTo('file') backdrop;
@@ -23,6 +24,7 @@ export default class Company extends Model {
@attr('string') backdrop_url;
@attr('string') description;
@attr('raw') options;
+ @attr('number') users_count;
@attr('string') type;
@attr('string') currency;
@attr('string') country;
diff --git a/console/app/routes/console/admin/organizations/index.js b/console/app/routes/console/admin/organizations/index.js
index 87c73d01..ff90aafe 100644
--- a/console/app/routes/console/admin/organizations/index.js
+++ b/console/app/routes/console/admin/organizations/index.js
@@ -14,11 +14,6 @@ export default class ConsoleAdminOrganizationsRoute extends Route {
};
model(params) {
- return this.store.query('company', params);
- }
-
- setupController(controller, model) {
- super.setupController(controller, model);
- controller.companies = model;
+ return this.store.query('company', { view: 'admin', ...params });
}
}
diff --git a/console/app/serializers/company.js b/console/app/serializers/company.js
new file mode 100644
index 00000000..e26f432b
--- /dev/null
+++ b/console/app/serializers/company.js
@@ -0,0 +1,15 @@
+import ApplicationSerializer from '@fleetbase/ember-core/serializers/application';
+import { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
+
+export default class CompanySerializer extends ApplicationSerializer.extend(EmbeddedRecordsMixin) {
+ /**
+ * Embedded relationship attributes
+ *
+ * @var {Object}
+ */
+ get attrs() {
+ return {
+ owner: { embedded: 'always' }
+ };
+ }
+}
diff --git a/console/app/templates/console/admin/organizations/index.hbs b/console/app/templates/console/admin/organizations/index.hbs
index ba9dc601..8ca3c725 100644
--- a/console/app/templates/console/admin/organizations/index.hbs
+++ b/console/app/templates/console/admin/organizations/index.hbs
@@ -1,15 +1,15 @@
{{page-title (t "console.admin.organizations.index.title")}}
-<Layout::Section::Header @title={{t "console.admin.organizations.index.title"}} @searchQuery={{this.query}} @onSearch={{perform this.search}} />
+<Layout::Section::Header @title={{t "console.admin.organizations.index.title"}} @searchQuery={{this.query}} @onSearch={{fn (noop)}} />
<Layout::Section::Body>
<Table
- @rows={{this.companies}}
+ @rows={{@model}}
@columns={{this.columns}}
@selectable={{true}}
@canSelectAll={{true}}
@onSetup={{fn (mut this.table)}}
@pagination={{true}}
- @paginationMeta={{this.companies}}
+ @paginationMeta={{@model.meta}}
@page={{this.page}}
@onPageChange={{fn (mut this.page)}}
@tfootVerticalOffset="53"
diff --git a/console/tests/unit/serializers/company-test.js b/console/tests/unit/serializers/company-test.js
new file mode 100644
index 00000000..205c8de8
--- /dev/null
+++ b/console/tests/unit/serializers/company-test.js
@@ -0,0 +1,24 @@
+import { module, test } from 'qunit';
+
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Serializer | company', function (hooks) {
+ setupTest(hooks);
+
+ // Replace this with your real tests.
+ test('it exists', function (assert) {
+ let store = this.owner.lookup('service:store');
+ let serializer = store.serializerFor('company');
+
+ assert.ok(serializer);
+ });
+
+ test('it serializes records', function (assert) {
+ let store = this.owner.lookup('service:store');
+ let record = store.createRecord('company', {});
+
+ let serializedRecord = record.serialize();
+
+ assert.ok(serializedRecord);
+ });
+});
diff --git a/console/translations/en-us.yaml b/console/translations/en-us.yaml
index a054d12c..59f82104 100644
--- a/console/translations/en-us.yaml
+++ b/console/translations/en-us.yaml
@@ -232,6 +232,10 @@ console:
organizations:
index:
title: Organizations
+ owner-name-column: Owner
+ owner-phone-column: Owner Phone
+ owner-email-column: Owner Phone
+ users-count-column: Users
phone-column: Phone
email-column: Email
users: