import { Action } from '@ngrx/store';

import { IItemTypes } from '../models/item.types';
import { IListItem } from '../models/list.item';
import { IUser } from '../models/user';
import { IItem } from '../models/item';
import { UserInfo } from 'angular-oauth2-oidc';

export const INITUSER = '[AppCommon] InitUser';
export const INITUSERSUCCESS = '[AppCommon] InitUserSuccess';

export const INITUSERPACKAGES = '[AppCommon] InitUserPackages';
export const INITUSERPACKAGESSUCCESS = '[AppCommon] InitUserPackagesSuccess';

export const INITPACKAGES = '[AppCommon] InitPackages';
export const INITPACKAGESSUCCESS = '[AppCommon] InitPackagesSuccess';

export const INITUSERSETTINGSROOT = '[AppCommon] InitUserSettingsRoot';
export const INITUSERSETTINGSROOTSUCCESS = '[AppCommon] InitUserSettingsRootSuccess';

export const INITROOT = '[Explorer] InitRoot';
export const INITROOTSUCCESS = '[Explorer] InitRootSuccess';

export const OPENMODAL = '[AppCommon] OpenModal';
export const CLOSEMODAL = '[AppCommon] CloseModal';
export const LOGIN = '[AppCommon] Login';
export const LOGOUT = '[AppCommon] Logout';
export const ESCAPE = '[AppCommon] Escape';
export const CLOSEALL = '[AppCommon] CloseAll';

export const LOADITEMTYPES = '[AppCommon] LoadItemTypes';
export const LOADITEMTYPESSUCCESS = '[AppCommon] LoadItemTypesSuccess';

export const ITEMCHANGEDEVENT = '[AppCommon] ItemChangedEvent';
export const ITEMADDEDEVENT = '[AppCommon] ItemAddedEvent';
export const ITEMDELETEDEVENT = '[AppCommon] ItemDeletedEvent';

export const TASKSTARTEVENT = '[AppCommon] TaskStartEvent';
export const TASKENDEVENT = '[AppCommon] TaskEndEvent';
export const TASKERROREVENT = '[AppCommon] TaskErrorEvent';
export const TASKPROGRESSEVENT = '[AppCommon] TaskProgressEvent';

export const DEVICEUPDATEEVENT = '[AppCommon] DeviceUpdateEvent';

export const NOTIFICATIONEVENT = '[AppCommon] NotificationEvent';

export const DELETEITEMS = '[AppCommon] DeleteItems';
export const DELETEITEMSSUCCESS = '[AppCommon] DeleteItemsSuccess';

export const STARTROUTELOADING = '[AppCommon] StartRouteLoading';
export const ENDROUTELOADING = '[AppCommon] EndRouteLoading';

export const FULLSCREEN = '[AppCommon] FullScreen';
export const SHOWNAVBAR = '[AppCommon] ShowNavBar';

export const EDITITEM = "[AppCommon] EditItem";

export const VIEWITEM = "[AppCommon] ViewItem";

export const FAIL = '[AppCommon] Fail';

export const UPLOADEDFILECLICK = '[AppCommon] UploadedFileClick';

export const TOGGLEMENU = '[AppCommon] ToggleMenu';

export const TOGGLEACCOUNTMENU = '[AppCommon] ToggleAccountMenu';

export const TOGGLEAPPMENU = '[AppCommon] ToggleAppMenu';

export const TOGGLENOTIFICATIONMENU = '[AppCommon] ToggleNotificationMenu';

export const TOGGLEHELPMENU = '[AppCommon] ToggleHelpMenu';

export const TOGGLESETTINGMENU = '[AppCommon] ToggleSettingMenu';

export const SETMENUVISIBLE = '[AppCommon] SetMenuVisible';

export const ONLINE = '[AppCommon] Online';

export const OFFLINE = '[AppCommon] Offline';

export const SETPAGEMODE = '[AppCommon] SetPageMode';

export const SETUNREADNOTIFICATIONS = '[AppCommon] SetUnreadNotifications';

export const SWITCHLANGUAGE = '[AppCommon] SwitchLanguage';

export const SETSETTINGMENUBACKGROUNDCOLOR = '[AppCommon] SetSettingMenuBackgroundColor';


export class InitUser implements Action {
  readonly type = INITUSER;

  constructor() { }
}

export class InitUserSuccess implements Action {
  readonly type = INITUSERSUCCESS;

  constructor(public user:IUser,public userinfo:UserInfo ) { }
}

export class InitUserPackages implements Action {
  readonly type = INITUSERPACKAGES;

  constructor() {}
}

export class InitUserPackagesSuccess implements Action {
  readonly type = INITUSERPACKAGESSUCCESS;

  constructor(public items:IItem[] ) { }
}

export class InitPackages implements Action {
  readonly type = INITPACKAGES;

  constructor() {}
}

export class InitPackagesSuccess implements Action {
  readonly type = INITPACKAGESSUCCESS;

  constructor(public items:IItem[] ) { }
}

export class InitUserSettingsRoot implements Action {
  readonly type = INITUSERSETTINGSROOT;

  constructor() {}
}

export class InitUserSettingsRootSuccess implements Action {
  readonly type = INITUSERSETTINGSROOTSUCCESS;

  constructor(public item: IListItem ) { }
}

export class InitRoot implements Action {
  readonly type = INITROOT;

  constructor() { }
}

export class InitRootSuccess implements Action {
  readonly type = INITROOTSUCCESS;

  constructor(public items:IListItem[]) { }
}

export class OpenModal implements Action {
  readonly type = OPENMODAL;

  constructor(public modalName: string) { }
}

export class CloseModal implements Action {
  readonly type = CLOSEMODAL;

  constructor() { }
}

export class CloseAll implements Action {
  readonly type = CLOSEALL;

  constructor() { }
}

export class StartRouteLoading implements Action {
  readonly type = STARTROUTELOADING;

  constructor() { }
}

export class EndRouteLoading implements Action {
  readonly type = ENDROUTELOADING;

  constructor() { }
}

export class Login implements Action {
  readonly type = LOGIN;

  constructor(public url: string) { }
}

export class Logout implements Action {
  readonly type = LOGOUT;

  constructor() { }
}

export class Escape implements Action {
  readonly type = ESCAPE;

  constructor(public escapeKey:boolean, public click:boolean) { }
}

export class LoadItemTypes implements Action {
  readonly type = LOADITEMTYPES;

  constructor() { }
}

export class LoadItemTypesSuccess implements Action {
  readonly type = LOADITEMTYPESSUCCESS;

  constructor(public itemTypes: IItemTypes) { }
}

export class Fail implements Action {
  readonly type = FAIL;

  constructor(public payload: string) { }
}

export class ItemChangedEvent implements Action {
  readonly type = ITEMCHANGEDEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class ItemAddedEvent implements Action {
  readonly type = ITEMADDEDEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class ItemDeletedEvent implements Action {
  readonly type = ITEMDELETEDEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class TaskStartEvent implements Action {
  readonly type = TASKSTARTEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class TaskEndEvent implements Action {
  readonly type = TASKENDEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class TaskErrorEvent implements Action {
  readonly type = TASKERROREVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class TaskProgressEvent implements Action {
  readonly type = TASKPROGRESSEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class DeviceUpdateEvent implements Action {
  readonly type = DEVICEUPDATEEVENT;

  constructor(public itemCode: string, public attributes: any) { }
}

export class NotificationEvent implements Action {
  readonly type = NOTIFICATIONEVENT;

  constructor(public attributes: any) { }
}

export class DeleteItems implements Action {
  readonly type = DELETEITEMS;

  constructor(public itemCodes: string[]) { }
}

export class DeleteItemsSuccess implements Action {
  readonly type = DELETEITEMSSUCCESS;

  constructor(public deletedItemCodes: string[]) { }
}

export class EditItem implements Action {
  readonly type = EDITITEM;

  constructor(public item: IListItem) { }
}

export class ViewItem implements Action {
  readonly type = VIEWITEM;

  constructor(public item: IListItem) { }
}

export class FullScreen implements Action {
  readonly type = FULLSCREEN;

  constructor() { }
}

export class ShowNavBar implements Action {
  readonly type = SHOWNAVBAR;

  constructor() { }
}

export class UploadedFileClick implements Action {
  readonly type = UPLOADEDFILECLICK;
  constructor(public itemCode:string) { }
}

export class ToggleMenu implements Action {
  readonly type = TOGGLEMENU;

  constructor() { }
}

export class ToggleAccountMenu implements Action {
  readonly type = TOGGLEACCOUNTMENU;

  constructor() { }
}

export class ToggleAppMenu implements Action {
  readonly type = TOGGLEAPPMENU;

  constructor() { }
}

export class ToggleNotificationMenu implements Action {
  readonly type = TOGGLENOTIFICATIONMENU;

  constructor() { }
}

export class ToggleHelpMenu implements Action {
  readonly type = TOGGLEHELPMENU;

  constructor() { }
}

export class ToggleSettingMenu implements Action {
  readonly type = TOGGLESETTINGMENU;

  constructor() { }
}

export class SetMenuVisible implements Action {
  readonly type = SETMENUVISIBLE;

  constructor(public visible:boolean) { }
}

export class Online implements Action {
  readonly type = ONLINE;

  constructor() { }
}

export class Offline implements Action {
  readonly type = OFFLINE;

  constructor() { }
}

export class SetPageMode implements Action {
  readonly type = SETPAGEMODE;

  constructor(public pageMode:boolean) {}
}

export class SetUnreadNotifications implements Action {
  readonly type = SETUNREADNOTIFICATIONS;

  constructor(public unread:number) {}

}
  
export class SwitchLanguage implements Action {
  readonly type = SWITCHLANGUAGE;

  constructor(public locale:string) { }
}

export class SetSettingMenuBackgroundColor implements Action {
  readonly type = SETSETTINGMENUBACKGROUNDCOLOR;

  constructor(public color:string) { }
}

export type Actions = OpenModal
  | InitRoot
  | InitRootSuccess
  | CloseModal
  | Login
  | Logout
  | ItemChangedEvent
  | ItemAddedEvent
  | ItemDeletedEvent
  | Escape
  | LoadItemTypes
  | LoadItemTypesSuccess
  | DeleteItems
  | DeleteItemsSuccess
  | Fail
  | EditItem
  | ViewItem
  | FullScreen
  | ShowNavBar
  | StartRouteLoading
  | EndRouteLoading
  | InitUser
  | InitUserSuccess
  | TaskStartEvent
  | TaskEndEvent
  | TaskErrorEvent
  | TaskProgressEvent
  | DeviceUpdateEvent
  | ToggleMenu
  | SetMenuVisible
  | InitUserPackages
  | InitUserPackagesSuccess
  | InitPackages
  | InitPackagesSuccess
  | InitUserSettingsRoot
  | InitUserSettingsRootSuccess
  | ToggleAccountMenu
  | CloseAll
  | Online
  | Offline
  | SetPageMode
  | ToggleAppMenu
  | ToggleNotificationMenu
  | ToggleHelpMenu
  | ToggleSettingMenu
  | NotificationEvent
  | SetUnreadNotifications
  | SwitchLanguage
  | SetSettingMenuBackgroundColor;


