mirror of
https://github.com/fleetbase/fleetbase.git
synced 2026-01-08 07:16:49 +00:00
fixed default dashboard actions and remove widget function
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
<DropdownButton
|
||||
class="h-10"
|
||||
@text="Select Dashboard"
|
||||
@text={{if this.dashboard.currentDashboard.name this.dashboard.currentDashboard.name "Select Dashboard"}}
|
||||
@textClass="text-sm mr-2"
|
||||
@buttonClass="flex-row-reverse"
|
||||
@icon="caret-down"
|
||||
@@ -45,19 +45,29 @@
|
||||
</div>
|
||||
<span>Create new Dashboard</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.onChangeEdit true)}}>
|
||||
<div class="w-6">
|
||||
<FaIcon @icon="edit" />
|
||||
</div>
|
||||
<span>Edit dashboard</span>
|
||||
</a>
|
||||
|
||||
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.deleteDashboard this.dashboard.currentDashboard)}}>
|
||||
<div class="w-6">
|
||||
<FaIcon @icon="trash" />
|
||||
</div>
|
||||
<span>Delete dashboard</span>
|
||||
</a>
|
||||
{{#unless (eq this.dashboard.currentDashboard.owner_uuid "system")}}
|
||||
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.onChangeEdit true)}}>
|
||||
<div class="w-6">
|
||||
<FaIcon @icon="edit" />
|
||||
</div>
|
||||
<span>Edit layout</span>
|
||||
</a>
|
||||
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.onAddingWidget true)}}>
|
||||
<div class="w-6">
|
||||
<FaIcon @icon="add" />
|
||||
</div>
|
||||
<span>Add widgets</span>
|
||||
</a>
|
||||
|
||||
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.deleteDashboard this.dashboard.currentDashboard)}}>
|
||||
<div class="w-6">
|
||||
<FaIcon @icon="trash" />
|
||||
</div>
|
||||
<span>Delete dashboard</span>
|
||||
</a>
|
||||
{{/unless}}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</DropdownButton>
|
||||
@@ -71,11 +81,11 @@
|
||||
</div>
|
||||
|
||||
<div class="px-10">
|
||||
<Dashboard::Create @isEdit={{this.dashboard.isEditingDashboard}} @dashboard={{this.dashboard.currentDashboard}} />
|
||||
{{#if this.dashboard.isEditingDashboard}}
|
||||
<Dashboard::Create @isEdit={{this.dashboard.isEditingDashboard}} @isAddingWidget={{this.dashboard.isAddingWidget}} @dashboard={{this.dashboard.currentDashboard}} />
|
||||
{{#if this.dashboard.isAddingWidget}}
|
||||
<EmberWormhole @to="console-home-wormhole">
|
||||
<Dashboard::WidgetPanel
|
||||
@isOpen={{this.dashboard.isEditingDashboard}}
|
||||
@isOpen={{this.dashboard.isAddingWidget}}
|
||||
@onLoad={{this.setWidgetSelectorPanelContext}}
|
||||
@dashboard={{this.dashboard.currentDashboard}}
|
||||
@onClose={{fn this.onChangeEdit false}}
|
||||
|
||||
@@ -77,4 +77,8 @@ export default class DashboardComponent extends Component {
|
||||
onChangeEdit(state = true) {
|
||||
this.dashboard.onChangeEdit(state);
|
||||
}
|
||||
|
||||
onAddingWidget(state = true) {
|
||||
this.dashboard.onAddingWidget(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@ import { helper } from '@ember/component/helper';
|
||||
|
||||
export default helper(function spreadWidgetOptions([params]) {
|
||||
const { id, options } = params;
|
||||
return { id, ...options };
|
||||
const gridOptions = { id, ...options };
|
||||
return gridOptions;
|
||||
});
|
||||
|
||||
@@ -66,27 +66,25 @@ export default class DashboardModel extends Model {
|
||||
});
|
||||
}
|
||||
|
||||
/** @methods */
|
||||
addWidget(widget) {
|
||||
removeWidget(widget) {
|
||||
const owner = getOwner(this);
|
||||
const store = owner.lookup('service:store');
|
||||
|
||||
const widgetRecord = store.createRecord('dashboard-widget', widget);
|
||||
const widgetRecord = store.peekRecord('dashboard-widget', widget);
|
||||
|
||||
widgetRecord.dashboard = this;
|
||||
console.log(widgetRecord);
|
||||
return new Promise((resolve, reject) => {
|
||||
widgetRecord
|
||||
.save()
|
||||
.then((widgetRecord) => {
|
||||
this.widgets.pushObject(widgetRecord);
|
||||
resolve(widgetRecord);
|
||||
})
|
||||
.catch((error) => {
|
||||
store.unloadRecord(widgetRecord);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
if (widgetRecord) {
|
||||
return new Promise((resolve, reject) => {
|
||||
widgetRecord
|
||||
.destroyRecord()
|
||||
.then(() => {
|
||||
this.widgets.removeObject(widgetRecord);
|
||||
resolve();
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updateWidget(widget) {
|
||||
|
||||
@@ -35,6 +35,10 @@ export default class DashboardService extends Service {
|
||||
|
||||
@task *selectDashboard(dashboard) {
|
||||
try {
|
||||
if (dashboard.owner_uuid === 'system') {
|
||||
this.currentDashboard = dashboard;
|
||||
return;
|
||||
}
|
||||
const response = yield this.fetch.post('dashboards/switch', { dashboard_uuid: dashboard.id });
|
||||
this.store.pushPayload(response);
|
||||
const selectedDashboardId = response.uuid;
|
||||
@@ -107,6 +111,7 @@ export default class DashboardService extends Service {
|
||||
const defaultDashboard = this.store.createRecord('dashboard', {
|
||||
name: 'Default Dashboard',
|
||||
is_default: false,
|
||||
owner_uuid: 'system',
|
||||
widgets: this._createDefaultDashboardWidgets(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user