Fossil SCM

Improve the /info page to show more detailed information about clusters.

drh 2024-12-20 14:38 trunk
Commit 4170e0bb02401808f543e3ebaa42f5f92c2683c84597e8c6cccedd264a2de3d9
1 file changed +124 -1
+124 -1
--- src/info.c
+++ src/info.c
@@ -1933,11 +1933,11 @@
19331933
tag_private_status(rid);
19341934
}
19351935
db_finalize(&q);
19361936
if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
19371937
rid, TAG_CLUSTER) ){
1938
- @ Cluster
1938
+ @ Cluster %z(href("%R/info/%S",zUuid))%S(zUuid)</a>.
19391939
cnt++;
19401940
}
19411941
if( cnt==0 ){
19421942
@ Unrecognized artifact
19431943
if( pDownloadName && blob_size(pDownloadName)==0 ){
@@ -3168,10 +3168,129 @@
31683168
ticket_output_change_artifact(pTktChng, 0, 1, 0);
31693169
manifest_destroy(pTktChng);
31703170
style_finish_page();
31713171
}
31723172
3173
+/*
3174
+** rid is a cluster. Paint a page that contains detailed information
3175
+** about that cluster.
3176
+*/
3177
+static void cluster_info(int rid, const char *zName){
3178
+ Manifest *pCluster;
3179
+ int i;
3180
+ Blob where = BLOB_INITIALIZER;
3181
+ Blob unks = BLOB_INITIALIZER;
3182
+ Stmt q;
3183
+ char *zSha1Bg;
3184
+ char *zSha3Bg;
3185
+ int badRid = 0;
3186
+ int hashClr = PB("hclr");
3187
+
3188
+ pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
3189
+ if( pCluster==0 ){
3190
+ artifact_page();
3191
+ return;
3192
+ }
3193
+ style_header("Cluster %S", zName);
3194
+ @ <p>Artifact %z(href("%R/artifact/%h",zName))%S(zName)</a> is a cluster
3195
+ @ with %d(pCluster->nCChild) entries:</p>
3196
+ blob_appendf(&where,"IN(0");
3197
+ for(i=0; i<pCluster->nCChild; i++){
3198
+ int rid = fast_uuid_to_rid(pCluster->azCChild[i]);
3199
+ if( rid ){
3200
+ blob_appendf(&where,",%d", rid);
3201
+ }else{
3202
+ if( blob_size(&unks)>0 ) blob_append_char(&unks, ',');
3203
+ badRid++;
3204
+ blob_append_sql(&unks,"(%d,%Q)",-badRid,pCluster->azCChild[i]);
3205
+ }
3206
+ }
3207
+ blob_append_char(&where,')');
3208
+ describe_artifacts(blob_str(&where));
3209
+ blob_reset(&where);
3210
+ if( badRid>0 ){
3211
+ db_multi_exec(
3212
+ "WITH unks(rx,hx) AS (VALUES %s)\n"
3213
+ "INSERT INTO description(rid,uuid,type,summmary) "
3214
+ " SELECT rx, hx, 'phantom', '' FROM unks;",
3215
+ blob_sql_text(&unks)
3216
+ );
3217
+ }
3218
+ blob_reset(&unks);
3219
+ db_prepare(&q,
3220
+ "SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref"
3221
+ " FROM description ORDER BY uuid"
3222
+ );
3223
+ if( skin_detail_boolean("white-foreground") ){
3224
+ zSha1Bg = "#714417";
3225
+ zSha3Bg = "#177117";
3226
+ }else{
3227
+ zSha1Bg = "#ebffb0";
3228
+ zSha3Bg = "#b0ffb0";
3229
+ }
3230
+ @ <table cellpadding="2" cellspacing="0" border="1">
3231
+ if( g.perm.Admin ){
3232
+ @ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks
3233
+ }else{
3234
+ @ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks
3235
+ }
3236
+ while( db_step(&q)==SQLITE_ROW ){
3237
+ int rid = db_column_int(&q,0);
3238
+ const char *zUuid = db_column_text(&q, 1);
3239
+ const char *zDesc = db_column_text(&q, 2);
3240
+ int isPriv = db_column_int(&q,3);
3241
+ int isPhantom = db_column_int(&q,4);
3242
+ const char *zRef = db_column_text(&q,6);
3243
+ if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
3244
+ /* Don't show private artifacts to users without Private (x) permission */
3245
+ continue;
3246
+ }
3247
+ if( rid<=0 ){
3248
+ @ <tr><td>&nbsp;</td>
3249
+ }else if( hashClr ){
3250
+ const char *zClr = db_column_bytes(&q,1)>40 ? zSha3Bg : zSha1Bg;
3251
+ @ <tr style='background-color:%s(zClr);'><td align="right">%d(rid)</td>
3252
+ }else{
3253
+ @ <tr><td align="right">%d(rid)</td>
3254
+ }
3255
+ if( rid<=0 ){
3256
+ @ <td>&nbsp;%S(zUuid)&nbsp;</td>
3257
+ }else{
3258
+ @ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
3259
+ }
3260
+ if( g.perm.Admin ){
3261
+ int rcvid = db_column_int(&q,5);
3262
+ if( rcvid<=0 ){
3263
+ @ <td>&nbsp;
3264
+ }else{
3265
+ @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a>
3266
+ }
3267
+ }
3268
+ @ <td align="left">%h(zDesc)</td>
3269
+ if( zRef && zRef[0] ){
3270
+ @ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
3271
+ }else{
3272
+ @ <td>&nbsp;
3273
+ }
3274
+ if( isPriv || isPhantom ){
3275
+ if( isPriv==0 ){
3276
+ @ <td>phantom</td>
3277
+ }else if( isPhantom==0 ){
3278
+ @ <td>private</td>
3279
+ }else{
3280
+ @ <td>private,phantom</td>
3281
+ }
3282
+ }else{
3283
+ @ <td>&nbsp;
3284
+ }
3285
+ @ </tr>
3286
+ }
3287
+ @ </table>
3288
+ db_finalize(&q);
3289
+ style_finish_page();
3290
+}
3291
+
31733292
31743293
/*
31753294
** WEBPAGE: info
31763295
** URL: info/NAME
31773296
**
@@ -3256,10 +3375,14 @@
32563375
if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
32573376
ci_page();
32583377
}else
32593378
if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
32603379
ainfo_page();
3380
+ }else
3381
+ if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
3382
+ rid, TAG_CLUSTER) ){
3383
+ cluster_info(rid, zName);
32613384
}else
32623385
{
32633386
artifact_page();
32643387
}
32653388
}
32663389
--- src/info.c
+++ src/info.c
@@ -1933,11 +1933,11 @@
1933 tag_private_status(rid);
1934 }
1935 db_finalize(&q);
1936 if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1937 rid, TAG_CLUSTER) ){
1938 @ Cluster
1939 cnt++;
1940 }
1941 if( cnt==0 ){
1942 @ Unrecognized artifact
1943 if( pDownloadName && blob_size(pDownloadName)==0 ){
@@ -3168,10 +3168,129 @@
3168 ticket_output_change_artifact(pTktChng, 0, 1, 0);
3169 manifest_destroy(pTktChng);
3170 style_finish_page();
3171 }
3172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3173
3174 /*
3175 ** WEBPAGE: info
3176 ** URL: info/NAME
3177 **
@@ -3256,10 +3375,14 @@
3256 if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
3257 ci_page();
3258 }else
3259 if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
3260 ainfo_page();
 
 
 
 
3261 }else
3262 {
3263 artifact_page();
3264 }
3265 }
3266
--- src/info.c
+++ src/info.c
@@ -1933,11 +1933,11 @@
1933 tag_private_status(rid);
1934 }
1935 db_finalize(&q);
1936 if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
1937 rid, TAG_CLUSTER) ){
1938 @ Cluster %z(href("%R/info/%S",zUuid))%S(zUuid)</a>.
1939 cnt++;
1940 }
1941 if( cnt==0 ){
1942 @ Unrecognized artifact
1943 if( pDownloadName && blob_size(pDownloadName)==0 ){
@@ -3168,10 +3168,129 @@
3168 ticket_output_change_artifact(pTktChng, 0, 1, 0);
3169 manifest_destroy(pTktChng);
3170 style_finish_page();
3171 }
3172
3173 /*
3174 ** rid is a cluster. Paint a page that contains detailed information
3175 ** about that cluster.
3176 */
3177 static void cluster_info(int rid, const char *zName){
3178 Manifest *pCluster;
3179 int i;
3180 Blob where = BLOB_INITIALIZER;
3181 Blob unks = BLOB_INITIALIZER;
3182 Stmt q;
3183 char *zSha1Bg;
3184 char *zSha3Bg;
3185 int badRid = 0;
3186 int hashClr = PB("hclr");
3187
3188 pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0);
3189 if( pCluster==0 ){
3190 artifact_page();
3191 return;
3192 }
3193 style_header("Cluster %S", zName);
3194 @ <p>Artifact %z(href("%R/artifact/%h",zName))%S(zName)</a> is a cluster
3195 @ with %d(pCluster->nCChild) entries:</p>
3196 blob_appendf(&where,"IN(0");
3197 for(i=0; i<pCluster->nCChild; i++){
3198 int rid = fast_uuid_to_rid(pCluster->azCChild[i]);
3199 if( rid ){
3200 blob_appendf(&where,",%d", rid);
3201 }else{
3202 if( blob_size(&unks)>0 ) blob_append_char(&unks, ',');
3203 badRid++;
3204 blob_append_sql(&unks,"(%d,%Q)",-badRid,pCluster->azCChild[i]);
3205 }
3206 }
3207 blob_append_char(&where,')');
3208 describe_artifacts(blob_str(&where));
3209 blob_reset(&where);
3210 if( badRid>0 ){
3211 db_multi_exec(
3212 "WITH unks(rx,hx) AS (VALUES %s)\n"
3213 "INSERT INTO description(rid,uuid,type,summmary) "
3214 " SELECT rx, hx, 'phantom', '' FROM unks;",
3215 blob_sql_text(&unks)
3216 );
3217 }
3218 blob_reset(&unks);
3219 db_prepare(&q,
3220 "SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref"
3221 " FROM description ORDER BY uuid"
3222 );
3223 if( skin_detail_boolean("white-foreground") ){
3224 zSha1Bg = "#714417";
3225 zSha3Bg = "#177117";
3226 }else{
3227 zSha1Bg = "#ebffb0";
3228 zSha3Bg = "#b0ffb0";
3229 }
3230 @ <table cellpadding="2" cellspacing="0" border="1">
3231 if( g.perm.Admin ){
3232 @ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks
3233 }else{
3234 @ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks
3235 }
3236 while( db_step(&q)==SQLITE_ROW ){
3237 int rid = db_column_int(&q,0);
3238 const char *zUuid = db_column_text(&q, 1);
3239 const char *zDesc = db_column_text(&q, 2);
3240 int isPriv = db_column_int(&q,3);
3241 int isPhantom = db_column_int(&q,4);
3242 const char *zRef = db_column_text(&q,6);
3243 if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){
3244 /* Don't show private artifacts to users without Private (x) permission */
3245 continue;
3246 }
3247 if( rid<=0 ){
3248 @ <tr><td>&nbsp;</td>
3249 }else if( hashClr ){
3250 const char *zClr = db_column_bytes(&q,1)>40 ? zSha3Bg : zSha1Bg;
3251 @ <tr style='background-color:%s(zClr);'><td align="right">%d(rid)</td>
3252 }else{
3253 @ <tr><td align="right">%d(rid)</td>
3254 }
3255 if( rid<=0 ){
3256 @ <td>&nbsp;%S(zUuid)&nbsp;</td>
3257 }else{
3258 @ <td>&nbsp;%z(href("%R/info/%!S",zUuid))%S(zUuid)</a>&nbsp;</td>
3259 }
3260 if( g.perm.Admin ){
3261 int rcvid = db_column_int(&q,5);
3262 if( rcvid<=0 ){
3263 @ <td>&nbsp;
3264 }else{
3265 @ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a>
3266 }
3267 }
3268 @ <td align="left">%h(zDesc)</td>
3269 if( zRef && zRef[0] ){
3270 @ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a>
3271 }else{
3272 @ <td>&nbsp;
3273 }
3274 if( isPriv || isPhantom ){
3275 if( isPriv==0 ){
3276 @ <td>phantom</td>
3277 }else if( isPhantom==0 ){
3278 @ <td>private</td>
3279 }else{
3280 @ <td>private,phantom</td>
3281 }
3282 }else{
3283 @ <td>&nbsp;
3284 }
3285 @ </tr>
3286 }
3287 @ </table>
3288 db_finalize(&q);
3289 style_finish_page();
3290 }
3291
3292
3293 /*
3294 ** WEBPAGE: info
3295 ** URL: info/NAME
3296 **
@@ -3256,10 +3375,14 @@
3375 if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){
3376 ci_page();
3377 }else
3378 if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){
3379 ainfo_page();
3380 }else
3381 if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d",
3382 rid, TAG_CLUSTER) ){
3383 cluster_info(rid, zName);
3384 }else
3385 {
3386 artifact_page();
3387 }
3388 }
3389

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button