Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
jio
Commits
d1895b24
Commit
d1895b24
authored
Nov 06, 2017
by
Aurélien Vermylen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests pass (except usual CryptStorage and stringify) and build.
parent
0e69426d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1286 additions
and
890 deletions
+1286
-890
dist/jio-v3.23.1.min.js
dist/jio-v3.23.1.min.js
+1
-1
dist/nodejs/jio.js
dist/nodejs/jio.js
+1251
-845
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+34
-44
No files found.
dist/jio-v3.23.1.min.js
View file @
d1895b24
This diff is collapsed.
Click to expand it.
dist/nodejs/jio.js
View file @
d1895b24
This diff is collapsed.
Click to expand it.
src/jio.storage/erp5storage.js
View file @
d1895b24
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
/*jslint nomen: true, unparam: true */
/*jslint nomen: true, unparam: true */
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob,
/*global jIO, UriTemplate, FormData, RSVP, URI, Blob,
SimpleQuery, ComplexQuery
, btoa
*/
SimpleQuery, ComplexQuery*/
(
function
(
jIO
,
UriTemplate
,
FormData
,
RSVP
,
URI
,
Blob
,
(
function
(
jIO
,
UriTemplate
,
FormData
,
RSVP
,
URI
,
Blob
,
SimpleQuery
,
ComplexQuery
)
{
SimpleQuery
,
ComplexQuery
)
{
...
@@ -24,9 +24,8 @@
...
@@ -24,9 +24,8 @@
"
type
"
:
"
GET
"
,
"
type
"
:
"
GET
"
,
"
url
"
:
storage
.
_url
,
"
url
"
:
storage
.
_url
,
"
xhrFields
"
:
{
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
withCredentials
:
true
},
}
"
headers
"
:
storage
.
_headers
});
});
})
})
.
push
(
function
(
event
)
{
.
push
(
function
(
event
)
{
...
@@ -51,9 +50,8 @@
...
@@ -51,9 +50,8 @@
view
:
options
.
_view
view
:
options
.
_view
}),
}),
"
xhrFields
"
:
{
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
withCredentials
:
true
},
}
"
headers
"
:
storage
.
_headers
});
});
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
...
@@ -130,8 +128,8 @@
...
@@ -130,8 +128,8 @@
});
});
}
}
function
extractPropertyFromForm
(
storage
,
id
)
{
function
extractPropertyFromForm
(
context
,
id
)
{
return
storage
.
getAttachment
(
id
,
"
view
"
)
return
context
.
getAttachment
(
id
,
"
view
"
)
.
push
(
function
(
blob
)
{
.
push
(
function
(
blob
)
{
return
jIO
.
util
.
readBlobAsText
(
blob
);
return
jIO
.
util
.
readBlobAsText
(
blob
);
})
})
...
@@ -151,17 +149,20 @@
...
@@ -151,17 +149,20 @@
}
}
this
.
_url
=
spec
.
url
;
this
.
_url
=
spec
.
url
;
this
.
_default_view_reference
=
spec
.
default_view_reference
;
this
.
_default_view_reference
=
spec
.
default_view_reference
;
this
.
_headers
=
null
;
this
.
_thisCredentials
=
true
;
if
(
spec
.
login
!==
undefined
&&
spec
.
password
!==
undefined
)
{
this
.
_headers
=
{
"
Authorization
"
:
"
Basic
"
+
btoa
(
spec
.
login
+
"
:
"
+
spec
.
password
)};
this
.
_thisCredentials
=
false
;
}
}
}
function
convertJSONToGet
(
json
)
{
function
convertJSONToGet
(
json
)
{
return
json
.
data
;
var
key
,
result
=
json
.
data
;
// Remove all ERP5 hateoas links / convert them into jIO ID
for
(
key
in
result
)
{
if
(
result
.
hasOwnProperty
(
key
))
{
if
(
!
result
[
key
])
{
delete
result
[
key
];
}
}
}
return
result
;
}
}
ERP5Storage
.
prototype
.
get
=
function
(
id
)
{
ERP5Storage
.
prototype
.
get
=
function
(
id
)
{
...
@@ -172,7 +173,7 @@
...
@@ -172,7 +173,7 @@
};
};
ERP5Storage
.
prototype
.
post
=
function
(
data
)
{
ERP5Storage
.
prototype
.
post
=
function
(
data
)
{
var
storage
=
this
,
var
context
=
this
,
new_id
;
new_id
;
return
getSiteDocument
(
this
)
return
getSiteDocument
(
this
)
...
@@ -185,16 +186,15 @@
...
@@ -185,16 +186,15 @@
url
:
site_hal
.
_actions
.
add
.
href
,
url
:
site_hal
.
_actions
.
add
.
href
,
data
:
form_data
,
data
:
form_data
,
xhrFields
:
{
xhrFields
:
{
withCredentials
:
storage
.
_thisCredentials
withCredentials
:
true
},
}
"
headers
"
:
storage
.
_headers
});
});
})
})
.
push
(
function
(
evt
)
{
.
push
(
function
(
evt
)
{
var
location
=
evt
.
target
.
getResponseHeader
(
"
X-Location
"
),
var
location
=
evt
.
target
.
getResponseHeader
(
"
X-Location
"
),
uri
=
new
URI
(
location
);
uri
=
new
URI
(
location
);
new_id
=
uri
.
segment
(
2
);
new_id
=
uri
.
segment
(
2
);
return
storage
.
put
(
new_id
,
data
);
return
context
.
put
(
new_id
,
data
);
})
})
.
push
(
function
()
{
.
push
(
function
()
{
return
new_id
;
return
new_id
;
...
@@ -202,9 +202,9 @@
...
@@ -202,9 +202,9 @@
};
};
ERP5Storage
.
prototype
.
put
=
function
(
id
,
data
)
{
ERP5Storage
.
prototype
.
put
=
function
(
id
,
data
)
{
var
storage
=
this
;
var
context
=
this
;
return
extractPropertyFromForm
(
storage
,
id
)
return
extractPropertyFromForm
(
context
,
id
)
.
push
(
function
(
result
)
{
.
push
(
function
(
result
)
{
var
key
,
var
key
,
json
=
result
.
form_data
,
json
=
result
.
form_data
,
...
@@ -237,7 +237,7 @@
...
@@ -237,7 +237,7 @@
403
403
);
);
}
}
return
storage
.
putAttachment
(
return
context
.
putAttachment
(
id
,
id
,
result
.
action_href
,
result
.
action_href
,
new
Blob
([
JSON
.
stringify
(
form_data
)],
{
type
:
"
application/json
"
})
new
Blob
([
JSON
.
stringify
(
form_data
)],
{
type
:
"
application/json
"
})
...
@@ -246,10 +246,10 @@
...
@@ -246,10 +246,10 @@
};
};
ERP5Storage
.
prototype
.
allAttachments
=
function
(
id
)
{
ERP5Storage
.
prototype
.
allAttachments
=
function
(
id
)
{
var
storage
=
this
;
var
context
=
this
;
return
getDocumentAndHateoas
(
this
,
id
)
return
getDocumentAndHateoas
(
this
,
id
)
.
push
(
function
()
{
.
push
(
function
()
{
if
(
storage
.
_default_view_reference
===
undefined
)
{
if
(
context
.
_default_view_reference
===
undefined
)
{
return
{
return
{
links
:
{}
links
:
{}
};
};
...
@@ -262,7 +262,6 @@
...
@@ -262,7 +262,6 @@
};
};
ERP5Storage
.
prototype
.
getAttachment
=
function
(
id
,
action
,
options
)
{
ERP5Storage
.
prototype
.
getAttachment
=
function
(
id
,
action
,
options
)
{
var
storage
=
this
;
if
(
options
===
undefined
)
{
if
(
options
===
undefined
)
{
options
=
{};
options
=
{};
}
}
...
@@ -309,9 +308,8 @@
...
@@ -309,9 +308,8 @@
"
dataType
"
:
"
blob
"
,
"
dataType
"
:
"
blob
"
,
"
url
"
:
action
,
"
url
"
:
action
,
"
xhrFields
"
:
{
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
withCredentials
:
true
},
}
"
headers
"
:
storage
.
_headers
};
};
if
(
options
.
start
!==
undefined
||
options
.
end
!==
undefined
)
{
if
(
options
.
start
!==
undefined
||
options
.
end
!==
undefined
)
{
start
=
options
.
start
||
0
;
start
=
options
.
start
||
0
;
...
@@ -331,11 +329,7 @@
...
@@ -331,11 +329,7 @@
}
}
range
=
"
bytes=
"
+
start
+
"
-
"
+
end
;
range
=
"
bytes=
"
+
start
+
"
-
"
+
end
;
}
}
if
(
storage
.
_headers
===
undefined
)
{
request_options
.
headers
=
{
Range
:
range
};
request_options
.
headers
=
{
Range
:
range
};
}
else
{
request_options
.
headers
.
Range
=
range
;
}
}
}
return
jIO
.
util
.
ajax
(
request_options
);
return
jIO
.
util
.
ajax
(
request_options
);
})
})
...
@@ -354,7 +348,6 @@
...
@@ -354,7 +348,6 @@
};
};
ERP5Storage
.
prototype
.
putAttachment
=
function
(
id
,
name
,
blob
)
{
ERP5Storage
.
prototype
.
putAttachment
=
function
(
id
,
name
,
blob
)
{
var
storage
=
this
;
// Assert we use a callable on a document from the ERP5 site
// Assert we use a callable on a document from the ERP5 site
if
(
name
.
indexOf
(
this
.
_url
)
!==
0
)
{
if
(
name
.
indexOf
(
this
.
_url
)
!==
0
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Can not store outside ERP5:
"
+
throw
new
jIO
.
util
.
jIOError
(
"
Can not store outside ERP5:
"
+
...
@@ -396,9 +389,8 @@
...
@@ -396,9 +389,8 @@
"
data
"
:
data
,
"
data
"
:
data
,
"
dataType
"
:
"
blob
"
,
"
dataType
"
:
"
blob
"
,
"
xhrFields
"
:
{
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
withCredentials
:
true
},
}
"
headers
"
:
storage
.
_headers
});
});
});
});
};
};
...
@@ -447,7 +439,6 @@
...
@@ -447,7 +439,6 @@
// jIO.Query.objectToSearchText(options.query) :
// jIO.Query.objectToSearchText(options.query) :
// undefined);
// undefined);
// }
// }
var
storage
=
this
;
return
getSiteDocument
(
this
)
return
getSiteDocument
(
this
)
.
push
(
function
(
site_hal
)
{
.
push
(
function
(
site_hal
)
{
var
query
=
options
.
query
,
var
query
=
options
.
query
,
...
@@ -516,9 +507,8 @@
...
@@ -516,9 +507,8 @@
local_roles
:
local_roles
local_roles
:
local_roles
}),
}),
"
xhrFields
"
:
{
"
xhrFields
"
:
{
withCredentials
:
storage
.
_thisCredentials
withCredentials
:
true
},
}
"
headers
"
:
storage
.
_headers
});
});
})
})
.
push
(
function
(
response
)
{
.
push
(
function
(
response
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment