Skip to content
Snippets Groups Projects
Verified Commit 079e2b0f authored by Marc Hanisch's avatar Marc Hanisch
Browse files

moves color info of actions into the classes

parent 4317a99f
No related branches found
No related tags found
2 merge requests!104Load and save Generic Device Actions,!93Actions UI for devices
......@@ -67,7 +67,7 @@ permissions and limitations under the Licence.
<v-timeline-item
v-for="(action, index) in actions"
:key="action.id"
:color="getActionColor(action)"
:color="action.getColor()"
class="mb-4"
small
>
......@@ -395,7 +395,11 @@ const toUtcDate = (dt: DateTime) => {
return dt.toUTC().toFormat('yyyy-MM-dd TT')
}
class DeviceSoftwareUpdateAction implements IAction {
interface IColoredAction {
getColor (): string
}
class DeviceSoftwareUpdateAction implements IAction, IColoredAction {
public id: string
public softwareTypeName: string
public softwareTypeUri: string
......@@ -431,9 +435,13 @@ class DeviceSoftwareUpdateAction implements IAction {
get isDeviceSoftwareUpdateAction (): boolean {
return true
}
getColor (): string {
return 'yellow'
}
}
class DeviceCalibrationAction implements IAction {
class DeviceCalibrationAction implements IAction, IColoredAction {
public id: string
public description: string
public currentCalibrationDate: DateTime
......@@ -469,6 +477,10 @@ class DeviceCalibrationAction implements IAction {
get isDeviceCalibrationAction (): boolean {
return true
}
getColor (): string {
return 'brown'
}
}
class DeviceMountAction {
......@@ -510,9 +522,13 @@ class DeviceMountAction {
get isDeviceMountAction (): boolean {
return true
}
getColor (): string {
return 'green'
}
}
class DeviceUnmountAction implements IAction {
class DeviceUnmountAction implements IAction, IColoredAction {
public id: string
public configurationName: string
public endDate: DateTime
......@@ -539,7 +555,20 @@ class DeviceUnmountAction implements IAction {
get isDeviceUnmountAction (): boolean {
return true
}
getColor (): string {
return 'red'
}
}
/**
* extend the original interface by adding the getColor() method
*/
declare module '@/models/GenericAction' {
export interface GenericAction extends IColoredAction {
}
}
GenericAction.prototype.getColor = (): string => 'blue'
@Component({
components: {
......@@ -687,21 +716,6 @@ export default class DeviceActionsPage extends Vue {
return this.$route.params.actionId
}
getActionColor (action: GenericAction | DeviceSoftwareUpdateAction | DeviceCalibrationAction | DeviceMountAction | DeviceUnmountAction) {
switch (true) {
case (action as GenericAction).isGenericAction:
return 'blue'
case (action as DeviceSoftwareUpdateAction).isDeviceSoftwareUpdateAction:
return 'yellow'
case (action as DeviceCalibrationAction).isDeviceCalibrationAction:
return 'brown'
case (action as DeviceMountAction).isDeviceMountAction:
return 'green'
case (action as DeviceUnmountAction).isDeviceUnmountAction:
return 'red'
}
}
get editedAction (): IAction | undefined {
if (!this.actionId) {
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment