<commit_before>/* JBoss, Home of Professional Open Source
* Copyright Red Hat, Inc., and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

App.MobileAppsIndexController = Ember.ArrayController.extend({
    sortProperties: [ "pushApplicationID" ],
    sortAscending: true,
    applicationPipe: App.AeroGear.pipelines.pipes.applications,
    edit: function( controller ) {
        var that = controller,
            applicationData,
            model = controller.get( "model" );

        model.validate();

        if( !model.get( "isValid" ) ) {
            this.send( "error", controller, model.get( "validationErrors.allMessages" ) );
        } else {
            applicationData = {
                name: controller.get( "name" ),
                id: controller.get( "pushApplicationID" ),
                description: controller.get( "description" )
            };

            this.applicationPipe.save( applicationData, {
                success: function() {
                    Ember.run( this, function() {
                        $( "form" )[0].reset();
                        that.transitionToRoute( "mobileApps" );
                    });
                },
                error: function( error ) {
                    Ember.run( this, function() {
                        switch( error.status ) {
                        case 401:
                            that.transitionToRoute( "login" );
                            break;
                        default:
                            that.send( "error", that, "Error Saving" );
                            break;
                        }
                    });
                }
            });
        }

    },
    cancel: function() {
        //Probably a better way
        $( "form" )[0].reset();

        this.transitionToRoute( "mobileApps" );
    },
    remove: function( app ) {
        var things = app,
            that = this;

        if( window.confirm( "Really Delete " + app.name + " ?" ) ) {
            this.applicationPipe.remove( app.pushApplicationID, {
                success: function() {
                    var content = that.get( "model" ).get( "content" ),
                        find;

                    find = content.find( function( value ) {
                        return value.pushApplicationID === things.pushApplicationID;
                    });

                    content.removeObject( find );
                },
                error: function( error ) { // TODO: Maybe Make this a class method?
                    switch( error.status ) {
                    case 401:
                        App.Router.router.transitionToRoute( "login" );
                        break;
                    default:
                        that.send( "error", that, "Error Saving" );
                        break;
                    }
                }
            });
        }
    },
    totalApps: function() {

        // Compute the total apps for this controller
        return this.get( "model" ).get( "content" ).length;

    }.property( "@each" )
});

/*
    The Controller for adding/editing Mobile apps
*/
App.MobileAppsEditController = Ember.ObjectController.extend({
    needs: "mobileAppsIndex"
});<commit_msg>add actions to controller to remove deprecation notice<commit_after>/* JBoss, Home of Professional Open Source
* Copyright Red Hat, Inc., and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

App.MobileAppsIndexController = Ember.ArrayController.extend({
    sortProperties: [ "pushApplicationID" ],
    sortAscending: true,
    applicationPipe: App.AeroGear.pipelines.pipes.applications,
    actions: {
        edit: function( controller ) {
            var that = controller,
                applicationData,
                model = controller.get( "model" );

            model.validate();

            if( !model.get( "isValid" ) ) {
                this.send( "error", controller, model.get( "validationErrors.allMessages" ) );
            } else {
                applicationData = {
                    name: controller.get( "name" ),
                    id: controller.get( "pushApplicationID" ),
                    description: controller.get( "description" )
                };

                this.applicationPipe.save( applicationData, {
                    success: function() {
                        Ember.run( this, function() {
                            $( "form" )[0].reset();
                            that.transitionToRoute( "mobileApps" );
                        });
                    },
                    error: function( error ) {
                        Ember.run( this, function() {
                            switch( error.status ) {
                            case 401:
                                that.transitionToRoute( "login" );
                                break;
                            default:
                                that.send( "error", that, "Error Saving" );
                                break;
                            }
                        });
                    }
                });
            }
        },
        cancel: function() {
            //Probably a better way
            $( "form" )[0].reset();

            this.transitionToRoute( "mobileApps" );
        },
        remove: function( app ) {
            var things = app,
                that = this;

            if( window.confirm( "Really Delete " + app.name + " ?" ) ) {
                this.applicationPipe.remove( app.pushApplicationID, {
                    success: function() {
                        var content = that.get( "model" ).get( "content" ),
                            find;

                        find = content.find( function( value ) {
                            return value.pushApplicationID === things.pushApplicationID;
                        });

                        content.removeObject( find );
                    },
                    error: function( error ) { // TODO: Maybe Make this a class method?
                        switch( error.status ) {
                        case 401:
                            App.Router.router.transitionToRoute( "login" );
                            break;
                        default:
                            that.send( "error", that, "Error Saving" );
                            break;
                        }
                    }
                });
            }
        },
    },
    totalApps: function() {

        // Compute the total apps for this controller
        return this.get( "model" ).get( "content" ).length;

    }.property( "@each" )
});

/*
    The Controller for adding/editing Mobile apps
*/
App.MobileAppsEditController = Ember.ObjectController.extend({
    needs: "mobileAppsIndex"
});
{'fraction_non_alphanumeric': 0.1010230179028133, 'fraction_numerical': 0.003069053708439898, 'mean_word_length': 1.3374178123132099, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3130956', 'n_tokens_mistral': 1897, 'n_tokens_neox': 1778, 'n_words': 518}