/[A3C]/lib/A3C/View/Strix.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/A3C/View/Strix.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 157 - (show annotations)
Sun Jun 15 10:51:57 2008 UTC (15 years, 10 months ago) by dpavlin
File size: 3923 byte(s)
create kind of copy/paste buffer which enables you to select some strix sites
and perform operations on them together (no ops implemented in this commit)
1 package A3C::View::Strix;
2
3 =head1 NAME
4
5 A3C::View::Strix
6
7 =head1 DESCRIPTION
8
9 Display information about Strix sites
10
11 =head1 TEMPLATES
12
13 =cut
14
15 use strict;
16 use warnings;
17
18 use Jifty::View::Declare -base;
19 use Data::Dump qw/dump/;
20
21 =head2 /
22
23 Display sites search and some stats
24
25 =cut
26
27 template 'index.html' => page {
28
29 title is _('Strix sites');
30
31 render_region(
32 name => 'user-selected-sites',
33 path => '/strix/selected-sites'
34 );
35
36 render_region(
37 name => 'search_sites',
38 path => '/strix/search_sites',
39 );
40
41 h1 { _('Statistics') }
42
43 my $orgs = A3C::Model::StrixSiteCollection->new;
44 $orgs->unlimit;
45
46 dt { _('Number of Strix sites') }
47 dd { $orgs->count }
48
49 };
50
51 =head2 name_diff
52
53 =cut
54
55 template 'name_diff' => page {
56
57 title is _('Strix sites | name differences between php config and internal state');
58
59 my $name_diff = A3C::SQL->new({ query => qq{
60 select
61 site,hreduorgurl,
62 _site_name,o
63 from strix_sites
64 join hr_edu_orgs on cn = site
65 where o != _site_name
66 }});
67
68 h1 { _('Name differences') }
69 dd {
70 table {
71 row {
72 th { _('Site') }
73 th { _('Strix site name') }
74 th { _('hrEduOrg.o') }
75 };
76 while ( my $row = $name_diff->next ) {
77 row {
78 cell { hyperlink( url => 'http://' . $row->hreduorgurl, label => $row->site ) }
79 cell { $row->_site_name }
80 cell { $row->o }
81 }
82 }
83 }
84 }
85
86 };
87
88 =head1 REGIONS
89
90 =head2 search_sites
91
92 =cut
93
94 template 'search_sites' => sub {
95
96 h1 { _('Find site') }
97
98 my $action = new_action(
99 class => 'SearchStrixSite',
100 moniker => 'search-strix-site',
101 sticky_on_success => 1,
102 sticky_on_failure => 1,
103 );
104
105
106 form {
107 render_action( $action => [ 'site_contains', '_site_name_contains' ] );
108 form_submit( label => _('Search') );
109 };
110
111 # warn dump( $action->result->content );
112
113 if ( my $search = $action->result->content('search') ) {
114 div { _('Found %1 results', $search->count ) }
115 table {
116 while (my $strix = $search->next) {
117 row {
118 cell { tt { $strix->site } }
119 cell { $strix->_site_name }
120 cell { show( 'site_selection', 'Create', '+', $strix->site ) }
121 }
122 }
123 }
124 }
125
126 };
127
128 =head2 selected_sites
129
130 Show Selected sites for current user
131
132 =cut
133
134 template 'selected-sites' => sub {
135 my $self = shift;
136
137 warn "## IN selected-sites ",dump( @_ );
138
139 if ( my $op = get 'op' ) {
140 my $site = get 'site' or die "no site?";
141 warn "# selected-sites $op on $site";
142
143 my $a;
144
145 if ( $op eq 'Create' ) {
146
147 $a = new_action(
148 class => $op . 'StrixSiteSelection',
149 moniker => $op,
150 arguments => {
151 strix => $site,
152 by_user => $self->current_user->id,
153 },
154 );
155
156 } elsif ( $op eq 'Delete' ) {
157
158 my $strix = A3C::Model::StrixSiteSelection->new;
159 $strix->load_by_cols( strix => $site, by_user => $self->current_user->id );
160 die "can't find site $site" unless $strix->id;
161 $a = $strix->as_delete_action;
162
163 }
164 warn "# argument_values = ",dump( $a->argument_values );
165 $a->run;
166 warn "can't $op site $site" unless $a->result->success;
167 }
168
169 my $selected = A3C::Model::StrixSiteSelectionCollection->new;
170 $selected->limit( column => 'by_user', value => Jifty->web->current_user->id );
171
172 if ( $selected->count > 0 ) {
173
174 div { _('%1 sites selected', $selected->count ) }
175 table {
176 while (my $s = $selected->next) {
177 row {
178 cell { tt { $s->strix->site } }
179 cell { $s->strix->_site_name }
180 cell { show( 'site_selection', 'Delete', '-', $s->strix->site ) }
181 }
182 }
183 }
184 } else {
185 div { _('No sites selected') }
186 }
187 };
188
189 =head2 site_selection
190
191 Display button to add/remove site from selection
192
193 show( 'site_selection', 'Delete', '-', $strix->site );
194
195 =cut
196
197 template 'site_selection' => sub {
198 my $self = shift;
199
200 warn "# site_selection = ",dump( @_ );
201
202 my ( $op, $label, $site ) = @_;
203
204 form {
205 hyperlink(
206 label => $label,
207 onclick => {
208 refresh => 'user-selected-sites',
209 path => '/strix/selected-sites',
210 args => {
211 site => $site,
212 op => $op,
213 }
214 },
215 );
216 }
217
218 };
219
220
221 1;

  ViewVC Help
Powered by ViewVC 1.1.26