[#369] change location in the tree page
This commit is contained in:
parent
3bbf6b54f2
commit
202ac91644
|
@ -1,7 +1,6 @@
|
||||||
RosaABF.controller('GitTreeCtrl', ['$scope', '$http', function($scope, $http) {
|
RosaABF.controller('GitTreeCtrl', ['$scope', '$http', '$location', function($scope, $http, $location) {
|
||||||
$scope.project = null;
|
$scope.project = null;
|
||||||
$scope.treeish = null;
|
$scope.treeish = null;
|
||||||
$scope.path = null;
|
|
||||||
$scope.root_path = null;
|
$scope.root_path = null;
|
||||||
$scope.tree = null;
|
$scope.tree = null;
|
||||||
$scope.breadcrumb = null;
|
$scope.breadcrumb = null;
|
||||||
|
@ -10,28 +9,21 @@ RosaABF.controller('GitTreeCtrl', ['$scope', '$http', function($scope, $http) {
|
||||||
$scope.init = function(project, treeish, path, root_path) {
|
$scope.init = function(project, treeish, path, root_path) {
|
||||||
$scope.project = project;
|
$scope.project = project;
|
||||||
$scope.treeish = treeish;
|
$scope.treeish = treeish;
|
||||||
|
$scope.root_path = root_path;
|
||||||
$scope.path = path;
|
$scope.path = path;
|
||||||
$scope.path_path = root_path;
|
//$scope.getTree();
|
||||||
$scope.getTree();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getTree = function($event, path, more) {
|
$scope.refresh = function(more) {
|
||||||
$scope.processing = true;
|
$scope.processing = true;
|
||||||
more = typeof more !== 'undefined' ? more : false;
|
|
||||||
|
|
||||||
if(path) { $scope.path = path; }
|
var params = { format: 'json', path: $scope.path };
|
||||||
if($scope.path) {
|
|
||||||
var treeish = $scope.treeish+'/'+$scope.path;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var treeish = $scope.treeish;
|
|
||||||
}
|
|
||||||
var params = {format: 'json'};
|
|
||||||
if(more) {
|
if(more) {
|
||||||
params.page = $scope.next_page;
|
params.page = $scope.next_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
$http.get(Routes.tree_path($scope.project, treeish, params)).then(function(res) {
|
$http.get(Routes.tree_path($scope.project, $scope.treeish, params)).then(function(res) {
|
||||||
$scope.path = res.data.path;
|
$scope.path = res.data.path;
|
||||||
$scope.root_path = res.data.root_path;
|
$scope.root_path = res.data.root_path;
|
||||||
$scope.breadcrumb = res.data.breadcrumb;
|
$scope.breadcrumb = res.data.breadcrumb;
|
||||||
|
@ -44,6 +36,28 @@ RosaABF.controller('GitTreeCtrl', ['$scope', '$http', function($scope, $http) {
|
||||||
}
|
}
|
||||||
$scope.processing = false;
|
$scope.processing = false;
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.$on('$locationChangeSuccess', function(event) {
|
||||||
|
$scope.path = $location.search()['path'];
|
||||||
|
$scope.refresh();
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.getTree = function($event, path, more) {
|
||||||
|
if($scope.processing && $event) {
|
||||||
|
return $event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
more = typeof more !== 'undefined' ? more : false;
|
||||||
|
if(path && path !== '') { $scope.path = path; }
|
||||||
|
else { $scope.path = null; }
|
||||||
|
|
||||||
|
if(more) {
|
||||||
|
$scope.refresh(more);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$location.search('path', $scope.path);
|
||||||
|
}
|
||||||
|
|
||||||
if($event) {
|
if($event) {
|
||||||
$event.preventDefault();
|
$event.preventDefault();
|
||||||
|
|
|
@ -14,6 +14,8 @@ class Projects::Git::TreesController < Projects::Git::BaseController
|
||||||
@tree = @tree / @path if @path.present?
|
@tree = @tree / @path if @path.present?
|
||||||
@commit = @branch.present? ? @branch.commit() : @project.repo.log(@treeish, @path, max_count: 1).first
|
@commit = @branch.present? ? @branch.commit() : @project.repo.log(@treeish, @path, max_count: 1).first
|
||||||
raise Grit::NoSuchPathError unless @commit
|
raise Grit::NoSuchPathError unless @commit
|
||||||
|
else
|
||||||
|
@tree = @tree / @path if @path.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%ol.breadcrumb
|
%ol.breadcrumb
|
||||||
%li= link_to @project.name, tree_path(@project, treeish: @treeish), 'ng-click' => "getTree($event, '/')"
|
%li= link_to @project.name, tree_path(@project, treeish: @treeish), 'ng-click' => "getTree($event, '')"
|
||||||
%li{ 'ng-repeat' => 'el in breadcrumb.paths' }
|
%li{ 'ng-repeat' => 'el in breadcrumb.paths' }
|
||||||
%a{ href: '#', 'ng-click' => 'getTree($event, el.path)' } {{el.name}}
|
%a{ href: '#', 'ng-click' => 'getTree($event, el.path)' } {{el.name}}
|
||||||
%li.active {{breadcrumb.last}}
|
%li.active {{breadcrumb.last}}
|
||||||
|
|
|
@ -4,15 +4,14 @@
|
||||||
.files
|
.files
|
||||||
.pull-left= render 'whereami'
|
.pull-left= render 'whereami'
|
||||||
.pull-right= render 'fork'
|
.pull-right= render 'fork'
|
||||||
- root_path = @path.present? ? File.join([@path, ".."].compact) : 'null'
|
|
||||||
%table.table.table-hover
|
%table.table.table-hover
|
||||||
%thead
|
%thead
|
||||||
%tr
|
%tr
|
||||||
%th= t 'layout.projects.filename'
|
%th= t 'layout.projects.filename'
|
||||||
%th.col-md-8= t 'layout.projects.message'
|
%th.col-md-8= t 'layout.projects.message'
|
||||||
%th= t 'layout.projects.age'
|
%th= t 'layout.projects.age'
|
||||||
%tbody
|
%tbody{ 'ng-hide' => 'processing' }
|
||||||
%tr{ 'ng-show' => 'path && !processing' }
|
%tr{ 'ng-show' => 'path' }
|
||||||
%td
|
%td
|
||||||
%span= fa_icon 'folder', class: 'text-primary'
|
%span= fa_icon 'folder', class: 'text-primary'
|
||||||
%a{ 'ng-href' => '{{root_path}}', 'ng-click' => 'getTree($event, root_path)' } ..
|
%a{ 'ng-href' => '{{root_path}}', 'ng-click' => 'getTree($event, root_path)' } ..
|
||||||
|
|
|
@ -62,7 +62,7 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
json.path @path
|
json.path @path
|
||||||
json.root_path @path.present? ? File.join([@path, ".."].compact) : nil
|
json.root_path @path.present? ? @path.split('/')[0...-1].join('/') : nil
|
||||||
params[:page].to_i
|
params[:page].to_i
|
||||||
json.next_page page.next if @tree.contents.count >= Project::CONTENT_LIMIT*(page+1)
|
json.next_page page.next if @tree && @tree.contents.count >= Project::CONTENT_LIMIT*(page+1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -361,7 +361,7 @@ Rosa::Application.routes.draw do
|
||||||
constraints Rosa::Constraints::Treeish do
|
constraints Rosa::Constraints::Treeish do
|
||||||
# Tree
|
# Tree
|
||||||
get '/' => "git/trees#show", as: :project
|
get '/' => "git/trees#show", as: :project
|
||||||
get '/tree/:treeish(/*path)' => "git/trees#show", as: :tree, format: false
|
get '/tree/:treeish' => "git/trees#show", as: :tree, format: false
|
||||||
# Tags
|
# Tags
|
||||||
get '/tags' => "git/trees#tags", as: :tags
|
get '/tags' => "git/trees#tags", as: :tags
|
||||||
# Branches
|
# Branches
|
||||||
|
|
Loading…
Reference in New Issue