<commit_before>var LIGHT_STATUS_UPDATE_INTERVAL = 20000;
var INITIAL_LIGHT_STATUS_UPDATE_TIMEOUT = 1500;

App = Ember.Application.create();

App.Router.map(function() {
    this.resource('about');
    this.resource('sysInfo');
    this.resource('garageCam');
});


App.LightStatusPoller = Ember.Object.extend({
    start: function() {
        this.timer = setInterval(this.onPoll.bind(this), LIGHT_STATUS_UPDATE_INTERVAL);
    },
    stop: function() {
        clearInterval(this.timer);
    }
});


// ------
// Models
// ------

App.Light = DS.Model.extend({
    name: DS.attr('string'),
    device: DS.attr('string'),
    instance: DS.attr('string'),
    status: DS.attr('string', {defaultValue: 'off'}),
    statusImagePath: function() {
        return 'assets/images/lamp_' + (this.get('status') != undefined ? this.get('status') : 'off') + '.png';
    }.property('status')
});

App.Scene = DS.Model.extend({
    name: DS.attr('string'),
    showOnUI: DS.attr('boolean'),
    buttonClass: DS.attr('string'),
    glyphiconClass: DS.attr('string'),
    description: DS.attr('string'),
    lights: DS.hasMany('light', {async:false}),
    action: DS.attr('string')
});

App.SysInfo = DS.Model.extend({
    hostName: DS.attr('string'),
    osType: DS.attr('string'),
    release: DS.attr('string'),
    cpu: DS.attr('string'),
    upTime: DS.attr('string'),
    totMem: DS.attr('string'),
    freeMem: DS.attr('string')
});


// ------
// Routes
// ------

App.IndexRoute = Ember.Route.extend({
    model: function() {
        var multiModel = Ember.Object.create({
            lights: this.store.find('light'),
            scenes: this.store.find('scene')
        });
        return multiModel;
    },
    setupController: function(controller, model) {

        controller.set('model', model);

        // NOTE: This is not the best way to do it, but it will have to do for the time being. At least it works.
        setTimeout(function() {
            updateLightStatus(controller, model);
        }, INITIAL_LIGHT_STATUS_UPDATE_TIMEOUT);

        if (Ember.isNone(this.get('lightStatusPoller'))) {
            this.set('lightStatusPoller', App.LightStatusPoller.create({
                onPoll: function() {
                    updateLightStatus(controller, model);
                }<commit_msg>Show update notification when updating light status<commit_after>var LIGHT_STATUS_UPDATE_INTERVAL = 20000;
var INITIAL_LIGHT_STATUS_UPDATE_TIMEOUT = 1500;

App = Ember.Application.create();

App.Router.map(function() {
    this.resource('about');
    this.resource('sysInfo');
    this.resource('garageCam');
});


App.LightStatusPoller = Ember.Object.extend({
    start: function() {
        this.timer = setInterval(this.onPoll.bind(this), LIGHT_STATUS_UPDATE_INTERVAL);
    },
    stop: function() {
        clearInterval(this.timer);
    }
});


// ------
// Models
// ------

App.Light = DS.Model.extend({
    name: DS.attr('string'),
    device: DS.attr('string'),
    instance: DS.attr('string'),
    status: DS.attr('string', {defaultValue: 'off'}),
    statusImagePath: function() {
        return 'assets/images/lamp_' + (this.get('status') != undefined ? this.get('status') : 'off') + '.png';
    }.property('status')
});

App.Scene = DS.Model.extend({
    name: DS.attr('string'),
    showOnUI: DS.attr('boolean'),
    buttonClass: DS.attr('string'),
    glyphiconClass: DS.attr('string'),
    description: DS.attr('string'),
    lights: DS.hasMany('light', {async:false}),
    action: DS.attr('string')
});

App.SysInfo = DS.Model.extend({
    hostName: DS.attr('string'),
    osType: DS.attr('string'),
    release: DS.attr('string'),
    cpu: DS.attr('string'),
    upTime: DS.attr('string'),
    totMem: DS.attr('string'),
    freeMem: DS.attr('string')
});


// ------
// Routes
// ------

App.IndexRoute = Ember.Route.extend({
    model: function() {
        var multiModel = Ember.Object.create({
            lights: this.store.find('light'),
            scenes: this.store.find('scene')
        });
        return multiModel;
    },
    setupController: function(controller, model) {

        controller.set('model', model);

        // NOTE: This is not the best way to do it, but it will have to do for the time being. At least it works.
        setTimeout(function() {
            humane.log("Updating...");
            updateLightStatus(controller, model);
        }, INITIAL_LIGHT_STATUS_UPDATE_TIMEOUT);

        if (Ember.isNone(this.get('lightStatusPoller'))) {
            this.set('lightStatusPoller', App.LightStatusPoller.create({
                onPoll: function() {
                    humane.log("Updating...");
                    updateLightStatus(controller, model);
                }
{'fraction_non_alphanumeric': 0.175, 'fraction_numerical': 0.0038135593220338985, 'mean_word_length': 2.761752988047809, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3786457', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1447, 'n_words': 274}