3 * Copyright 2017 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 import rw
from 'utils/rw'
19 import modelActions
from './modelActions'
20 import Utils
from 'utils/utils'
21 import $ from 'jquery';
24 loadModel: function () {
26 remote: function (state
, path
) {
27 return new Promise(function (resolve
, reject
) {
29 url
: '/model?path=' + path
,
31 success: function (result
) {
34 error: function (xhr
, errorType
, errorMessage
) {
35 console
.log("There was an error updating the model: ", errorType
, errorMessage
, xhr
);
36 reject({response
: xhr
.responseJSON
, errorType
, errorMessage
});
41 success
: modelActions
.processRequestSuccess
,
42 loading
: modelActions
.processRequestInitiated
,
43 error
: modelActions
.processRequestFailure
46 updateModel: function () {
48 remote: function (state
, path
, data
) {
49 const url
= path
.reduce((url
, node
) => {
50 url
+= node
[0] !== '[' ? '/' : '';
52 }, `/model?path=/${state.path}`);
53 return new Promise(function (resolve
, reject
) {
58 success: function (result
) {
61 error: function (xhr
, errorType
, errorMessage
) {
62 console
.log("There was an error updating the model: ", errorType
, errorMessage
, xhr
);
63 reject({response
: xhr
.responseJSON
, errorType
, errorMessage
});
68 success
: modelActions
.processRequestSuccess
,
69 loading
: modelActions
.processRequestInitiated
,
70 error
: modelActions
.processRequestFailure
73 createModel: function () {
75 remote: function (state
, path
, data
) {
76 const url
= path
.reduce((url
, node
) => {
77 url
+= node
[0] !== '[' ? '/' : '';
79 }, `/model?path=/${state.path}`);
80 return new Promise(function (resolve
, reject
) {
85 success: function (result
) {
88 error: function (xhr
, errorType
, errorMessage
) {
89 console
.log("There was an error updating the model: ", errorType
, errorMessage
, xhr
);
90 reject({response
: xhr
.responseJSON
, errorType
, errorMessage
});
95 success
: modelActions
.processRequestSuccess
,
96 loading
: modelActions
.processRequestInitiated
,
97 error
: modelActions
.processRequestFailure
101 deleteModel: function () {
103 remote: function (state
, path
) {
104 const url
= path
.reduce((url
, node
) => {
105 url
+= node
[0] !== '[' ? '/' : '';
107 }, `/model?path=/${state.path}`);
108 return new Promise(function (resolve
, reject
) {
112 success: function (result
) {
115 error: function (xhr
, errorType
, errorMessage
) {
116 console
.log("There was an error updating the model: ", errorType
, errorMessage
, xhr
);
117 reject({response
: xhr
.responseJSON
, errorType
, errorMessage
});
122 success
: modelActions
.processRequestSuccess
,
123 loading
: modelActions
.processRequestInitiated
,
124 error
: modelActions
.processRequestFailure
128 module
.exports
= source
;