Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/postman.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ jobs:
# published image, not the branch under review. The workflow checks this
# repository out at the commit under test and swaps it into the container.
overlay-package: fleetbase/fleetops-api
# v0.7.2 needs core-api 2.0.3, which isn't tagged yet. Link its release branch until it is.
extra-overlays: |
fleetbase/core-api@release/v2.0.3 fleetbase/core-api
secrets: inherit
6 changes: 6 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@

- **Fleet-Ops tables that foreign keys point at can be altered on MySQL 8.4 with `restrict_fk_on_non_standard_key` on.** MySQL 8.4 refuses any change to a table that a foreign key points at through a non-unique key, with `1553 Cannot drop index '<unknown key name>'`. v0.7.1 worked around this for one migration. This release removes the cause: `uuid` is now unique on `devices`, `inspection_forms`, `inspection_submissions`, `order_configs`, `telematics`, `warranties` and `work_orders`. Each column's old index is replaced, so it is not indexed twice. A column that already has a unique or primary key is left alone. A table with duplicate values is skipped and reported, and the migration can be run again once they are removed. Runs on the main and sandbox databases. Storefront's foreign keys to `order_configs` are covered too.

- **Push apps: your own apps send pushes with their own keys.** Settings → **Push Apps** holds each of the organization's own apps (a customer app such as Passenger, a white-label driver app) with its Apple key and Firebase service account. Keys are stored encrypted and never shown again.
- Each push app has a key. An app sends it as `push_app` (and its APNs build as `environment`) to `v1/customers/register-device` or `v1/drivers/register-device`, and that device's Fleet-Ops pushes then go out with the app's own credentials. An unknown key is refused.
- Every Fleet-Ops push (order updates from order config triggers, assigned, dispatched, canceled, completed, pings and the rest) reaches push-app devices this way. Navigator and every device registered without a key keep the install-wide push settings, unchanged.
- **Send test push** checks an app's keys against one device token.

---
## Upgrading

- Requires `fleetbase/core-api` 2.0.3, which adds push apps (the `push_apps` table).
- Run `php artisan migrate` and `php artisan sandbox:migrate`. If a table is reported as having duplicate values, it is skipped. Remove the duplicates, then run the `php artisan migrate:refresh --force --path=…` command the message gives. It rolls back and re-runs only that migration, and lists every other migration as "Migration not found" without touching them.
- No new dependency: the migration doesn't need core-api 2.0.2's migration hook.

Expand Down
2 changes: 2 additions & 0 deletions addon/components/layout/fleet-ops-sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export default class LayoutFleetOpsSidebarComponent extends Component {
this.createItem('menu.map', 'map', 'settings.map', 'fleet-ops view map-settings', 'fleet-ops see map-settings'),
this.createItem('menu.payments', 'cash-register', 'settings.payments', 'fleet-ops view payments', 'fleet-ops see payments'),
this.createItem('menu.notifications', 'bell', 'settings.notifications', 'fleet-ops view notification-settings', 'fleet-ops see notification-settings'),
this.createItem('menu.push-apps', 'mobile-screen', 'settings.push-apps', 'fleet-ops view notification-settings', 'fleet-ops see notification-settings'),
this.createItem('menu.routing', 'route', 'settings.routing', 'fleet-ops view routing-settings', 'fleet-ops see routing-settings'),
this.createItem('menu.dispatch', 'paper-plane', 'settings.dispatch', 'fleet-ops view routing-settings', 'fleet-ops see routing-settings'),
this.createItem('menu.orchestrator', 'circle-nodes', 'settings.orchestrator', 'fleet-ops view routing-settings', 'fleet-ops see routing-settings'),
Expand Down Expand Up @@ -411,6 +412,7 @@ export default class LayoutFleetOpsSidebarComponent extends Component {
'settings.map': 2,
'settings.payments': 3,
'settings.notifications': 4,
'settings.push-apps': 4,
'settings.routing': 5,
'settings.dispatch': 6,
'settings.orchestrator': 7,
Expand Down
157 changes: 157 additions & 0 deletions addon/controllers/settings/push-apps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { task } from 'ember-concurrency';

const P = 'settings.push-apps';
const blankForm = () => ({
name: '',
status: 'active',
apn: { key_id: '', team_id: '', app_bundle_id: '', private_key_content: '', environment: '' },
fcm: { credentials: '', android_channel_id: '' },
});

/**
* The organization's own apps and the APNs and FCM credentials each one's pushes are sent
* with. An app registers devices with its push app key; keys are entered here but never shown
* again, and leaving one empty when editing keeps the saved key.
*/
export default class SettingsPushAppsController extends Controller {
@service fetch;
@service notifications;
@service modalsManager;
@service intl;
@service abilities;

@tracked pushApps = [];
@tracked editing = null;
@tracked form = blankForm();
@tracked error = null;
@tracked testing = null;
@tracked test = { token: '', platform: 'ios', environment: '' };
@tracked testResult = null;

get canUpdate() {
return this.abilities.can('fleet-ops update notification-settings');
}

get environments() {
return [
{ value: '', label: this.intl.t(`${P}.environment-both`) },
{ value: 'production', label: this.intl.t(`${P}.environment-production`) },
{ value: 'sandbox', label: this.intl.t(`${P}.environment-sandbox`) },
];
}

get platforms() {
return [
{ value: 'ios', label: 'iOS' },
{ value: 'android', label: 'Android' },
];
}

get editingApp() {
return this.pushApps.find((app) => app.id === this.editing) ?? null;
}

@task *load() {
try {
const { push_apps } = yield this.fetch.get('fleet-ops/settings/push-apps');
this.pushApps = push_apps ?? [];
} catch (error) {
this.notifications.serverError(error);
}
}

@action add() {
this.editing = 'new';
this.form = blankForm();
this.error = null;
}

@action edit(app) {
this.editing = app.id;
this.error = null;
this.form = {
name: app.name,
status: app.status,
apn: {
key_id: app.apn?.key_id ?? '',
team_id: app.apn?.team_id ?? '',
app_bundle_id: app.apn?.app_bundle_id ?? '',
private_key_content: '',
environment: app.apn?.environment ?? '',
},
fcm: { credentials: '', android_channel_id: app.fcm?.android_channel_id ?? '' },
};
}

@action cancel() {
this.editing = null;
this.error = null;
}

@action set(path, event) {
const value = event?.target ? event.target.value : event;
const [group, field] = path.split('.');
this.form = field ? { ...this.form, [group]: { ...this.form[group], [field]: value } } : { ...this.form, [group]: value };
}

@action toggleStatus(on) {
this.form = { ...this.form, status: on ? 'active' : 'inactive' };
}

@task *save() {
this.error = null;
const isNew = this.editing === 'new';
try {
const { push_app } = isNew ? yield this.fetch.post('fleet-ops/settings/push-apps', this.form) : yield this.fetch.put(`fleet-ops/settings/push-apps/${this.editing}`, this.form);
this.pushApps = isNew ? [...this.pushApps, push_app] : this.pushApps.map((app) => (app.id === push_app.id ? push_app : app));
this.editing = null;
this.notifications.success(this.intl.t(isNew ? `${P}.created` : `${P}.saved`, { name: push_app.name }));
} catch (error) {
this.error = error?.message ?? String(error);
}
}

@action remove(app) {
this.modalsManager.confirm({
title: this.intl.t(`${P}.delete-title`, { name: app.name }),
body: this.intl.t(`${P}.delete-body`, { count: app.devices }),
acceptButtonText: this.intl.t(`${P}.delete`),
acceptButtonScheme: 'danger',
onConfirm: async () => {
try {
await this.fetch.delete(`fleet-ops/settings/push-apps/${app.id}`);
this.pushApps = this.pushApps.filter((item) => item.id !== app.id);
this.notifications.success(this.intl.t(`${P}.deleted`, { name: app.name }));
} catch (error) {
this.notifications.serverError(error);
}
},
});
}

@action openTest(app) {
this.testing = this.testing === app.id ? null : app.id;
this.testResult = null;
this.test = { token: '', platform: app.apn ? 'ios' : 'android', environment: '' };
}

@action setTest(field, event) {
this.test = { ...this.test, [field]: event?.target ? event.target.value : event };
}

@task *sendTest(app) {
this.testResult = null;
try {
const result = yield this.fetch.post(`fleet-ops/settings/push-apps/${app.id}/test`, this.test);
this.testResult = result.sent
? { ok: true, text: this.intl.t(`${P}.test-sent`) }
: { ok: false, text: this.intl.t(`${P}.test-failed`, { reason: result.reason ?? result.status }) };
} catch (error) {
this.testResult = { ok: false, text: error?.message ?? String(error) };
}
}
}
1 change: 1 addition & 0 deletions addon/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export default buildRoutes(function () {
this.route('settings', function () {
this.route('navigator-app');
this.route('notifications');
this.route('push-apps');
this.route('custom-fields');
this.route('avatars');
this.route('routing');
Expand Down
21 changes: 21 additions & 0 deletions addon/routes/settings/push-apps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class SettingsPushAppsRoute extends Route {
@service notifications;
@service hostRouter;
@service abilities;
@service intl;

beforeModel() {
if (this.abilities.cannot('fleet-ops view notification-settings')) {
this.notifications.warning(this.intl.t('common.unauthorized-access'));
return this.hostRouter.transitionTo('console.fleet-ops');
}
}

setupController(controller) {
super.setupController(...arguments);
controller.load.perform();
}
}
11 changes: 11 additions & 0 deletions addon/styles/fleetops-engine.css
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,17 @@ body[data-theme='light'] .flow-activity-link-label-text {
border: 1px solid var(--oc-border);
}

.oc-tag {
display: inline-flex;
align-items: center;
padding: 0.125rem 0.5rem;
border-radius: 9999px;
font-size: 0.75rem;
color: var(--oc-muted);
background: var(--oc-surface);
border: 1px solid var(--oc-border);
}

.oc-flow-events {
display: inline-flex;
align-items: center;
Expand Down
Loading
Loading