1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8">
|
5 | <title>JSDoc: Source: src/js/NouvPartitionPanel.js</title>
|
6 |
|
7 | <script src="scripts/prettify/prettify.js"> </script>
|
8 | <script src="scripts/prettify/lang-css.js"> </script>
|
9 | |
10 |
|
11 |
|
12 | <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
|
13 | <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
|
14 | </head>
|
15 |
|
16 | <body>
|
17 |
|
18 | <div id="main">
|
19 |
|
20 | <h1 class="page-title">Source: src/js/NouvPartitionPanel.js</h1>
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | <section>
|
28 | <article>
|
29 | <pre class="prettyprint source linenums"><code>/*
|
30 |
|
31 | !----------------------------------------------------------------------------!
|
32 | ! !
|
33 | ! Yexpert : (your) Système Expert sous Mumps GT.M et GNU/Linux !
|
34 | ! Copyright (C) 2001-2015 by Hamid LOUAKED (HL). !
|
35 | ! !
|
36 | !----------------------------------------------------------------------------!
|
37 |
|
38 | */
|
39 |
|
40 | "use strict"
|
41 |
|
42 | var React = require('react');
|
43 | var ReactBootstrap = require('react-bootstrap');
|
44 | var Inspector = require('react-json-inspector');
|
45 |
|
46 | var {
|
47 | Button,
|
48 | Glyphicon,
|
49 | OverlayTrigger,
|
50 | Panel,
|
51 | Tooltip,
|
52 | form,
|
53 | FormGroup,
|
54 | ControlLabel,
|
55 | FormControl,
|
56 | HelpBlock
|
57 | } = ReactBootstrap;
|
58 |
|
59 | var NouvPartitionPanel = React.createClass({
|
60 |
|
61 | componentWillMount: function() {
|
62 |
|
63 | this.controller = require('./controller-NouvPartitionPanel')(this.props.controller, this);
|
64 |
|
65 | this.title = (
|
66 | <h1>Nouvelle partition</h1>
|
67 | );
|
68 | },
|
69 |
|
70 | // *******
|
71 |
|
72 | getInitialState() {
|
73 | return {
|
74 | valueNomPartition: 'DMO',
|
75 | valueTaillePartition: 1,
|
76 | isLoading: false,
|
77 | status: 'initial'
|
78 | };
|
79 | },
|
80 |
|
81 | getValidationNomPartition() {
|
82 | const length = this.state.valueNomPartition.length;
|
83 | if (length > 5) return 'error';
|
84 | else if (length > 3) return 'warning';
|
85 | else if (length == 3) return 'success';
|
86 | },
|
87 |
|
88 | getValidationTaillePartition() {
|
89 | const taille = this.state.valueTaillePartition;
|
90 | if (taille > 0 && taille <= 5) return 'success';
|
91 | else if (taille > 1 && taille <= 10) return 'warning';
|
92 | else if (taille <= 0 || taille > 10) return 'error';
|
93 | },
|
94 |
|
95 | handleChangeNomPartition(e) {
|
96 | const re = /[a-zA-Z]/g;
|
97 | const np = e.target.value.replace(re,"");
|
98 | if (e.target.value.replace(re,"")=="") {
|
99 | this.setState({
|
100 | valueNomPartition: e.target.value.toUpperCase(),
|
101 | });
|
102 | } else {
|
103 | this.setState({
|
104 | valueNomPartition: e.target.value.substring(0,e.target.value.length-1)
|
105 | });
|
106 | }
|
107 | },
|
108 |
|
109 | // ******2
|
110 |
|
111 | handleChangeTaillePartition(e) {
|
112 | this.setState({
|
113 | valueTaillePartition: e.target.value
|
114 | });
|
115 | },
|
116 |
|
117 | handleClick() {
|
118 | this.setState({isLoading: true});
|
119 | this.refresh();
|
120 |
|
121 | // This probably where you would have an `ajax` call
|
122 | setTimeout(() => {
|
123 | // Completed of async action, set loading state back
|
124 | this.setState({isLoading: false});
|
125 | }, 2000);
|
126 | },
|
127 |
|
128 | componentDidUpdate: function() {
|
129 |
|
130 | //console.log('status: ' + this.state.status);
|
131 | var that = this;
|
132 |
|
133 | setTimeout(function() {
|
134 | $('.json-inspector__leaf').each(function(ix, item) {
|
135 | var id = $(item).attr('id');
|
136 | var name = id.split('root.')[1];
|
137 | if (!name) {
|
138 | $(item).find('span.json-inspector__key').first().hide();
|
139 | $(item).find('span.json-inspector__value').first().hide();
|
140 | }
|
141 | else if (name.indexOf('.') === -1 && that.data[name]) {
|
142 | $(item).find('span.json-inspector__key').first().addClass('json-inspector__docName');
|
143 | }
|
144 | });
|
145 | }, 100);
|
146 | },
|
147 |
|
148 | // ******
|
149 |
|
150 | componentWillReceiveProps: function(newProps) {
|
151 | this.onNewProps(newProps);
|
152 | },
|
153 |
|
154 | render: function() {
|
155 |
|
156 | //var componentPath = this.controller.updateComponentPath(this);
|
157 |
|
158 | /**
|
159 | * @todo Améliorer le test sur laille de la partition
|
160 | * @todo La taille ne doit pas excéder 50% de la taille disponible en local
|
161 | */
|
162 |
|
163 | let isLoading = this.state.isLoading;
|
164 |
|
165 | // Créer un clone de données pour assurer un nouveau rendu
|
166 | if (this.data) {
|
167 | var newData = {};
|
168 | Object.assign(newData, this.data);
|
169 | }
|
170 |
|
171 | return (
|
172 | <Panel
|
173 | collapsible
|
174 | expanded={this.expanded}
|
175 | header={this.title}
|
176 | bsStyle="primary"
|
177 | >
|
178 |
|
179 | <form>
|
180 | <FormGroup
|
181 | controlId="formBasicText"
|
182 | validationState={this.getValidationNomPartition()}
|
183 | >
|
184 | <ControlLabel>Indiquer le nom de votre nouvelle partition.</ControlLabel>
|
185 | <FormControl
|
186 | type="text"
|
187 | value={this.state.valueNomPartition}
|
188 | placeholder="Saisir votre partition"
|
189 | onChange={this.handleChangeNomPartition}
|
190 | />
|
191 | <FormControl.Feedback />
|
192 | <HelpBlock>Le nom doit être en majscules, comporter 3 caractères au minimum et 5 caractères au maximum.</HelpBlock>
|
193 | </FormGroup>
|
194 |
|
195 | <FormGroup
|
196 | controlId="formTaillePartition"
|
197 | validationState={this.getValidationTaillePartition()}
|
198 | >
|
199 | <ControlLabel>Indiquer la taille en Go de votre nouvelle partition.</ControlLabel>
|
200 | <FormControl
|
201 | type="number"
|
202 | value={this.state.valueTaillePartition}
|
203 | placeholder="Saisir la taille de votre partition"
|
204 | onChange={this.handleChangeTaillePartition}
|
205 | />
|
206 | <FormControl.Feedback />
|
207 | <HelpBlock>La taille recommandée est de 1 Go et limitée à 10 Go.</HelpBlock>
|
208 | </FormGroup>
|
209 | </form>
|
210 |
|
211 | <Button
|
212 | bsStyle="primary"
|
213 | disabled={isLoading}
|
214 | onClick={!isLoading ? this.handleClick : null}>
|
215 | {isLoading ? 'En traitement...' : 'Soumettre'}
|
216 | </Button>
|
217 |
|
218 | <Inspector
|
219 | data={newData}
|
220 | isExpanded = {this.isExpanded}
|
221 | onClick={this.nodeClicked}
|
222 | search={false}
|
223 | />
|
224 |
|
225 | </Panel>
|
226 | );
|
227 | }
|
228 | });
|
229 |
|
230 | module.exports = NouvPartitionPanel;
|
231 |
|
232 |
|
233 |
|
234 | </code></pre>
|
235 | </article>
|
236 | </section>
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | </div>
|
242 |
|
243 | <nav>
|
244 | <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-lib_yexper-js.html">lib/yexper-js</a></li></ul><h3>Classes</h3><ul><li><a href="module-lib_yexper-js.handlers.cdNameSpace.html">cdNameSpace</a></li><li><a href="module-lib_yexper-js.handlers.getNameSpace.html">getNameSpace</a></li></ul>
|
245 | </nav>
|
246 |
|
247 | <br class="clear">
|
248 |
|
249 | <footer>
|
250 | Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Jan 29 2017 13:56:33 GMT+0100 (CET)
|
251 | </footer>
|
252 |
|
253 | <script> prettyPrint(); </script>
|
254 | <script src="scripts/linenumber.js"> </script>
|
255 | </body>
|
256 | </html>
|