Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
7885b2ba
Commit
7885b2ba
authored
Sep 04, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More stuff
parent
55ca9f4d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
31 deletions
+81
-31
.gitignore
.gitignore
+1
-1
dev/slapos_load_schema/load_schema.js
dev/slapos_load_schema/load_schema.js
+15
-3
dev/slapos_parameter/index.html
dev/slapos_parameter/index.html
+4
-0
dev/slapos_parameter/parameter_editor.js
dev/slapos_parameter/parameter_editor.js
+19
-12
dev/slapos_request/index.html
dev/slapos_request/index.html
+4
-3
dev/slapos_request/slapos_request.js
dev/slapos_request/slapos_request.js
+38
-12
No files found.
.gitignore
View file @
7885b2ba
...
@@ -31,6 +31,6 @@ apache2.conf
...
@@ -31,6 +31,6 @@ apache2.conf
*~
*~
node_modules/
node_modules/
dev/
#
dev/
tmp/
tmp/
.tern-port
.tern-port
dev/slapos_load_schema/load_schema.js
View file @
7885b2ba
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
throw
error
});
throw
error
});
};
};
var
validateJSON
=
function
(
json
)
{
var
validateJSON
Schema
=
function
(
json
)
{
var
promise
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
promise
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
return
resolve
(
getMetaJSONSchema
());
return
resolve
(
getMetaJSONSchema
());
...
@@ -48,11 +48,23 @@
...
@@ -48,11 +48,23 @@
throw
error
});
throw
error
});
};
};
var
validateJSON
=
function
(
json
,
generated_json
)
{
console
.
log
(
tv4
.
validate
(
generated_json
,
json
));
return
generated_json
;
};
gk
.
declareMethod
(
"
loadJSONSchema
"
,
function
(
url
)
{
gk
.
declareMethod
(
"
loadJSONSchema
"
,
function
(
url
)
{
return
getJSON
(
url
).
then
(
function
(
json
)
{
return
getJSON
(
url
).
then
(
function
(
json
)
{
return
validateJSON
(
json
);
return
validateJSON
Schema
(
json
);
},
function
(
error
)
{
},
function
(
error
)
{
throw
error
});
throw
error
});
})
.
declareMethod
(
"
validateJSON
"
,
function
(
schema_url
,
generated_json
)
{
return
getJSON
(
schema_url
).
then
(
function
(
json
)
{
return
validateJSON
(
json
,
generated_json
);
},
function
(
error
)
{
throw
error
});
});
});
}(
window
,
rJS
,
RSVP
,
jQuery
));
}(
window
,
rJS
,
RSVP
,
jQuery
));
dev/slapos_parameter/index.html
View file @
7885b2ba
...
@@ -11,6 +11,10 @@
...
@@ -11,6 +11,10 @@
</head>
</head>
<body>
<body>
<div>
<div>
<fieldset
id=
"top"
>
<label>
Software Release URL
</label>
<div
class=
"software_release_url"
></div>
</fieldset>
<fieldset
id=
"main"
>
</fieldset>
<fieldset
id=
"main"
>
</fieldset>
<fieldset
id=
"optional"
>
</fieldset>
<fieldset
id=
"optional"
>
</fieldset>
</div>
</div>
...
...
dev/slapos_parameter/parameter_editor.js
View file @
7885b2ba
...
@@ -50,27 +50,38 @@
...
@@ -50,27 +50,38 @@
return
input
;
return
input
;
};
};
gk
.
ready
(
function
(
g
)
{
gk
.
declareMethod
(
"
getJSON
"
,
function
()
{
g
.
declareGadget
(
gadget_path_list
.
connection
,
{})
for
(
var
key
in
document
.
getElementByTagName
(
"
input
"
))
{
console
.
log
(
input
.
value
);
}
})
.
declareMethod
(
'
render
'
,
function
(
options
)
{
if
(
options
.
software_release_url
===
undefined
)
{
throw
"
undefined software_release_url
"
;
}
var
g
=
this
;
return
g
.
declareGadget
(
gadget_path_list
.
connection
,
{})
.
push
(
function
(
gadget
)
{
.
push
(
function
(
gadget
)
{
return
gadget
.
loadJSONSchema
(
json_url
);
return
gadget
.
loadJSONSchema
(
json_url
);
})
})
.
push
(
function
(
json
)
{
.
push
(
function
(
json
)
{
var
fieldset
=
g
.
__element
.
getElementsByTagName
(
'
fieldset
'
)[
0
];
var
fieldset
=
document
.
getElementsByTagName
(
'
fieldset
'
)[
1
];
var
fieldset_optional
=
g
.
__element
.
getElementsByTagName
(
'
fieldset
'
)[
1
];
var
fieldset_optional
=
document
.
getElementsByTagName
(
'
fieldset
'
)[
2
];
for
(
var
key
in
json
.
properties
)
{
for
(
var
key
in
json
.
properties
)
{
var
div
=
document
.
createElement
(
"
div
"
);
var
div
=
document
.
createElement
(
"
div
"
);
div
.
klass
=
"
field
"
;
div
.
setAttribute
(
"
class
"
,
"
field
"
)
;
div
.
title
=
json
.
properties
[
key
].
description
;
div
.
title
=
json
.
properties
[
key
].
description
;
console
.
log
(
key
);
/* console.log(key); */
var
label
=
document
.
createElement
(
"
label
"
);
var
label
=
document
.
createElement
(
"
label
"
);
label
.
textContent
=
json
.
properties
[
key
].
title
;
label
.
textContent
=
json
.
properties
[
key
].
title
;
div
.
appendChild
(
label
);
div
.
appendChild
(
label
);
var
div_input
=
document
.
createElement
(
"
div
"
);
var
div_input
=
document
.
createElement
(
"
div
"
);
div
.
klass
=
"
input
"
;
div
.
setAttribute
(
"
class
"
,
"
input
"
)
;
var
input
=
render_field
(
json
.
properties
[
key
]);
var
input
=
render_field
(
json
.
properties
[
key
]);
input
.
name
=
key
;
input
.
name
=
key
;
input
.
setAttribute
(
"
class
"
,
"
slapos-parameter
"
);
div_input
.
appendChild
(
input
);
div_input
.
appendChild
(
input
);
div
.
appendChild
(
div_input
);
div
.
appendChild
(
div_input
);
...
@@ -81,10 +92,6 @@
...
@@ -81,10 +92,6 @@
}
}
}
}
});
});
}).
declareMethod
(
"
getCouscou
"
,
function
()
{
var
sp
=
document
.
createElement
(
"
span
"
);
sp
.
textContent
=
"
couscous
"
;
return
sp
});
});
}(
window
,
document
,
rJS
));
}(
window
,
document
,
rJS
));
dev/slapos_request/index.html
View file @
7885b2ba
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
/>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
/>
<script
src=
"../lib/rsvp.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/rsvp.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/renderjs.min.js"
type=
"text/javascript"
></script>
<script
src=
"../lib/jquery.js"
></script>
<script
src=
"slapos_request.js"
type=
"text/javascript"
></script>
<script
src=
"slapos_request.js"
type=
"text/javascript"
></script>
<link
rel=
"stylesheet"
href=
"./slapos_request.css"
media=
"screen"
></link>
<link
rel=
"stylesheet"
href=
"./slapos_request.css"
media=
"screen"
></link>
<link
rel=
"http://www.renderjs.org/rel/interface"
<link
rel=
"http://www.renderjs.org/rel/interface"
...
@@ -15,9 +16,9 @@
...
@@ -15,9 +16,9 @@
data-gadget-url=
"../slapos_parameter/index.html"
data-gadget-url=
"../slapos_parameter/index.html"
data-gadget-scope=
"parameter"
>
data-gadget-scope=
"parameter"
>
</div>
</div>
<
div
id=
"main"
>
<
button
class=
"update-button"
>
Update
</button>
<textarea></textarea
>
<div
class=
"debug"
>
</div
>
</div>
</div>
</div>
</body>
</body>
</html>
</html>
dev/slapos_request/slapos_request.js
View file @
7885b2ba
/*jslint nomen: true*/
/*jslint nomen: true*/
/*global rJS */
/*global rJS */
(
function
(
window
,
document
,
rJS
)
{
(
function
(
window
,
document
,
$
,
rJS
)
{
"
use strict
"
;
"
use strict
"
;
var
gk
=
rJS
(
window
);
var
gk
=
rJS
(
window
);
var
json_url
=
"
../slapos_load_schema/schema.json
"
;
var
gadget_path_list
=
{
var
gadget_path_list
=
{
connection
:
"
../slapos_parameter/index.html
"
parameter
:
"
../slapos_parameter/index.html
"
,
connection
:
"
../slapos_load_schema/index.html
"
};
};
gk
.
ready
(
function
(
g
)
{
gk
.
declareMethod
(
'
render
'
,
function
(
options
)
{
if
(
options
.
software_release_url
===
undefined
)
{
throw
"
undefined software_release_url
"
;
}
var
g
=
this
;
var
gadget
=
g
.
declareGadget
(
gadget_path_list
.
parameter
,
{
software_release_url
:
options
.
software_instance_url
,
json_url
:
json_url
})
.
push
(
function
(
gadget
)
{
return
gadget
.
render
(
options
);
});
var
connection_gadget
=
g
.
declareGadget
(
gadget_path_list
.
connection
,
{})
g
.
declareGadget
(
gadget_path_list
.
connection
,
{})
.
push
(
function
(
gadget
)
{
g
.
__element
.
querySelector
(
"
div.software_release_url
"
).
innerHTML
=
options
.
software_release_url
;
return
gadget
.
getCouscou
();
})
$
(
this
.
__element
).
find
(
"
.update-button
"
).
click
(
function
(
e
)
{
.
push
(
function
(
element
)
{
var
json_dict
=
{};
g
.
__element
.
querySelector
(
"
div#main
"
).
innerHTML
=
element
.
innerHTML
;
var
input_list
=
document
.
getElementsByClassName
(
"
slapos-parameter
"
);
});
for
(
var
key
in
input_list
)
{
});
if
(
input_list
[
key
].
value
!==
""
)
{
json_dict
[
input_list
[
key
].
name
]
=
input_list
[
key
].
value
;
}
}
json
=
connection_gadget
.
validateJSON
(
json_url
,
json_dict
);
$
(
'
div.debug
'
)[
0
].
innerHTML
=
JSON
.
stringify
(
json_dict
);
});
});
}(
window
,
document
,
rJS
));
}(
window
,
document
,
$
,
rJS
));
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