diff --git a/addon/components/driver-form-panel.hbs b/addon/components/driver-form-panel.hbs new file mode 100644 index 0000000..83e774a --- /dev/null +++ b/addon/components/driver-form-panel.hbs @@ -0,0 +1,131 @@ + + +
+
+ {{#if @driver.id}} +
+
+
+
+
+
+
+
+
+
+ {{@driver.name}} + + + +
+
+

+ {{#if @driver.id}} + {{@driver.name}} + {{else}} + {{#if @driver.name}} + {{@driver.name}} + {{else}} + New Driver + {{/if}} + {{/if}} +

+
+ {{#if @driver.vehicle}} +
+ {{@driver.vehicle.displayName}} +
+ {{else}} +
+ No vehicle assigned +
+ {{/if}} +
+
+
+
+
+ +
+
+
+ + +
+
+
+ + +
+
+ +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + {{model.name}} + +
+ +
+ + + {{model.display_name}} + +
+ +
+ + +
+ +
+ + +
+
+
+
+
\ No newline at end of file diff --git a/addon/components/driver-form-panel.js b/addon/components/driver-form-panel.js new file mode 100644 index 0000000..f4119f8 --- /dev/null +++ b/addon/components/driver-form-panel.js @@ -0,0 +1,39 @@ +import Component from '@glimmer/component'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; + +export default class DriverFormPanelComponent extends Component { + @service store; + @service notifications; + @service hostRouter; + @service loader; + + @action save() { + const { driver, onAfterSave } = this.args; + + this.loader.showLoader('.overlay-inner-content', 'Saving driver...'); + + try { + return driver + .save() + .then((vehicle) => { + this.notifications.success(`Driver (${driver.name}) saved successfully.`); + + if (typeof onAfterSave === 'function') { + onAfterSave(vehicle); + } + }) + .catch(this.notifications.serverError) + .finally(() => { + this.loader.removeLoader(); + }); + } catch (error) { + this.loader.removeLoader(); + } + } + + @action viewDetails() { + const { driver } = this.args; + return this.hostRouter.transitionTo('console.fleet-ops.management.drivers.index.details', driver.public_id); + } +} diff --git a/addon/components/driver-panel.hbs b/addon/components/driver-panel.hbs new file mode 100644 index 0000000..a8fc671 --- /dev/null +++ b/addon/components/driver-panel.hbs @@ -0,0 +1,60 @@ + + +
+
+ {{!--
+
+
+
+
+
+
+
+ {{@driver.name}} + + + +
+
+

{{@driver.name}}

+
+ {{#if @driver.vehicle}} +
+ {{@driver.vehicle.displayName}} +
+ {{else}} +
+ No vehicle assigned + {{!--
+ {{/if}} +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+
+ {{component this.tab.component driver=@driver tabOptions=this.tab params=this.tab.componentParams}} +
+
+
\ No newline at end of file diff --git a/addon/components/driver-panel.js b/addon/components/driver-panel.js new file mode 100644 index 0000000..182830c --- /dev/null +++ b/addon/components/driver-panel.js @@ -0,0 +1,57 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { action, computed } from '@ember/object'; +import { inject as service } from '@ember/service'; +import { isArray } from '@ember/array'; +import DriverPanelDetailComponent from './driver-panel/details'; + +export default class DriverPanelComponent extends Component { + @service fetch; + @service modalsManager; + @service universe; + @service store; + @service hostRouter; + @tracked currentTab; + @tracked devices = []; + @tracked deviceApi = {}; + @tracked vehicle; + + get tabs() { + const registeredTabs = this.universe.getMenuItemsFromRegistry('component:driver-panel'); + // this.universe._createMenuItem('Tracking', null, { icon: 'satellite-dish', component: DriverPanelTrackingComponent }), + const defaultTabs = [this.universe._createMenuItem('Details', null, { icon: 'circle-info', component: DriverPanelDetailComponent })]; + + if (isArray(registeredTabs)) { + return [...defaultTabs, ...registeredTabs]; + } + + return defaultTabs; + } + + @computed('currentTab', 'tabs') get tab() { + if (this.currentTab) { + return this.tabs.find(({ slug }) => slug === this.currentTab); + } + + return null; + } + + constructor() { + super(...arguments); + this.vehicle = this.args.vehicle; + this.changeTab(this.args.tab || 'details'); + } + + @action async changeTab(tab) { + this.currentTab = tab; + + if (typeof this.args.onTabChanged === 'function') { + this.args.onTabChanged(tab); + } + } + + @action editDriver() { + const { driver } = this.args; + return this.hostRouter.transitionTo('console.fleet-ops.management.drivers.index.edit', driver.public_id); + } +} diff --git a/addon/components/driver-panel/details.hbs b/addon/components/driver-panel/details.hbs new file mode 100644 index 0000000..729a9e3 --- /dev/null +++ b/addon/components/driver-panel/details.hbs @@ -0,0 +1,48 @@ +
+ +
+
+
Name
+
{{n-a @driver.name}}
+
+
+
ID
+
{{n-a @driver.public_id}}
+
+
+
Internal ID
+
{{n-a @driver.internal_id}}
+
+
+
Drivers License
+
{{n-a @driver.drivers_license}}
+
+
+
Email
+
{{n-a @driver.email}}
+
+
+
Phone
+
{{n-a @driver.phone}}
+
+
+
Current Job
+
{{n-a @driver.current_job_id}}
+
+
+
City
+
{{n-a @driver.city}}
+
+ {{!--
+
Country
+
+ +
+
--}} +
+
Coordinates
+
{{point-coordinates @driver.location}}
+
+
+
+
\ No newline at end of file diff --git a/addon/components/fleet-form-panel.hbs b/addon/components/fleet-form-panel.hbs new file mode 100644 index 0000000..8d36c81 --- /dev/null +++ b/addon/components/fleet-form-panel.hbs @@ -0,0 +1,46 @@ + + + {{#if @fleet.id}} +