2016-10-27 10:02:12 +13:00
|
|
|
|
2016-11-13 12:55:00 +13:00
|
|
|
import * as helpers from '../../helpers'
|
2016-10-27 10:02:12 +13:00
|
|
|
|
2017-07-21 22:56:28 +12:00
|
|
|
export function setSelectedTracks(keys = []){
|
|
|
|
|
if (typeof(keys) === 'string'){
|
|
|
|
|
keys = [keys]
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
type: 'SET_SELECTED_TRACKS',
|
|
|
|
|
keys: keys
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-29 16:25:05 +13:00
|
|
|
export function showContextMenu(data){
|
2017-12-20 16:33:38 +13:00
|
|
|
|
|
|
|
|
// Touchend
|
|
|
|
|
if (data.e.changedTouches){
|
|
|
|
|
data.position_x = data.e.changedTouches[0].clientX;
|
|
|
|
|
data.position_y = data.e.changedTouches[0].clientY;
|
|
|
|
|
|
|
|
|
|
// Touchstart
|
|
|
|
|
} else if (data.e.touches){
|
2017-12-07 16:54:28 +13:00
|
|
|
data.position_x = data.e.touches[0].clientX;
|
|
|
|
|
data.position_y = data.e.touches[0].clientY;
|
2017-12-20 16:33:38 +13:00
|
|
|
|
|
|
|
|
// Click/mousedown/mouseup/etc
|
2017-12-07 16:54:28 +13:00
|
|
|
} else {
|
|
|
|
|
data.position_x = data.e.clientX;
|
|
|
|
|
data.position_y = data.e.clientY;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 10:02:12 +13:00
|
|
|
return {
|
2016-11-09 15:51:38 +13:00
|
|
|
type: 'SHOW_CONTEXT_MENU',
|
2016-10-27 10:02:12 +13:00
|
|
|
data: data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-17 07:16:33 +12:00
|
|
|
export function setSlimMode(slim_mode){
|
|
|
|
|
return {
|
|
|
|
|
type: 'SET_SLIM_MODE',
|
|
|
|
|
slim_mode: slim_mode
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-27 10:02:12 +13:00
|
|
|
export function hideContextMenu(){
|
2016-11-09 15:49:25 +13:00
|
|
|
return {
|
2016-11-09 15:51:38 +13:00
|
|
|
type: 'HIDE_CONTEXT_MENU'
|
2016-11-09 15:49:25 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-29 16:25:05 +13:00
|
|
|
export function showTouchContextMenu(data){
|
|
|
|
|
return {
|
|
|
|
|
type: 'SHOW_TOUCH_CONTEXT_MENU',
|
|
|
|
|
data: data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function hideTouchContextMenu(){
|
|
|
|
|
return {
|
|
|
|
|
type: 'HIDE_TOUCH_CONTEXT_MENU'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
export function lazyLoading(start){
|
2016-11-01 08:57:28 +13:00
|
|
|
return {
|
2016-11-09 15:51:38 +13:00
|
|
|
type: 'LAZY_LOADING',
|
2016-11-01 08:57:28 +13:00
|
|
|
start: start
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
export function toggleSidebar(new_state = 'toggle'){
|
2017-10-21 18:45:55 +13:00
|
|
|
var action = {
|
|
|
|
|
type: 'TOGGLE_SIDEBAR'
|
|
|
|
|
}
|
|
|
|
|
if (new_state != 'toggle'){
|
|
|
|
|
action.new_state = new_state
|
|
|
|
|
}
|
2016-11-30 09:32:46 +13:00
|
|
|
return action
|
2016-11-21 21:46:53 +13:00
|
|
|
}
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
export function dragStart(e, context, from_uri = null, victims, victims_indexes = null){
|
2016-11-10 16:17:10 +13:00
|
|
|
return {
|
|
|
|
|
type: 'DRAG_START',
|
|
|
|
|
context: context,
|
2017-02-15 19:21:42 +13:00
|
|
|
from_uri: from_uri,
|
2016-11-10 16:17:10 +13:00
|
|
|
victims: victims,
|
2016-11-15 17:08:21 +13:00
|
|
|
victims_indexes: victims_indexes,
|
|
|
|
|
start_x: e.clientX,
|
|
|
|
|
start_y: e.clientY
|
2016-11-10 16:17:10 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 17:08:21 +13:00
|
|
|
export function dragActive(){
|
|
|
|
|
return { type: 'DRAG_ACTIVE' }
|
2016-11-10 21:33:23 +13:00
|
|
|
}
|
|
|
|
|
|
2016-11-10 16:17:10 +13:00
|
|
|
export function dragEnd(){
|
|
|
|
|
return { type: 'DRAG_END' }
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
export function set(data){
|
2016-11-21 10:06:25 +13:00
|
|
|
return {
|
2016-12-09 18:47:10 +13:00
|
|
|
type: 'UI_SET',
|
|
|
|
|
data: data
|
2016-11-21 10:06:25 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-18 21:39:03 +13:00
|
|
|
export function getIcon(name){
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
var config = {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
timeout: 15000,
|
|
|
|
|
url: 'assets/icons/'+name+'.svg'
|
|
|
|
|
}
|
|
|
|
|
$.ajax(config).then(
|
|
|
|
|
response => {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: 'ICON_LOADED',
|
|
|
|
|
key: name,
|
|
|
|
|
icon: new XMLSerializer().serializeToString(response)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
(xhr, status, error) => {
|
|
|
|
|
dispatch(
|
|
|
|
|
handleException(
|
|
|
|
|
'Could not load '+name+' icon',
|
|
|
|
|
{
|
|
|
|
|
config: config,
|
|
|
|
|
xhr: xhr,
|
|
|
|
|
status: status,
|
|
|
|
|
error: error
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-02 09:31:05 +12:00
|
|
|
|
|
|
|
|
|
2016-12-13 11:08:13 +13:00
|
|
|
/**
|
|
|
|
|
* Modal
|
|
|
|
|
*
|
|
|
|
|
* Immersive full-screen dialog
|
|
|
|
|
**/
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
export function openModal(name, data){
|
2016-11-11 23:21:51 +13:00
|
|
|
return {
|
|
|
|
|
type: 'OPEN_MODAL',
|
|
|
|
|
modal: {
|
|
|
|
|
name: name,
|
|
|
|
|
data: data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function closeModal(){
|
2017-08-01 14:59:59 +12:00
|
|
|
return {
|
|
|
|
|
type: 'CLOSE_MODAL'
|
|
|
|
|
}
|
2016-11-11 23:21:51 +13:00
|
|
|
}
|
2016-10-27 10:02:12 +13:00
|
|
|
|
2016-12-13 11:08:13 +13:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Notifications
|
|
|
|
|
*
|
|
|
|
|
* Subtle info/tooltip messages
|
|
|
|
|
**/
|
|
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
export function createBrowserNotification(data){
|
2017-02-21 05:46:28 +13:00
|
|
|
return {
|
|
|
|
|
type: 'BROWSER_NOTIFICATION',
|
|
|
|
|
data: data
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 09:35:38 +13:00
|
|
|
// content, type = 'default', key = null, title = null, description = null, sticky = false
|
|
|
|
|
|
|
|
|
|
export function createNotification(data){
|
2016-12-13 11:08:13 +13:00
|
|
|
return {
|
|
|
|
|
type: 'CREATE_NOTIFICATION',
|
2018-02-23 09:35:38 +13:00
|
|
|
notification: Object.assign(
|
|
|
|
|
{
|
|
|
|
|
key: helpers.generateGuid(),
|
2018-02-27 08:44:20 +13:00
|
|
|
duration: 3,
|
2018-02-23 09:35:38 +13:00
|
|
|
type: 'default',
|
|
|
|
|
title: null,
|
|
|
|
|
content: null,
|
|
|
|
|
description: null,
|
|
|
|
|
sticky: false
|
|
|
|
|
},
|
|
|
|
|
data
|
|
|
|
|
)
|
2016-12-13 11:08:13 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 20:28:41 +12:00
|
|
|
export function removeNotification(key){
|
2016-12-13 11:08:13 +13:00
|
|
|
return {
|
|
|
|
|
type: 'REMOVE_NOTIFICATION',
|
2017-04-05 20:28:41 +12:00
|
|
|
key: key
|
2016-12-13 11:08:13 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-06-02 09:31:05 +12:00
|
|
|
|
2017-03-27 14:23:38 +13:00
|
|
|
/**
|
|
|
|
|
* Loaders
|
|
|
|
|
**/
|
2016-12-13 11:08:13 +13:00
|
|
|
|
2017-03-27 14:23:38 +13:00
|
|
|
export function startLoading(key,source){
|
|
|
|
|
return {
|
|
|
|
|
type: 'START_LOADING',
|
|
|
|
|
source: source,
|
|
|
|
|
key: key
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function stopLoading(key){
|
|
|
|
|
return {
|
|
|
|
|
type: 'STOP_LOADING',
|
|
|
|
|
key: key
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-05 20:28:41 +12:00
|
|
|
|
2017-08-11 21:59:14 +12:00
|
|
|
export function startProcess(key,message,data = {}){
|
2017-04-05 20:28:41 +12:00
|
|
|
return {
|
|
|
|
|
type: 'START_PROCESS',
|
2017-04-06 09:01:53 +12:00
|
|
|
key: key,
|
2017-08-11 21:59:14 +12:00
|
|
|
message: message,
|
|
|
|
|
data: data
|
2017-04-05 20:28:41 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 12:40:27 +12:00
|
|
|
export function resumeProcess(key,message,data = {}){
|
|
|
|
|
return {
|
|
|
|
|
type: 'RESUME_PROCESS',
|
|
|
|
|
key: key
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-11 21:59:14 +12:00
|
|
|
export function updateProcess(key,message,data = {}){
|
2017-08-10 16:41:19 +12:00
|
|
|
return {
|
|
|
|
|
type: 'UPDATE_PROCESS',
|
|
|
|
|
key: key,
|
2017-08-11 21:59:14 +12:00
|
|
|
message: message,
|
|
|
|
|
data: data
|
2017-08-10 16:41:19 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-11 21:59:14 +12:00
|
|
|
export function runProcess(key,data = {}){
|
2017-08-10 16:41:19 +12:00
|
|
|
return {
|
2017-08-12 00:02:41 +12:00
|
|
|
type: key,
|
|
|
|
|
data: data
|
2017-08-10 16:41:19 +12:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-05 20:28:41 +12:00
|
|
|
export function cancelProcess(key){
|
|
|
|
|
return {
|
|
|
|
|
type: 'CANCEL_PROCESS',
|
|
|
|
|
key: key
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 16:36:50 +12:00
|
|
|
export function processCancelled(key){
|
|
|
|
|
return {
|
|
|
|
|
type: 'PROCESS_CANCELLED',
|
|
|
|
|
key: key
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-10 16:41:19 +12:00
|
|
|
export function processFinished(key){
|
2017-04-05 20:28:41 +12:00
|
|
|
return {
|
2017-08-10 16:41:19 +12:00
|
|
|
type: 'PROCESS_FINISHED',
|
2017-04-05 20:28:41 +12:00
|
|
|
key: key
|
|
|
|
|
}
|
|
|
|
|
}
|