api-console-assets
Version:
This repo only exists to publish api console components to npm
176 lines (157 loc) • 5.78 kB
HTML
<!--
@license
Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>raml-request-parameters-editor demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../../font-roboto/roboto.html">
<link rel="import" href="../../arc-demo-helpers/raml-demo-page.html">
<link rel="import" href="../../paper-input/paper-input.html">
<link rel="import" href="../raml-request-parameters-editor.html">
<link rel="import" href="../raml-request-parameters-model.html">
<style is="custom-style">
html,
body {
margin: 0;
padding: 0;
font-family: 'Roboto', 'Noto', sans-serif;
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
font-size: 14px;
font-weight: 400;
line-height: 20px;
}
.url-value {
margin-top: 40px;
}
:root {
--raml-request-parameters-editor-subheader: {
@apply(--paper-font-subhead);
};
--inline-documentation-color: rgba(0, 0, 0, 0.54);
--inline-documentation-color: rgba(63, 81, 181, 0.87);
--raml-request-parameters-editor-input-label-color: rgba(0, 0, 0, 0.87);
/* --raml-request-parameters-form-array-paramtere: {
margin-bottom: 25px;
}; */
/* --query-parameter-input-add-actions: {
color: blue;
};
--query-parameter-input-add-icon: {
color: blue;
};
--query-parameter-input-add-actions-hover: {
color: red;
};
--query-parameter-input-add-button: {
margin-left: 0;
margin-right: 0;
padding-left: 0;
padding-right: 0;
}; */
}
[main] {
margin-left: 16px;
}
output {
display: block;
margin: 12px 0;
}
output label {
display: block;
font-weight: 500;
}
output code {
white-space: pre-wrap;
}
</style>
</head>
<body unresolved>
<template is="dom-bind" id="app">
<raml-demo-page raml="{{raml}}" selected-object="{{selected}}" is-method="{{isMethod}}">
<paper-item data-url$="[[testRaml]]">Test case 1</paper-item>
<paper-item data-url$="[[testRaml2]]">Test case 2</paper-item>
<h1>The raml-request-parameters-editor element</h1>
<div main>
<template is="dom-if" if="[[isMethod]]" restamp="true">
<raml-request-parameters-editor query-model="[[qm]]" uri-model="[[um]]" has-query-parameters="[[hqp]]" has-uri-parameters="[[hup]]" has-parameters="[[hp]]"></raml-request-parameters-editor>
<raml-request-parameters-model query-parameters="[[selected.queryParameters]]" uri-parameters="[[selected.allUriParameters]]" query-model="{{qm}}" uri-model="{{um}}" has-query-parameters="{{hqp}}" has-uri-parameters="{{hup}}" has-parameters="{{hp}}" base-uri="[[selected.absoluteUri]]"></raml-request-parameters-model>
<output>
<label>URI properties</label>
<code>[[uriProperties]]</code>
</output>
<output>
<label>Query properties</label>
<code>[[queryProperties]]</code>
</output>
<!-- <div class="url-value">
<p>Produced URL value is:</p>
<raml-request-url-editor auto-validate required uri-parameters="[[selected.allUriParameters]]" url="[[selected.absoluteUri]]" value="{{url}}" ></raml-request-url-editor>
</div> -->
</template>
<p hidden$="[[isMethod]]">Select a method</p>
</div>
</raml-demo-page>
</template>
<script>
var scope = document.getElementById('app');
scope.uriProperties = '';
scope.queryProperties = '';
scope.observers = [
'_envUriChanged(envUri)',
'_selectedChanged(selected)'
];
scope._selectedChanged = function() {
scope.uriProperties = '';
scope.queryProperties = '';
// When model is the same for query / URI parameters as for previous endpoint
// there's no change event (for performance reasons). In next event loop
// tasks check for existing properties.
// Path selection change can also be handled in one of the `raml-parh-selector`
// events.
setTimeout(function() {
scope._uriChanged();
scope._queryChanged();
}, 1);
};
scope._uriChanged = function() {
var result = {};
if (scope.um) {
scope.um.forEach(function(item) {
result[item.key] = item.value;
});
}
scope.uriProperties = JSON.stringify(result, null, 2);
};
scope._queryChanged = function() {
var result = {};
if (scope.qm) {
scope.qm.forEach(function(item) {
result[item.key] = item.value;
});
}
scope.queryProperties = JSON.stringify(result, null, 2);
};
window.addEventListener('uri-parameter-changed', scope._uriChanged);
window.addEventListener('query-parameter-changed', scope._queryChanged);
var path = location.pathname;
if (~path.indexOf('.html')) {
path = path.substr(0, path.lastIndexOf('/') + 1);
}
var ramlRoot = location.protocol + '//' + location.host + path.replace('demo', 'test');
scope.testRaml = ramlRoot + 'test.raml';
scope.testRaml2 = ramlRoot + 'test2.raml';
</script>
</body>
</html>