This commit is contained in:
@@ -3,6 +3,106 @@
|
|||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// General utility library
|
// General utility library
|
||||||
//
|
//
|
||||||
|
|
||||||
|
const icons = {
|
||||||
|
image: "fa-file-image",
|
||||||
|
pdf: "fa-file-pdf",
|
||||||
|
word: "fa-file-word",
|
||||||
|
powerpoint: "fa-file-powerpoint",
|
||||||
|
excel: "fa-file-excel",
|
||||||
|
csv: "fa-file-csv",
|
||||||
|
audio: "fa-file-audio",
|
||||||
|
video: "fa-file-video",
|
||||||
|
archive: "fa-file-archive",
|
||||||
|
code: "fa-file-code",
|
||||||
|
text: "fa-file-alt",
|
||||||
|
file: "fa-file"
|
||||||
|
};
|
||||||
|
const mimeTypes = {
|
||||||
|
"image/gif": icons.image,
|
||||||
|
"image/jpeg": icons.image,
|
||||||
|
"image/png": icons.image,
|
||||||
|
|
||||||
|
"application/pdf": icons.pdf,
|
||||||
|
|
||||||
|
"application/msword": icons.word,
|
||||||
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document":
|
||||||
|
icons.word,
|
||||||
|
|
||||||
|
"application/mspowerpoint": icons.powerpoint,
|
||||||
|
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
|
||||||
|
icons.powerpoint,
|
||||||
|
|
||||||
|
"application/msexcel": icons.excel,
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
||||||
|
icons.excel,
|
||||||
|
|
||||||
|
"text/csv": icons.csv,
|
||||||
|
|
||||||
|
"audio/aac": icons.audio,
|
||||||
|
"audio/wav": icons.audio,
|
||||||
|
"audio/mpeg": icons.audio,
|
||||||
|
"audio/mp4": icons.audio,
|
||||||
|
"audio/ogg": icons.audio,
|
||||||
|
|
||||||
|
"video/x-msvideo": icons.video,
|
||||||
|
"video/mpeg": icons.video,
|
||||||
|
"video/mp4": icons.video,
|
||||||
|
"video/ogg": icons.video,
|
||||||
|
"video/quicktime": icons.video,
|
||||||
|
"video/webm": icons.video,
|
||||||
|
|
||||||
|
"application/gzip": icons.archive,
|
||||||
|
"application/zip": icons.archive,
|
||||||
|
|
||||||
|
"text/css": icons.code,
|
||||||
|
"text/html": icons.code,
|
||||||
|
"text/javascript": icons.code,
|
||||||
|
"application/javascript": icons.code,
|
||||||
|
|
||||||
|
"text/plain": icons.text,
|
||||||
|
"text/richtext": icons.text,
|
||||||
|
"text/rtf": icons.text
|
||||||
|
};
|
||||||
|
|
||||||
|
const extensions = {
|
||||||
|
gif: icons.image,
|
||||||
|
jpeg: icons.image,
|
||||||
|
jpg: icons.image,
|
||||||
|
png: icons.image,
|
||||||
|
|
||||||
|
pdf: icons.pdf,
|
||||||
|
|
||||||
|
doc: icons.word,
|
||||||
|
docx: icons.word,
|
||||||
|
|
||||||
|
ppt: icons.powerpoint,
|
||||||
|
pptx: icons.powerpoint,
|
||||||
|
|
||||||
|
xls: icons.excel,
|
||||||
|
xlsx: icons.excel,
|
||||||
|
|
||||||
|
csv: icons.csv,
|
||||||
|
|
||||||
|
aac: icons.audio,
|
||||||
|
mp3: icons.audio,
|
||||||
|
ogg: icons.audio,
|
||||||
|
|
||||||
|
avi: icons.video,
|
||||||
|
flv: icons.video,
|
||||||
|
mkv: icons.video,
|
||||||
|
mp4: icons.video,
|
||||||
|
|
||||||
|
gz: icons.archive,
|
||||||
|
zip: icons.archive,
|
||||||
|
|
||||||
|
css: icons.code,
|
||||||
|
html: icons.code,
|
||||||
|
js: icons.code,
|
||||||
|
|
||||||
|
txt: icons.text
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// CLEAN OBJECT
|
// CLEAN OBJECT
|
||||||
@@ -215,46 +315,39 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
//https://gist.github.com/colemanw/9c9a12aae16a4bfe2678de86b661d922
|
//https://gist.github.com/colemanw/9c9a12aae16a4bfe2678de86b661d922
|
||||||
iconForMIMEType: function(mimeType) {
|
iconForFile: function(fileName, mimeType) {
|
||||||
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
|
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
|
||||||
var icon_classes = {
|
|
||||||
// Media
|
|
||||||
image: "fa-file-image",
|
|
||||||
audio: "fa-file-audio",
|
|
||||||
video: "fa-file-video",
|
|
||||||
// Documents
|
|
||||||
"application/pdf": "fa-file-pdf",
|
|
||||||
"application/msword": "fa-file-word",
|
|
||||||
"application/vnd.ms-word": "fa-file-word",
|
|
||||||
"application/vnd.oasis.opendocument.text": "fa-file-word",
|
|
||||||
"application/vnd.openxmlformats-officedocument.wordprocessingml":
|
|
||||||
"fa-file-word",
|
|
||||||
"application/vnd.ms-excel": "fa-file-excel",
|
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml":
|
|
||||||
"fa-file-excel",
|
|
||||||
"application/vnd.oasis.opendocument.spreadsheet": "fa-file-excel",
|
|
||||||
"application/vnd.ms-powerpoint": "fa-file-powerpoint",
|
|
||||||
"application/vnd.openxmlformats-officedocument.presentationml":
|
|
||||||
"fa-file-powerpoint",
|
|
||||||
"application/vnd.oasis.opendocument.presentation": "fa-file-powerpoint",
|
|
||||||
"text/plain": "fa-file-alt",
|
|
||||||
"text/html": "fa-file-code",
|
|
||||||
"application/json": "fa-file-code",
|
|
||||||
// Archives
|
|
||||||
"application/gzip": "fa-file-archive",
|
|
||||||
"application/zip": "fa-file-archive"
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var key in icon_classes) {
|
let extension = null;
|
||||||
if (icon_classes.hasOwnProperty(key)) {
|
if (fileName && fileName.includes(".")) {
|
||||||
if (mimeType.search(key) === 0) {
|
extension = fileName.split(".").pop();
|
||||||
// Found it
|
extension = extension.toLowerCase();
|
||||||
return icon_classes[key];
|
|
||||||
}
|
}
|
||||||
} else {
|
if (!extension && !mimeType) {
|
||||||
|
console.log(
|
||||||
|
"gzutil:iconForFile -> No mime or extension for " +
|
||||||
|
fileName +
|
||||||
|
" " +
|
||||||
|
mimeType
|
||||||
|
);
|
||||||
return "fa-file";
|
return "fa-file";
|
||||||
}
|
}
|
||||||
|
mimeType = mimeType.toLowerCase();
|
||||||
|
|
||||||
|
let iconFromExtension = extensions[extension];
|
||||||
|
let iconFromMIME = mimeTypes[mimeType];
|
||||||
|
|
||||||
|
if (iconFromMIME) {
|
||||||
|
return iconFromMIME;
|
||||||
}
|
}
|
||||||
|
if (iconFromExtension) {
|
||||||
|
return iconFromExtension;
|
||||||
|
}
|
||||||
|
//debugger;
|
||||||
|
console.log(
|
||||||
|
"gzutil:iconForFile -> No icon for file:" + fileName + " Mime:" + mimeType
|
||||||
|
);
|
||||||
|
return "fa-file";
|
||||||
}
|
}
|
||||||
|
|
||||||
//new functions above here
|
//new functions above here
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
<span class="v-label v-label--active theme--light">
|
<span class="v-label v-label--active theme--light">
|
||||||
{{ $ay.t("Attachments") }}
|
{{ $ay.t("Attachments") }}
|
||||||
</span>
|
</span>
|
||||||
{{ displayList }}
|
|
||||||
<v-tabs v-model="tab" color="primary">
|
<v-tabs v-model="tab" color="primary">
|
||||||
<v-tabs-slider></v-tabs-slider>
|
<v-tabs-slider></v-tabs-slider>
|
||||||
<v-tab key="list"><v-icon>fa-folder</v-icon></v-tab>
|
<v-tab key="list"><v-icon>fa-folder</v-icon></v-tab>
|
||||||
@@ -166,7 +165,7 @@ export default {
|
|||||||
hour12
|
hour12
|
||||||
),
|
),
|
||||||
notes: o.notes,
|
notes: o.notes,
|
||||||
icon: window.$gz.util.iconForMIMEType(o.contentType)
|
icon: window.$gz.util.iconForFile(o.displayFileName, o.contentType)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.displayList = ret;
|
this.displayList = ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user