diff --git a/data/index.html b/data/index.html index fd5a08c..2b38b6b 100644 --- a/data/index.html +++ b/data/index.html @@ -12,22 +12,8 @@
-
- Strip + Pixels
  • - - -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
  • - -
  • -
- +

Network

+
+

NeoPixel

+
- +
+ System +
+
 bytes

+ +
+
diff --git a/data/script.js b/data/script.js index b3ce2fb..5215086 100644 --- a/data/script.js +++ b/data/script.js @@ -10784,12 +10784,30 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +let endpoint = '/pixel'; + __WEBPACK_IMPORTED_MODULE_0_jquery___default()(() => { new __WEBPACK_IMPORTED_MODULE_1__core_App__["a" /* default */](__WEBPACK_IMPORTED_MODULE_0_jquery___default()('body')) .components(__WEBPACK_IMPORTED_MODULE_2__components_exports__) - .websocket(new WebSocket('ws://192.168.1.246/pixel')); -}); + .websocket(new WebSocket(endpoint.indexOf('/') === 0 ? "ws://" + window.location.host + endpoint : endpoint)); + // TODO make components + __WEBPACK_IMPORTED_MODULE_0_jquery___default()('.collapsible').each((i, container) => { + container.querySelector('.heading').addEventListener('click', (item) => { + container.classList.toggle('open'); + }); + }); + + __WEBPACK_IMPORTED_MODULE_0_jquery___default()('.js-restart').click((evt) => { + __WEBPACK_IMPORTED_MODULE_0_jquery___default.a.post('/restart'); + alert('restarting...'); + }); + + __WEBPACK_IMPORTED_MODULE_0_jquery___default.a.get('/heap', (data) => { + __WEBPACK_IMPORTED_MODULE_0_jquery___default()('.js-heap').html(data); + }); + +}); /* let click = element => element.click(); let check = element => element.setAttribute('checked', 'checked'); @@ -11035,38 +11053,71 @@ class Form extends __WEBPACK_IMPORTED_MODULE_1__core_Component__["a" /* default constructor(ctx, node) { super(ctx, node); - this.store = new __WEBPACK_IMPORTED_MODULE_3__core_store_RestStore__["a" /* default */](this.config.endpoint); - this.render(this.config); - this.fields = []; - let tf1 = new __WEBPACK_IMPORTED_MODULE_2__TextInput_TextInput__["a" /* default */](ctx); - tf1.config = { - name: 'ssid', - label: 'SSID', - placeholder: 'some AP' - }; - tf1.value = 'MyAp'; - - this.fields.push(tf1); - this.fields.forEach((f) => { - f.render({ - name: 'ssid', - label: 'SSID', - placeholder: 'some AP' - }); - this.node.prepend(f); + __WEBPACK_IMPORTED_MODULE_0_jquery___default.a.get(this.config.from, (cfg) => { + this.node.append( + __WEBPACK_IMPORTED_MODULE_0_jquery___default()(this.formTpl({ + endpoint: this.config.endpoint, + fields: this.configToFormRow(cfg) + })).submit(evt => this.ajaxFormhandler(evt)) + ); }); - this.node.delegate('click', '.js-submit', this.onSubmit.bind(this)); + //this.node.delegate('click', '.js-submit', this.onSubmit.bind(this)); } - onSubmit(evt) { + formTpl(data) { + return ` +
+ ${data.fields.join('')} +
+ +
+
+ `; + } + + formRowTpl(data) { + return ` +
+ +
+
+ `; + } + + configToFormRow (cfg){ + let arr = []; + for (let key in cfg) { + arr.push(this.formRowTpl({ + label: key, + name: key, + value: cfg[key], + fieldType: key.indexOf('assword') > -1 ? 'password' : 'text' + })) + } + return arr; + }; + + ajaxFormhandler(evt){ + evt.preventDefault(); + let data = __WEBPACK_IMPORTED_MODULE_0_jquery___default()(evt.currentTarget) + .serializeArray() + .reduce((obj, item) => { + obj[item.name] = item.value; + return obj; + }, {}); + __WEBPACK_IMPORTED_MODULE_0_jquery___default.a.post(this.config.endpoint, { fileName: this.config.filename, config: JSON.stringify(data) }); + }; + + + /* onSubmit(evt) { let obj = {}; obj[this.config.name] = this.value; //this.store.save(obj); console.log(this.value); - } + } */ } /* harmony export (immutable) */ __webpack_exports__["a"] = Form; diff --git a/data/styles.css b/data/styles.css index 0746973..56f95d5 100644 --- a/data/styles.css +++ b/data/styles.css @@ -10,7 +10,7 @@ .sui { background: #000000; color: #0eb8c0; - font-family: "Open Sans"; + font-family: Tahoma, Geneva, sans-serif; font-size: 16px; } .sui * { @@ -37,6 +37,10 @@ display: block; margin-bottom: 16px; } +.sui h2 { + font-size: 16px; + font-weight: 400; +} .container { background: #333333; padding: 16px; @@ -231,6 +235,14 @@ form .form-row input[type="checkbox"] { flex: 3; } } +@media screen and (max-width: 460px) { + form .form-row.wrapped { + display: block; + } + form .form-row.wrapped * { + display: block; + } +} @media screen and (min-width: 992px) { form .form-row > input, form .form-row > span { @@ -245,7 +257,7 @@ form .form-row input[type="checkbox"] { } .sui input[type="text"], .sui input[type="password"] { - height: 16px; + height: 32px; background: transparent; border: none; color: #eeeeee; diff --git a/src/app/components/base/Form/Form.html b/src/app/components/base/Form/Form.html index d781886..e69de29 100644 --- a/src/app/components/base/Form/Form.html +++ b/src/app/components/base/Form/Form.html @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file diff --git a/src/app/components/base/Form/Form.js b/src/app/components/base/Form/Form.js index 0e9c640..d5a2b29 100644 --- a/src/app/components/base/Form/Form.js +++ b/src/app/components/base/Form/Form.js @@ -7,37 +7,70 @@ export default class Form extends Component { constructor(ctx, node) { super(ctx, node); - this.store = new Store(this.config.endpoint); - this.render(this.config); - this.fields = []; - let tf1 = new TextInput(ctx); - tf1.config = { - name: 'ssid', - label: 'SSID', - placeholder: 'some AP' - }; - tf1.value = 'MyAp'; - - this.fields.push(tf1); - this.fields.forEach((f) => { - f.render({ - name: 'ssid', - label: 'SSID', - placeholder: 'some AP' - }); - this.node.prepend(f); + $.get(this.config.from, (cfg) => { + this.node.append( + $(this.formTpl({ + endpoint: this.config.endpoint, + fields: this.configToFormRow(cfg) + })).submit(evt => this.ajaxFormhandler(evt)) + ); }); - this.node.delegate('click', '.js-submit', this.onSubmit.bind(this)); + //this.node.delegate('click', '.js-submit', this.onSubmit.bind(this)); } - onSubmit(evt) { + formTpl(data) { + return ` +
+ ${data.fields.join('')} +
+ +
+
+ `; + } + + formRowTpl(data) { + return ` +
+ +
+
+ `; + } + + configToFormRow (cfg){ + let arr = []; + for (let key in cfg) { + arr.push(this.formRowTpl({ + label: key, + name: key, + value: cfg[key], + fieldType: key.indexOf('assword') > -1 ? 'password' : 'text' + })) + } + return arr; + }; + + ajaxFormhandler(evt){ + evt.preventDefault(); + let data = $(evt.currentTarget) + .serializeArray() + .reduce((obj, item) => { + obj[item.name] = item.value; + return obj; + }, {}); + $.post(this.config.endpoint, { fileName: this.config.filename, config: JSON.stringify(data) }); + }; + + + /* onSubmit(evt) { let obj = {}; obj[this.config.name] = this.value; //this.store.save(obj); console.log(this.value); - } + } */ } \ No newline at end of file diff --git a/src/app/main.js b/src/app/main.js index 3e0200a..856743f 100644 --- a/src/app/main.js +++ b/src/app/main.js @@ -4,12 +4,30 @@ import $ from 'jquery'; import App from './core/App'; import * as components from './components/exports'; +let endpoint = '/pixel'; + $(() => { new App($('body')) .components(components) - .websocket(new WebSocket('ws://192.168.1.246/pixel')); -}); + .websocket(new WebSocket(endpoint.indexOf('/') === 0 ? "ws://" + window.location.host + endpoint : endpoint)); + // TODO make components + $('.collapsible').each((i, container) => { + container.querySelector('.heading').addEventListener('click', (item) => { + container.classList.toggle('open'); + }); + }); + + $('.js-restart').click((evt) => { + $.post('/restart'); + alert('restarting...'); + }); + + $.get('/heap', (data) => { + $('.js-heap').html(data); + }); + +}); /* let click = element => element.click(); let check = element => element.setAttribute('checked', 'checked'); diff --git a/src/pages/index.html b/src/pages/index.html index fd5a08c..2b38b6b 100644 --- a/src/pages/index.html +++ b/src/pages/index.html @@ -12,22 +12,8 @@
-
- Strip + Pixels
  • - - -
  • - - -
  • -
  • - - -
  • -
  • - - -
  • -
  • - -
  • -
- +

Network

+
+

NeoPixel

+
- +
+ System +
+
 bytes

+ +
+
diff --git a/src/styles/form/layout.less b/src/styles/form/layout.less index 8ad18d7..a4903d3 100644 --- a/src/styles/form/layout.less +++ b/src/styles/form/layout.less @@ -31,8 +31,18 @@ form { } @media screen and (min-width: 768px) { - .form-row > input, .form-row > span { - flex: 3; + .form-row > input, .form-row > span { + flex: 3; + } + } + @media screen and (max-width: 460px) { + .form-row { + &.wrapped { + display: block; + * { + display: block; + } + } } } @media screen and (min-width: 992px) { diff --git a/src/styles/heading.less b/src/styles/heading.less index 991dc7e..0efbf04 100644 --- a/src/styles/heading.less +++ b/src/styles/heading.less @@ -2,4 +2,11 @@ font-size: 1.2em; display: block; margin-bottom: @default-margin; +} + +.sui { + h2 { + font-size: 16px; + font-weight: 400; + } } \ No newline at end of file diff --git a/src/styles/theme.less b/src/styles/theme.less index dac0b4a..89d51f2 100644 --- a/src/styles/theme.less +++ b/src/styles/theme.less @@ -1,4 +1,4 @@ -@default-font: "Open Sans"; +@default-font: Tahoma, Geneva, sans-serif; @color-black: #000000; @color-white: #eeeeee; @@ -15,5 +15,5 @@ @default-border-color: #555555; @default-font-size: 16px; -@input-text-height: 16px; +@input-text-height: 32px; @input-checkbox-scale: 2;