Subversion Repositories wimsdev

Rev

Rev 14864 | Rev 14984 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
14297 guerimand 1
!! define variables :
2
!! quota_total : deprecated use wims_class_quota instead ?
3
!! quota_free : actual free space of the class
14595 obado 4
!! quota_used : actual used space
14297 guerimand 5
!! quota_reserved : actual reserved space for some activity (active freework ...)
6
!! auth_upload : yes if class capacity is ok (else no)
7
!! wims_read_parm is proc or html (proc make calcul and html show result on page)
8
 
14864 obado 9
!if $wims_read_parm isitemof proc,html,canvas
10
  !goto $wims_read_parm
14297 guerimand 11
!endif
12
 
13
:proc
14
!! ---- calcul
15
!read adm/du $wims_home/log/classes/$wims_class
14320 guerimand 16
!if $class_type=$empty
17
  class_type=!defof class_type in wimshome/log/classes/$wims_class/.def
18
!endif
19
!if $class_type iswordof 2 4 and $wims_superclass_quota!=$empty
20
  quota_total=$wims_superclass_quota
21
!else
22
  quota_total=$wims_class_quota
23
!endif
14297 guerimand 24
quota_used=$du
25
!! -------------------- calculate space reserved
26
quota_reserved=0
27
!! ------- space reserved for active freework of type>=2
28
nb_=!recordcnt wimshome/log/classes/$wims_class/freeworks/.freeworks
29
nbuser_=!recordcnt wimshome/log/classes/$wims_class/.userlist
30
!for k_=1 to $nb_
31
  dt_=!record $k_ of wimshome/log/classes/$wims_class/freeworks/.freeworks
32
  !distribute line $dt_ into s_,bl,bl,bl,bl,t_,bl,bl,c_
33
  !if $s_=1 and $t_>=2
34
    !read adm/du $wims_home/log/classes/$wims_class/freeworksdata/$k_/work
35
    quota_reserved=$[$quota_reserved+$nbuser_*$c_*0.25-$du]
36
  !endif
37
!next k_
38
 
39
quota_reserved=$[min($quota_reserved,$wims_class_quota-$quota_used)]
40
!! -------------------- end reserved calculation
41
quota_free=$[$quota_total-$quota_used-$quota_reserved]
42
 
43
!if $quota_free<5
44
  auth_upload=no
45
!else
46
  auth_upload=yes
47
!endif
48
 
49
!exit
50
 
51
:html
14863 obado 52
!readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
53
!set x1=$[floor($quota_used/$wims_class_quota*10000)/100]
54
!set x1_int=$[floor($x1)]
55
!set x2=$[floor($quota_reserved/$wims_class_quota*10000)/100]
56
!set x2_int=$[floor($x2)]
57
!set x3=$[floor($quota_free/$wims_class_quota*10000)/100]
58
 
14907 obado 59
<div class="wims_quotafree">
60
  <style>@import "html/themes/_css/quota_bar.css";</style>
61
  <div class="wimscenter">
62
    $(name_availablespace[1]) ($wims_class_quota $name_mega)
63
  </div>
64
  <div class="quota-bar" role="progressbar" tabindex="0"
65
       aria-valuenow="$x1" aria-valuemin="0" aria-valuemax="100"
66
       aria-valuetext="$(name_availablespace[2]): $x1% of $wims_class_quota$name_mega">
67
    !! used
68
    <div class="quota-index alert" title="$x1% $(name_availablespace[2])" style="width:$x1%">$x1_int%</div>
69
    !! reserved
70
    !if $x2>0
71
      <div class="quota-index warning" title="$x2% $(name_availablespace[4])" style="width:$x2%">$x2_int%</div>
72
    !endif
73
    !!free
74
    <div class="quota-index blank" title="$x3% $(name_availablespace[3])">&nbsp;</div>
75
  </div>
76
  <p class="formHelp wimscenter">
77
    <span class="quota-legend alert">$(name_availablespace[2]): $quota_used$name_mega</span>;
78
    !if $quota_reserved>0
79
      <span class="quota-legend warning">$(name_availablespace[4]): $quota_reserved$name_mega</span>;
80
    !endif
81
    <span class="quota-legend">$(name_availablespace[3]): $quota_free$name_mega</span>.
82
  </p>
14863 obado 83
</div>
84
 
85
!exit
86
:canvas
14595 obado 87
  !readproc adm/class/classlang lang/scriptadmclass.phtml adm_class_quotafree
88
  <div class="wimscenter">
89
    <label for="freespace">$(name_availablespace[1]) ($wims_class_quota $name_mega)</label>
90
    <canvas id="freespace" width="700" height="50">
91
      $(name_availablespace[1]) : $wims_class_quota  $name_mega ($(name_availablespace[2]): $quota_used $name_mega ; $(name_availablespace[4]): $quota_reserved $name_mega ; $(name_availablespace[3]): $quota_free $name_mega ).
92
    </canvas>
93
    !set x1=$[floor(($quota_used)/$wims_class_quota*700)]
94
    !set x2=$[floor(($quota_reserved)/$wims_class_quota*700)]
95
    <script>
14297 guerimand 96
    function draw() {
97
      var canvas = document.getElementById("freespace");
98
      if (canvas.getContext) {
99
        var ctx = canvas.getContext("2d");
100
 
14595 obado 101
          ctx.fillStyle = 'red';
102
          ctx.fillRect(1,1,$x1,24);
103
          ctx.fillRect(100,30,10,10);
14297 guerimand 104
 
14595 obado 105
          !if $quota_reserved>0
106
            ctx.fillStyle = 'yellow';
107
            ctx.fillRect($x1,1,$x2,24);
108
            ctx.fillRect(250,30,10,10);
109
          !endif
110
 
111
          ctx.fillStyle = 'green';
112
          ctx.fillRect($[1+$x1+$x2],1,$[700-$x1-$X2],24);
113
          ctx.fillRect(400,30,10,10);
114
 
115
          ctx.fillStyle = 'black';
116
          ctx.strokeRect(0, 0, 700, 24);
117
          ctx.fillText('$(name_availablespace[2])',120,40);
118
          ctx.fillText('$quota_used',$[floor($x1/2)],15);
119
          ctx.fillText('$(name_availablespace[3])',420,40);
120
          ctx.fillText('$quota_free',$[floor((700+$x1+$x2)/2)],15);
121
          !if $quota_reserved>0
122
            ctx.fillText('$(name_availablespace[4])',270,40);
123
            ctx.fillText('$quota_reserved',$[floor($x1+($x2)/2)],15);
124
          !endif
125
        }
14297 guerimand 126
      }
14595 obado 127
      draw();
128
    </script>
129
  </div>
14297 guerimand 130
!exit