Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
55db5c7
setting selected-key attribute as null clears dropdown
Aug 20, 2020
743a9c2
removed duplicate json-edit, fixed two-way issue of debug-obj
Aug 22, 2020
6e36a37
improved comments
Aug 22, 2020
997ab5c
added "title" attribute. "label" attribute is now optional
Aug 22, 2020
e2467c0
run-ls now supports "-w" switch that restarts target on change
Aug 23, 2020
6baa8ac
comment out unnecessary info output
Aug 26, 2020
f48aa57
debug-ls is added. run-ls is cleaned up
Aug 31, 2020
4d5ef7e
update debug-ls
Sep 1, 2020
b3cd3a9
updated dcs to work with debug-ls
Sep 4, 2020
c113dc9
watch-run is the part of debug-ls. debug-ls is updated.
Sep 22, 2020
61fa1e8
added +set mixin
Oct 8, 2020
31fa5ba
update debug-ls
Oct 8, 2020
8814179
added custom mimetype setting
Oct 9, 2020
8f337c7
update dcs
Oct 10, 2020
28c5f0a
fixes #193
Oct 11, 2020
5de8ab0
dropdown supports _tooltip key in options
Oct 11, 2020
4483e8a
fixed annoying autofill behavior from dropdown
Jan 17, 2021
47553c8
add missing dependency
Jan 17, 2021
fa32cae
fixed symbolic link traversal
Jan 18, 2021
b9e59a8
Update using-virtual-environment.md
ceremcem Jan 15, 2021
0c384be
Update using-virtual-environment.md
ceremcem Jan 15, 2021
a342cbd
Update using-virtual-environment.md
ceremcem Jan 16, 2021
d194f10
added listen-external switch
Jan 18, 2021
4412512
dropdown autofill attempt number-2
Jan 18, 2021
0e53a5e
releases are now unattended
Jan 18, 2021
4847a54
fixed forgotten import
Jan 19, 2021
9620f36
update dcs
Jan 22, 2021
6281117
dropdown listens external "selected-key" changes by default
Jan 22, 2021
14be2b2
selected key update is delayed (workaround)
Jan 22, 2021
14e7cd9
added debug-ls dependency
Jan 22, 2021
746eb63
update dcs
Jan 22, 2021
7e09d45
update dcs
Jan 23, 2021
45dc7bb
shelljs is now a standard part of scada.js
Jan 23, 2021
4965c0f
search-term is set as "selected key" if there is no error
Apr 9, 2021
ee5a6bd
update dcs
Sep 15, 2021
d143676
update dcs
Sep 25, 2021
e92e953
update dcs
Sep 28, 2021
9faff18
addded Makefile shortcut for "using virtual environment" script
Apr 1, 2022
26566f2
added npm-audit shortcuts
Apr 1, 2022
d44aba1
fixes issues reported by dependabot
Apr 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "tools/download.sh"]
path = tools/download.sh
url = https://github.com/ceremcem/download.sh
[submodule "tools/debug-ls"]
path = tools/debug-ls
url = https://github.com/ceremcem/debug-ls
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ update-deps: __c
update-app-version:
touch lib/app-version.json

production: __c __prepare_release_dir __production __release_commit
release: __c __prepare_release_dir __production __release_commit

__production: __app
gulp --webapp $(APP) --production
Expand Down Expand Up @@ -55,6 +55,9 @@ create-venv:
$(eval NODE_VERSION := $(shell echo `grep "^#node@" nodeenv.txt | cut -d@ -f2` | sed 's/^$$/system/'))
nodeenv --requirement=./nodeenv.txt --node=$(NODE_VERSION) --prompt="($(VENV_NAME))" --jobs=4 nodeenv

use-venv:
./venv

__prepare_release_dir:
@( if [ ! -d release/$(APP) ]; then \
mkdir -p release; \
Expand All @@ -64,7 +67,14 @@ __prepare_release_dir:
)

__release_commit:
( cd release/$(APP) && git add . && git commit )
( cd release/$(APP) && git add . && git commit -m "unattended commit")

release-push:
@( cd release/$(APP) && git push )

list-modules:
@find . -name package.json -and -not -path "*/node_modules/*" | xargs dirname | sort

npm-audit-all:
@$(MAKE) list-modules --no-print-directory | xargs -I '{}' bash -c \
'cd {}; echo -e "-----------\nAudit for {}:\n-----------\n\n"; npm i --package-lock-only; npm audit'
22 changes: 0 additions & 22 deletions components/debug-obj/index.ls
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
Ractive.components['json-edit'] = Ractive.extend do
template: require('./json-edit.pug')
isolated: true
data: ->
objStr: null
objFormatted: null
computed:
objFormatted:
get: ->
if @get \objTmp
return that
else
return JSON.stringify @get('value'), null, 2

set: (objStr) ->
try
obj = JSON.parse(objStr)
@set('value', obj)
@set('objTmp', null)
catch
return @set 'objTmp', objStr

Ractive.components['debug-obj'] = Ractive.extend do
template: require('./index.pug')
data: ->
Expand Down
3 changes: 1 addition & 2 deletions components/debug-obj/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
icon.bug

modal(title="{{title}}" basedon="{{mymodal1}}")
.ui.segment(style="width: 80vw; height: calc(80vh - 80px)")
json-edit(value="{{obj || null}}" style="width: 100%; height: 100%;")
json-edit(value="{{obj}}" style="width: 80vw; height: calc(80vh - 120px)")
3 changes: 0 additions & 3 deletions components/debug-obj/json-edit.pug

This file was deleted.

26 changes: 21 additions & 5 deletions components/dropdown/index.ls
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Ractive.components['dropdown'] = Ractive.extend do
selected-key-observer = null
update-dropdown = (_new) ~>
if @get \debug
@actor.log.log "#{@_guid}: selected key is changed to: ", _new
@actor.log.log "#{@_guid}: selected key is _being_ changed to: ", _new
<~ set-immediate
external-change := yes
<~ :lo(op) ~>
Expand Down Expand Up @@ -113,6 +113,7 @@ Ractive.components['dropdown'] = Ractive.extend do
# button action. When selected key is cleared, all
# necessary actions are handled in the listener.
@fire \select, c, {}, (err) ~>
debugger if @get \debug
if err and typeof! err is \String
@actor.v-err err
return op!
Expand Down Expand Up @@ -150,13 +151,16 @@ Ractive.components['dropdown'] = Ractive.extend do
if @get \async
selected-key-observer.silence!
@fire \select, c, selected, (err) ~>
debugger if @get \debug
unless err
@set \emptyReduced, no
update-dropdown selected[keyField]
else
curr = @get \selected-key
if typeof! err is \String
@actor.v-err err
@actor.v-err """#{err}
Dropdown, called #{@get 'selected'}
"""
@actor.c-warn "Error reported for dropdown callback: ", err,
"falling back to #{curr}"
@set \emptyReduced, yes
Expand Down Expand Up @@ -204,7 +208,9 @@ Ractive.components['dropdown'] = Ractive.extend do
#@actor.c-log "Dropdown (#{@_guid}) : searchTerm is empty"
@set \dataReduced, small-part-of data
on-change: (value, text, selected) ~>
return if external-change
if external-change and not @get('listen-external')
if @get \debug => @actor.c-log "Dropdown: Exiting from on-change handler as this is an external change."
return
if @get \debug => @actor.c-log "Dropdown: #{@_guid}: dropdown is changed: ", value
if @get \multiple
set-item unless value? => [] else value.split ','
Expand Down Expand Up @@ -251,6 +257,8 @@ Ractive.components['dropdown'] = Ractive.extend do
update-dropdown _new

selected-key-observer = @observe \selected-key, ((val) ~>
unless val?
dd.dropdown 'clear'
if @get \async
console.log "this is async mode and item is changed: ", val
set-item val
Expand All @@ -259,7 +267,9 @@ Ractive.components['dropdown'] = Ractive.extend do
), {-init}

# first update should be silent
set-immediate ~>
sleep 100ms, ~>
if @get \debug
@actor.c-log "Setting initial dropdown value: ", @get 'selected-key'
dd.dropdown 'set selected', @get('selected-key')
dd.dropdown 'refresh'

Expand All @@ -270,7 +280,8 @@ Ractive.components['dropdown'] = Ractive.extend do
'_add': (ctx) ->
c.button = ctx.component
sleep 10, -> dd.dropdown 'show'
err <~ @fire \add, c, @get \search-term
newKey = @get \search-term
err <~ @fire \add, c, newKey
# dropdown should only be closed if there is
# no error returned
unless err
Expand All @@ -279,6 +290,10 @@ Ractive.components['dropdown'] = Ractive.extend do
@set \search-term, ''
# clear the dropdown search field
$('.ui.dropdown').find(".search").val("")
<~ set-immediate
dd.dropdown 'set selected', newKey
dd.dropdown 'refresh'

data: ->
'search-fields': <[ description ]>
'search-term': ''
Expand All @@ -303,3 +318,4 @@ Ractive.components['dropdown'] = Ractive.extend do
'selected-key': null
'selected-name': null
'load-first': 100
'listen-external': yes # listen external key changes by default
7 changes: 5 additions & 2 deletions components/dropdown/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@
span.text -------
+endif
.menu
//turn off autocomplete
input(type="hidden" value="something")
.ui.icon.search.input
i.search.icon
input(type="text" placeholder="Search...")
input(type="search" autocomplete="off" placeholder="Search...")

+each('dataReduced as item')
.item(
data-value!="{{item[keyField]}}"
class-disabled="blacklist == item[keyField]"
title="{{._tooltip}}"
) {{item[nameField]}}

+if('emptyReduced && ~/["allow-addition"]')
Expand Down Expand Up @@ -72,7 +75,7 @@
.default.text {{ placeholder }}
.menu
+each('dataReduced')
.item(data-value!="{{.[keyField]}}") {{.[nameField]}}
.item(data-value!="{{.[keyField]}}" title="{{._tooltip}}") {{.[nameField]}}

+if('@this.getContext().hasListener("add", true) && ~/["search-term"]')
+iff("@this.partials.addNew ")
Expand Down
1 change: 1 addition & 0 deletions components/index.ls
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ require! './data-table'
require! './date-picker'
require! './db-img'
require! './debug-obj'
require! './json-edit'
require! './example-component'
require! './export-to-csv'
require! './file-button'
Expand Down
23 changes: 10 additions & 13 deletions components/json-edit/index.ls
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
require! 'relaxed-json': rjson

fixJSON = (x) -> rjson.parse(x)

Ractive.components['json-edit'] = Ractive.extend do
template: '''
<textarea lazy="true"
style="{{style}}; white-space: pre-wrap; border: {{#if err}}2px dashed red{{else}}1px solid green{{/if}}"
title="{{err}}"
class="{{class}}"
>{{ objFormatted }}</textarea>
'''
template: require('./index.pug')
isolated: yes
data: ->
objTmp: null
value: null
err: null
timeout: 500ms
readonly: no
title: null

computed:
objFormatted:
get: ->
if @get \objTmp
return that
that
else
return JSON.stringify(@get('value'), null, 2)
JSON.stringify (@get('value') or null), null, 2

set: (objStr) ->
objStr ?= null
return if @get \readonly
try
obj = fixJSON objStr
obj = rjson.parse objStr
@set \value, obj
@set \objTmp, null
@set \err, null
catch
console.warn "json-edit error was: ", e
#console.warn "json-edit error was: ", e
@set \err, e.message
@set \objTmp, objStr
14 changes: 14 additions & 0 deletions components/json-edit/index.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.ui.form(style="height: 100%; width: 100%;")
.field(style="height: 100%; width: 100%")
+if('title')
label {{title}}

//- lazy="xxx" : Update the content only when the mouse out of editing area
or timeout of xxx milliseconds is over.
textarea(
readonly="{{readonly}}"
lazy="{{timeout}}"
style="height: 100%; width: 100%; {{style}}; white-space: pre-wrap; border: {{#if err}}2px dashed red{{else}}1px solid green{{/if}};"
title="{{err}}"
class="{{class}}"
) {{ objFormatted }}
2 changes: 1 addition & 1 deletion components/router/index.ls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require! 'actors': {RactiveActor}
require! './tools': {
change-hash-listener, set-window-hash, make-link, scroll-to,
set-scroll-top, get-scroll-top, parse-link, get-window-hash, get-offset
set-window-hash
set-window-hash, basename
}

Ractive.components['a'] = Ractive.extend do
Expand Down
2 changes: 1 addition & 1 deletion components/router/tools.ls
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require! 'prelude-ls': {take, drop, split, find}

basename = (.split(/[\\/]/).pop!) # https://stackoverflow.com/questions/3820381#comment29942319_15270931
export basename = (.split(/[\\/]/).pop!) # https://stackoverflow.com/questions/3820381#comment29942319_15270931

export get-offset = ->
$ 'body' .scrollTop!
Expand Down
11 changes: 6 additions & 5 deletions doc/using-virtual-environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

pip install nodeenv

2. Download or create the project:
2. Download (or create) your project:

# download
# download an existing project:
git clone --recursive https://github.com/aktos-io/scadajs-template myproject && cd myproject

# create
# or create a project from scratch:
git init myproject && cd myproject
git submodule add git submodule add https://github.com/aktos-io/scada.js

Expand All @@ -29,8 +29,9 @@

5. Optional: Move your nodeenv to a central location and use it between projects:

mv nodeenv/ ~/nodeenv/scadajs-1 # or anywhere you like
echo "export SCADAJS_1_ENV="~/nodeenv/scadajs-1" >> ~/.bashrc
dest=$HOME/nodeenv/scadajs-1 # or anywhere you like
mv nodeenv/ $dest
echo "export SCADAJS_1_ENV='$dest'" >> ~/.bashrc

> Next time you can use: `./scada.js/venv`

Expand Down
6 changes: 3 additions & 3 deletions lib/aea/file-download.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// taken from https://stackoverflow.com/a/31438726/1952991
var createDownload = function(filename,text){
var createDownload = function(filename,content,mimetype="text/plain"){
// Set up the link
var link = document.createElement("a");
link.setAttribute("target","_blank");
if(Blob !== undefined) {
var blob = new Blob([text], {type: "text/plain"});
var blob = new Blob([content], {type: mimetype});
link.setAttribute("href", URL.createObjectURL(blob));
} else {
link.setAttribute("href","data:text/plain," + encodeURIComponent(text));
link.setAttribute("href","data:"+mimetype+"," + encodeURIComponent(content));
}
link.setAttribute("download",filename);
document.body.appendChild(link);
Expand Down
Loading