summaryrefslogtreecommitdiffstats
path: root/idrop-web/grails-app/views/browse/_dataObjectInfoToolbar.gsp
blob: 20b7923d90e92724ba594906dcc1979a684394da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<div id="dataObjectInfoToolbar" >

	<div id="dataObjectInfoToolbarMenu" class="btn-toolbar">
		
		<div id="dataObjectInfoButtonGroup1" class="btn-group">
			<g:if  test="${irodsStarredFileOrCollection}">
				<button id="unstarDataObject" onclick="dibUnstarFile()"><img class="icon-star"/><g:message
					code="text.unstar" /></button>
			</g:if>
			<g:else>
				<button id="starDataobject" onclick="dibStarFile()"><img class="icon-star-empty"/><g:message
					code="text.star.file" /></button>
			</g:else>
			<button id="downloadFile" onclick="dibDownloadFile()"><img class="icon-download"/><g:message
					code="text.download" /></button>
			<button id="addToCart" onclick="addToCartViaToolbar()"><img class="icon-shopping-cart"/><g:message
					code="text.add.to.cart" /></button>			
		</div>
		<div id="dataObjectInfoButtonGroup2" class="btn-group">
			<button id="renameDataObject" onclick="dibRenameFile()"><img class="icon-pencil"/><g:message
					code="text.rename" /></button>
			<button id="deleteDataObject" onclick="dibDeleteFile()"><img class="icon-trash"/><g:message
					code="text.delete" /></button>
		</div>
</div>

<script type="text/javascript">

function dibDownloadFile() {
	var path = $("#infoAbsPath").val();
	if (path == null) {
		showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
		return false;
	}

	downloadViaToolbarGivenPath(path);
}

/**
* Delete the file currently displayed in the info view
*/
function dibRenameFile() {
	var path = $("#infoAbsPath").val();
	if (path == null) {
		showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
		return false;
	}

	renameViaToolbarGivenPath(path);
}

/**
* call delete using the path in the info panel
*/
function dibDeleteFile() {
	var path = $("#infoAbsPath").val();
	if (path == null) {
		showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
		return false;
	}

	deleteViaToolbarGivenPath(path);
}

/**
* favorite, or 'star' the data object currently displayed in the info view
*/
function dibStarFile() {
	var path = $("#infoAbsPath").val();
	if (path == null) {
		showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
		return false;
	}

	if (path == null) {
		setErrorMessage("No path was selected, use the tree to select an iRODS collection or file to star"); // FIXME:
		// i18n
		return;
	}

	lcShowBusyIconInDiv("#infoDialogArea");
	var url = "/browse/prepareStarDialog";

	var params = {
		absPath : path
	}

	lcSendValueWithParamsAndPlugHtmlInDiv(url, params, "#infoDialogArea", null);
}

/**
* unfavorite favorite, or 'star' the collection currently displayed in the info view
*/
function dibUnstarFile() {
	var path = $("#infoAbsPath").val();
	if (path == null) {
		showErrorMessage(jQuery.i18n.prop('msg.path.missing'));
		return false;
	}

	if (path == null) {
		setErrorMessage("No path was selected, use the tree to select an iRODS collection or file to unstar"); // FIXME:
		// i18n
		return;
	}

	showBlockingPanel();
	var url = "/browse/unstarFile";

	var params = {
			absPath : path
	}

	var jqxhr = $.post(context + url, params,
			function(data, status, xhr) {
			}, "html").success(
			function(returnedData, status, xhr) {
				var continueReq = checkForSessionTimeout(returnedData, xhr);
				if (!continueReq) {
					return false;
				}
				setMessage(jQuery.i18n.prop('msg_file_unstarred'));
				updateBrowseDetailsForPathBasedOnCurrentModel(selectedPath);
				closeStarDialog();
				unblockPanel();
			}).error(function(xhr, status, error) {
				setErrorMessage(xhr.responseText);
				closeStarDialog();
				unblockPanel();
			});
}


		
</script>