-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from nextcloud/vue
Vue
- Loading branch information
Showing
19 changed files
with
6,758 additions
and
650 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
app_name=notifications | ||
|
||
project_dir=$(CURDIR)/../$(app_name) | ||
build_dir=$(CURDIR)/build | ||
source_dir=$(build_dir)/$(app_name) | ||
sign_dir=$(build_dir)/sign | ||
|
||
all: package | ||
|
||
dev-setup: clean npm-update build-js | ||
|
||
npm-update: | ||
rm -rf node_modules | ||
npm update | ||
|
||
build-js: | ||
npm run dev | ||
|
||
build-js-production: | ||
npm run build | ||
|
||
clean: | ||
rm -rf $(build_dir) | ||
|
||
package: clean build-js-production | ||
mkdir -p $(source_dir) | ||
rsync -a \ | ||
--exclude=/build \ | ||
--exclude=/docs \ | ||
--exclude=/js-src \ | ||
--exclude=/l10n/.tx \ | ||
--exclude=/tests \ | ||
--exclude=/.git \ | ||
--exclude=/.github \ | ||
--exclude=/CONTRIBUTING.md \ | ||
--exclude=/issue_template.md \ | ||
--exclude=/README.md \ | ||
--exclude=/.gitignore \ | ||
--exclude=/.scrutinizer.yml \ | ||
--exclude=/.travis.yml \ | ||
--exclude=/.drone.yml \ | ||
--exclude=/node_modules \ | ||
--exclude=/npm-debug.log \ | ||
--exclude=/package.json \ | ||
--exclude=/package-lock.json \ | ||
--exclude=/Makefile \ | ||
$(project_dir)/ $(source_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* @copyright (c) 2016 Joas Schilling <coding@schilljs.com> | ||
* @copyright (c) 2015 Tom Needham <tom@owncloud.com> | ||
* | ||
* @author Tom Needham <tom@owncloud.com> | ||
* @author Joas Schilling <coding@schilljs.com> | ||
* | ||
* This file is licensed under the Affero General Public License version 3 or | ||
* later. See the COPYING file. | ||
*/ | ||
|
||
/* global OC, OCA, $, _, t, define, console */ | ||
|
||
define(function (require) { | ||
"use strict"; | ||
|
||
return { | ||
|
||
/** @type {number} */ | ||
pollInterval: 30000, // milliseconds | ||
|
||
/** @type {number|null} */ | ||
interval: null, | ||
|
||
/** @type {Vue|null} */ | ||
vm: null, | ||
|
||
/** | ||
* Initialise the app | ||
*/ | ||
initialise: function() { | ||
|
||
// Add to the UI | ||
$('form.searchbox').after($('<div>').attr('id', 'notifications')); | ||
|
||
// Setup Vue | ||
var Vue = require('vue'); | ||
this.vm = new Vue(require('./components/root.vue')); | ||
|
||
// Initial call to the notification endpoint | ||
this._fetch(); | ||
|
||
// Setup the background checker | ||
this.interval = setInterval(this._backgroundFetch.bind(this), this.pollInterval); | ||
}, | ||
|
||
/** | ||
* Performs the AJAX request to retrieve the notifications | ||
*/ | ||
_fetch: function() { | ||
var request = $.ajax({ | ||
url: OC.linkToOCS('apps/notifications/api/v2', 2) + 'notifications', | ||
type: 'GET', | ||
beforeSend: function (request) { | ||
request.setRequestHeader('Accept', 'application/json'); | ||
} | ||
}); | ||
|
||
request.done(function(data, statusText, xhr) { | ||
if (xhr.status === 204) { | ||
// 204 No Content - Intercept when no notifiers are there. | ||
this._shutDownNotifications(); | ||
} else if (!_.isUndefined(data) && !_.isUndefined(data.ocs) && !_.isUndefined(data.ocs.data) && _.isArray(data.ocs.data)) { | ||
this.vm.notifications = data.ocs.data; | ||
} else { | ||
console.debug("data.ocs.data is undefined or not an array"); | ||
} | ||
}.bind(this)); | ||
request.fail(function(xhr) { | ||
if (xhr.status === 503) { | ||
// 503 - Maintenance mode | ||
console.debug('Shutting down notifications: instance is in maintenance mode.'); | ||
} else if (xhr.status === 404) { | ||
// 404 - App disabled | ||
console.debug('Shutting down notifications: app is disabled.'); | ||
} else { | ||
console.error('Shutting down notifications: [' + xhr.status + '] ' + xhr.statusText); | ||
} | ||
|
||
this._shutDownNotifications(); | ||
}.bind(this)); | ||
}, | ||
|
||
_backgroundFetch: function() { | ||
this.vm.backgroundFetching = true; | ||
this._fetch(); | ||
}, | ||
|
||
/** | ||
* The app was disabled or has no notifiers, so we can stop polling | ||
* And hide the UI as well | ||
*/ | ||
_shutDownNotifications: function() { | ||
window.clearInterval(this.interval); | ||
this.vm.shutdown = true; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<template> | ||
<button class="action-button pull-right" :class="{ primary: primary }" | ||
:data-type="type" :data-href="link" @click="onClickActionButton">{{label}}</button> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "action", | ||
props: [ | ||
'label', | ||
'link', | ||
'type', | ||
'primary' | ||
], | ||
methods: { | ||
onClickActionButton: function () { | ||
$.ajax({ | ||
url: this.link, | ||
type: this.type || 'GET', | ||
success: function () { | ||
this.$parent._$el.fadeOut(OC.menuSpeed); | ||
this.$parent.$emit('remove'); | ||
$('body').trigger(new $.Event('OCA.Notification.Action', { | ||
notification: this.$parent, | ||
action: { | ||
url: this.link, | ||
type: this.type || 'GET' | ||
} | ||
})); | ||
}.bind(this), | ||
error: function () { | ||
OC.Notification.showTemporary(t('notifications', 'Failed to perform action')); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
</script> |
Oops, something went wrong.