#369: updated UI for Contents, Clone, Advisories

This commit is contained in:
Vokhmin Alexey V 2014-10-27 23:14:49 +03:00
parent 3a815832ac
commit ea5a9c8b05
21 changed files with 264 additions and 143 deletions

View File

@ -0,0 +1,71 @@
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: $('#platform_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', $('#platform_term').val())
$scope.$on '$locationChangeSuccess', (event) ->
$scope.updateParams()
$scope.refresh()
$scope.updateParams = ->
params = $location.search()
$('#path').val(params['path'])
$('#platform_term').val(params['term'])
$('#page').val(params['page'])
$scope.goToPage = (number) ->
$location.search('page', number)
]

View File

@ -1,5 +1,6 @@
class Platforms::ContentsController < Platforms::BaseController class Platforms::ContentsController < Platforms::BaseController
include PaginateHelper include PaginateHelper
layout 'bootstrap'
before_filter :authenticate_user! before_filter :authenticate_user!
skip_before_filter :authenticate_user!, only: :index if APP_CONFIG['anonymous_access'] skip_before_filter :authenticate_user!, only: :index if APP_CONFIG['anonymous_access']

View File

@ -57,7 +57,7 @@ module ApplicationHelper
def alert_class(type) def alert_class(type)
case type.to_s case type.to_s
when 'error' when 'error', 'alert'
'alert-danger' 'alert-danger'
when 'notice' when 'notice'
'alert-success' 'alert-success'

View File

@ -108,9 +108,10 @@ class Platform < ActiveRecord::Base
:released, :released,
:platform_arch_settings_attributes, :platform_arch_settings_attributes,
:automatic_metadata_regeneration, :automatic_metadata_regeneration,
:admin_id :admin_id,
:term
attr_accessor :admin_id attr_accessor :admin_id, :term
attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type attr_readonly :name, :distrib_type, :parent_platform_id, :platform_type

View File

@ -1,58 +0,0 @@
- set_meta_tags title: [title_object(@platform), t('layout.platforms.contents')]
= render 'platforms/base/submenu'
= render 'platforms/base/sidebar'
%h3
= t('layout.platforms.contents_of')
= @platform.name
#contents{ 'ng-controller' => 'ContentsController' }
= form_for @platform, html: { class: :form, 'ng-submit' => 'search()', id: 'search_contents_form' } do |f|
= f.hidden_field :name
= hidden_field_tag 'path'
= hidden_field_tag 'page'
%input#term{ name: 'term', type: 'text', placeholder: t('layout.platforms.search_contents') }
= f.submit t('layout.search.header'), data: {'disable-with' => t('layout.processing')}
%br
.path
%a{ 'ng-repeat' => 'folder in folders' }
%span.text{ 'ng-click' => "open(folder.path)" } {{folder.name}}
%span.arrow-right
.both
- can_remove = can? :remove_file, @platform
%table.tablesorter.project{cellpadding: 0, cellspacing: 0, 'ng-hide' => 'processing' }
%tbody
%tr{ 'ng-show' => 'back' }
%td
%a{ 'ng-click' => "open(back)" } ../
%td
%td
- if can_remove
%td
%tr{'ng-repeat' => 'content in contents'}
%td{ 'ng-show' => 'content.is_folder' }
.pic= image_tag 'folder.png'
.name
%a.files-see{ 'ng-click' => "open(content)" } {{content.name}}
%td{ 'ng-hide' => 'content.is_folder' }
.pic= image_tag 'code.png'
.name
%a.files-see{'ng-href' => '{{content.download_url}}'} {{content.name}}
%td
%a{'ng-href' => '{{content.build_list.url}}', 'ng-show' => 'content.build_list' }
= t('activerecord.models.build_list')
%td {{content.size}}
- if can_remove
%td{ 'ng-show' => 'content.is_folder' }
%td.buttons{ 'ng-hide' => 'content.is_folder' }
%div{ 'ng-show' => 'content.processing' }
= t('layout.processing')
%span.delete{ 'ng-click' => "destroy(content)", 'ng-hide' => 'content.processing', 'ng-confirm-click' => t('layout.confirm') } &nbsp;
.both
= render 'shared/angularjs_will_paginate'

View File

@ -0,0 +1,79 @@
- set_meta_tags title: [title_object(@platform), t('layout.platforms.contents')]
= render 'platforms/base/submenu'
.container
h3
= t('layout.platforms.contents_of')
| &nbsp;
= @platform.name
#contents ng-controller='ContentsController'
= simple_form_for @platform, html: { 'ng-submit' => 'search()', id: 'search_contents_form' } do |f|
fieldset
= f.hidden_field :name
= hidden_field_tag 'path'
= hidden_field_tag 'page'
= f.input :term
.button_block
button type="submit" class="btn btn-default" data-disable-with=t('layout.processing')
= t('layout.search.header')
/ input name='term' type='text' placeholder=t('layout.platforms.search_contents')
/ | &nbsp;
/ = f.submit t('layout.search.header'), data: {'disable-with' => t('layout.processing')}, class: 'btn btn-sm btn-primary'
/ = form_for @platform, html: { class: :form, 'ng-submit' => 'search()', id: 'search_contents_form' } do |f|
/ = f.hidden_field :name
/ = hidden_field_tag 'path'
/ = hidden_field_tag 'page'
/ input name='term' type='text' placeholder=t('layout.platforms.search_contents')
/ | &nbsp;
/ = f.submit t('layout.search.header'), data: {'disable-with' => t('layout.processing')}, class: 'btn btn-sm btn-primary'
br
.path
a ng-repeat='folder in folders'
span.text ng-click="open(folder.path)" {{folder.name}}
span.arrow-right
.both
- can_remove = can? :remove_file, @platform
table.table ng-show='!processing'
tbody
tr ng-show='back'
td
a ng-click="open(back)" ../
td
td
- if can_remove
td
tr ng-repeat='content in contents'
td ng-show='content.is_folder'
span.glyphicon.glyphicon-folder-close
| &nbsp;
span
a.files-see ng-click="open(content)" {{content.name}}
td ng-hide='content.is_folder'
span.glyphicon.glyphicon-file
| &nbsp;
span
a.files-see ng-href='{{content.download_url}}' {{content.name}}
td
a ng-href='{{content.build_list.url}}' ng-show='content.build_list'
= t('activerecord.models.build_list')
td
| {{content.size}}
- if can_remove
td ng-show='content.is_folder'
td.buttons ng-hide='content.is_folder'
div ng-show='content.processing'
= t('layout.processing')
span.delete ng-click="destroy(content)" ng-hide='content.processing' ng-confirm-click=t('layout.confirm')
| &nbsp;
.both
= render 'shared/angularjs_will_paginate'

View File

@ -1,7 +0,0 @@
%table#myTable.tablesorter.advisories{cellspacing: "0", cellpadding: "0"}
%thead
%tr
%th.th1= t("activerecord.attributes.advisory.advisory_id")
%th.th2= t("activerecord.attributes.advisory.description")
%tbody
= render partial: 'advisory', collection: @advisories, as: :advisory

View File

@ -0,0 +1,7 @@
table.table.table-striped
thead
tr
th= t("activerecord.attributes.advisory.advisory_id")
th= t("activerecord.attributes.advisory.description")
tbody
= render partial: 'advisory', collection: @advisories, as: :advisory

View File

@ -1,3 +0,0 @@
%tr{class: cycle("odd", "even")}
%td= link_to advisory.advisory_id, advisory_path(advisory)
%td= truncate(advisory.description, length: 50)

View File

@ -0,0 +1,3 @@
tr
td= link_to advisory.advisory_id, advisory_path(advisory)
td= truncate(advisory.description, length: 120)

View File

@ -1,6 +1,7 @@
- set_meta_tags title: [title_object(@platform), t('layout.advisories.list_header')] - set_meta_tags title: [title_object(@platform), t('layout.advisories.list_header')]
= render 'submenu' = render 'submenu'
= render 'sidebar'
.container
.row
= render partial: 'advisories', object: @advisories = render partial: 'advisories', object: @advisories
= will_paginate @advisories = will_paginate @advisories

View File

@ -1,17 +0,0 @@
-set_meta_tags title: [title_object(@platform), t('layout.platforms.clone_header')]
= render 'submenu'
= render 'sidebar'
= form_for @cloned, url: make_clone_platform_path(@platform), html: { class: :form } do |f|
.leftlist= f.label :name, class: :label
.rightlist= f.text_field :name, class: 'text_field'
.leftlist= f.label :description, class: :label
.rightlist= f.text_field :description, class: 'text_field'
.both
.button_block
= submit_tag t('layout.clone'), data: {'disable-with' => t('layout.processing')}
%span.text_button_padding= t("layout.or")
= link_to t("layout.cancel"), platform_path(@platform), class: "button"

View File

@ -0,0 +1,18 @@
- set_meta_tags title: [title_object(@platform), t('layout.platforms.clone_header')]
= render 'submenu'
.container
.row
= simple_form_for @cloned, url: make_clone_platform_path(@platform) do |f|
fieldset
= f.input :name
= f.input :description, as: :text
.button_block
button type="submit" class="btn btn-default" data-disable-with=t('layout.processing')
= t('layout.clone')
| &nbsp;
= t('layout.or')
| &nbsp;
= link_to t('layout.cancel'), platform_path(@platform)

View File

@ -1,24 +0,0 @@
-set_meta_tags title: t('layout.platforms.list_header')
.row{ 'ng-controller' => 'PlatformsCtrl', 'ng-init' => "init(#{@platforms_count}, #{params[:page]})" }
.col-md-6.col-md-offset-3{ 'ng-cloak' => true }
= link_to t('layout.platforms.new'), new_platform_path, class: 'btn btn-primary' if can? :create, Platform
%table.table.table-hover.offset20
%thead
%tr
%th
%th= t 'activerecord.attributes.platform.name'
%th= t 'activerecord.attributes.platform.distrib_type'
%tbody
%tr{ 'ng-repeat' => 'item in platforms' }
%td
%i.fa.fa-lg{ 'ng-class' => 'item.visibility_class' }
%td
%a{ 'ng-href' => "{{item.link}}" }
{{item.name}}
%td {{item.distrib_type}}
= paginate( total_items: 'total_items',
page: 'page',
per_page: Platform.per_page,
ng_show: "total_items > #{Platform.per_page}",
select_page: "goToPage(page)" )

View File

@ -0,0 +1,25 @@
- set_meta_tags title: t('layout.platforms.list_header')
.row ng-controller='PlatformsCtrl' ng-init="init(#{@platforms_count}, #{params[:page]})"
.col-md-6.col-md-offset-3 ng-cloak=true
= link_to t('layout.platforms.new'), new_platform_path, class: 'btn btn-primary' if can? :create, Platform
table.table.table-hover.offset20
thead
tr
th
th= t 'activerecord.attributes.platform.name'
th= t 'activerecord.attributes.platform.distrib_type'
tbody
tr ng-repeat='item in platforms'
td
i.fa.fa-lg ng-class='item.visibility_class'
td
a ng-href="{{item.link}}"
| {{item.name}}
td
| {{item.distrib_type}}
= paginate( total_items: 'total_items',
page: 'page',
per_page: Platform.per_page,
ng_show: "total_items > #{Platform.per_page}",
select_page: "goToPage(page)" )

View File

@ -1,10 +0,0 @@
-set_meta_tags title: [title_object(@platform), t('layout.platforms.members')]
= render 'submenu'
= render 'sidebar'
= render "shared/members_table",
remove_members_path: remove_members_platform_path(@platform),
remove_member_path: remove_member_platform_path(@platform),
add_member_path: add_member_platform_path(@platform),
members: @members.select{|u| u != @platform.owner},
editable_object: @platform

View File

@ -0,0 +1,11 @@
-set_meta_tags title: [title_object(@platform), t('layout.platforms.members')]
= render 'submenu'
.container
.row
= render "shared/members_table",
remove_members_path: remove_members_platform_path(@platform),
remove_member_path: remove_member_platform_path(@platform),
add_member_path: add_member_platform_path(@platform),
members: @members.select{|u| u != @platform.owner},
editable_object: @platform

View File

@ -1,17 +0,0 @@
/ Add to controller something like:
/ $scope.goToPage = (number) ->
/ $location.search('page', number)
#will_paginate{'ng-show' => 'pages'}
.pagination
%div{'ng-class' => "{'disabled': !page.active}", 'ng-repeat' => 'page in pages', 'ng-switch' => 'page.type'}
%a{'ng-switch-when' => 'previous_page', 'ng-click' => 'goToPage(page.number)', href: ''}
= t('datatables.previous_label')
%a{'ng-switch-when' => 'first', href: ''}
{{page.number}}
%a{'ng-switch-when' => 'page', 'ng-click' => 'goToPage(page.number)', href: ''}
{{page.number}}
%a{'ng-switch-when' => 'more', 'ng-click' => 'goToPage(page.number)', href: ''} …
%a{'ng-switch-when' => 'last', 'ng-click' => 'goToPage(page.number)', href: ''}
{{page.number}}
%a{'ng-switch-when' => 'next_page', 'ng-click' => 'goToPage(page.number)', href: ''}
= t('datatables.next_label')

View File

@ -0,0 +1,20 @@
/ Add to controller something like:
/ $scope.goToPage = (number) ->
/ $location.search('page', number)
ul.pagination ng-show='pages'
li ng-class="{'disabled': !page.active}" ng-repeat='page in pages' ng-switch='page.type'
a ng-switch-when='previous_page' ng-hide='page.active'
= t('datatables.previous_label')
a ng-switch-when='previous_page' ng-show='page.active' ng-click='goToPage(page.number)'
= t('datatables.previous_label')
a ng-switch-when='first'
| {{page.number}}
a ng-switch-when='page' ng-click='goToPage(page.number)'
| {{page.number}}
a ng-switch-when='more' ng-click='goToPage(page.number)' …
a ng-switch-when='last' ng-click='goToPage(page.number)'
| {{page.number}}
a ng-switch-when='next_page' ng-hide='page.active'
= t('datatables.next_label')
a ng-switch-when='next_page' ng-show='page.active' ng-click='goToPage(page.number)'
= t('datatables.next_label')

View File

@ -3,7 +3,6 @@ en:
platforms: platforms:
contents: Contents contents: Contents
contents_of: Contents of contents_of: Contents of
search_contents: Search name of file/folder...
admin_id: Owner admin_id: Owner
build_all: Build all build_all: Build all
list: List list: List
@ -95,3 +94,15 @@ en:
visibility_types: visibility_types:
open: Public open: Public
hidden: Private hidden: Private
simple_form:
labels:
platform:
term: Search
admin_id: Owner
placeholders:
platform:
term: Enter the name of file or folder here.

View File

@ -95,3 +95,12 @@ ru:
visibility_types: visibility_types:
open: Публичный open: Публичный
hidden: Приватный hidden: Приватный
simple_form:
labels:
platform:
term: Искать
admin_id: Владелец
placeholders:
platform:
term: Введите имя файла или папки здесь.