<commit_before>'use strict';

/* Controllers */
var myAppControllers = angular.module('myApp.controllers', []);

myAppControllers.
    controller('ArtistsListCtrl', ['$scope', '$routeParams', '$location', 'Artist', function ($scope, $routeParams, $location, Artist) {

            Artist.query(function(response){
              $scope.artists = response;
            });
    }]);

myAppControllers.
  controller('ArtistCtrl', ['$scope', '$routeParams', '$location', 'Artist', function ($scope, $routeParams, $location, Artist) {

    Artist.get({artistId: $routeParams.artistId}, function(artist) {
      $scope.artist = artist;
    });

    //Jos tän scheman saa jostain
    var schema = {
        name: { type: String, default: '' },
        picture: String,
        quote: String,
        content: String,
        featured: String,
        status: String,
        stage: String,
        day: String,
        time_start: Date,
        time_stop: Date,
        founded: Number,
        genre: String,
        members: [String],
        albums: [String],
        highlights: String,
        youtube: String,
        spotify: String,
        contact_info: String,
        press_image: String,
        credits: String,
        place: Number
    };

    //Voidaan rakentaa taulukko fields
    $scope.fields = [];

    //Johon tulee oliot joissa on kentät name ja type
    Object.getOwnPropertyNames(schema).forEach(function(name) {
        var type;
        if (schema[name].type)
            type = schema[name].type.toString();
        else
            type = schema[name].toString();
        type = type.split(" ")[1].slice(0,-2);
        $scope.fields.push({"name": name, "type": type})
    });

    $scope.saveArtist = function(){
      Artist.update({ artistId:$scope.artist._id},$scope.artist);
    }
  }]);

myAppControllers.
    controller('EventsListsCtrl', ['$scope', 'Events', function ($scope, Event) {
        $scope.events = Event.query();
    }]);

myAppControllers.
    controller('HomeCtrl', ['$scope', function($scope) {
        $scope.hello = 'Hola!';
    }]);

myAppControllers.
    controller('NewsListCtrl', ['$scope', 'News', function($scope, News) {
        $scope.news = query();
    }]);

myAppControllers.
    controller('LocationsListCtrl', ['$scope', 'Locations',function($scope, Locations) {
        $scope.locations = query();
    }]);

myAppControllers.
    controller('InfoListCtrl', ['$scope', 'Info', function($scope, Info) {
        $scope.info = query();
    }]);

myAppControllers.
    controller('FestivalCtrl', ['$scope', 'Festival', function($scope, Festival) {
        $scope.hello2 = Festival.query();
    }]);<commit_msg>Basic controllers for event, news, locations and info<commit_after>'use strict';

/* Controllers */
var myAppControllers = angular.module('myApp.controllers', []);

myAppControllers.
    controller('ArtistsListCtrl', ['$scope', '$routeParams', '$location', 'Artist', function ($scope, $routeParams, $location, Artist) {

            Artist.query(function(response){
              $scope.artists = response;
            });
    }]);

myAppControllers.
  controller('ArtistCtrl', ['$scope', '$routeParams', '$location', 'Artist', function ($scope, $routeParams, $location, Artist) {

    Artist.get({artistId: $routeParams.artistId}, function(artist) {
      $scope.artist = artist;
    });

    //Jos tän scheman saa jostain
    var schema = {
        name: { type: String, default: '' },
        picture: String,
        quote: String,
        content: String,
        featured: String,
        status: String,
        stage: String,
        day: String,
        time_start: Date,
        time_stop: Date,
        founded: Number,
        genre: String,
        members: [String],
        albums: [String],
        highlights: String,
        youtube: String,
        spotify: String,
        contact_info: String,
        press_image: String,
        credits: String,
        place: Number
    };

    //Voidaan rakentaa taulukko fields
    $scope.fields = [];

    //Johon tulee oliot joissa on kentät name ja type
    Object.getOwnPropertyNames(schema).forEach(function(name) {
        var type;
        if (schema[name].type)
            type = schema[name].type.toString();
        else
            type = schema[name].toString();
        type = type.split(" ")[1].slice(0,-2);
        $scope.fields.push({"name": name, "type": type})
    });

    $scope.saveArtist = function(){
      Artist.update({ artistId:$scope.artist._id},$scope.artist);
    }
  }]);

myAppControllers.
    controller('EventsListsCtrl', ['$scope', 'Events', function ($scope, Event) {
        $scope.events = Event.query();
    }]);

myAppControllers.
  controller('EventCtrl', ['$scope', '$routeParams', '$location', 'Event', function ($scope, $routeParams, $location, Event) {

    Event.get({eventId: $routeParams.eventId}, function(event) {
      $scope.event = event;
    });
    
    $scope.saveEvent = function(){
      Event.update({ eventId:$scope.event._id},$scope.event);
    }
  }]);

myAppControllers.
    controller('NewsListCtrl', ['$scope', 'News', function($scope, News) {
        $scope.news = query();
    }]);

myAppControllers.
  controller('NewsCtrl', ['$scope', '$routeParams', '$location', 'News', function ($scope, $routeParams, $location, News) {

    News.get({newsId: $routeParams.newsId}, function(news) {
      $scope.news = news;
    });

    $scope.saveNews = function(){
      News.update({ newsId:$scope.news._id},$scope.news);
    }
  }]);

myAppControllers.
    controller('LocationsListCtrl', ['$scope', 'Locations',function($scope, Locations) {
        $scope.locations = query();
    }]);

myAppControllers.
  controller('LocationsCtrl', ['$scope', '$routeParams', '$location', 'Locations', function ($scope, $routeParams, $location, Locations) {

    Locations.get({locationsId: $routeParams.locationsId}, function(locations) {
      $scope.locations = locations;
    });

    $scope.saveLocations = function(){
      Locations.update({ locationsId:$scope.locations._id},$scope.locations);
    }
  }]);

myAppControllers.
    controller('InfoListCtrl', ['$scope', 'Info', function($scope, Info) {
        $scope.info = query();
    }]);

myAppControllers.
  controller('InfoCtrl', ['$scope', '$routeParams', '$location', 'Info', function ($scope, $routeParams, $location, Info) {

    Info.get({infoId: $routeParams.infoId}, function(info) {
      $scope.info = info;
    });

    $scope.saveInfo = function(){
      Info.update({ infoId:$scope.info._id},$scope.info);
    }
  }]);

myAppControllers.
  controller('FestivalCtrl', ['$scope', '$routeParams', '$location', 'Festival', function ($scope, $routeParams, $location, Festival) {

    $scope.hello2 = Festival.query();

    Festival.get({festivalId: $routeParams.festivalId}, function(festival) {
      $scope.festival = festival;
    });

    $scope.saveInfo = function(){
      Festival.update({ festivalId:$scope.festival._id},$scope.festival);
    }
  }]);

myAppControllers.
  controller('HomeCtrl', ['$scope', function($scope) {
    $scope.hello = 'Hola!';
  }]);
{'fraction_non_alphanumeric': 0.1699254466169644, 'fraction_numerical': 0.0011253340835560557, 'mean_word_length': 3.0260475651189127, 'pattern_counts': {'":': 4, '<': 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': '4400477', 'n_tokens_mistral': 2184, 'n_tokens_neox': 2172, 'n_words': 437}