Skip to content

Commit

Permalink
Merge pull request #123 from DataTorrent/release-1.0.0
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
andyperlitch committed Mar 16, 2015
2 parents 626f84b + f7f0719 commit aebd4b9
Show file tree
Hide file tree
Showing 72 changed files with 1,955 additions and 1,479 deletions.
3 changes: 3 additions & 0 deletions .bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"directory": "bower_components"
}
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
13 changes: 6 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
bower_components
.idea
.DS_Store
/template/dashboard.js
/coverage
/demo_dist
node_modules/
bower_components/
.sass-cache/
.tmp/
dist/
/demo/
13 changes: 10 additions & 3 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
Expand All @@ -18,9 +17,17 @@
"strict": true,
"trailing": true,
"smarttabs": true,
"white": true,
"validthis": true,
"globals": {
"angular": false,
"_": false,
"jQuery": false
"inject": false,
"describe": false,
"it": false,
"before": false,
"beforeEach": false,
"after": false,
"afterEach": false,
"expect": false
}
}
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ language: node_js
node_js:
- '0.10'
before_script:
- 'npm install -g bower grunt-cli'
- 'npm install -g bower gulp'
- 'bower install'
script:
- 'gulp'
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ It is possible to use your own template for the dashboard and widget markup (rep
| defaultWidgets | Array | n/a | yes | List of objects where an object is `{ name: [NAME_OF_WIDGET_DEFINITION] }`. TODO: Allow just list of names.
| widgetButtons | Boolean | true | no | Display buttons for adding and removing widgets.
| storage | Object | null | no | If defined, this object should implement three methods: `setItem`, `getItem`, and `removeItem`. See the **Persistence** section below.
| storageId | String | null | no (yes if `storage` is defined) | This is used as the first parameter passed to the three `storage` methods above. See the **Persistence** | section below.
| storageId | String | null | no (yes if `storage` is defined) | This is used as the first parameter passed to the three `storage` methods above. See the **Persistence** section below.
| storageHash | String | '' | no | This is used to validate/invalidate loaded state. See the **Persistence** section below.
| stringifyStorage | Boolean | true | no | If set to true, the dashboard state will be converted to a JSON string before being passed to `storage.setItem`. Likewise, it will be | passed through JSON.parse after being retrieved from `storage.getItem`. See the **Persistence** section below.
| explicitSave | Boolean | false | no | The dashboard will not automatically save to storage for every change. Saves must instead be called explicitly using the `saveDashboard` | method that is attached to the option event upon initialization.
| stringifyStorage | Boolean | true | no | If set to true, the dashboard state will be converted to a JSON string before being passed to `storage.setItem`. Likewise, it will be passed through JSON.parse after being retrieved from `storage.getItem`. See the **Persistence** section below.
| explicitSave | Boolean | false | no | The dashboard will not automatically save to storage for every change. Saves must instead be called explicitly using the `saveDashboard` method that is attached to the option event upon initialization.
| sortableOptions | Object | n/a | no | Allows to specify the various [sortable options](http://api.jqueryui.com/sortable/#options) of the underlying jQuery UI Sortable.
| hideWidgetSettings | Boolean | false | no | If true, the cog button in the top right corner of each widget will not be present. |
| hideWidgetClose | Boolean | false | no | If true, the "x" button in the top right corner of each widget will not be present. |
Expand All @@ -176,24 +176,26 @@ You can think of Widget Definition Objects as a __class__ and the widgets on the

| key | type | default value | required | description
| ----------------- | ------ | ------------- | -------- | -----------
| name | Object | n/a | true | Name of Widget Definition Object. If no `templateUrl`, `template`, or `directive` are on the Widget Definition | Object, this is assumed to be a directive name. In other words, the `directive` attribute is set to this value.
| name | String | n/a | true | Name of Widget Definition Object. If no `templateUrl`, `template`, or `directive` are on the Widget Definition Object, this is assumed to be a directive name. In other words, the `directive` attribute is set to this value.
| title | String | n/a | false | Default title of widget instances
| attrs | Object | n/a | false | Map of attributes to add to the markup of the widget. Changes to these will be stored when using the `storage` option | (see **Persistence** section below).
| templateUrl | String | n/a | false | URL of template to use for widget content
| template | String | n/a | false | String template (ignored if templateUrl is present)
| directive | String | n/a | false | HTML-injectable directive name (eg. `"ng-show"`)
| dataModelType | Function or String | n/a | false | Constructor for the dataModel object, which provides data to the widget (see below for more information).
| dataModelOptions | Object | n/a | false | Arbitrary values to supply to the dataModel. Available on dataModel instance as this.dataModelOptions. Serializable | values in this object will also be saved if `storage` is being used (see the **Persistence** section below).
| dataModelOptions | Object | n/a | false | Arbitrary values to supply to the dataModel. Available on dataModel instance as this.dataModelOptions. Serializable values in this object will also be saved if `storage` is being used (see the **Persistence** section below).
| dataModelArgs | Object | n/a | false | Object to be passed to data model constructor function. This object is not serialized by default and if defined should be present in widget definitions.
| dataAttrName | String | n/a | false | Name of attribute to bind `widgetData` model
| storageHash | String | n/a | false | This is analogous to the `storageHash` option on the dashboard, except at a widget-level instead of a dashboard-wide | level. This can be helpful if you would only like to invalidate stored state of one widget at a time instead of all widgets.
| storageHash | String | n/a | false | This is analogous to the `storageHash` option on the dashboard, except at a widget-level instead of a dashboard-wide level. This can be helpful if you would only like to invalidate stored state of one widget at a time instead of all widgets.
| settingsModalOptions | Object | see below | no | Overrides same-named option in dashboard options for this widget. See the **Custom Widget Settings** section below. |
| size | Object | n/a | false | Widget size, e.g { width: '50%', height: '250px' } |
| style | Object | n/a | false | Widget style, e.g { float: 'right' } |
| enableVerticalResize | Boolean | true | false | Option to enable/disable vertical resize. Should be provided in "widgetDefinitions" since it is not serialized by default. |
| onSettingsClose | Function | see below | no | Overrides same-named option in dashboard options for this widget. See the **Custom Widget Settings** section below. |
| onSettingsDismiss | Function | see below | no | Overrides same-named option in dashboard options for this widget. See the **Custom Widget Settings** section below. |
| serialize | Function | see below | no | Define this to override how this widget gets saved to storage. See **persistence** section below. |

As of v1.0.0, you can also add arbitrary data to your WDOs and this data will be copied to your widget. Keep in mind though, that if you want to SAVE some of this arbitrary info with storage, you will need to implement your own serialize method that includes this (see the **persistence** section below).

### Widget Resize

Expand Down Expand Up @@ -263,7 +265,7 @@ This dashboard component offers a means to save the state of the user's dashboar
- widget titles
- any serializable data stored in `dataModelOptions` if the widget instance has a `ds` (instantiated `dataModelType`)

There are three options you can specify in the `dashboardOptions` object relating to persistence:
There are four options you can specify in the `dashboardOptions` object relating to persistence:

### `storage` (Object)
This object will be used by the dashboard to save its state. It should implement the following three methods:
Expand All @@ -284,6 +286,19 @@ This string will be stored along with the dashboard state. Then later, when stat
### `stringifyStorage` (Boolean)
By default (`stringifyStorage=true`), the dashboard will convert its state (a JavaScript Object) to a string using `JSON.stringify` before passing it to `storage.setItem`. Additionally, the dashboard will assume that `storage.getItem` will return a JSON string and try to parse it with `JSON.parse`. This works with `window.localStorage` nicely, since objects cannot be used as `value` in `localStorage.setItem(key, value)`. However, if you are implementing your own `storage` and would not like this stringification business, set `stringifyStorage` to `false`.

There are also two options you can specify on WDOs that relate to persistence:

### `storageHash` (String)
Analogous to the `storageHash` option on the dashboard, except at a widget-level instead of a dashboard-wide level. This can be helpful if you would only like to invalidate stored state of one widget at a time instead of all widgets.

### `serialize` (Function)
This function will determine how the state of the widget gets saved. It takes no arguments and should return a `JSON.stringify`able object. The default implementation is as follows:
```js
serialize: function() {
return _.pick(this, ['title', 'name', 'style', 'size', 'dataModelOptions', 'attrs', 'storageHash']);
}
```
See [_.pick](https://lodash.com/docs#pick) for more details. The most common use-case for this would be to add another key to this list, or remove a key.

Custom Widget Settings
----------------------
Expand Down Expand Up @@ -377,7 +392,7 @@ key | type | default value | required | description
--- | ---- | ------------- | -------- | -----------
widgetDefinitions | Array | n/a | yes | Same as in `dashboardOptions`
lockDefaultLayouts | Boolean| false | no | `true` to lock default layouts (prevent from removing and renaming), layout lock can also be controlled with `locked` layout property
defaultLayouts | Array | n/a | yes | List of objects where an object is `{ title: [STRING_LAYOUT_TITLE], active: [BOOLEAN_ACTIVE_STATE], locked: [BOOLEAN], defaultWidgets: [ARRAY_DEFAULT_WIDGETS] }`. Note that `defaultWidgets` is the same as in `dashboardOptions`.
defaultLayouts | Array | n/a | yes | List of objects where an object is `{ title: [STRING_LAYOUT_TITLE], active: [BOOLEAN_ACTIVE_STATE], locked: [BOOLEAN], defaultWidgets: [ARRAY_DEFAULT_WIDGETS], widgetDefinitions: [ARRAY_OF_WIDGET_DEFS] }`. Note that `defaultWidgets` is the same as in `dashboardOptions`. Also note that the `widgetDefinitions` array is optional on individual default layouts. By default, layouts will use the `widgetDefintions` from the dashboardLayouts options object. See issue #83.
widgetButtons | Boolean | true | no | Same as in `dashboardOptions`
storage | Object | null | no | Same as in `dashboardOptions`, only the saved objects look like: `{ layouts: [...], states: {...}, storageHash: '' }`
storageId | String | null | no (yes if `storage` is defined) | This is used as the first parameter passed to the three `storage` methods `setItem`, `getItem`, `removeItem`. See the **Persistence** section above.
Expand Down
30 changes: 19 additions & 11 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
{
"name": "malhar-angular-dashboard",
"main": "./dist/angular-ui-dashboard.js",
"version": "0.8.2",
"license": "Apache License, v2.0",
"version": "1.0.0",
"dependencies": {
"jquery": "~2.0.3",
"bootstrap": "~3.3.1",
"angular-bootstrap": "0.12.x",
"angular": "~1.3",
"angular-bootstrap": "~0.11.0",
"angular-ui-sortable": "~0.13.1",
"jquery-ui": "~1.11.0",
"lodash": "~2.4.1"
"angular-ui-sortable": "~0.13.3",
"lodash": "~3.1"
},
"main": [
"dist/malhar-angular-dashboard.css",
"dist/malhar-angular-dashboard.js"
],
"devDependencies": {
"angular-route": "~1.3",
"angular-mocks": "~1.3",
"angular-markdown-directive": "~0.3.0",
"bootstrap": "~3.2.0"
"angular-route": "~1.3",
"angular-markdown-directive": "~0.3.1"
},
"overrides": {
"showdown": {
"main": "src/showdown.js"
}
},
"resolutions": {
"angular": "~1.3"
}
}
74 changes: 0 additions & 74 deletions demo/index.html

This file was deleted.

80 changes: 80 additions & 0 deletions dist/malhar-angular-dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.dashboard-widget-area {
margin: 10px 0 30px;
min-height: 200px;
}
.widget-container {
float: left;
display: inline-block;
width: 33%;
padding-bottom: 1em;
}
.widget {
margin: 0 1em 0 0;
background-color: white;
border: 2px solid #444;
border-radius: 5px;
position: relative;
height: 100%;
}
.widget-header {
overflow: hidden;
}
.widget-header .label {
display: inline-block;
vertical-align: middle;
}
.widget-header .glyphicon {
cursor: pointer;
float: right;
opacity: 0.5;
margin-left: 5px;
}
.widget-header .glyphicon:hover {
opacity: 1;
}
.widget-header .widget-title {
vertical-align: middle;
}
.widget-header form.widget-title {
display: inline;
}
.widget-header form.widget-title input.form-control {
width: auto;
display: inline-block;
}
.widget-content {
overflow: hidden;
}
.widget .widget-ew-resizer {
position: absolute;
width: 5px;
right: -2px;
height: 100%;
top: 0;
cursor: ew-resize;
}
.widget .widget-s-resizer {
cursor: ns-resize;
height: 5px;
width: 100%;
bottom: -7px;
left: 0;
}
.widget .widget-resizer-marquee {
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
position: absolute;
top: 0;
left: 0;
z-index: 2;
}
.remove-layout-icon {
vertical-align: text-top;
cursor: pointer;
opacity: 0.3;
}
.remove-layout-icon:hover {
opacity: 1;
}
.layout-title {
display: inline-block;
}
Loading

0 comments on commit aebd4b9

Please sign in to comment.