2eb840e2f6321346a970fc26e010158f57ff7602 max Mon Mar 25 07:21:48 2024 -0700 showing view counts in session list and adding the copy to clipboard button here, too, refs #33248 diff --git src/hg/hgSession/hgSession.c src/hg/hgSession/hgSession.c index 370c9b7..f2e1b46 100644 --- src/hg/hgSession/hgSession.c +++ src/hg/hgSession/hgSession.c @@ -177,48 +177,48 @@ else dyStringPrintf(dyTmp, "%shgTracks?hgS_doOtherUser=submit&" "hgS_otherUserName=%s&hgS_otherUserSessionName=%s", hLocalHostCgiBinUrl(), userName, sessionName); if (encode) { dyStringPrintf(dy, "%s", cgiEncodeFull(dyTmp->string)); } else { dyStringPrintf(dy, "%s", dyTmp->string); } dyStringFree(&dyTmp); } -void printCopyToClipboardButton(struct dyString *dy, char *iconId, char *targetId) +void printCopyToClipboardButton(struct dyString *dy, char *iconId, char *targetId, char *buttonLabel) /* print a copy-to-clipboard button with DOM id iconId that copies the node text of targetId */ { -dyStringPrintf(dy, " \n", iconId, targetId); +dyStringPrintf(dy, " \n", iconId, targetId, buttonLabel); jsOnEventById("click", iconId, "copyToClipboard(event);"); } void printShareMessage(struct dyString *dy, char *userName, char *sessionName, boolean encode) { struct dyString *dyTmp = dyStringNew(0); addSessionLink(dyTmp, userName, sessionName, encode, TRUE); dyStringPrintf(dy, "

You can share this session with the following URL:
%s ", dyTmp->string); -printCopyToClipboardButton(dy, "copyIcon", "urlText"); +printCopyToClipboardButton(dy, "copyIcon", "urlText", " Copy to Clipboard"); dyStringAppend(dy, "

"); } char *getSessionLink(char *encUserName, char *encSessionName) /* Form a link that will take the user to a bookmarkable page that * will load the given session. */ { struct dyString *dy = dyStringNew(1024); dyStringPrintf(dy, "Browser\n"); return dyStringCannibalize(&dy); } char *getSessionEmailLink(char *encUserName, char *encSessionName) @@ -311,103 +311,122 @@ "$(document).ready(function () {\n" " $('#sessionTable').DataTable({\"columnDefs\": [{\"orderable\":false, \"targets\":[0,4,5,6,7,8]}],\n" " \"order\":[2,'desc'],\n" " \"stateSave\":true,\n" " \"stateSaveCallback\": %s,\n" " \"stateLoadCallback\": %s\n" " });\n" "} );\n" "}\n" , jsDataTableStateSave(hgSessionPrefix), jsDataTableStateLoad(hgSessionPrefix, cart)); printf("

My Sessions

\n"); printf("
"); printf("\n"); printf(""); -printf("" +printf("" + "" + "" "" "" "" "" "", cartSidUrlString(cart)); printf(""); printf("\n"); if (gotSettings) - sqlSafef(query, sizeof(query), "SELECT sessionName, shared, firstUse, contents, settings from %s " + sqlSafef(query, sizeof(query), "SELECT sessionName, shared, firstUse, useCount, contents, settings from %s " "WHERE userName = '%s' ORDER BY sessionName;", namedSessionTable, encUserName); else - sqlSafef(query, sizeof(query), "SELECT sessionName, shared, firstUse, contents from %s " + sqlSafef(query, sizeof(query), "SELECT sessionName, shared, firstUse, useCount, contents from %s " "WHERE userName = '%s' ORDER BY sessionName;", namedSessionTable, encUserName); sr = sqlGetResult(conn, query); +int rowIdx = 0; + while ((row = sqlNextRow(sr)) != NULL) { char *encSessionName = row[0]; char *sessionName = cgiDecodeClone(encSessionName); char *link = NULL; int shared = atoi(row[1]); char *firstUse = row[2]; char buf[512]; boolean inGallery = FALSE; boolean hasDescription = FALSE; if (shared >=2) inGallery = TRUE; printf("" - "" + "" + "
session name (click to load)created onassemblysession name (click to load)created onview countassemblyview/edit 
details 
delete this 
session 
share with 
others? 
post in 
public listing?
send to
mail
  "); + char iconId[256]; + char linkId[256]; + safef(linkId, sizeof(linkId), "linkEl-%d", rowIdx); + safef(iconId, sizeof(iconId), "iconEl-%d", rowIdx); + struct dyString *buttonText = dyStringNew(4096); + printCopyToClipboardButton(buttonText, iconId, linkId, ""); + puts(dyStringCannibalize(&buttonText)); + puts(" "); + struct dyString *dy = dyStringNew(1024); addSessionLink(dy, encUserName, encSessionName, FALSE, TRUE); - printf("%s", dyStringContents(dy), htmlEncode(sessionName)); + char *sessionUrl = dyStringContents(dy); + printf("%s", rowIdx, sessionUrl, sessionUrl, htmlEncode(sessionName)); dyStringFree(&dy); + rowIdx++; struct tm firstUseTm; ZeroVar(&firstUseTm); strptime(firstUse, "%Y-%m-%d %T", &firstUseTm); char *spacePt = strchr(firstUse, ' '); if (spacePt != NULL) *spacePt = '\0'; + + char *useCount = row[3]; printf("  %s  ", mktime(&firstUseTm), firstUse); + "%s  %s", mktime(&firstUseTm), firstUse, useCount); char *dbIdx = NULL; - if (startsWith("db=", row[3])) - dbIdx = row[3]+3; + if (startsWith("db=", row[4])) + dbIdx = row[4]+3; else - dbIdx = strstr(row[3], "&db=") + 4; + dbIdx = strstr(row[4], "&db=") + 4; if (dbIdx != NULL) { char *dbEnd = strchr(dbIdx, '&'); char *db = NULL; if (dbEnd != NULL) db = cloneStringZ(dbIdx, dbEnd-dbIdx); else db = cloneString(dbIdx); - printf("%s", db); + printf("%s", db); } else printf("n/a"); if (gotSettings) { safef(buf, sizeof(buf), "%s%s", hgsEditPrefix, encSessionName); cgiMakeButton(buf, "view/edit"); - char *description = getSetting(row[4], "description"); + char *description = getSetting(row[5], "description"); if (!isEmpty(description)) hasDescription = TRUE; } else printf("unavailable"); printf(""); safef(buf, sizeof(buf), "%s%s", hgsDeletePrefix, encSessionName); char command[512]; safef(command, sizeof(command), confirmDeleteFormat, encSessionName); cgiMakeOnClickSubmitButton(command, buf, "delete"); printf(""); safef(buf, sizeof(buf), "%s%s", hgsSharePrefix, encSessionName); cgiMakeCheckBoxWithId(buf, shared>0, buf);