Skip to content

Commit

Permalink
Merge pull request #39 from AlCalzone/preserve-transitiontime
Browse files Browse the repository at this point in the history
Add the possibility to preserve the transition time for lightbulbs
  • Loading branch information
AlCalzone committed Feb 7, 2018
2 parents 2484459 + cf15d83 commit 66b378c
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 77 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ The result object `ret` looks as follows:

## Changelog

#### 1.1.0 (2018-02-07)
* (AlCalzone) Added an option to preserve the transition duration for single lightbulbs

#### 1.0.7 (2018-02-05)
* (AlCalzone) Fixed an error loading virtual groups

Expand Down
63 changes: 26 additions & 37 deletions admin/build/main.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/build/main.bundle.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion admin/build/runtime.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions admin/src/components/fragment.tsx

This file was deleted.

25 changes: 19 additions & 6 deletions admin/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as ReactDOM from "react-dom";
import {$$, $window, _, instance, sendTo, socket} from "./lib/adapter";

// components
import Fragment from "./components/fragment";
import { Tabs } from "./components/tabs";
import { GroupDictionary, Groups } from "./pages/groups";
import { OnSettingsChangedCallback, Settings } from "./pages/settings";
Expand Down Expand Up @@ -68,26 +67,39 @@ export class Root extends React.Component<any, any> {

public render() {
return (
<Fragment>
<>
<Header />
<Tabs labels={["Settings", "Groups"]}>
<Settings settings={this.props.settings} onChange={this.props.onSettingsChanged} />
<Groups groups={this.state.groups} devices={this.state.devices} />
</Tabs>
</Fragment>
</>
);
}

}

let curSettings: any;
let curSettings: Record<string, any>;
let originalSettings: Record<string, any>;

/**
* Checks if any setting was changed
*/
function hasChanges(): boolean {
for (const key of Object.keys(originalSettings)) {
if (originalSettings[key] !== curSettings[key]) return true;
}
return false;
}

// the function loadSettings has to exist ...
$window.load = (settings, onChange) => {

const settingsChanged: OnSettingsChangedCallback = (newSettings, hasChanges: boolean) => {
originalSettings = settings;

const settingsChanged: OnSettingsChangedCallback = (newSettings) => {
curSettings = newSettings;
onChange(hasChanges);
onChange(hasChanges());
};

ReactDOM.render(
Expand All @@ -104,4 +116,5 @@ $window.load = (settings, onChange) => {
$window.save = (callback) => {
// save the settings
callback(curSettings);
originalSettings = curSettings;
};
Loading

0 comments on commit 66b378c

Please sign in to comment.