Skip to content

Commit

Permalink
Merge pull request #32 from valadas/rm/list-columns
Browse files Browse the repository at this point in the history
Implemented more list-view columns
  • Loading branch information
valadas authored Feb 21, 2022
2 parents 23ed6dd + 23f2be2 commit f57e555
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
:host {
display: block;
margin-right: 1em;
}

table{
width: 100%;
border-collapse: collapse;
thead{
font-weight: bold;
tr{
border-bottom: 2px solid lightgray;
}
}
tbody{
td{
&:first-child{
img{
height: 2.5em;
display: block;
margin: 0 auto;
tr{
border-bottom: 1px solid lightgray;
td{
&:first-child{
img{
height: 2.5em;
display: block;
margin: 0 auto;
}
}
.date{
display: flex;
flex-direction: column;
}
&.size{
text-align: right;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ import state from "../../store/store";
})
export class DnnRmItemsListview {

private getLocalDateString(dateString: string) {
const date = new Date(dateString);
return <div class="date">
<span>{date.toLocaleDateString()}</span>
<span>{date.toLocaleTimeString()}</span>
</div>
}

private getFileSize(fileSize: number) {
if (fileSize == undefined || fileSize == undefined){
return "";
}

if (fileSize < 1024){
return fileSize.toString() + " B";
}

if (fileSize < 1048576 ){
return Math.round(fileSize / 1024).toString() + " KB";
}

return Math.round(fileSize / 3221225472).toString() + " MB";
}

render() {
return (
<Host>
Expand All @@ -17,20 +41,25 @@ export class DnnRmItemsListview {
<tr>
<td></td>
<td>{state.localization?.Name}</td>
<td>{state.localization?.Created}</td>
<td>{state.localization?.LastModified}</td>
<td>{state.localization?.Size}</td>
</tr>
</thead>
<tbody>
{state.currentItems.items?.map(item =>
<tr>
<td><img src={item.iconUrl} /></td>
<td>{item.itemName}</td>
</tr>
<td>{this.getLocalDateString(item.createdOn)}</td>
<td>{this.getLocalDateString(item.modifiedOn)}</td>
<td class="size">{this.getFileSize(item.fileSize)}</td>
</tr>
)}
</tbody>
</table>
}
</Host>
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,10 @@ export interface Item{
thumbnailAvailable?: boolean | undefined;
/** The relative url to the item thumbnail. */
thumbnailUrl?: string;
/** And ISO 8601 string representing the created date of the item. */
createdOn: string;
/** And ISO 8601 string representing the last modified date of the item. */
modifiedOn: string;
/** The size of the file (only available for file Items) */
fileSize?: number,
}
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,9 @@ private object GetItemViewModel(object item)
isFolder = true,
itemId = folder.FolderID,
itemName = folder.FolderName,
iconUrl = GetFolderIconUrl(this.PortalSettings.PortalId, folder.FolderMappingID),
iconUrl = GetFolderIconUrl(this.PortalSettings.PortalId, folder.FolderMappingID),
createdOn = folder.CreatedOnDate,
modifiedOn = folder.LastModifiedOnDate,
};
}

Expand All @@ -574,7 +576,10 @@ private object GetItemViewModel(object item)
path = FileManager.Instance.GetUrl(file),
iconUrl = GetFileIconUrl(file.Extension),
thumbnailAvailable = thumbnailsManager.ThumbnailAvailable(file.FileName),
thumbnailUrl = thumbnailsManager.ThumbnailUrl(this.ActiveModule.ModuleID, file.FileId, 110, 110),
thumbnailUrl = thumbnailsManager.ThumbnailUrl(this.ActiveModule.ModuleID, file.FileId, 110, 110),
createdOn = file.CreatedOnDate,
modifiedOn = file.LastModifiedOnDate,
fileSize = file.Size,
};
}

Expand Down

0 comments on commit f57e555

Please sign in to comment.