[#369] move assets angular-new -> angularjs

This commit is contained in:
Alexander Machehin 2015-02-03 02:15:31 +05:00
parent ea504fcc64
commit 3b58c6ca5d
60 changed files with 12 additions and 209 deletions

View File

@ -1,40 +0,0 @@
RosaABF.controller('ProductBuildListController', ['$scope', '$http', '$timeout', 'SoundNotificationsHelper', function($scope, $http, $timeout, SoundNotificationsHelper) {
$scope.id = $('#product_build_list_id').val();
$scope.pbl = null;
$scope.subject = {}; // See: shared/build_results
$scope.getProductBuildList = function() {
$http.get(Routes.product_build_list_path($scope.id, {format: 'json'})).success(function(results) {
var product_build_list = results.product_build_list;
if ($scope.pbl && $scope.pbl.status != product_build_list.status)
SoundNotificationsHelper.buildStatusChanged();
$scope.pbl = $scope.subject = product_build_list;
});
}
$scope.cancelRefresh = null;
$scope.refresh = function() {
if (!$scope.pbl ||
!(
$scope.pbl.status == <%=ProductBuildList::BUILD_COMPLETED%> ||
$scope.pbl.status == <%=ProductBuildList::BUILD_FAILED%> ||
$scope.pbl.status == <%=ProductBuildList::BUILD_CANCELED%>
)
) {
$scope.getProductBuildList();
}
$scope.cancelRefresh = $timeout($scope.refresh, 10000);
}
$scope.refresh();
$scope.updateStatus = function() {
$http.put(
Routes.product_build_list_path($scope.id),
{product_build_list: {not_delete: $scope.pbl.not_delete}, format: 'json'}
).success(function(results) {
$scope.pbl = $scope.subject = results.product_build_list;
});
}
}]);

View File

@ -1,8 +0,0 @@
RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', 'SoundNotificationsHelper',
function($scope, LocalesHelper, SoundNotificationsHelper) {
$scope.init = function(locale, sound_notifications) {
LocalesHelper.setLocale(locale);
moment.locale(locale);
SoundNotificationsHelper.enabled(sound_notifications);
}
}]);

View File

@ -1,15 +0,0 @@
RosaABF = angular.module 'RosaABF'
RosaABF.directive "ngConfirmClick", ->
priority: 100
restrict: "A"
link: (scope, element, attr) ->
msg = attr.ngConfirmClick || "Are you sure?"
clickAction = attr.confirmedClick
element.bind 'click', (event) ->
if clickAction
scope.$apply clickAction if window.confirm(msg)
else
unless confirm(msg)
event.stopImmediatePropagation()
event.preventDefault

View File

@ -1,48 +0,0 @@
var RosaABF = angular.module('RosaABF', ['ngResource', 'ng-rails-csrf', 'angular-i18n', 'angularMoment']);
var DateTimeFormatter = function() {
var UtcFormatter = function(api_time) {
return moment.utc(api_time * 1000).format('YYYY-MM-DD HH:mm:ss UTC');
}
return {
utc : UtcFormatter
}
}
RosaABF.factory("DateTimeFormatter", DateTimeFormatter);
var LocalesHelper = function($locale) {
var locales = {
'ru' : 'ru-ru',
'en' : 'en-us'
}
return {
setLocale: function(locale) {
$locale.id = locales[locale];
}
}
}
RosaABF.factory("LocalesHelper", ['$locale', LocalesHelper]);
var SoundNotificationsHelper = function() {
var isOn = true;
var statusChangedSound = null;
soundManager.setup({
// url: '/assets/swf/',
preferFlash: false,
onready: function() {
statusChangedSound = soundManager.createSound({url: "<%=asset_path('garbage_shattering.wav')%>"});
}
});
return {
buildStatusChanged: function() {
if (isOn && statusChangedSound)
statusChangedSound.play();
},
enabled: function(status) {
isOn = status;
}
}
}
RosaABF.factory('SoundNotificationsHelper', SoundNotificationsHelper);

View File

@ -1,17 +0,0 @@
RosaABF.controller('AutomaticMetadataRegenerationController', ['$scope', '$http', function($scope, $http) {
// See: Platfrom::AUTOMATIC_METADATA_REGENERATIONS
$scope.items = {
'day': 'platform.automatic_metadata_regeneration.day',
'week': 'platform.automatic_metadata_regeneration.week'
};
$scope.platform_id = null;
$scope.update = function() {
$http.put(
Routes.platform_path($scope.platform_id),
{platform: {automatic_metadata_regeneration: $scope.amr}, format: 'json'}
);
}
}]);

View File

@ -1,71 +0,0 @@
RosaABF.controller 'ContentsController', ['$scope', '$http', '$location', ($scope, $http, $location) ->
$scope.platform = $('#platform_name').val()
$scope.processing = true
$scope.contents = []
$scope.folders = []
$scope.pages = []
# Fixes: redirect to page after form submit
$("#search_contents_form").on 'submit', ->
false
$scope.refresh = ->
$scope.processing = true
params =
platform_id: $scope.platform
path: $('#path').val()
term: $('#term').val()
page: $('#page').val()
format: 'json'
$http.get(Routes.platform_contents_path(params)).success( (data) ->
$scope.folders = data.folders
$scope.contents = data.contents
$scope.pages = data.pages
$scope.back = data.back
$scope.processing = false
).error( ->
$scope.contents = []
$scope.processing = false
)
true
$scope.open = (content) ->
return if $scope.processing
if $.type(content) == 'string'
$location.search('path', content)
else if content.is_folder
$location.search('path', content.subpath)
$scope.destroy = (content) ->
params =
path: content.subpath
format: 'json'
content.processing = true
$http.delete(Routes.remove_file_platform_contents_path($scope.platform, params)).success( ->
$scope.refresh()
).error( ->
$scope.refresh()
)
true
$scope.search = ->
$location.search('term', $('#term').val())
$scope.$on '$locationChangeSuccess', (event) ->
$scope.updateParams()
$scope.refresh()
$scope.updateParams = ->
params = $location.search()
$('#path').val(params['path'])
$('#term').val(params['term'])
$('#page').val(params['page'])
$scope.goToPage = (number) ->
$location.search('page', number)
]

View File

@ -1,8 +1,8 @@
RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', 'SoundNotificationsHelper', function($scope, LocalesHelper, SoundNotificationsHelper) {
RosaABF.controller('RosaABFController', ['$scope', 'LocalesHelper', 'SoundNotificationsHelper',
function($scope, LocalesHelper, SoundNotificationsHelper) {
$scope.init = function(locale, sound_notifications) {
LocalesHelper.setLocale(locale);
moment.locale(locale);
SoundNotificationsHelper.enabled(sound_notifications);
}
}]);
}]);

View File

@ -5,7 +5,11 @@ RosaABF.directive "ngConfirmClick", ->
restrict: "A"
link: (scope, element, attr) ->
msg = attr.ngConfirmClick || "Are you sure?"
clickAction = attr.confirmedClick
element.bind 'click', (event) ->
unless confirm(msg)
event.stopImmediatePropagation()
event.preventDefault
if clickAction
scope.$apply clickAction if window.confirm(msg)
else
unless confirm(msg)
event.stopImmediatePropagation()
event.preventDefault

View File

@ -16,7 +16,6 @@
//= require angular-ui-bootstrap-tpls
//= require ui-codemirror
//= require angular-i18n
//= require angularjs/locales
//= require angular-resource
//= require ng-rails-csrf
@ -26,9 +25,8 @@
//= require angular-rails-templates
//= require moment
//= require angularjs/angular-moment
//= require_tree ./angular-new
//= require_tree ./angularjs
//= require loading-bar
//= require underscore